[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2004-04-04
5
Medium Priority
?
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 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