473,397 Members | 2,099 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,397 software developers and data experts.

Process class and main window handle property

Hi,

In the Process class there is a CloseMainWindow, why is there not a
BringMainWindowToForeground or similar method?

What would be the best way to do this if we jsut have the process info and
MainWindowHandle without PInvoke?
Thanks
Nov 15 '05 #1
4 9978
I tried calling the flat SetActiveWindow(HWND hWnd) funtion but the
Process.MainWindowHandle = 0.

1. Why is Process.MainWindowHandle = 0 when infact it has a form created?

2. How can we easily get this handle and bring the window to the foreground
(top Zorder app).

Thanks

<di********@discussion.microsoft.com> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
Hi,

In the Process class there is a CloseMainWindow, why is there not a
BringMainWindowToForeground or similar method?

What would be the best way to do this if we jsut have the process info and MainWindowHandle without PInvoke?
Thanks

Nov 15 '05 #2

<di********@discussion.microsoft.com> wrote in message
news:u8*************@TK2MSFTNGP10.phx.gbl...
I tried calling the flat SetActiveWindow(HWND hWnd) funtion but the
Process.MainWindowHandle = 0.
Ok, its zero because its the running process, but I want the already
active process so I can bring that to the foreground and exit this
instance.

I am trying to have a single instance of the application only on
attempting to start the 2nd.

1. Why is Process.MainWindowHandle = 0 when infact it has a form created?

2. How can we easily get this handle and bring the window to the foreground (top Zorder app).

Thanks

<di********@discussion.microsoft.com> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
Hi,

In the Process class there is a CloseMainWindow, why is there not a
BringMainWindowToForeground or similar method?

What would be the best way to do this if we jsut have the process info

and
MainWindowHandle without PInvoke?
Thanks


Nov 15 '05 #3
Meh, theyre all zero.
<di********@discussion.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

<di********@discussion.microsoft.com> wrote in message
news:u8*************@TK2MSFTNGP10.phx.gbl...
I tried calling the flat SetActiveWindow(HWND hWnd) funtion but the
Process.MainWindowHandle = 0.


Ok, its zero because its the running process, but I want the already
active process so I can bring that to the foreground and exit this
instance.

I am trying to have a single instance of the application only on
attempting to start the 2nd.

1. Why is Process.MainWindowHandle = 0 when infact it has a form created?
2. How can we easily get this handle and bring the window to the

foreground
(top Zorder app).

Thanks

<di********@discussion.microsoft.com> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
Hi,

In the Process class there is a CloseMainWindow, why is there not a
BringMainWindowToForeground or similar method?

What would be the best way to do this if we jsut have the process
info and
MainWindowHandle without PInvoke?
Thanks



Nov 15 '05 #4
Ok, Activating the window doesnt seem to be reliable, the MainWindowHandle
property is sometimes a value and sometimes ZERO.

Probably some timeing issue when getting the list of processes

Is there a more reliable way to do this? Im calling the user32.dll version
of SetForegroundWindow(processList[0].MainWindowHandle); then
SetActiveWindow(processList[0].MainWindowHandle);

<di********@discussion.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Meh, theyre all zero.
<di********@discussion.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

<di********@discussion.microsoft.com> wrote in message
news:u8*************@TK2MSFTNGP10.phx.gbl...
I tried calling the flat SetActiveWindow(HWND hWnd) funtion but the
Process.MainWindowHandle = 0.


Ok, its zero because its the running process, but I want the already
active process so I can bring that to the foreground and exit this
instance.

I am trying to have a single instance of the application only on
attempting to start the 2nd.

1. Why is Process.MainWindowHandle = 0 when infact it has a form created?
2. How can we easily get this handle and bring the window to the

foreground
(top Zorder app).

Thanks

<di********@discussion.microsoft.com> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> In the Process class there is a CloseMainWindow, why is there not a > BringMainWindowToForeground or similar method?
>
> What would be the best way to do this if we jsut have the process info and
> MainWindowHandle without PInvoke?
>
>
> Thanks
>
>



Nov 15 '05 #5

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

Similar topics

4
by: | last post by:
Hi, In the Process class there is a CloseMainWindow, why is there not a BringMainWindowToForeground or similar method? What would be the best way to do this if we jsut have the process info...
12
by: serge calderara | last post by:
Dear all, I have an application which is suppose to start another executable process. As soon as that process is running, I need to retrive its handle. The problem of the particular process I am...
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
2
by: MattMenard | last post by:
I've written a C program that I want to run inside an Gui wrapper that I started to write in MFC. I have to select some files then kick off a process running the C program. I have the initial...
2
by: siddharthkhare | last post by:
Hi All, I am launching a IE using following code. ======================================================================= m_IeProcess = new Process(); m_IeProcess.StartInfo.WindowStyle =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...
0
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...

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.