Solved

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

Posted on 2009-04-13
5
818 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Put text in a picture ASP.NET C# 2 68
Hide vba in gp 7 115
Help me. 3 69
Powerpoint 2013: Change cell reference in excel link 3 122
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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