Solved

VB6 - Selecting a form within a form makes the parent form 'inactive'

Posted on 2009-04-13
5
813 Views
Last Modified: 2012-05-06
Okay, lets say I have a form, and I add a child form to appear in it.. What I mean is:

In FormMain I have a button with:
    frmChild.Show vbModeless, Me

And in frmChild, FormLoad is:

    SetParent Me.hWnd, frmMain.hWnd
    Me.Top = (Me.Height - frmMain.Height) - frmStart.Top + 4300
    Me.Left = 2190

Basicly, a form gets loaded INSIDE frmMain. The issue is, when I alt tab and try to click the form when frmChild is active, it doesn't get pushed up, basicly it doesn't reconize that frmMain should be brought up when I click frmChild.. FOR EXAMPLE: I bring up frmMain, click the button to bring up frmChild.. I open up lets say notepad, so notepad is now active. I try to click frmMain in the background without using the taskbar, basicly by trying to click frmChild, and it DOES NOT become active again! Basicly frmChild is not seen as part of frmMain is what I am guessing.. Wierd behaviour...

As well, when I click frmChild that is inside the frmMain, frmMain goes 'inactive', basicly what I mean is the top bar becomes 'inactive', so it would become gray, or a light blue in Vista to indicate the form is not the active form. This is an issue because I want to have frmChild apart of frmMain, so frmMain should be active too!
0
Comment
Question by:Valleriani
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:cmrobertson
ID: 24133513
did you set the mdichild property of the child form to true?
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 24133747
Yes. That sort of behaviour is best achieved in VB6 with the parent form being an MDI form with any contained forms should having their MDIChild property set.
0
 
LVL 7

Author Comment

by:Valleriani
ID: 24133924
How would i load a MDI child? Right now when I use frmChild.Show vbModeless, Me for example, it states No MDI form avail to load.

I use a MDI form, however, I'm wondering how to get the main form to appear. for example I'll show an example of how I'm using it via picture.

Where the white area is, the sub-forms appear when you click the buttons on the left.

I'm not sure how I can acheieve this with a MDI form, because it seems like I'd have to make the current parent form a MDI child as well?.. Confused in that sense...
test.jpg
0
 
LVL 7

Author Comment

by:Valleriani
ID: 24133936
Oh the above is how I have it as well, not a MDI form, just how it comes as a regular form.. How would I achieve to change this now?

The forms must move inside the main form, so when I click one of the side buttons, some info fills in at the main middle form where the white is, basicly loads a form... However, right now it moves fine and such with the current 'parent' form.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 24134092
You really have to start out with the MDI model. You cannot convert a standard form into an MDI form. You might be able to copy the existing controls from the old to the new.

There are restrictions to MDI forms. You can only use certain controls directly on the form - 'bar' controls and the picture control. They are always 'docked'.  In your form, the left-hand panel could be (and possibly already is) a picture box. The bar at the button could be a label placed on to a picture box.

I used to use the Sheridan (SS) panel, but that is now deprecated.

Another possibility to using MDI is to use the API SetWindowsPos, though I haven't tried it myself in this context.
0

Featured Post

Free Trending Threat Insights Every Day

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

758 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

18 Experts available now in Live!

Get 1:1 Help Now