[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Planting (Docking) a form in a form....

Posted on 2004-04-04
5
Medium Priority
?
375 Views
Last Modified: 2010-05-02
I want to plant or dock a form in another form, i want it to stick, and i want the option to make it so it doesnt need to stick.  can someone help me?  Thanks...
0
Comment
Question by:GBLX-Bill
  • 2
  • 2
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 10752773
Sounds like you're looking for Multiple-Document Interface (MDI) Applications.
Read more abou it here:http://msdn.microsoft.com/library/en-us/vbcon/html/vbconmdiapplications.asp
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 1400 total points
ID: 10753023
You can use (as mentioned) MDI or the method I proposed for your other question (SetParent). By "stick" do you mean to keep users from moving it? If so, you can subclass the form and ignore window-messages when the user tries to move the form from the title-bar.


Form1:
============

Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
    'Allow Form2 to be moved
    bAllowMove = True
End Sub
Private Sub Form_Load()
    Call Load(Form2)
    With Form2
        .Width = 700
        .Height = 700
        .Visible = True
    End With
    bAllowMove = False
    Call WindowHook(True, Form2.hWnd)
    Call SetParent(Form2.hWnd, Form1.hWnd)
End Sub
Private Sub Form_Unload(Cancel As Integer)
    Call WindowHook(False, Form2.hWnd)
    Call Unload(Form2)
End Sub


Module1:
===========

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 CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const GWL_WNDPROC = (-4)
Private Const WM_NCLBUTTONDOWN = &HA1

Public lPrevProc As Long
Public bAllowMove As Boolean
Public Sub WindowHook(ByVal bHook As Boolean, lHandle As Long)
    If bHook = True Then
        lPrevProc = SetWindowLong(lHandle, GWL_WNDPROC, AddressOf WindowProc)
    Else
        Call SetWindowLong(lHandle, GWL_WNDPROC, lPrevProc)
    End If
End Sub
Public Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    If uMsg = WM_NCLBUTTONDOWN Then
        'Ignore left-button down messages (when form is moved from titlebar)
        If bAllowMove = False Then Exit Function
    End If
    WindowProc = CallWindowProc(lPrevProc, hWnd, uMsg, wParam, lParam)
End Function
0
 

Author Comment

by:GBLX-Bill
ID: 10753041
No, actually mean to fix it on a form so people can't move it with out mvoing my form.
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10753107
Yes. Similar to the other question, it'll reside inside the form itself (you mentioned IN so I'm taking it you don't mean to dock it NEXT to the main form). The above example should prevent the "docked" form from moving (by titlebar) until you click on the button that changes bAllowMove  to true.
0
 

Author Comment

by:GBLX-Bill
ID: 10753274
THANK YOU
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question