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

win32 c++ set window location to the right-down corner

How to set a window to the right-down corner of the screen (not including the taskbar)? Can I accomplish it with CreateWindowEx? But I only saw CW_USEDEFAULT and there is no CW_ to set it to the corner. HWND hwnd = CreateWindowEx( NULL, …
user11847100
3
votes
1 answer

Create window and listen on native messages in nodejs

Already for a hole year I try time to time again to create a windows window in nodejs to get the native handl and listen to incoming messages. I used as a workaround an electron window. But creating a full-blown browser just to listen to windows…
Noim
  • 445
  • 1
  • 3
  • 20
3
votes
1 answer

Bitmap from program child window returns as black

Current situation: I have a program called "NoxPlayer" which is basically an android emulator. I also have a c++ program which locates the window handle of said NoxPlayer and makes a bitmap of the current state of the window and saves it to the…
user7346067
3
votes
1 answer

Warning when casting int to HWND

I have a program I'm writing for Win64 in C++ that is executed from a parent program, and needs to set its parent window to the parent program's window. The parent program passes in it's HWND in as a command line argument, and I'm parsing the…
Thomas
  • 1,123
  • 3
  • 13
  • 36
3
votes
3 answers

Convert HWND to Hex String in C++

What is the best way to convert HWND to Hex String in C++, I mean also with a "0x" prefix? HWND hWnd = FindWindow(L"Notepad", L"Untitled - Notepad"); MessageBox(nullptr, LPCWSTR(hWnd), L"Hello World!", MB_ICONINFORMATION | MB_OK |…
Blueeyes789
  • 543
  • 6
  • 18
3
votes
1 answer

QML get the winId of a loaded qml window

I would like to get the winId of a qml window. I have the following files. main.qml : import QtQuick 2.5 import QtQuick.Window 2.2 import QtQuick.Controls 1.4 Window { id: myMainWindow title: "MyMainWindow" width: 200 height: 200; …
SteveTJS
  • 635
  • 17
  • 32
3
votes
1 answer

How to change console window style at runtime?

I'm making a game in console application and I want to prevent user resizing and maximizing window. How can I do this using HWND?
Ovidzikas
  • 113
  • 11
3
votes
0 answers

How to monitor the close event of a window by its handle?

I have a method that retrieves the handle of the current fore-window on windows explorer. I want a method/procedure to be fired when this window closes or before window closes. What are the available windows APIs available for this job ? (if any…
Nilaksha Perera
  • 715
  • 2
  • 12
  • 36
3
votes
2 answers

HWND Change cursor when mouse Hover

I need to change the cursor icon when the mouse hovers a certain HWND. I achieved the mouse cursor change with SetClassLong(hWindow, GCL_HCURSOR, (LONG)LoadCursor (NULL, IDC_CROSS)); But it applies the cursor to each element which share the same…
ProtectedVoid
  • 1,293
  • 3
  • 17
  • 42
3
votes
2 answers

How do I reliably determine the window handle of a given Outlook inspector window with WordMail turned on from inside a COM-Addin (Outlook <=2003)?

[This code is called from within the Inspector.Activate event handler (first call), i.e. right before the inspector window is actually shown.] For "native" mail inspectors I can simply QI the Inspector interface to IOleWindow and call its GetWindow…
Oliver Giesen
  • 9,129
  • 6
  • 46
  • 82
3
votes
0 answers

Difference between lpClassName and lpWindowName

I was searching through the Window Properties of a normal Application-Window in Windows. There are winapi functions like: HWND WINAPI FindWindow( _In_opt_ LPCTSTR lpClassName, _In_opt_ LPCTSTR lpWindowName ); ...which return a Window handle…
Vinz
  • 3,030
  • 4
  • 31
  • 52
3
votes
1 answer

Get hwnd of Excel InputBox Method

I think I have a fairly simple question. I'm looking for a method to get the hwnd for an excel input box. I'm automating a process and I'm noticing that a type 8 input box is consistently underneath the excel window (I'm automating excel from…
MattB
  • 2,203
  • 5
  • 26
  • 48
3
votes
1 answer

How can I know which item in a mult-select Microsoft Access listbox was clicked?

I have a listbox in a Microsoft Access form. The MultiSelect property is set to simple. I want to know which item in the listbox was clicked. Keep in mind that an item may be clicked to SELECT or UNSELECT an item. Is there a simple way to do…
Seth Spearman
  • 6,710
  • 16
  • 60
  • 105
3
votes
2 answers

How often are process handles reused

I note an applications handle when I use the shell function to open it. I then use that handle to close the application later. However the user can also close that other application himself. Can that handle then be reused by windows so that when I…
jjb
  • 1,340
  • 1
  • 13
  • 21
3
votes
1 answer

Get window hwnd if owner hwnd, class name and size of the window are known

I need some specific help. I know the class name, the owner hwnd and the size of a window. How do I get its hwnd? Or, at least, get a list of all the windows meeting those conditions. Thanks in advance! Vali
Valentin Radu
  • 629
  • 1
  • 11
  • 26