05-31-2002, 11:55 AM
When you take a default VB6 form (Standard EXE Project)
and add menus to it, it puts the menus below the title bar.
If I set the Controlbox to False and the Caption to
nothing, the titlebar disappears.
If I make a custom titlebar, like with a picturebox for example,
how could I put it above the menus? It seems impossible but
maybe their is a suggestion you have. (?)
05-31-2002, 12:21 PM
There are probably easier ways to do this, but one way would be to insert a form within a form. You can actually do this by messing around with the API functions GetWindowLong and SetWindowLong. The idea is that you set one form up as a child of the other.
Do a search on these two functions with my name because I seem to recall posting about it somewhere....
05-31-2002, 01:36 PM
Do you mean I could use a MDI form and put my graphical
titlebar on that, then have a child form and put my menus
The only reason I think I would need to use SetWindowLong
and GetWindowLong for is to hide the child form's min, max,
and close buttons, right?
05-31-2002, 02:53 PM
No, not exactly....
I'm talking about 2 normal forms. You can use these API functions to make one form a child of the other, without involving an MDI form.
05-31-2002, 03:00 PM
Hmmm.....Sorry....I did a search myself and realized that I actually used the SETPARENT API call rather than getwindowlong/setwindowlong....
05-31-2002, 04:07 PM
Okay, I tried that function out. I opened up a Standard Exe
Project and added another form (form2). I used...
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
Dim lngParentRet As Long
lngParentRet = SetParent(Form2.hWnd, Me.hWnd)
If lngParentRet = 0 Then MsgBox "FAILED" Else MsgBox "Success!"
Private Sub Form_Load()
...in Form1. It popped up "Success!" but didn't do nothing
else. What do I do after I set the parent and child of the
05-31-2002, 04:57 PM
If you just load a form, it won't be visible until you show it or make it visible.
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent 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
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000 ' WS_BORDER Or WS_DLGFRAME
Private Sub Form_Load()
'the following gets rid of the caption, while retaining the menu
SetWindowLong Form2.hwnd, GWL_STYLE, GetWindowLong(Form2.hwnd, GWL_STYLE) And Not WS_CAPTION
SetParent Form2.hwnd, Me.hwnd 'inserts form2 into form1
Form2.Visible = True 'makes it visible (duh)
Private Sub Form_Resize()
Form2.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
Private Sub Form_Unload(Cancel As Integer)
Unload Form2 'have to explicitly unload form2
05-31-2002, 05:29 PM
Oh yeah! Don't know what I was thinking.
Thank you alot for this code.