944,010 Members | Top Members by Rank

Ad:
Jun 10th, 2007
0

Borderless MDI form

Expand Post »
hello all,

can anyone tell, how can i make an mdi form borderless.
i don't want the user to click on the close button present in the title bar. i want them to exit the way i directed them.

thanks in advance.
Sayen
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Es Sayen is offline Offline
19 posts
since Jun 2007
Jun 10th, 2007
0

Re: Borderless MDI form

Why don't you use the query unload event and place 'cancel = true' there?

Otherwise look here: http://vbnet.mvps.org/index.html?cod.../killclose.htm

*change: Private Sub Form_Load() IN Private Sub MDIForm_Load()
Last edited by PVBert; Jun 10th, 2007 at 4:46 pm. Reason: added the alternative
Reputation Points: 10
Solved Threads: 5
Junior Poster in Training
PVBert is offline Offline
60 posts
since Mar 2007
Jun 11th, 2007
0

Re: Borderless MDI form

you cannot make a mdiform borderless. instead of you can disable the close button on the titlebar of the mdiform. to disable the close button use this code :-

'declare these api functions in general section of the mdiform
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, _
ByVal nPosition As Long, ByVal wFlags As Long) As Long

Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, _
ByVal bRevert As Long) As Long

Private Const MF_BYPOSITION = &H400&
Private ReadyToClose As Boolean

'create a sub-routine like this
Private Sub RemoveMenus(frm As Form, remove_close As Boolean)
Dim hMenu As Long
hMenu = GetSystemMenu(hwnd, False)
If remove_close Then DeleteMenu hMenu, 6, MF_BYPOSITION
End Sub

'in load event add this
Private Sub MDIForm_Load()
RemoveMenus Me, True
End Sub

'within your exit option add this
ReadyToClose = True
End
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007
Jun 13th, 2007
0

Re: Borderless MDI form

hello,

thank you. both of you. it really works and i appreciate for your reply.

Thanks again.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Es Sayen is offline Offline
19 posts
since Jun 2007
Feb 27th, 2008
0

Re: Borderless MDI form

I am a .NET developer and don't have pre-.NET skills, so forgive me if this is version-incorrect. But I have made MDI forms borderless with no problems other than getting MdiLayout to work smoothly.


I set the MdiParent's FormBorderStyle to "None". Then, I created user controls for my new "skinned" form borders and docked them respectively in the Mdi parent form. When docking, z-order controls how they layout against each other. My new "Titlebar" control implements all the functionality to move, minimize, restore, and close the form. You could simply exclude these methods to accomplish what you want.

NOTE: I realize this thread is pretty old. But I though it might help someone who comes along via their own "googling".
Last edited by freQ; Feb 27th, 2008 at 1:01 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
freQ is offline Offline
1 posts
since Feb 2008
Dec 30th, 2009
0

Make a MDI Form borderless

I realize that this tread is some quite old, but...

1. freQ, really you can set FormBorderStyle in VB.Net environment; but, in earlier versions, this property doesn't exist;

2 choudhuryshouvi, if you use API for disable buttons in title bar, why not to disable border in the form? It's possible, but need a bit of work on it. Use two APIs of USER32 file: GETWINDOWLONG and SETWINDOWLONG;

3. PVBert, if the only aim of hide the MDI form's border is to prevent that the user can close the application, your sollution works fine... but, if you need to "redesign" your application, reshape the "Windows window" (this sounds very strange) with a picture, for example?

I made a "form picture", with "title", "borders" and so on (in a photoshop-like application), and need to take out the conventional border of the MDI and put my image in the background, simulating a "skin" for my VB6 program.
The result is very cool... and the above code solve my problem!

It's adpated from
http://phsoftware.de/index.php/content/view/18/49/


I hope this can be usefull for anyone that "googles" for borderless MDI form in pre-NET Visual Basic, and apologize for the bad writing (not speak english very well).


Best regards,
Sidnei
Sao Paulo - Brasil



'This is the API declaration; I suggest to put it in a module, OR change private to public
Private Declare Function GetWindowLong Lib "USER32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "USER32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long


'Constants to make code more readable
Private Const GWL_STYLE = (-16)
Private Const WS_BORDER = &H800000
Private Const WS_CAPTION = &HC00000


'A generic function to make a form borderless
Public Sub RetiraBorda(ByRef nFormHWND As Long)

  Dim nEstilo As Long
  
  
  On Error GoTo errRetiraBorda
  
  nEstilo = GetWindowLong(nFormHWND, GWL_STYLE)
  nEstilo = nEstilo And Not WS_CAPTION
  SetWindowLong nFormHWND, GWL_STYLE, nEstilo

Exit Sub

errRetiraBorda:
  MsgBox "Erro na execução da rotina:" & vbNewLine & vbNewLine & Err.Number & " - " & Err.Description, vbExclamation, "RetiraBorda"

End Sub


'The function can be called this way, in the form for example
Private Sub MDIForm_Activate()

  Dim rTela As tCoord
  
  RetiraBorda Me.hwnd
  rTela = AreaTrabalho
  
  'Some other code to initialize application
  '(...)

End Sub
Reputation Points: 22
Solved Threads: 10
Junior Poster in Training
sidnei is offline Offline
55 posts
since Dec 2009
Jan 26th, 2010
0
Re: Borderless MDI form
there is 1 issue with this code : when you have a statusbar on the bottom of your mdi form then the resize/grab handle of the statusbar is now functional and you can resize the statusbar instead of the mdi form

to make sure the statusbar itself cant be resized either have a look at : http://www.vbforums.com/showthread.php?t=552272
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Hrqls is offline Offline
1 posts
since Jan 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: a textbox to accept negative & positive numbers but will not accept string...pls help
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: get data of the count(*) as query..error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC