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

Unable to figure out problem with BitBlt in win32

I am new to windows programming and stuck with legacy code of software and having difficulty in figuring out the cause. The problem at hand is I have a SourceHDC and I am dumping it onto ScreenDC(HWND) and to memory DC. The screenDC behaves…
Illuminati
  • 111
  • 7
2
votes
3 answers

Win32 Unable to add custom toolbar icon having transparency

I am using this code to add a toolbar to the window with one button having a custom image: HWND hToolbar = CreateWindow(TOOLBARCLASSNAME, NULL,WS_CHILD | TBSTYLE_FLAT|TBSTYLE_AUTOSIZE |TBSTYLE_LIST|CCS_BOTTOM, 0, 0, 0, 0, hwnd,…
user11847100
2
votes
2 answers

Win32 Use a resource font inside the application

I have an application, and I imported some fonts into the resource. Now, I want to use those resourced fonts inside the application, without installing them to the computer that runs it. The way I want to use the font resources is that I want to…
user11847100
2
votes
1 answer

How to vertically center text in an edit control?

Trying to vertically center/align the text in an edit control (Win32 API, pure C, no MFC) but with no luck. Tried solutions from other answers such as this one or this and other quite old forums around, but no luck: I could reduce the height of the…
evilmandarine
  • 4,241
  • 4
  • 17
  • 40
2
votes
2 answers

How to get a Java component ID

I'm using MPlayer in my java application. According to its doc, it's needed that I tell to MPlayer the window ID for embedding it. I'm doing this like that: long winid = 0; //Window ID. if (osName.startsWith("Windows")){ final Class cl =…
Manoel Afonso
  • 47
  • 1
  • 10
2
votes
1 answer

OpenCV c++ hwnd2mat(screenshot) -> blobFromImage : Error

I am working on screen capture object recognition system. My code: #include "opencv2/imgproc.hpp" #include "opencv2/highgui.hpp" #include "opencv2/dnn.hpp" #include #include #include using…
Kmopsuy
  • 95
  • 1
  • 2
  • 10
2
votes
3 answers

How to find main HWND handle of MFC-using parent process

I have a DLL file that is running under a parent piece of software. The parent software uses MFC and displays a main GUI window. What I want to do is create my own little modeless dialog box to pop up on the screen and sit right next to the main…
Scott
  • 1,176
  • 2
  • 13
  • 19
2
votes
1 answer

How to get the hwnd of WIn10 start menu in C++?

I used FindWindowEx+ CLassname:Windows.UI.Core.CoreWindow and caption: start menu to find the hwnd of win10 start menu, but return NULL, i wangt to get it's hwnd ,then i can get the rectangle,but i can't get the hwnd , there is anybody know how to…
2
votes
2 answers

How can I make a Form and a HWND mutually reposition?

I have a System.Windows.Form and a IntPtr acting as HWND. I want each of them to place the other on move. I'm surprised I couldn't find anything on the web with "Hwnd get/set position c#" and many variations, perhaps I'm overlooking obvious…
Lazlo
  • 8,518
  • 14
  • 77
  • 116
2
votes
1 answer

how to display the virtual folder only when user open the windows explorer from an app on win 7?

--------------------------------second updates------------------------ I tried: STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, void *) { // Get the path and module name. WCHAR szModulePathAndName[MAX_PATH]; GetModuleFileName(hInstance,…
beasone
  • 1,073
  • 1
  • 14
  • 32
2
votes
1 answer

Control any SAVE button (or other) in VBA with IUIAutomation

There is a few intents of using IUIAutomation with VBA in this forum. But all of them relies on the fact that you know the name of the class to use it in FindWindowEx. In the most popular one is: Controlling IE11 "Do you want to Open/Save" dialogue…
Weichafe
  • 97
  • 1
  • 10
2
votes
1 answer

How can DOM elements be retrieved from a C++ program?

I would need to get all elements of webpage displayed in IE from a c++ program. I tried to see with spy++ but there's only the IEFrame. So I'm thinking about using the developement tool (F12 in IE), I heard there's a way to automat it, a good idea…
Entretoize
  • 2,124
  • 3
  • 23
  • 44
2
votes
0 answers

Handling keyboard input winapi

Suddenly had to finish the old project and ran into problem with keyboard input handling. I have a window with a list of items. I want to select an item by pressing the first few letters of its name on the keyboard, as it works in the Windows.…
Peter
  • 435
  • 1
  • 3
  • 11
2
votes
0 answers

When the HWND is destroyed and recreated during the lifetime of a component?

In this question, Remy said in a comment that: the HWND provided by the TWinControl.Handle property is not persistent. It can get destroyed and recreated during a component's lifetime, even multiple times. Every time the TShellListView gets a new…
Marus Gradinaru
  • 2,824
  • 1
  • 26
  • 55
2
votes
1 answer

Prevent generation of WM_MOUSEMOVE after popup window is shown/hidden

I have encountered an annoying problem. When the mouse pointer is positioned over my main window and the owning popup window is shown (see example below) or is made invisible a WM_MOUSEMOVE message is generated each time even if the mouse has not…
bkausbk
  • 2,740
  • 1
  • 36
  • 52