473,786 Members | 2,399 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Process class and main window handle property

Hi,

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

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

1. Why is Process.MainWin dowHandle = 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********@dis cussion.microso ft.com> wrote in message
news:ux******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

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

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

Nov 15 '05 #2

<di********@dis cussion.microso ft.com> wrote in message
news:u8******** *****@TK2MSFTNG P10.phx.gbl...
I tried calling the flat SetActiveWindow (HWND hWnd) funtion but the
Process.MainWin dowHandle = 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.MainWin dowHandle = 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********@dis cussion.microso ft.com> wrote in message
news:ux******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

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

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

and
MainWindowHandl e without PInvoke?
Thanks


Nov 15 '05 #3
Meh, theyre all zero.
<di********@dis cussion.microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..

<di********@dis cussion.microso ft.com> wrote in message
news:u8******** *****@TK2MSFTNG P10.phx.gbl...
I tried calling the flat SetActiveWindow (HWND hWnd) funtion but the
Process.MainWin dowHandle = 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.MainWin dowHandle = 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********@dis cussion.microso ft.com> wrote in message
news:ux******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

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

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



Nov 15 '05 #4
Ok, Activating the window doesnt seem to be reliable, the MainWindowHandl e
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 SetForegroundWi ndow(processLis t[0].MainWindowHand le); then
SetActiveWindow (processList[0].MainWindowHand le);

<di********@dis cussion.microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Meh, theyre all zero.
<di********@dis cussion.microso ft.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..

<di********@dis cussion.microso ft.com> wrote in message
news:u8******** *****@TK2MSFTNG P10.phx.gbl...
I tried calling the flat SetActiveWindow (HWND hWnd) funtion but the
Process.MainWin dowHandle = 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.MainWin dowHandle = 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********@dis cussion.microso ft.com> wrote in message
news:ux******** ******@TK2MSFTN GP09.phx.gbl...
> Hi,
>
> In the Process class there is a CloseMainWindow , why is there not a > BringMainWindow ToForeground or similar method?
>
> What would be the best way to do this if we jsut have the process info and
> MainWindowHandl e 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
3913
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 and MainWindowHandle without PInvoke? Thanks
12
2954
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 starting is that it has a welcome window first which gets displayed and then the real windows after a while,in other words it means that the process name is the same, but the handle I need to retrive is the one from the final window and not the...
3
4266
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 of a subclassed DataGridTextBoxColum dos not seem like a practical way to do it. I have subclassed a DataGrid and overridden the OnPaint as such:
2
1708
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 dialog file selection stuff written, but am not sure how to run the C program inside a seperate thread. I'm using VS.NET 2003 and am trying to use the Thread and Process objects, but am not sure if I can use that with MFC. I can't compile the code...
2
1916
by: siddharthkhare | last post by:
Hi All, I am launching a IE using following code. ======================================================================= m_IeProcess = new Process(); m_IeProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; m_IeProcess = Process.Start("IExplore.exe","www.ABC.com"); ======================================================================= how do i get refrence to the InternetExplorer from the process.
0
9492
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10360
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...
0
10163
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10108
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
9960
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
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
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
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.