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
6
votes
2 answers

How to get active window app name as shown in task manager

I am trying to get the active window's name as shown in the task manager app list (using c#). I had the same issue as described here. I tried to do as they described but I have issue while the focused application is the picture library I get…
eskadi
  • 245
  • 3
  • 17
6
votes
2 answers

Can I get the behavior of setting my WinForms form's owner using an hwnd / NativeWindow?

My application is a vb6 executable, but some newer forms in the system are written in C#. I would like to be able to set the C# form's Owner property using a handle to the main application window, so that the dialogs remain on top when tabbing back…
mcw
  • 3,500
  • 1
  • 31
  • 33
6
votes
3 answers

Is HWND visible?

Those darned users and their minimized windows. In C#, if I have a window's HWND, is there a way to tell if it is visible on the desktop?
directedition
  • 11,145
  • 18
  • 58
  • 79
6
votes
6 answers

How can I get the window handle (hWnd) for a Stage in JavaFX?

We're building a JavaFX application in Windows, and we want to be able to do some things to manipulate how our application appears in the Windows 7/8 taskbar. This requires modifying a Windows variable called the "Application User Model ID". We've…
Xanatos
  • 1,576
  • 18
  • 28
6
votes
2 answers

Delete an HWND object

I have a situation where when I receive a message I must delete a window just from the hWnd. I though this must be possible since CreateWindowEx creates an object by returning a HWND, I must be able to delete one. Note : The hWnd lies on some other…
user1151738
6
votes
8 answers

getting the HWND for my own application in C

since I couldn't find an answer to this question I researched a bit further into the MSDN and I found isChild(). It might give me the answer to that other question. Now, in order to use isChild() I need to pass the HWND of the parent application…
wonderer
  • 3,487
  • 11
  • 49
  • 59
5
votes
1 answer

GDI rendering to WPF window

I've done some searching, but I can't find an exact answer on this. In my C# WPF app, I get the HWND pointer and pass it to a C dll. That C dll then attempts to use GDI calls to render an overlay of sorts on my window. There are no errors, but…
Arian Kulp
  • 831
  • 8
  • 31
5
votes
2 answers

How do I get a HWND from inside a DLL?

I have a DLL that I want to play sounds using Direct Sound. In order to play sounds, I need the HWND of the executable. I don't have a HWND of the executable that loads the DLL. How do I get that in the DLL without passing it in from the…
zooropa
  • 3,929
  • 8
  • 39
  • 61
5
votes
4 answers

WPF rendering problem with HWND children in the way

I suppose it is safe to say that WPF renders its contents as a window background. There are no child windows in a traditional HWND sense. So, when one introduces something HWND based in a WPF app, like a WebBrowser, things start to go wrong way it…
wpfwannabe
  • 14,587
  • 16
  • 78
  • 129
4
votes
1 answer

Get HMENU from HWND within a Hook

I'm installing a hook within my application to get the standard EDIT context menu (with undo/copy/edit/paste/etc.). I need to insert a new menu item for my application. I've set a windows hook, but I can't seem to get the HMENU for the context menu.…
jubican
  • 43
  • 1
  • 3
4
votes
1 answer

How to convert a command line string to hwnd in C++?

I want to create a screen saver in C++ using OpenGL. The command line sent to my app for previewing the screen saver in a small window contains a number which is the hwnd of the small monitor window in screen saver control panel applet. how can I…
Sina
  • 41
  • 1
  • 2
4
votes
2 answers

C# show hidden window

I am developing an add in for excel. At some point, I can receive async events. I need to be able to show the Excel window if hidden on these events. I am able to store the Hwnd property, which I believe must be an immutable int/reference to…
BuZz
  • 16,318
  • 31
  • 86
  • 141
4
votes
0 answers

Win32: Enumerate real windows in real activation order

I am beyond tired researching this topic at this point. There are a million APIs in the system to achieve part of this, i.e. enumerate all windows, but nothing about how to get them in the real z-order. How to do that? Let me explain. Firstly, of…
user1371019
  • 159
  • 9
4
votes
1 answer

Embed HWND (Window Handle) in a JPanel

I am trying to embed a HWND (Window Handle) in a JPanel. Actually, I can embed my HWND into a JFrame, but the embedded window alway stay on top of the other component and I can't move it. If a try to remove all the child component of my JFrame, the…
Etienne
  • 1,024
  • 25
  • 33
4
votes
2 answers

How to get Node handle in javafx8

We're building a JavaFX application in Windows. I've tried to use JNA Native.getComponentPointer() method which works with java.awt.panel, but I can't figure out a good way to do this with a javafx.scene.layout.Pane Does anyone know of any way to…
yeyb
  • 41
  • 1
1 2
3
26 27