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

How to init glad without the glfw loader (using windows headers)

I'm trying to render to a HWND window using a HGLRC OpenGL rendering context. I have to initiate the glad but gladLoadGLLoader((GLADloadproc)wglGetProcAddress)) and the gladLoadGL() seems to be failing. glad OpenGL version : 4.0 core I've been…
LucasSokol
  • 125
  • 4
1
vote
2 answers

HGLRC OpenGL rendering context - How to indicate the version of the OpenGL

How I'm creating my rendering context using wgl : //Device HDC hdc = GetDC(hWnd); HGLRC hRC = wglCreateContext(hdc); How/where/when should I change the version of the OpenGL context? Is there a function like wglCreateContextVer(hdc, major(3)…
LucasSokol
  • 125
  • 4
1
vote
0 answers

C# FindWindowsEx unable to get child handle

I want to launch an external application and get the handle of its Connect button. I get the top level "000A0B32" and I can get this 100% correct. Then I'm trying to get the child element "000F0C58" and get the Connect button under it. But getting…
okaken
  • 13
  • 4
1
vote
0 answers

.NET Handle to HWND

Another basic problem - I can't convert a Process.MainWindowHandle to an HWND. I've tried using Process->MainWindowHandle.ToPointer() and passing that through, but still no love. Here is a function that gets an HWND from a Point, and then passes…
HeWhoWas
  • 601
  • 1
  • 10
  • 22
1
vote
0 answers

Have Direct2D, DXGI SwapChain, HWND transparency, all working at once in C++, without XAML or similar

Context I have 2 big projects I'm working on: a game engine, and a file explorer replacement. My focus is Windows only. I know they're 2 huge things I'll likely never complete, I just enjoy coding during free time. Across my many projects I started…
Barnack
  • 921
  • 1
  • 8
  • 20
1
vote
0 answers

Can't display unicode on title bar in WIN32

I have been trying to create a Window whose title bar could be in any language. But I am getting something like ▯*. I writing as escape characters as of now. I am attesting the entirity of the code. #define WIN32_LEAN_AND_MEAN #include…
1
vote
0 answers

How can I capture the HWND of the last opened Explorer window before my PowerShell script console opens?

I have a script that is invoked via right click context menu in Windows Explorer. I'm not sure if this is possible, but I want to capture the HWND of the window from which I invoked the script. Right now I have this: Add-Type @" using System; …
fmotion1
  • 237
  • 4
  • 12
1
vote
1 answer

find the hwnd of a window which user selects, through c#

I've written a c# program which reproduces keyboard strokes programatically. My idea was to pass these keyboard strokes to another application which may have a textbox set in focus. So in my program i want the user to select the window to which i…
Anirudh Goel
  • 4,571
  • 19
  • 79
  • 109
1
vote
1 answer

How to pass variables to function exported by a DLL, I get error LNK2001

I have to pass a HWND variable from the main program to a function exported by a DLL. Variable is called mainHwnd and DLL is defined in this way: mydll.h #ifdef MYDLL_EXPORTS #define MYDLL_API extern "C" __declspec(dllexport) #else #define MYDLL_API…
gc5
  • 9,468
  • 24
  • 90
  • 151
1
vote
1 answer

openCV - Using matchTemplate() from a window using hWND C++

I am running an infinite loop and every frame I'm taking a screenshot from a desired window and turning it into a Mat then searching that Mat for a template image using matchTemplate. If I read in the template image and the entire image, I can use…
1
vote
0 answers

How to get WM_COPYDATA in python

i'm trying to do (what should be) some minor work with win32. I basically just need to send a message and wait for a response. I need the HWND or window handle of my python script/program to actually send the message. I need to receive a…
BunnyHoppin
  • 39
  • 2
  • 5
1
vote
1 answer

How can you get the handle of a chrome process in java using JNA

I am new to JNA, and I need to take a screenshot of a chrome window using java and JNA, I already have the function for taking screenshots of a given window using this code: public BufferedImage capture(WinDef.HWND hWnd) { WinDef.HDC…
xliquid
  • 17
  • 5
1
vote
2 answers

In Win32, How can I detect if a HWND is a dialog?

In a pure C Win32 application, how can I detect if a HWND is a dialog?
rodrigocfd
  • 6,450
  • 6
  • 34
  • 68
1
vote
1 answer

hwnd window handle problem in saving file in different locations

New to windows forms/window handle. Trying to save files in different locations. SaveFileDialog Image: enter image description here I am able to get the edit box handle of the file name edit boxes in save file dialog. Able to paste the path. enter…
Baj B
  • 65
  • 4
1
vote
1 answer

Get ITaskbarList3 data of specific window

ITaskbarList3 interface provides only setter methods. Is there a way to get the information (like HWND list of the tabs) for a specific taskbar entry?