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

How to get the Handle Id from Process, HWND programmatically?

I try to get Handle ID of opened applications (windows). I run Window detective program, (like spy++) to verify that I get proper values. For testing I try to get only one Handle Id pointed by red arrow (see the image): So I have program that gives…
Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225
2
votes
1 answer

c++ ShellExecute "open" in already opened window

I'm trying to open a new folder in the same window that is already opened. This is the code: if (DirectoryExists(myfolder)) { HWND currenthwnd,hwnd; hwnd=NULL; currenthwnd=GetForegroundWindow(); if (currenthwnd!=hwnd) …
2
votes
1 answer

What are the implications of WPF not using Windows (pl.) for Controls?

It would appear that in a classic Windowstm application each control that is displayed (Button, ListBox, Menu, ...) gets it own Window (as in HWND). Further, with Windows Forms (WinForms), while the controls no longer use the classic Window Classes,…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
2
votes
2 answers

Is any application have HWND?

I'm learning C++. I wonder is any C++ application have HWND. Example bellow app, with no window created. If it have, how I can get its HWND? Thank you very much! #include int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,…
user2289150
  • 31
  • 1
  • 4
2
votes
2 answers

Get Window Handle (HWND) of a window created by a library call

EDIT: I forgot to mention, I do not have source code for the DLL that creates window, so I can't actually change the function to return HWND. I am creating a Win32 application, and am using a DLL that creates a window for me through one of its…
aeon
  • 1,029
  • 2
  • 13
  • 23
2
votes
1 answer

Win32: How do I make an HWND transparent to clicks?

I want an HWND that is transparent to clicks (i.e. passes them through to windows underneath). At first I tried WS_EX_TRANSPARENT but that has all sorts of redraw problems. Windows underneath end up drawing over my HWND. I did some searching and…
Vinnie Falco
  • 5,173
  • 28
  • 43
2
votes
1 answer

Qt, c++ QML and HWND

I need to use a DLL -library that requests a window handle (HWND) to draw it self on a form. I don't want it to ocupy the whole main form but be displayed in for example a sub widget's area. Now this is no problem using windows forms. But Can I do…
Artis De Partis
  • 311
  • 5
  • 13
2
votes
4 answers

Discover hWnd where mouse is

A long time ago I remember using a program where I just moved my mouse around the screen and it displayed the hWnd information (and some other stuff) of the window (and parent, and child) to where you were pointing your mouse. Does anyone know of…
Felipe
2
votes
2 answers

Cannot find child window with FindWindowEx function

I'm working on a little program to make my life easier when using Microsoft Remote Assistance (msra.exe). Using c++, I'm able to open msra.exe, then find the window handle. I then want to find the child windows(buttons), and interact with them. …
KrisSodroski
  • 2,796
  • 3
  • 24
  • 39
1
vote
1 answer

How can I determent if a window still exists with a HWND

Possible Duplicate: Validate HWND using Win32 API How can I determent if the window of a HWND still exists? I have a HWND of a window. The window exists in another process. I want to know if the Window is still “alive”. What is the best way to do…
Laurence
  • 1,815
  • 4
  • 22
  • 35
1
vote
2 answers

Excel VBA : Get hwnd value of a CommandButton

I'm going nuts here... How do you find the "hwnd" value of a CommandButton, in an Excel 2007 Form ? I've Googled, I've tried all kinds of suggestions (most of which suggest that a command button has a .hwnd member property - but it doesn't) and…
Mike Gledhill
  • 27,846
  • 7
  • 149
  • 159
1
vote
1 answer

LNK2028 and LNK2019 errors

I'm a total n00b to c++ and am trying to make a simple form app, but run into this kind of problem: 1>proyecto.obj : error LNK2028: unresolved token (0A00001E) "extern "C" int __stdcall SetWindowRgn(struct HWND__ *,struct HRGN__ *,int)"…
user1151923
  • 1,853
  • 6
  • 28
  • 44
1
vote
0 answers

C++ - How to execute python code using GetDlgItemText?

I have a .pyd, that when imported, creates a window in C++, with a Button and Edit box. When you click the button, it grabs the text out of the edit control using something like this: char szString[100000]; GetDlgItemText(hwnd, 2, szString,…
GreenMyth
  • 31
  • 1
  • 4
1
vote
2 answers

Is this hWnd a child of mine?

How can I tell if an hWnd belongs to one of my child controls? I want to do something like: if(this.Controls.Find(hWnd) != null) return false;
John Weldon
  • 39,849
  • 11
  • 94
  • 127
1
vote
1 answer

Reading Text in a Label From Different Application

I have a application working in my pc. I can get every detail of that application(handle,mainwindowhandle,etc.) And that application has a lot of labels, and I want to read that label and msgbox that string in my own application.
sarkolata
  • 370
  • 2
  • 7
  • 17