Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Keeping Non-MDI forms within a Main form?

Posted on 2006-11-07
3
Medium Priority
?
217 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 86

Expert Comment

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

Expert Comment

by:Mike Tomlinson
ID: 17894506
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 1500 total points
ID: 17912660
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Simple Linear Regression
Six Sigma Control Plans

916 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