Questions tagged [hwnd]

The Microsoft Windows operating environment identifies each form in an application by assigning it a handle, or hWnd. The hWnd property is used with Windows API calls. Many Windows operating environment functions require the hWnd of the active window as an argument.

In computer programming, a handle is an abstract reference to a resource. Handles are used when application software references blocks of memory or objects managed by another system, such as a database or an operating system.

While a pointer literally contains the address of the item to which it refers, a handle is an abstraction of a reference which is managed externally; its opacity allows the referent to be relocated in memory by the system without invalidating the handle, which is impossible with pointers. The extra layer of indirection also increases the control the managing system has over operations performed on the referent. Typically the handle is an index or a pointer into a global array of tombstones.

Handles were a popular solution to memory management in operating systems of the 1980s, such as Mac OS and Windows. Unix file descriptors are essentially handles. Like other desktop environments, the Windows API heavily uses handles to represent objects in the system and to provide a communication pathway between the operating system and user space. For example, a window on the desktop is represented by a handle of type HWND (handle, window).

Doubly indirect handles have fallen out of favour in recent times, as increases in available memory and improved virtual memory algorithms have made the use of the simpler pointer more attractive. However, many operating systems still apply the term to pointers to opaque, "private" data structures—opaque pointers—or to indexes into internal arrays passed from one process to its client.

A handle leak is a type of software bug that occurs when a computer program asks for a handle to a resource but does not free the handle when it is no longer used.

Wikipedia Article

397 questions
3
votes
1 answer

How to steal another application's video (via hwnd) and show it in separate application

I would like to take Skype's video and insert it into my own application. I am using skype4com to control the call, but I can find no reference or example which suggests a facility to get at its video stream to embed it in your application. I…
Quinxy von Besiex
  • 976
  • 11
  • 21
3
votes
2 answers

Convert c# windows panel to c HWND

I have a dll which accepts HWND, (code in the dll); void VideoCapture::SetVideoWindow(HWND VidWind) { VideoWindow = VidWind; } i am calling the above dll in a sample c#.net application by adding the dll in references, in c#.net i have a form…
Shiva Kumar
  • 389
  • 3
  • 22
3
votes
1 answer

How to get WNDCLASS from HWND?

I'm working now with playground SDK and need to get WNDCLASS of my game window. I haven't found anything in SDK, thats why I'm trying to do this with hWnd of game window. So is there any way to get WNDCLASS from HWND? I need this to change system…
ElDorado
  • 448
  • 6
  • 19
3
votes
2 answers

Setting a HWND's lpfnWndProc from another process

I have a win32 main application that spawns a child process. At the moment I use CreateWindowEx to create a HWND in the main application followed by spawning a child process. The child process then looks up the HWND using FindWindow. I would like to…
Joe Tam
  • 564
  • 5
  • 16
3
votes
4 answers

What is the correct way to use ShellExecute() in C to open a .txt

Alright so i need to open a .txt file that will be created in the same file as the program. I would like to use ShellExecute(); to do this and i have done a lot of research on it and i just cant seem to get the syntax correct mostly because i dont…
Bevilacqua
  • 465
  • 3
  • 8
  • 19
3
votes
2 answers

Get Control/Form object from IntPtr Handle

I try to get the managed control from a shown Word Application window using following code: Process[] processes = null; processes = Process.GetProcessesByName("WINWORD"); Process wordProc = processes[0]; Control wordControl =…
inva
  • 751
  • 2
  • 13
  • 28
3
votes
1 answer

Wrapping and Passing HWND with Boost.Python

I've created a Boost.Python wrapper (using Py++) for a C++ legacy class that takes a HWND window handle in its constructor. However, after exporting the module to python when I try to use it, I get a type mismatch error. Here is the C++ class I'm…
Ehsan
  • 61
  • 6
2
votes
3 answers

"SendMessage" to 3 different processes in C++

I want to send keystrokes to multiple processes. For example, if I press “1”, then I want to send the “1” to 3 "Notepad windows". Frist I want to try to send a keystroke to notepad, but it fails on the HWND: //HANDLE hWin; HWND windowHandle…
Laurence
  • 1,815
  • 4
  • 22
  • 35
2
votes
2 answers

Create child Window of another process's HWND? (e.g. screensaver preview)

I'm writing a screensaver in Java. It's primarily for Windows, though I'd prefer it to be as portable as practical. According to http://support.microsoft.com/kb/182383, when a screensaver is invoked with command line args /p HWND, the screensaver…
LarsH
  • 27,481
  • 8
  • 94
  • 152
2
votes
2 answers

In wx.Python, how would I get the window handle (hwnd) to my frame and set its style?

How can I get a handle to my current window in wx.Python (hWnd) and set it's style to WS_EX_NOPARENTNOTIFY, or can I set this when I initialize the frame? This question is a result from an answer here
Fry
  • 4,106
  • 9
  • 38
  • 51
2
votes
0 answers

Getting the HINSTANCE from HWND

GetWindowLong (GetTopWindow(NULL),GWL_HINSTANCE) returns 0 ... (Also tried with GetWindowLongPtr) Does anyone have an idea why is that? Also how do you convert LONG to HINSTANCE? GetTopWindow(NULL) does not return null EDIT: The check is for a…
Raedok
  • 51
  • 1
  • 7
2
votes
1 answer

c# HwndSourceHook with Windows.Forms

i found this code: protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource; if (hwndSource != null) …
zee
2
votes
1 answer

How to pass a form handle to a DLL for use in Windows API?

First of all, I'm not too comfortable with DLL's. I've done them before, but know very little and always have problems. This DLL I'm building requires passing a windows form handle (HWND) into the DLL function, and the DLL shall call a Windows API…
Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
2
votes
2 answers

C++/Win32 enumerate windows belonging to my process & close them

I have a Windows app that houses a web browser (Internet explorer) embedded in it. The app can be closed from another process by means of IPC. It works just fine except the situation when the embedded web browser may be displaying a pop-up dialog…
ahmd0
  • 16,633
  • 33
  • 137
  • 233
2
votes
2 answers

C# HwndSource from Process.MainWindowHandle

I am trying to "hook" in to the messages of a window to detect a minimize/maximize. I've looked around, and think that the only/best solution to do this, is to hook into the messages of a window, and check for the WM_WINDOWPOSCHANGED message, and…
René Sackers
  • 2,395
  • 4
  • 24
  • 43