Hi,
In developing a GUI I need to place a form within a frame in a windows depending upon the button the user clicks. Is there any way to to place a form "frmContent" within a frame "frmEvents" placed in frmMain.
Thanks
shibdas
Printable View
Hi,
In developing a GUI I need to place a form within a frame in a windows depending upon the button the user clicks. Is there any way to to place a form "frmContent" within a frame "frmEvents" placed in frmMain.
Thanks
shibdas
Welcome to the Forums.
Yes, since a frame has a window handle you can nest a form inside it using the SetParent API.
VB Code:
Option Explicit Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Sub Form_Load() Load Form2 SetParent Form2.hWnd, Frame1.hWnd Form2.Move 0, 0, Frame1.Width, Frame1.Height Form2.Show End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Unload Form2 End Sub
Hi,
I have just used your code, however I was wondering how to make it so when you click within the frame it doesn't treat the form as if you've clicked another one.
Thanks :)
meaning you don't want user to be able to move or resize form2?
On form2 set
BorderStyle = 1
Caption = ""
ControlBox=False
MinButton=False
MaxButton=False
http://www.ingomania.co.uk/problem.jpg
This is my problem.. I've already done all that !
do you mean the parent window titlebar loses focus?
http://www.vbaccelerator.com/home/vb...wn/article.asp
(your pic is 404)
Yea that's what I mean. I'm not too sure what code to use from that site.. And the images seems to work this end :/
ps thanks
Could anyone help me with the code in the link http://www.vbaccelerator.com/home/vb...wn/article.asp
Thanks
You'll need to do a little research on subclassing. Search the forums for subclass or subclassing