473,473 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Bring another window to back of my apllication when activated

1 New Member
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 1743

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: 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
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...
1
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...
0
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,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.