hwnd

long to HWND (VS8 C++)

Hi, How can I cast long to HWND (C++ visual studio 8)? Long lWindowHandler; HWND oHwnd = (HWND)lWindowHandler; But I got the following warning: warning C4312: 'type cast' : conversion from 'LONG' to 'HWND' of greater size Thanks. ...

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 and forth between my app and other apps. I can get the hwnd of the main application wind...

Help getting QTP to identify a control

We're trying to use QTP (QuickTest Professional) to auto-test a legacy C++ application. However, the main window for the app is composed of several IDENTICAL panels. Each panel has a unique title. If I view the window in Spy++ (comes with DevStudio), I see: + Window <hwnd> "Window Title" taskwindowclass + Window <hwnd> "Panel A" ch...

How do I GetModuleFileName() if I only have a window handle (hWnd)?

I'm trying to get the name of the executable of a window that is outside my C# 2.0 application. My app currently gets a window handle (hWnd) using the GetForegroundWindow() call from "user32.dll". From the digging that I've been able to do, I think I want to use the GetModuleFileNameEx() function (from PSAPI) to obtain the name, but Get...

Detecting an Application Focus Change / Hooking something for HWND changes?

How could I detect when any application loses focus? Is there any system hooks to use? I want to pick up when ever a new application is in focus, or when one is lost. Even having the "current" HWND of the user would be good. I am using C#, however, its all win api stuff I am sure... so any info would be great. ...

Is the order in which handles are returned by EnumWindows meaningful?

From a couple of preliminary tests it seems that EnumWindows always returns windows in reverse instantiation order, i.e. most recently instantiated window first. Is that a valid observation? If so, is it true across all versions of Windows? And is this a reliable assumption, i.e. is that behaviour documented somewhere? Context: I'm de...

How do I reliably determine the window handle of a given Outlook inspector window with WordMail turned on from inside a COM-Addin (Outlook <=2003)?

[This code is called from within the Inspector.Activate event handler (first call), i.e. right before the inspector window is actually shown.] For "native" mail inspectors I can simply QI the Inspector interface to IOleWindow and call its GetWindow method. However, this will not work for Word inspectors which are in fact instances of Wo...

In Java Swing how do you get a Win32 window handle (hwnd) reference to a window?

In Java 1.4 you could use ((SunToolkit) Toolkit.getDefaultToolkit()).getNativeWindowHandleFromComponent() but that was removed. It looks like you have to use JNI to do this now. Do you have the JNI code and sample Java code to do this? I need this to call the Win32 GetWindowLong and SetWindowLong API calls, which can be done via the Ja...

How can I tell if a Window has focus? (Win32 API)

Using the Win32 API (in C, but that's inconsequential) how can I tell if a given window (identified by HWND) has focus? I'm hooking an application watching for an event, and when that event occurs I want to check if the application already has focus. If it doesn't, I want to flash the window until they give focus to it. Alternately, doe...

find the hwnd of a window which user selects, through c#

I've written a c# program which reproduces keyboard strokes programatically. My idea was to pass these keyboard strokes to another application which may have a textbox set in focus. So in my program i want the user to select the window to which i must redirect the keyboard strokes to. For that, I want to know a method where i can wait,...

Can I pass a HWND in a COM method?

Is it possible to have a COM method which passes a HWND? With the following method in my object CoCreateInstance returns DISP_E_BADVARTYPE (0x80020008): STDMETHODIMP ShowDialog(HWND hWndParent); So far, I'm getting round this problem by passing an OLE_HANDLE then casting it but it feels like a cludge: STDMETHODIMP ShowDialog(OLE_HAND...

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; ...

c# HwndSourceHook with Windows.Forms

Hello, i found this code: protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource; if (hwndSource != null) { installedHandle = hwndSource.Handle; viewerHandle = SetC...

In wx.Python, how would I get the window handle (hwnd) to my frame and set its style?

How can I get a handle to my current window in wx.Python (hWnd) and set it's style to WS_EX_NOPARENTNOTIFY, or can I set this when I initialize the frame? This question is a result from an answer here ...

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 something like this? I cant find it anymore. (btw this is windows 7) Edited: it's not ye...

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 that I want to check, in this case my own application. How do I get the HWND of my own appli...

QWidget::find(hwnd) always returning 0

Hey, I'm grabbing a window handle with the following code: HWND hwnd = FindWindow(L"QWidget", NULL); and it returns a HWND to a QWidget (I checked with Spy++, the handles match). But after this, if I try the following: QWidget* widget = QWidget::find(hwnd); or QWidget* widget = QWidget::find((WId)hwnd); widget is always 0. Does ...

How to get tooltip text for a given HWND?

I'm looking for a way to get the tooltip control (if any) which is associated with a given HWND. The text of the tooltip control would be sufficient, too. The closest thing I found is the TTM_GETTEXT message, but it's meant to be sent to the tooltip control itself instead of the tool it's associated with. I don't have a handle to the too...

Loading a WPF Window without showing it

I create a global hot key to show a window by PInvoking RegisterHotKey(). But to do this I need that window's HWND, which doesn't exist until the window is loaded, that means shown for the first time. But I don't want to show the window before I can set the hot key. Is there a way to create a HWND for that window that is invisible to the...

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 found a suggestion to respond to WM_NCHITTEST by returning HTTRANSPARENT. This seemed to wo...