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

List windows and detect new windows

I'd like to get a list of all the windows every time a new window is created. For now, I'm using a timer which gets an enumeration of all the windows. But I'd like to avoid using a timer, and subscribe to any kind of event that is triggered when a…
Drarig29
  • 1,902
  • 1
  • 19
  • 42
0
votes
0 answers

How can I set a window to a specified scale,just like window+tab do

I have a native window and I know it's HWND,how can I scale it just like window+tab do. That is, I want to embed a window to my own application and scale the window to fit my application's size. Thanks. window+tab
xiangxw
  • 1
  • 2
0
votes
2 answers

Is there a window style that corresponds to a HWND's class menu?

Windows has a number of window styles that corresponds to attributes of a window, and SetWindowLongPtr, used with parameters GWL_EXSTYLE or GWL_STYLE, can be used to toggle these attributes ON/OFF. For example, WS_CAPTION can be used to toggle a…
lancery
  • 658
  • 1
  • 6
  • 18
0
votes
0 answers

How to cleanup $IE object, close current processes

Is there a simple command to close the current IE COM Object as part of cleanup? First attempt, didn't work: Try{ $ErrorActionPreference = "Stop" $ie = New-Object -COMObject InternetExplorer.Application $ie.visible = $true …
Eric Furspan
  • 742
  • 3
  • 15
  • 36
0
votes
1 answer

Embed skia canvas in NSView and HWND, canvas flushed as blank when window resize

I'm trying to embed skia canvas into NSView and HWND to do some cross platform drawing. I'm using the class SkView comes with the skia source code, and use SkOSWindow as the window. But the window got blanked when the window is resizing. As showing…
Zhiqiang Li
  • 401
  • 7
  • 16
0
votes
1 answer

Native Handle of QMdiSubWindow

I'm trying to get the HWND of a QMdiSubWindow which I added to a QMdiArea. I used the following code to get the handle: Dialog* subWindow = new Dialog(this); QMdiSubWindow* sw = ui->mdiArea->addSubWindow(subWindow); (HWND) hwnd = id->winId(); To…
Kevin H. Klein
  • 403
  • 1
  • 5
  • 14
0
votes
0 answers

C++ .NET Construct control from HWND

Is it possible to construct a .NET control from an HWND? For example: HWND mHwnd; //ListView handler ListView^ lv = gcnew ListView(mHwnd); Or just a method that gets the control by an HWND: HWND mHwnd; ListView^ lv; lv =…
ProtectedVoid
  • 1,293
  • 3
  • 17
  • 42
0
votes
1 answer

Delphi - Get current monitor of running process's focused window (external)

So, as mentioned in the title, I'm after identifying which monitor (in multiscreen situation) is the external process (application) running on. I know that my form can be identified by TForm.Monitor.MonitorNum property, and so far I can get the…
That Marc
  • 1,134
  • 3
  • 19
  • 42
0
votes
1 answer

C++ Winapi HWND Get element by Name

Is there a way I can get a HWND by it's property "name"? I know that every IDE has its own properties for HWND elements but those properties are applied to the HWND. I'm not working in Visual Studio, this is just a case. I want to get HWNDs by Name…
ProtectedVoid
  • 1,293
  • 3
  • 17
  • 42
0
votes
2 answers

Getting handles of all controls on a window using it's classname

I can get handles using mouse location by clicking. But i need to find handles of all controls on a window using it's classname without clicking. I have to get them, while the window opened. Is it possible?
Onur Adıgüzel
  • 35
  • 3
  • 10
0
votes
1 answer

How to access windows in another session

I am developing an application for observing other applications (including applications of another user sessions) My application should collect information about CPU loading, memory usage and state of main window (if exists) of each application. Now…
0
votes
0 answers

Wrong hWnd pointers when migrating multi-project C++ MFC application from VS6 to VS2013

We are porting a multi-project C++ MFC application from Visual Studio 6 to Visual Studio 2013. We have encountered run-time errors that affect some of the MDI (multiple document interface) projects within the application. The hWnd pointers of some…
Ben VE
  • 1
  • 1
0
votes
0 answers

Add QT widgets to Windows API GUI

How can I add a QT widget to an existing GUI which created by Windows API. I have its HWND. If it is not possible, is there any way for nesting them? Thanks!
aviyaChe
  • 145
  • 1
  • 9
0
votes
3 answers

How to get the Handle that is executed in winexec or shellexecute?

i use to create a custom function like winexec(...):Hwnd that will retun the handle of executed application. i did use the findwindow() but having problem if it change window caption.
XBasic3000
  • 3,418
  • 5
  • 46
  • 91
0
votes
0 answers

C++ Get the Window object at a POINT in Windows

I have a LowLevelMouseProc implemented. When the user clicks the center mouse button I call WindowFromPoint to get the window at that point. What I want to do is be able to get the object that is actually being clicked on within the window at that…
Sean
  • 447
  • 1
  • 4
  • 15