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

Unanswered old post: Excel custom icon lost with multiple workbooks

I can use the following code to set a custom icon for the Excel application. This will change the icon of the window, and the icon displayed in the Windows taskbar: Public Const strIcon As String = "%SystemRoot%\system32\SHELL32.dll" ' Icon…
Chris Melville
  • 1,476
  • 1
  • 14
  • 30
1
vote
2 answers

Create Object in Main Form (EXE) from DLL

I am trying to create a TButton object in DLL to show it up in EXE Main Form.Here is My Code: DLL: library dlltest1; {$mode objfpc}{$H+} uses Classes,sysutils,Forms,Interfaces,StdCtrls,Windows,Dialogs { you can add units after this }; function…
HolyLilly
  • 43
  • 6
1
vote
0 answers

Drawing On Top Of TitleBar (With Graphics.FromHWnd())

I am attempting to overlay a status message on an external application. Previously, I achieved this by using a TransparencyKey on a Form and the following API call to get the window location with a hook to capture the window moved…
ScottishTapWater
  • 3,656
  • 4
  • 38
  • 81
1
vote
0 answers

How to get a relational window tree like Spy++ does?

I'm trying to understand the hierarchy of window handles on Windows (Win32's HWNDs.) So my question is, say if I have a starting HWND, how do I build its relational tree with Win32 APIs? Akin to what spy++ tool does in Visual Studio: I tried…
MikeF
  • 1,021
  • 9
  • 29
1
vote
1 answer

Implement HwndHost to handle MouseMove and MouseWheel in C# WPF

I am trying to host DirectX content inside WPF app. What I learnt from this link is to subclass HwndHost and create your own implementation of WndProc as well BuildWindowCore and DestroyWindowCore.…
Jay Nanavaty
  • 1,089
  • 1
  • 15
  • 29
1
vote
1 answer

Visual Studio 2010 hijacks Interop Callbacks and/or hides the true window handle

I am working with a vendor provided non-managed DLL to interface with some custom hardware. Unfortunately I cannot post the vendor code, but hopefully the sanitized code below will provide enough information as to the cause of the problem. The…
ViNull
  • 1,022
  • 8
  • 12
1
vote
0 answers

How do I create a button in c++ with my own custom image?

I've been looking for a way to make a picture a button in c++ for a few hours now.. I've found stuff on using bitmaps, what what i am currently using to display the image is GDI+, because i want to use jpg/png files. This is how i created my Image…
D.C.Adams
  • 15
  • 8
1
vote
1 answer

Bind window handle (HWND) to class name/ component type in unmanaged code

I would like to find out the top level component name of a window from knowing its window handle. This is done like so in managed C++ code: //handle is the window handle as int System::Windows::Forms::Control^ c =…
prettyCode
  • 103
  • 2
  • 11
1
vote
1 answer

How to get PID (Process ID) of Word instance or Hwnd property?

I'm looking for a better way of coding for proper closing of WINWORD.EXE or word process in my application by getting its PID (Process ID) just like getting the PID in Excel. This is my sample of getting the PID of an Excel using Hwnd property and…
chobowski
  • 109
  • 1
  • 13
1
vote
1 answer

Does a handle received by FindWindow need to be released?

The application I'm writing is using a virtual keyboard. To show, hide, resize or move the virtual keyboard, I first need to get a handle to it through a call to FindWindow function and then send it some messages by PostMessage. Since I have no…
relatively_random
  • 4,505
  • 1
  • 26
  • 48
1
vote
1 answer

DirectX to OpenGL hot-swap, doesn't display on Win32 window

During the developement of my engine, I'm trying to implement a feature, that enables hot-swapping between OpenGL and DirectX. Currently I'm testing on Win32 platform, and came across the following problem: I implemented both renderer (OpenGL 3.0,…
Sipka
  • 2,291
  • 2
  • 27
  • 30
1
vote
1 answer

Use HWND to toggle application fullscreen

So I am trying to move another application to a second screen and then I want to set it full screen in C++. I have the HWND handle from the application from a list of processes and then I can set the position from the window where I want with…
Alexander S.
  • 158
  • 2
  • 16
1
vote
1 answer

Create resizable window with fixed top coordinate

I'd like to implemented a window that its top coordinate is always X (for simplicity let's say 0). Meaning, the window's top side is fixed on 0 which is the top of the screen. I've already implemented the window, set its position using SetWindowPos…
idanshmu
  • 5,061
  • 6
  • 46
  • 92
1
vote
2 answers

Find Window and change it's name

Sup What i'm trying to do is a way to find a window though it's process ID, get the name of that window and change it to something that i want. I found some things about that : ( Code 1 ) int WINAPI GetWindowText( _In_ HWND hWnd, _Out_…
Bruno Cerk
  • 355
  • 3
  • 16
1
vote
1 answer

Window clicked - what happens then?

I am working on a limited remote control of another PC over network. At first the controlled window is chosen and the client may control that window and all child windows. I am having a problem with the mouse though, I can move it using…
Neo_b
  • 231
  • 5
  • 9