473,396 Members | 2,129 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.

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
Jul 21 '05 #1
4 3895
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

Jul 21 '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


Jul 21 '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



Jul 21 '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
>
>



Jul 21 '05 #5

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

Similar topics

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...
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...
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
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?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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
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.