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

Make Qt top-level window "owned" by other non-Qt window within a single process

Is it doable on Windows through Qt API? I need such feature/behavior because I would like to integrate my Qt code as a plugin into a 3rd party application, and I want to do it as seamless as possible. For instance, I don't want to have another item…
Michal Wirth
  • 169
  • 2
  • 8
2
votes
1 answer

Qt mouse click simulation ERROR (AUTO CLICKER)

#include "mainwindow.h" #include "ui_mainwindow.h" #include #include #include #include #include #include #include #include std::vector
Artur Lodklif
  • 83
  • 1
  • 9
2
votes
0 answers

Using handles to extract data from external application

I need to extract data from an external application using handles.My problem is that if the application is closed and opened again the HWND is changed every time,so I was thinking of hooking to its windowClass name,all good until I found out…
John Pietrar
  • 513
  • 7
  • 19
2
votes
0 answers

Convert Selenium WindowHandle to WinAPI hWnd

Is there any way I can convert the Window handle in Selenium into a real window handle to use in WinAPI calls? Driver.CurrentWindow is returning "2dbb281a-e0aa-454c-8e40-2cdb7de7f238" I want to get a handle I can use with the…
BanksySan
  • 27,362
  • 33
  • 117
  • 216
2
votes
2 answers

Invalid HWND for parent

Is it possible to have a valid HWND with a valid parent, and then the parent become invalid without the child becoming invalid?
James Feder
  • 137
  • 1
  • 7
2
votes
1 answer

Host external app in a WPF panel

I am trying to host/run an Exe application within a panel inside of the main window of my program. The main window has a grid with 3 columns - two columns split evenly with a vertical grid splitter to section the left and right columns. The left…
Caleb
  • 23
  • 1
  • 5
2
votes
0 answers

Get HWND (Window Handle) of Windows Core Window in WPF application in C#

I am using the method GetForegroundWindow() to get the window a user is using. But if the window is Windows Store App/UWP app (example the calculator) I get the window with a title (Reiknivél in Icelandic), but the process is ApplicationFrameHost.…
Chris Johnsson
  • 468
  • 4
  • 13
2
votes
1 answer

handing qwidget.winid to DLL in Python

I have a dll, which use OpenGl to draw on window. Dll get window by HWMD. DLL: extern "C" __declspec(dllexport) int Init(HWND hWnd); extern "C" __declspec(dllexport) void Resize(HWND hWnd, int w, int h); extern "C" __declspec(dllexport) void…
den
  • 141
  • 1
  • 1
  • 6
2
votes
2 answers

HWND API: How to disable window animations when calling ShowWindow(...)

I would like to know how to suppress the animations when calling the HWnd ShowWindow() method. Here is my code: [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommands…
Mr Anderson
  • 2,200
  • 13
  • 23
2
votes
3 answers

Get outlook Active window handle hwnd in C#

I want to get the outlook Active window handle (hwnd) in C#. I want to use this for SendMessage() method which takes hwnd as first parameter. Outlook is open and not minimized. Tried to do like this.. dynamic winHwnd=…
2
votes
1 answer

Cannot find window using FindWindow

I've been trying to capture and copy to clipboard a window using C++. I've managed to make the code work for Notepad, but weirdly enough it won't find other windows that I tried : "Calculator" , "Wordpad", etc. This is the code: RECT rc; HWND…
Idan Raman
  • 31
  • 1
  • 3
2
votes
1 answer

Releasing and restoring an embedded window in Qt

In my Qt application, I need to embed a native window. I start by obtaining it's WinId. After that, I create the embedded widget in the following way: QWindow * window = new QWindow::fromWinId(winid); QWidget * widget =…
blomm444
  • 113
  • 1
  • 8
2
votes
1 answer

Determine if window belongs to desktop or Windows Store app

There are traditional desktop applications and Windows Store apps on the screen. I have their HWNDs. Can I determine what type of windows they are (Desktop or Store apps) based on their HWNDs?
2
votes
0 answers

Loading a window texture from a HWND into an OpenGL texture

So what I'm trying to accomplish is getting a handle to a window by name (e.g. Slack) and copying that windows pixel information into an OpenGL texture. I've been basically learning C++ and OpenGL as I've been trying to accomplish this. Before this…
Bjorninn
  • 4,027
  • 4
  • 27
  • 39
2
votes
1 answer

C++ Winapi HWND Get WndProc configuration

I need to get the current WndProc with its messages and configuration and add my own code to it. Why do I need this? Because I'm working under an IDE that defines a window (and its children controls) with a WndProc, and I need to modify it because…
ProtectedVoid
  • 1,293
  • 3
  • 17
  • 42