473,771 Members | 2,372 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
Jul 21 '05 #1
4 3912
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

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


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



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



Jul 21 '05 #5

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

Similar topics

12
2953
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...
4
9991
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
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
1915
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
9454
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
10260
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
10102
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...
0
9910
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
8933
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
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
5354
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
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

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.