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
0 answers

Java Swing, create a panel over a window by its hwnd handler

I'm writing a java app and at some point I create a window using Windows API through JNI. How can I create a jpanel over a part of that window so I can add gui to it in the java side? If that's not possible, then can I create a window in java…
Damian
  • 5,471
  • 11
  • 56
  • 89
0
votes
1 answer

Show video from device driver in QWidget with native window handle (HWND) on QGraphicsScene

This is related to my previous question Qt GLWidget in GraphicsScene for fast video display from image data (C++ , Windows)?. I have been converting and showing video frames via a QPixMapItem in a QGraphicsScene / View, i.e. not with OpenGL. The…
handle
  • 5,859
  • 3
  • 54
  • 82
0
votes
1 answer

Get Win 32 window from Wnd Proc call

In my wpf project, i am hosting a win 32 window with listbox control. In this, is it possible to get that Win 32 window in Message Hook event handler? var view = new Win32Host(source.Handle, mViewMgr); view.MessageHook += View_MessageHook; IntPtr…
Muthalagu
  • 156
  • 1
  • 16
0
votes
2 answers

get active textview or activity using IME android

Im developing an IME for android. I want to get the activity or textview control information while using my IME program. Like Hwnd property in win32 API or sender property of focused control in .Net . Is there any possible API available? Sorry for…
0
votes
2 answers

Autohotkey - Trigger script when a certain button was clicked in a window

I know the actual button's handle. What I would like to check if that button was clicked and if so that would trigger an autohotkey script. Thanks in advance!
Ismo
  • 47
  • 1
  • 3
  • 7
0
votes
1 answer

Java: DataOutputStream through socket is wrong on other side (which is Python)

I've got a Socket, s and an long, 1312992. DataOutputStream out = new DataOutputStream(s.getOutputStream()); out.writeLong(hwnd); out.flush(); Doing self.hwnd, = struct.unpack('!Q', self.appletconn.recv(8)) print(self.hwnd) on the (python)…
Name McChange
  • 2,750
  • 5
  • 27
  • 46
0
votes
0 answers

VB.NET / Get WndProc of a window?

I'm trying to get the WNDPROC from a open Windows Explorer window. I can successfully get the handle of the window, but "GetWindowLongPtr" returns always "0". I'm declaring the entry: _ …
Meyer
  • 1
0
votes
0 answers

Covnersion from System::IntPtr to HWND

I have the following C++ code: HRESULT hr = S_OK; hr = DwmExtendFrameIntoClientArea(this->Handle, &margins); But, when I try to compile I get the following error: error C2664: 'DwmExtendFrameIntoClientArea' : cannot convert parameter 1 from…
Victor
  • 13,914
  • 19
  • 78
  • 147
0
votes
2 answers

WinAPI - how to organize lots of HWND objects?

As I push forward my first winapi UI, I find myself creating large, uncomfortable stacks of HWND variables in my WinMain file: HWND foo; HWND bar; HWND baz; HWND etc; int WINAPI WinMain(...) {} Of course, these variables are used in the functions…
Ben
  • 54,723
  • 49
  • 178
  • 224
0
votes
0 answers

Attach a HWND to a foreign, existing one (windows order)

just a hopefully not too long qquestion: Is it possible in C++ to "attach" to HWNDs to eachother? As an result the one should always follow the otehr one, no matter whether there are other windows infront of them or whether that window is…
DragonGamer
  • 834
  • 3
  • 9
  • 27
0
votes
0 answers

GetForegroundWindow not always correct?

I have some code that seems to have an error. I didn't write it, in fact it is in c++ and until a few weeks ago I have never written any code in c++. We have a keyboard for a touch screen that we bring up when keyboard entry is required and closed…
Brian Hanf
  • 544
  • 2
  • 11
  • 31
0
votes
1 answer

bitmap inverted color

Some time ago I asked a question about saving hwnd into ppm file. Thanks to a stackoverflow user I have solved my issue. Iy's work correctly but I still have a problem: the red and blue color are inverted. the code and my previous question where…
ramone
  • 266
  • 1
  • 2
  • 10
0
votes
1 answer

hwnd to ppm issue

I have a function which save a hwnd into a ppm file. This function is inspired by a msdn example. Both the msdn sample and my function work but ... I have an issue ... But first, here is the function. int CaptureAnImage(HWND hWnd) { HDC…
ramone
  • 266
  • 1
  • 2
  • 10
-1
votes
1 answer

Can't figure out how to register a global hot key in my C++ application

Hotkey events are only getting to my application if I have a visible main window. I'm trying to register global hotkeys. When my application doesn't have a visible main window running, GetMessage never returns. I'm not sure how to fix it. int…
user3056541
  • 75
  • 1
  • 5
-1
votes
1 answer

Given an HWND, how can I cast to a String in C++?

I need to write a program in C++ that queries the OS for running Windows, find a Window with a specific window title, and return the Native Window Handle value as a String. So far, I've figured out everything but the last part. I'm not too familiar…
lakers5824
  • 345
  • 1
  • 2
  • 10