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
2
votes
0 answers

SetParent causes my WPF window to become invisible

I'm writing a program in WPF which will make a Window appear overlaid on top of a specific Win32 window in another process. So far this generally works: Get the hWnd of the window I want to overlay (the target). Instantiate my overlay window (class…
Dai
  • 141,631
  • 28
  • 261
  • 374
2
votes
0 answers

How can i determine target control/window when WindowFromDC returns null?

I am new to win32 programming.I am intercepting an application from my application using MadHookc, by hooking dll funceions. I am hooking the ExtTextOutW function to get the text used for display in the application. Hookign ExtTextOutW gives me near…
Anonymous
  • 1,726
  • 4
  • 22
  • 47
2
votes
1 answer

Managed form as child of unmanaged HWND

I need to show my System.Windows.Forms.Form as a child window of an unmanaged C++ HWND. This is the C# SDK code that retrieves the NativeWindow: public static NativeWindow MainWindow() { Diagnostics.Process process =…
David Rutten
  • 4,716
  • 6
  • 43
  • 72
2
votes
0 answers

How To CaptureScreen at Virtual Desktop?

I run test program windows8 or 7 64/32bit but i can't capture screen when running virtual desktop here is my code hwnd h1 = createwindows(....) or dialog.. //if this line remove capture code works fine hDesktopCurrent = NULL; hOriginalInput =…
user3451580
  • 31
  • 1
  • 5
2
votes
2 answers

How to introduce HWND in C++/CLI code?

Big picture -- I have regular C++ code (some functions put in the namespaces) and I have C# code which should call this C++ stuff. As I was told the only way to do this is to write C++/CLI wrapper. Based on what I read I try to use the headers from…
greenoldman
  • 16,895
  • 26
  • 119
  • 185
2
votes
2 answers

Direct2D window black when not in focus

I have a Direct2D window which paints fine when in focus; however, when focus moves to another window (same application or another), the entire window goes black. I pinned the issue down to the use of ID2D1HwndRenderTarget::Clear. This function is…
Saul
  • 992
  • 1
  • 13
  • 26
2
votes
3 answers

Automate drop-down menu, button clicks using C++

I've an EXE for an application "MyWindow1" which launches a window which has few drop-down menus, few buttons etc.. I don't have the source code for this application "MyWindow1". What I've is just it's EXE & some of it's dependent DLLs which are…
codeLover
  • 3,720
  • 10
  • 65
  • 121
2
votes
0 answers

Get ScrollInfo for TNewCheckListBox (Inno Setup)

I'm trying to use the scroll bar position code from this article to get the scroll bar position of a TNewCheckListBox object I have defined. It seems like the handle parameter is not accessible. I want to be able to adjust the related hover message…
Tom Clarke
  • 118
  • 8
2
votes
1 answer

WINAPI GetMessage HWND

I am working on window creation with Win32 API and I'm having a problem with this part: GetMessage(&message, NULL, 0, 0); My problem is that when I try to change the second parameter (hwnd) which is going to receive the messages to the window I…
user3407319
  • 227
  • 2
  • 10
2
votes
1 answer

How to get DC handle from Wnd handle for PathCompactPath?

I'm trying to figure out how to use the Windows API function PathCompactPath. It needs a handle to a device context (hDC) in addition to a pixel length to which a path string is shortened, where the device context contains information about the font…
Felix Dombek
  • 13,664
  • 17
  • 79
  • 131
2
votes
0 answers

Black lines on bitmap of captured HWND

I am working on an app that basically capture an application and draw it in openGL. I first get a valid HWND and want to retrieve all the other windows that are related to it. I fetch all those by using the main HWND pid. I put all of them in a list…
Al_th
  • 1,174
  • 1
  • 12
  • 24
2
votes
1 answer

Setting active a Chrome window (C++)

I am trying to set a Chrome Window to the foreground and active it in order to get the focus of the keyboard. My code works with Notepad or IE, but does not work with Google Chrome. //Getting the HWND of Chrome HWND chromeWindow =…
Víctor Martínez
  • 854
  • 2
  • 11
  • 29
2
votes
1 answer

WPF application crashes randomly reporting internal error with exit code 80131506

I have an issue with my WPF application crashing randomly (but at least twice per day) leaving the following message in windows Application log: Application: AppName.exe Framework Version: v4.0.30319 Description: The process was terminated due…
Netrunner
  • 43
  • 5
2
votes
1 answer

How do i convert HWND to LPCSTR in C++

What should i do to convert a HWND data type to LPCSTR. I need to print it to debug window using OutputDebugStringA function
Jasir
  • 677
  • 1
  • 8
  • 26
2
votes
2 answers

Finding the hwnd of a textbox in another window

Im trying to get this thing to work all day. Im trying to paste an input text to a textbox in another windows application, (lets say Chrome's URL bar) I managed to get the main window hwnd, but when I used SendMessage, it just changed the title of…
user1018517