Windows OS is full of windows, even objects inside windows as we know them are also windows. Each window has a handle that is a pointer to the memory in which information about the window is stored.
Questions tagged [window-handles]
220 questions
68
votes
10 answers
Winforms issue - Error creating window handle
We are seeing this error in a Winform application. Can anyone help on why you would see this error, and more importantly how to fix it or avoid it from happening.
System.ComponentModel.Win32Exception: Error creating window handle.
at…
![](../../users/profiles/4653.webp)
leora
- 163,579
- 332
- 834
- 1,328
61
votes
4 answers
Check if any alert exists using selenium with python
I'm trying to write a test with selenium in python language for a web page that manages users. In this page someone can add role for users and if a role exists while adding it, an alert raises. I don't know if the alert is a javascript alert or an…
![](../../users/profiles/1626977.webp)
Zeinab Abbasimazar
- 7,585
- 15
- 58
- 110
50
votes
7 answers
How do I get the handle of a console application's window
Can someone tell me how to get the handle of a Windows console application in C#? In a Windows Forms application, I would normally try this.Handle.
![](../../users/profiles/96854.webp)
Grant
- 10,358
- 32
- 85
- 134
21
votes
3 answers
Mac OS X: Can one process render to another process's window?
Greetings!
I'm currently porting a web browser plugin from Win32 to MacOSX. One of the features of the plugin is that when the plugin is loaded, it spawns a separate process that serves as the "engine" of the plugin and executes drawing operations…
![](../../users/profiles/57720.webp)
fixermark
- 1,112
- 12
- 18
15
votes
3 answers
C# Process.MainWindowHandle always returns IntPtr Zero
this is my code:
using (Process game = Process.Start(new ProcessStartInfo() {
FileName="DatabaseCheck.exe",
RedirectStandardOutput = true,
CreateNoWindow = true,
UseShellExecute = false }))
{
…
![](../../users/profiles/1757073.webp)
Kfir Eichenblat
- 517
- 2
- 8
- 25
14
votes
1 answer
WinForms main window handle
In my winforms application I am trying to get a main window handle, so I can set it as parent to my wpf modal window. I am not too experienced with winforms, so after a bit of googling I found two ways to get it.…
![](../../users/profiles/1386995.webp)
Nikita B
- 3,043
- 1
- 20
- 36
13
votes
3 answers
How to convert IntPtr to int
A window handle sometimes of type int and other times of type IntPtr
int example:
[DllImport("user32.dll")]
static extern uint GetWindowThreadProcessId(int hWnd, int ProcessId);
IntPtr example:
[DllImport("user32.dll", CharSet =…
![](../../users/profiles/2473577.webp)
E Mett
- 2,236
- 3
- 13
- 35
12
votes
4 answers
C# window positioning
Using Windows Forms I wanted to position window into specific coords. I thought it can be done in a simple way, but following code does not work at all:
public Form1()
{
InitializeComponent();
this.Top = 0;
this.Left = 0;
}
However,…
![](../../users/profiles/1082992.webp)
Fremen
- 121
- 1
- 1
- 5
10
votes
4 answers
Why using IntPtr for handle?
When using PInvoke, I noticed that we need to use IntPtr to refer to Windows handles. I am wondering why not just use int for the handle? My understanding of a handle is that it is just an integer value.
![](../../users/profiles/705414.webp)
user705414
- 17,800
- 36
- 105
- 151
10
votes
3 answers
Get all window handles for a process
Using Microsoft Spy++, I can see that the following windows that belong to a process:
Process XYZ window handles, displayed in tree form just like Spy++ gives me:
A
B
C
D
E
F
G
H
I
J
K
I can get the process, and the…
![](../../users/profiles/9266.webp)
Jeremy
- 40,978
- 63
- 191
- 304
10
votes
4 answers
C# get window handle after starting a process
Is there a way to get the window handle (IntPtr) for a window after its launched from a C# app with Process.Start()?
![](../../users/profiles/82017.webp)
James Cadd
- 11,568
- 28
- 82
- 133
8
votes
5 answers
Are window handles (HWND) unique, or do they ever get reused?
I am thinking if there are handles of the same value ?
To clarify my question, let's say I open Notepad, type in some text, save it and then close Notepad. If I repeat this a thousand times (or even more), will I ever have a chance to see the same…
![](../../users/profiles/893532.webp)
Aussay Marshal
- 165
- 2
- 10
8
votes
4 answers
Get window handle from window class name
I'm trying to get a window handle on a child window in my process and the only information I have is the window class name. Are there any win32 functions I can use for that? I'm doing this from C#.
A bit more detail: This is a Visual Studio plugin,…
![](../../users/profiles/35716.webp)
Einar Egilsson
- 3,556
- 8
- 32
- 39
8
votes
1 answer
Getting X11 window handle from GtkWidget
The wxWindow::GetHandle() function returns HWND on Windows and GtkWidget on linux. I need to get X11 Window Handle, which isn't the widget itself. How can I get the handle from that widget? I need C++ code as it's the main language of wxWidgets.
![](../../users/profiles/1873947.webp)
user1873947
- 1,651
- 3
- 25
- 44
7
votes
1 answer
How to get count of opened handles that belongs to a certain process?
You can use the program Process Explorer to see how many handles running applications have. Is there a way with Delphi code to get this number? I am interested in tracking the number for the application itself; not to find the number of handles…
![](../../users/profiles/86235.webp)
M Schenkel
- 6,001
- 10
- 56
- 102