473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Bring another window to back of my apllication when activated

Hi folks,
I got a requirement in my project where in when my application is activated another window should get activated and upon it my application should be present. Both should be in restored state not maximised.
To accomplish this, in the activated event of my MainForm I first activated the other window and then activated my window.
I've implemented the following piece of code in the activated event of my MainForm:

private void MainForm_Activated(object sender, EventArgs e) {
Process[] proc = Process.GetProcessesByName("IEXPLORE");
foreach(Process p in proc){
if(p.MainWindowTitle.Equals("Hi - Microsoft Internet Explorer")){
IntPtr hwnd = p.MainWindowHandle;

SetForegroundWindow(hwnd);
ShowWindow((int)hwnd,1);
this.Activated -= new EventHandler(MainForm_Activated);
SetForegroundWindow(this.Handle);
ShowWindow((int)this.Handle,1);

this.Activated += new EventHandler(MainForm_Activated);
return;
}
}
}

But this code is not working properly all the times.
When both the windows are minimised it works fine but when both are in restored state when my mainform is activated the other window comes to front but my MainForm never comes to front. Also, i am unable to minimize my application from taskbar as the activated event is getting fired andboth the windows are being restored. But, i am able to minimize from the minimize button on the form.

Can anybody propose me a solution with reasons(comments)

Thanks in advance,
Pavan..
May 12 '06 #1
0 1736

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dai Ba Wong | last post by:
Hi: Currently I am having a problem with my webpage. My page consist of two frames, one consist of input text field and the other contains link for different pop-up windows. The problem...
4
by: Brian Kitt | last post by:
I don't know where to ask this question. If you know of a better place to ask it, please let me know. I have a main web page containing many links to detail pages. All detail links open with...
0
by: sara | last post by:
I have a DB and all of a sudden the DB window is gone - and I can't get it back. Note: I am having trouble with my laptop keyboard and it seems to have a ghost so things "happen" when I'm not...
7
by: tom | last post by:
Hi, I want a listbox below a hidden calendar control. The problem is that the listbox will shadow the calendar when the calendar is visible. How can I bring the calendar from back to front? ...
9
by: DraguVaso | last post by:
Hi, I want my application to bring another application to the Front. I thought best way to do this was by the Process-model: Dim c As Process = Process.GetCurrentProcess() Dim p As Process...
4
by: Mark | last post by:
We have a windows 2000 server with terminal services activated. Users will connect using RDP and launch an application. Sometimes, users will minimize the application when they meant to minimize...
13
by: tochiromifune | last post by:
Hello The window.open method brings my window to the top only if it is new. If it's being reused, the window does not come to the foreground (with IE 6 it does). Is there a new way in...
2
by: jackson2005 | last post by:
OK, I need to do three different things. On the ONLOAD event I would like a popup box to open. In this popup box I need two text boxes. One for the UserName and one for the BillingTo name. ...
3
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.