user32

How can I be notified when a new window is created on Win32?

。_饼干妹妹 提交于 2019-11-28 07:02:21
Is there a way using Win32, to register for notifications when a new window is created. I'm trying to keep a list of current open windows, but am now just polling the list of current windows using EnumWindows() . Anyone done something similar? Thanks I'm not sure if I'm doing this right, but I'm not able to get the SetWindowsHookEx method to fire. anything come to mind? here is my snip [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr SetWindowsHookEx(HookType hook, HookProc callback, IntPtr hMod, uint dwThreadId); [DllImport("user32.dll")] private static extern int

Once and for all: how do I get a fully transparent checkbox, button, radio button, etc. in Windows API, and not with a black background?

我的梦境 提交于 2019-11-28 02:24:12
First, sorry if I sound arrogant/rude here. All right, so everyone has run into this by now (I hope); I just haven't found any adequate answer anywhere . We start with a Common Controls 6 manifest and case WM_CTLCOLORSTATIC: if (/* window has WS_EX_TRANSPARENT */) { SetBkMode((HDC) wParam, TRANSPARENT); return (LRESULT) GetStockObject(HOLLOW_BRUSH); } and give our labels WS_EX_TRANSPARENT . They become transparent; so far so good. Now we have to add that style to our checkboxes (because checkboxes respond to that and not to WM_CTLCOLORBTN for some reason). And... the checkboxes become black!

Need to activate a window

不羁岁月 提交于 2019-11-27 22:36:37
I have a situation like this. I have the window handle of an application. I need to activate it. I tried all these functions but is not working always.(most of the time , it doesn't work the first time and I'll have to manually click on it to activate it. Second attempt onwards it works fine) The reason why I am doing this is because I have code written in the Form.Activate event of the form which I need to execute. Application is a single instance application. When a new instance is created , it first checks for the existence of any other process, If found, the handle of old process is passed

Move window when external application's window moves

泄露秘密 提交于 2019-11-27 20:55:49
I've got an always on-top application (basically a status display) that I want to follow around another program and always sit just to the left of the minimize button. I can get the Rect representing the "target" process using the following code which I can then pair with an offset to generate the initial position of my overlay. Get the HWnd IntPtr: private IntPtr HWnd = Process.GetProcessesByName("targetapplication")[0].MainWindowHandle; Declare the function from user32.dll : [DllImport("user32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool

Directing mouse events [DllImport(“user32.dll”)] click, double click

杀马特。学长 韩版系。学妹 提交于 2019-11-27 12:31:05
问题 I tried [DllImport("user32.dll")] static extern bool SetCursorPos(int X, int Y); and it works pretty fine to move the cursor to the desired point. I have never tried such kind of a DLL import before but it works :). However I want more what else can I extract? Mainly I want to make double click, click or use wheel options without any mouse input, just the code how can I do that? and how can I check what else is included in user32dll? Thanx 回答1: [DllImport("user32.dll", CharSet = CharSet.Auto,

Once and for all: how do I get a fully transparent checkbox, button, radio button, etc. in Windows API, and not with a black background?

核能气质少年 提交于 2019-11-27 04:56:03
问题 First, sorry if I sound arrogant/rude here. All right, so everyone has run into this by now (I hope); I just haven't found any adequate answer anywhere . We start with a Common Controls 6 manifest and case WM_CTLCOLORSTATIC: if (/* window has WS_EX_TRANSPARENT */) { SetBkMode((HDC) wParam, TRANSPARENT); return (LRESULT) GetStockObject(HOLLOW_BRUSH); } and give our labels WS_EX_TRANSPARENT . They become transparent; so far so good. Now we have to add that style to our checkboxes (because

How can I be notified when a new window is created on Win32?

左心房为你撑大大i 提交于 2019-11-27 01:29:28
问题 Is there a way using Win32, to register for notifications when a new window is created. I'm trying to keep a list of current open windows, but am now just polling the list of current windows using EnumWindows() . Anyone done something similar? Thanks I'm not sure if I'm doing this right, but I'm not able to get the SetWindowsHookEx method to fire. anything come to mind? here is my snip [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr SetWindowsHookEx(HookType hook,

How do I lock a windows workstation programmatically? [duplicate]

喜你入骨 提交于 2019-11-27 01:09:39
问题 This question already has an answer here : Closed 6 years ago . Possible Duplicate: Lock Windows workstation programmatically in C# I am currently working on a visual studio windows form application that requires a function that locks the workstation. How can i make use of user32.dll to do a lock (Windows + L) when the function is called? 回答1: I haven't tried it myself, but I found this on google Process.Start(@"C:\WINDOWS\system32\rundll32.exe", "user32.dll,LockWorkStation"); edit: I tried

Move window when external application's window moves

半城伤御伤魂 提交于 2019-11-26 22:59:36
问题 I've got an always on-top application (basically a status display) that I want to follow around another program and always sit just to the left of the minimize button. I can get the Rect representing the "target" process using the following code which I can then pair with an offset to generate the initial position of my overlay. Get the HWnd IntPtr: private IntPtr HWnd = Process.GetProcessesByName("targetapplication")[0].MainWindowHandle; Declare the function from user32.dll : [DllImport(

How to get the text of a MessageBox when it has an icon?

半世苍凉 提交于 2019-11-26 22:05:21
问题 I am working on trying to close a specific MessageBox if it shows up based on the caption and text. I have it working when the MessageBox doesn't have an icon. IntPtr handle = FindWindowByCaption(IntPtr.Zero, "Caption"); if (handle == IntPtr.Zero) return; //Get the Text window handle IntPtr txtHandle = FindWindowEx(handle, IntPtr.Zero, "Static", null); int len = GetWindowTextLength(txtHandle); //Get the text StringBuilder sb = new StringBuilder(len + 1); GetWindowText(txtHandle, sb, len + 1);