473,703 Members | 2,351 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bringing a child form to the front

I have the application's form (MainForm) along with a 2nd form (Form2). If
the user minimizes MainForm, I also minimize Form2. And when the user
restores the application, I also restore Form2. But, Form2 is ending up
behind MainForm. Anyone have an idea of how can I set/keep Form2 to be in
front of the MainForm?

And before someone suggests it, no -- I don't consider TopMost to be the
solution. That will make the form the topmost window for everything. I'm
trying to make Form2 the top most form only in relationship to MainForm.
Nor do I want to have a MDI application.

Here's the basic code I'm working with:

Private Sub MainForm_Resize (ByVal sender as Object, ByVal e as
System.EventArg s) Handles MyBase.Resize
If Me.WindowState = FormWindowState .Minimized Then
If Not (Form2 Is Nothing) Then
Form2.Visible = False
End If
Else
If Not (Form2 Is Nothing) Then
Form2.Visible = True
' code to bring Form2 to front goes here
End If
End If
End Sub

I did find the thread "Bring To Front of a Process/Other application"
http://groups.google.com/groups?hl=e...2522%26hl%3Den
but it's not working for me.

Based upon the above thread, I inserted the following code in the above code
fragment:

Dim handle As IntPtr = Form2.Handle
If Not IntPtr.Zero.Equ als(handle) Then
Win32Helper.Sho wWindow(handle, 1)
Win32Helper.Set Foregroundwindo w(handle)
End If

All I'm getting is Form2's windows briefly flashing in front of the main
form. BTW, I'm using Visual Studio 2004 on a Windows 2000 Pro machine.

Anyone have any suggestions?

Thanks in advance,

Richard Rosenheim
Nov 21 '05 #1
3 3227
Hi,

Form2.BringToFr ont
http://msdn.microsoft.com/library/de...fronttopic.asp

Ken
-------------------
"Richard L Rosenheim" <ri*****@rlr.co m> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I have the application's form (MainForm) along with a 2nd form (Form2). If
the user minimizes MainForm, I also minimize Form2. And when the user
restores the application, I also restore Form2. But, Form2 is ending up
behind MainForm. Anyone have an idea of how can I set/keep Form2 to be in
front of the MainForm?

And before someone suggests it, no -- I don't consider TopMost to be the
solution. That will make the form the topmost window for everything. I'm
trying to make Form2 the top most form only in relationship to MainForm.
Nor do I want to have a MDI application.

Here's the basic code I'm working with:

Private Sub MainForm_Resize (ByVal sender as Object, ByVal e as
System.EventArg s) Handles MyBase.Resize
If Me.WindowState = FormWindowState .Minimized Then
If Not (Form2 Is Nothing) Then
Form2.Visible = False
End If
Else
If Not (Form2 Is Nothing) Then
Form2.Visible = True
' code to bring Form2 to front goes here
End If
End If
End Sub

I did find the thread "Bring To Front of a Process/Other application"
http://groups.google.com/groups?hl=e...2522%26hl%3Den
but it's not working for me.

Based upon the above thread, I inserted the following code in the above code
fragment:

Dim handle As IntPtr = Form2.Handle
If Not IntPtr.Zero.Equ als(handle) Then
Win32Helper.Sho wWindow(handle, 1)
Win32Helper.Set Foregroundwindo w(handle)
End If

All I'm getting is Form2's windows briefly flashing in front of the main
form. BTW, I'm using Visual Studio 2004 on a Windows 2000 Pro machine.

Anyone have any suggestions?

Thanks in advance,

Richard Rosenheim

Nov 21 '05 #2
In article <#5************ **@TK2MSFTNGP09 .phx.gbl>, Richard L Rosenheim
<ri*****@rlr.co m> writes
Anyone have an idea of how can I set/keep Form2 to be in
front of the MainForm?


Will

form2.BringToFr ont

do it for you?

Regards
--
No Sheds
Nov 21 '05 #3
It helps -- missed that method call.

Thanks.
"No Sheds" <me@privacy.net > wrote in message
news:i2******** ******@heaser.c om...
In article <#5************ **@TK2MSFTNGP09 .phx.gbl>, Richard L Rosenheim
<ri*****@rlr.co m> writes
Anyone have an idea of how can I set/keep Form2 to be in
front of the MainForm?


Will

form2.BringToFr ont

do it for you?

Regards
--
No Sheds

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1580
by: Terry | last post by:
when using one form - i can set the z-order. Is there a way programatically to create a "z-order" across .exe. I have 2 .exe - one that paints a background form and then another that fills in the middle of the screen on top of that form. The .exes need to be separate, although the middle .exe knows about the size of the outer background/border form via a remoted object and events that get triggered on resize. Everything is working...
0
1269
by: clu82 | last post by:
I have an MDI app that allows the user to open multiple client address child forms. The user has a child form open that has client id "1001" and the records associated data displayed. If the user chooses to open a new child form and then try to select client id "1001" again, I would like to automatically close this form and bring the other form that already had client "1001" to the front. With the code below, I can find the correct...
2
5949
by: zobie | last post by:
In the parent of my MDI application I declare a child form private frmChild = null; which is to be activated on a menu click. In the click event I am using the following code: if (frmChild == null || !frmChild .IsHandleCreated) { frmChild = new frmChild ();
1
2077
by: zbcong | last post by:
hello if there are several child forms are opened in their mdi parent.how can i move the one of the child forms to the front end to show in the CODE?? thank you!!!
0
2339
by: Beenish Sahar Khan | last post by:
I'm working on a C# application(2003.) I have an MDI form which contains multiple MDI children, i want to bring an MDI child in the front and make it the top most form. As you can see, i want it to show the behavior of a normal form when the (normal form's) TopMost property is set to true, i-e. we could work on the other MDI children but the TopMost MDI Child will remain in the front even if it is deactivated. In case of MDI Children...
4
1711
by: Kevin Carter | last post by:
Hi there...hoping somebody can help me out because I am almost ready to pull out my hair. My problem is as follows: In a method in my main form (non MDI app), I instantiate and .Show another form. As a result of the .Show, the form's Load event is called and I have a population routine fires off. Normally, all is well and good and the new form is active and gets displayed on top of the main
7
3108
by: Siv | last post by:
Hi, I have an MDI application that uses a generic "ShowPage" routine in a module that is called when I want to display a child form. The basic idea is that in the module I have declared each form as follows: Friend F0 As frmMain Friend F1 As frmStart Friend F2 As frmSearch Then in my ShowPage routine (which is passed a string "pageToShow" which is the name of the form I wish to open), I first check to see if we already have an instance...
2
14020
by: JohnR | last post by:
Let's say I have an MDI parent form with a textbox. If I create an MDI child form and, at runtime, move the MDI child window over the textbox on the MDI parent, the textbox appears in front of the MDI child window. How can I make the MDI child window appear in front of any controls that may be on the MDI parent? thanks, John
3
3700
by: O.B. | last post by:
I have a form that shows another child form using the Show() operation. Since the child is modaless, I would like the option that when I click anywhere on the parent form that the parent form comes in front of the child. I added a callback in the parent form to call BringToFront() when I selected anywhere in the parent form, but it didn't work. Is there an option that I can specify in the child form to allow for this behavior?
0
8758
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9251
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6588
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4432
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3123
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.