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

Sending message to explorer.exe main window with a hook causes crash?

I am trying to set a WH_CALLWNDPROC hook on a window using the HWND I got from WindowFromPoint and send a message WM_USER+x after. But depending on the HWND I use it crashes the window. Let me explain the scenario: When getting an HWND through the…
Nur1
  • 418
  • 4
  • 11
-1
votes
1 answer

hWnd PostMessage simulation of a left keypress doesn't work

I'm trying to make a program that will simulate a LEFT keypress to a window. I'm using this: PostMessage(hwnd, WM_KEYDOWN, new IntPtr(0x25), new IntPtr(0)); and this: PostMessage(hwnd, WM_KEYUP, new IntPtr(0x25), new IntPtr(0)); But the results of…
Flafy
  • 176
  • 1
  • 3
  • 15
-1
votes
1 answer

identifier "hWnd" is undefined

I am trying to create a simple Tic-Tac-Toe game for a school project. I don't really know how to work with windows and I just want to work with others' code, using the default "Windows Desktop Application" (C++) in Visual Studio, but it keeps giving…
-1
votes
1 answer

Get Correct HWND With Comparing GetCurrentProcessId();

I am wondering how i can get the correct HWND from the process my DLL is injected into. I made the code bellow myself and are wondering how and if i can improve it so it does the same think as if i used the FindWindow function like this…
gofmode
  • 21
  • 4
-1
votes
2 answers

Can't select text in RichEditComponent control

I want to keep my app's window in front of another programs's window. My app is created with WPF, I set owner with another window's hwnd like this: // this: my wpf window WindowInteropHelper helper = new WindowInteropHelper(this); //The hwnd is…
cqsir
  • 1
  • 1
-1
votes
1 answer

How do I determine the internal HWND used by COM in my current process?

I want to Post messages directly to the HWND that's owned by COM in my process. How do I get the HWND that COM is using in single-threaded-apartment mode?
zumalifeguard
  • 8,648
  • 5
  • 43
  • 56
-1
votes
1 answer

Select IE window using HWND

Wondering if it is possible to select an IE window based on the HWND property (or similar). My script clicks a link which opens a new page in a separate window and I would like to be able to work with this new window. Here is my…
Eric Furspan
  • 742
  • 3
  • 15
  • 36
-1
votes
1 answer

Even faster reading desktop color info

Is there any way to achieve faster color reading than what I wrote? class MyApi: def __init__(self): self.width = win32api.GetSystemMetrics(win32con.SM_CXVIRTUALSCREEN) self.height =…
Marek
  • 1,189
  • 3
  • 13
  • 33
-1
votes
1 answer

Window handle doesn't save correctly

I don't really get how to use HWND in c++. I want to press a button and it should start a thread with a code running. But I never receive the command for button click in an other callback. So I did some debugging and it seems like that…
user1552075
-1
votes
1 answer

DWM, how to not render a window?

My application is a fullscreen window rendering a specified window or the desktop. I would like to know if it's possible to fetch the window bitmap (like i'm already doing) but without the render of my window's application ? There is the idea :…
Erwan Douaille
  • 553
  • 1
  • 10
  • 31
-1
votes
1 answer

Can I activate and hide an HWND at same time?

I know that a window handle "HWND" can be hidden by the function ShowWindow(hwnd,SW_HIDE), this function deactivates and hides the window. What I want to do is to hide and activate the window at the same time, I want to get data from the window but…
ahmed
  • 37
  • 3
  • 7
-2
votes
2 answers

What's the format value from the HWND returned from CreateWindow()?

Is this a memory address ranging to (theorically) 2^32-1 on 32-bit machine? The reason I'd like to know that is I'm trying to somehow associate a HWND returned by CreateWindow() to a class instance, so in order to know how properly store that HWND…
Jack
  • 16,276
  • 55
  • 159
  • 284
-2
votes
1 answer

Get HWND of a window i clicked on

I'm making a program, with c++ and winapi, where you can click a button, then select a window and it changes the transparency of that window. I have no problems of making the window transparent, but i can't get the hwnd of a window. When I use this…
z32byTe
  • 13
  • 1
-2
votes
1 answer

SendInput() MouseClick have the right Position but no click

I have a problem and hope you have any solution for this problem! When executing from the SendInput function, the mouse is put in the right place but comically does not come a click. Did I possibly forget something? As you can see is the button of…
Lendoria
  • 127
  • 1
  • 11
-2
votes
1 answer

Learning reversing via C++, but what does this line do?

typedef int(__stdcall *__MessageBoxA)(HWND, LPCSTR, LPCSTR, UINT); As I said, im trying to learn how to reverse engineer programs using C++ / Assembly, so I'm going through some open source projects I found on the internet. But can anyone explain…
Wes
  • 11
  • 1
  • 3
1 2 3
26
27