Results 1 to 9 of 9

Thread: Placing a form within a frame

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    3

    Placing a form within a frame

    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

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Placing a form within a frame

    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:
    1. Option Explicit
    2.  
    3. Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    4.  
    5. Private Sub Form_Load()
    6.     Load Form2
    7.     SetParent Form2.hWnd, Frame1.hWnd
    8.     Form2.Move 0, 0, Frame1.Width, Frame1.Height
    9.     Form2.Show
    10. End Sub
    11.  
    12. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    13.     Unload Form2
    14. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    New Member
    Join Date
    Jun 2006
    Posts
    4

    Re: Placing a form within a frame

    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

  4. #4
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Placing a form within a frame

    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

  5. #5
    New Member
    Join Date
    Jun 2006
    Posts
    4

    Re: Placing a form within a frame

    http://www.ingomania.co.uk/problem.jpg

    This is my problem.. I've already done all that !

  6. #6
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Placing a form within a frame

    do you mean the parent window titlebar loses focus?
    http://www.vbaccelerator.com/home/vb...wn/article.asp

    (your pic is 404)

  7. #7
    New Member
    Join Date
    Jun 2006
    Posts
    4

    Re: Placing a form within a frame

    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

  8. #8
    New Member
    Join Date
    Jun 2006
    Posts
    4

    Re: Placing a form within a frame

    Could anyone help me with the code in the link http://www.vbaccelerator.com/home/vb...wn/article.asp

    Thanks

  9. #9
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Placing a form within a frame

    You'll need to do a little research on subclassing. Search the forums for subclass or subclassing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width