Solved

Keeping Non-MDI forms within a Main form?

Posted on 2006-11-07
3
190 Views
Last Modified: 2010-04-16
I am using non-MDI forms in my application only because the ability to add a MDI form has been disabled in the Project menu (don't know why either). Anyway, I have an active main form and when I show a new form....I wish for it to remain in the main form. I've seen an example of this before but can't remember where.

Thanks!
0
Comment
Question by:BlakeMcKenna
  • 2
3 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Why do you have two accounts Blake?...
http://www.experts-exchange.com/Programming/Q_22052432.html
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
You can make a form a pseudo-mdi child using the SetParent() API:

Option Explicit

Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
   
Private Sub Command1_Click()
    Dim f2 As New Form2
    f2.Show
    SetParent f2.hWnd, Me.hWnd
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Dim f As Form
    For Each f In Forms
        Unload f
    Next f
End Sub
0
 
LVL 5

Accepted Solution

by:
sivachirravuri earned 500 total points
Comment Utility
this API can be used to keep window on top or center.

Private Declare Function SetWindowPos _
                Lib "user32" _
                (ByVal hwnd As Long, _
                 ByVal hWndInsertAfter As Long, _
                 ByVal x As Long, ByVal Y As Long, _
                 ByVal cx As Long, ByVal cy As Long, _
                 ByVal wFlags As Long) As Long

Private sub Form_load()
l = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 1)
End sub
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now