hwnd

What is the lifetime of a CWnd obtained from CWnd::FromHandle?

落爺英雄遲暮 提交于 2019-11-30 07:27:25
问题 According to msdn, when I get a CWnd* with CWnd::FromHandle, The pointer may be temporary and should not be stored for later use. What is meant by "later use" is not clear to me. Is it only the scope of the current method? As far as I know, there is no GC in Win32! 回答1: MFC maintains a number of handle maps, from HWND to CWnd, HDC to CDC etc, which are stored in the thread state. Each handle map contains a permanent map and temporary map - permanent entries are added when you call a method

Loading a WPF Window without showing it

ぐ巨炮叔叔 提交于 2019-11-30 06:14:27
问题 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 user? 回答1: If you are targeting .NET 4.0 you can make use of the new EnsureHandle method available on the WindowInteropHelper : public void InitHwnd() {

Difference between HANDLE and HWND in Windows API?

假如想象 提交于 2019-11-30 03:53:05
I'm trying to use function SetForegroundWindow(HWND hWnD) . I have some handles but it's not working as parameter of above function. My handle is a thread and I want to run it in foreground. What are the differences between a HWND and a HANDLE? They are just abstract data types . According to MSDN , HANDLE and HWND are defined as: HANDLE is a handle to an object. HWND is a handle to a window. So, a HWND is a HANDLE , but not all HANDLE s are HWND . In fact: typedef void *PVOID; typedef PVOID HANDLE; typedef HANDLE HWND; Example You should only pass HWND to SetForegroundWindow unless you know

How to change console window style at runtime?

自古美人都是妖i 提交于 2019-11-29 16:50:54
I'm making a game in console application and I want to prevent user resizing and maximizing window. How can I do this using HWND? I found solution. This code will disable window Size and Maximize box: HWND consoleWindow = GetConsoleWindow(); SetWindowLong(consoleWindow, GWL_STYLE, GetWindowLong(consoleWindow, GWL_STYLE) & ~WS_MAXIMIZEBOX & ~WS_SIZEBOX); 来源: https://stackoverflow.com/questions/41172595/how-to-change-console-window-style-at-runtime

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

ε祈祈猫儿з 提交于 2019-11-29 14:43:24
问题 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 window. I'm not sure what I can do from there? UPDATE Oct 20 '08 at 17:06: Scott, Thanks for the response. I had overlooked that the Show/ShowDialog method

How do I clear a Direct2D render target to fully transparent

白昼怎懂夜的黑 提交于 2019-11-29 10:36:24
I'm trying to draw semi-transparent rectangles on an invisible HWND . However, clearing the window with ID2D1HwndRenderTarget::Clear just makes the entire window black, so when I draw rectangles on top, they look semi-black. If I don't Clear() and don't draw, then the window is invisible, as it should be. Clear() is the culprit here; however if I don't use it then painting messes up pretty badly. Here's the code I'm using in my WindowProc: case WM_PAINT: // Begin drawing pRenderTarget->BeginDraw(); pRenderTarget->SetTransform(D2D1::Matrix3x2F::Identity()); // Clear the window pRenderTarget-

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

浪子不回头ぞ 提交于 2019-11-29 05:06:12
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 already managed to do exactly what we want in Swing by using JNA , and we'd like to repeat our solution in JavaFX. Unfortunately, to do this, we need to be able to retrieve the hWnd (window handle) for each window in our application. This can be done in Swing/AWT via the JNA Native.getWindowPointer() method, which works with java.awt.Window , but I

What is the lifetime of a CWnd obtained from CWnd::FromHandle?

自古美人都是妖i 提交于 2019-11-29 03:50:20
According to msdn , when I get a CWnd* with CWnd::FromHandle, The pointer may be temporary and should not be stored for later use. What is meant by "later use" is not clear to me. Is it only the scope of the current method? As far as I know, there is no GC in Win32! MFC maintains a number of handle maps, from HWND to CWnd, HDC to CDC etc, which are stored in the thread state. Each handle map contains a permanent map and temporary map - permanent entries are added when you call a method such as CWnd::Create or CDC::Attach, while temporary entries are created when you call FromHandle on a handle

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

怎甘沉沦 提交于 2019-11-29 02:00:16
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 GetModuleFileNameEx() requires a handle to a Process, not a Window. Is it possible to get a process handle from a window handle? (Do I need to get the thread handle of the window first?) EDITED the first sentence to make it clearer what I'm trying to do. UPDATE!

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

坚强是说给别人听的谎言 提交于 2019-11-28 21:19:04
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 dealing with a situation where I am triggering a third-party application to open several non-modal windows and I need to send some window messages to those windows once they're open, yet I have no sure-fire way of identifying them as neither their window classes nor