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
1
vote
1 answer

What happens when the thread that is responsible for processing messages is hung?

I have an application in which one of the dll modules is responsible for processing user defined messages that get posted to its hidden window. Supposing the thread that is responsible to process these messages is hung while processing some other…
user2101801
  • 719
  • 2
  • 8
  • 20
1
vote
0 answers

C++ Win32: HDC's, HWND's, SelectObject, and GetObject

I'm new to win32 and there are some concepts I haven't fully grasped. For one, the difference between HDC and HWND. I understand (or think I understand) that they're handles to a objects and that hdc's can be derived from hwnd's. Like in the case of…
Jean Valjean
  • 747
  • 1
  • 9
  • 30
1
vote
1 answer

Find Messenger Hwnd

Does someone knows how can I find the HWND for all the msn messenger currently opened conversations windows? OR how can i find the HWND for the textbox whih is currently focused? TY
Itay.B
  • 3,991
  • 14
  • 61
  • 96
1
vote
1 answer

In Windows API programming how do I prevent mouse from leaving window?

How do I limit mouse to one particular HWND in Win32 API programming? This HWND is not necessarily created by me. It could be a browser window, or photoshop program window. I'm trying to write a program that doesn't let mouse leave particular…
bodacydo
  • 75,521
  • 93
  • 229
  • 319
1
vote
1 answer

GetWindowText is returning nothing

In one of my project I have to get the title of foreground window so I called GetForegroundWindow() Entry Point form User32.dll for getting the windows Handle then I called GetWindowText() for the title everything goes error less but the output…
1
vote
0 answers

How to get current URL for chrome current version in C++

i want to get URL from Google Chrome using the MSAA apis, i already found this on StackOverflow but i want to replicate this behaviour =>How to get current URL for chrome current version , without using AccessibleObjectFromEvent but with…
1
vote
0 answers

Meaning of negative value of MessageBoxA hWnd argument

I'm analyzing a malware in IDA, where I observed the malware launching a MessageBox with negative value of hWnd (FFFFFFF7h). Message box arguments (Source:MSDN) int WINAPI MessageBox( _In_opt_ HWND hWnd, _In_opt_ LPCTSTR lpText, _In_opt_ …
Kumar Vikramjeet
  • 253
  • 1
  • 4
  • 13
1
vote
1 answer

Is it possible to add control to another process's window?

I've created a MFC window and, from another project, I wanted to add a button to that window via its handle (using FindWindow). The handle is correct, but nothing happens. Is this unachievable or am I doing something wrong? Here's my code: HWND hWnd…
conectionist
  • 2,694
  • 6
  • 28
  • 50
1
vote
1 answer

Is there a way to get the Handle or CWnd* of a control using the ID of the control

If I have an MFC dialog with a button control on it, is there a way to get construct the HWND or CWND for that control using the button's ID (e.g IDC_BUTTON_YES)?
Amre
  • 1,630
  • 8
  • 29
  • 41
1
vote
1 answer

Cannot release Device Context, HWND, and cannot unregister Windows Class(OpenGL) -

I am following the http://nehe.gamedev.net/tutorial/creating_an_opengl_window_(win32)/13001/ OpenGL tutorial, and I got the code from that working. Now, I am trying to organise things by using multiple classes. As I was creating this class, I became…
Xcox123
  • 25
  • 4
1
vote
1 answer

Help getting QTP to identify a control

We're trying to use QTP (QuickTest Professional) to auto-test a legacy C++ application. However, the main window for the app is composed of several IDENTICAL panels. Each panel has a unique title. If I view the window in Spy++ (comes with…
Jeff B
  • 1,856
  • 2
  • 17
  • 28
1
vote
1 answer

Sending a message to any windows textbox just by focus

I need to know how I can send a message to any text box of windows. If a focus the google chrome url textbox, then I will "auto paste" the message, or if I focus a Word Document string, or notepad, or anything! I got a code ho sends by setting the…
Renan Macedo
  • 23
  • 1
  • 4
1
vote
2 answers

How to change the toolbar button's Bitmap in win32?

I have created a toolbar with some controls on it using ReBar within a window. Can anyone please tell me, How to get the HWND of a buttons/combobox/etc (not normal buttons in a window) if I know (only) the Id of it ? How to obtain the HBITMAP if…
Morpheus
  • 1,722
  • 5
  • 27
  • 38
1
vote
1 answer

How to get the list of controls from the window in Visual C++?

How to get the list of the controls from the window, specified by "FindWindow" function? For example I have a handle to the Notepad window by HWND Window = FindWindow(L"Notepad", L"dummy.txt - Notepad"); then I can make a handle to an "Edit"…
user3754079
  • 21
  • 1
  • 5
1
vote
1 answer

Getting handle of externally running visible windows c++

The problem is that, I want to get handles of all visible windows. Up to now I have achieved to get hwnd of a window which includes a substring. Here is my code. The block i have mentioned is in the comment, but i couldn't find any method to check…
zorkaya
  • 113
  • 1
  • 9