Want my form to permit focus to "penetrate" to whatever window is under
-
So if i had my form open, and i click, the click will fall to the desktop, or other forms... any easy way to do this?
-
So if i had my form open, and i click, the click will fall to the desktop, or other forms... any easy way to do this?
Not a trivial way, no.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Not a trivial way, no.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
hmm so does the hard way involve wndproc in some fashion, or are we talking harder :P
-
hmm so does the hard way involve wndproc in some fashion, or are we talking harder :P
You can actually call an API called WindowFromPoint. So, hide your window, call that API on the screen point you clicked, convert to a point relative to the window and send it a WM_CLICK message. And a WM_LBUTTONDOWN and WM_LBUTTONUP. FIddly, more than anything.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
So if i had my form open, and i click, the click will fall to the desktop, or other forms... any easy way to do this?
Did you use search? There are several articles at codeproject showing how to achieve it.
Giorgi Dalakishvili #region signature my articles #endregion
-
So if i had my form open, and i click, the click will fall to the desktop, or other forms... any easy way to do this?
-
You can actually call an API called WindowFromPoint. So, hide your window, call that API on the screen point you clicked, convert to a point relative to the window and send it a WM_CLICK message. And a WM_LBUTTONDOWN and WM_LBUTTONUP. FIddly, more than anything.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Ya no luck with WindowFromPoint (in vista) so far... Also how do i "hide" a form from WindowFromPoint but keep it visible?, i tried making it not enabled, and some ShowWindowAsync(shades.Handle, SW_HIDE) which definatally hides it from view, but i want it visible still... Also i tried with one of those lowlevel-ish hooks to watch the mouse when it's off my form, and so far WindowFromPoint returns 0 regardless... something that caught my eye though was:
private const int WM\_NCHITTEST = 0x0084; private const int HTTRANSPARENT = (-1); /// <summary> /// Overrides the standard Window Procedure to ensure the /// window is transparent to all mouse events. /// </summary> /// <param name="m">Windows message to process.</param> protected override void WndProc(ref Message m) { if (m.Msg == WM\_NCHITTEST) { m.Result = (IntPtr)HTTRANSPARENT; } else { base.WndProc(ref m); } }
but it doesn't work for other threads... else it'd be very good solution :P
-
Ya no luck with WindowFromPoint (in vista) so far... Also how do i "hide" a form from WindowFromPoint but keep it visible?, i tried making it not enabled, and some ShowWindowAsync(shades.Handle, SW_HIDE) which definatally hides it from view, but i want it visible still... Also i tried with one of those lowlevel-ish hooks to watch the mouse when it's off my form, and so far WindowFromPoint returns 0 regardless... something that caught my eye though was:
private const int WM\_NCHITTEST = 0x0084; private const int HTTRANSPARENT = (-1); /// <summary> /// Overrides the standard Window Procedure to ensure the /// window is transparent to all mouse events. /// </summary> /// <param name="m">Windows message to process.</param> protected override void WndProc(ref Message m) { if (m.Msg == WM\_NCHITTEST) { m.Result = (IntPtr)HTTRANSPARENT; } else { base.WndProc(ref m); } }
but it doesn't work for other threads... else it'd be very good solution :P
Ok no idea why but now i'm seeing WindowFromPoint working now... i'll see now if i can get this to work.
-
You can actually call an API called WindowFromPoint. So, hide your window, call that API on the screen point you clicked, convert to a point relative to the window and send it a WM_CLICK message. And a WM_LBUTTONDOWN and WM_LBUTTONUP. FIddly, more than anything.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Ok been through hell with this, and starting to show progress: 1. i made a new WindowFromPoint function that effectively finds the window underneath. to do this i had to use api:enumWindows... whichs gives a list of windows in the correct z-order, and just filter the results to visible windows that don't match my programs handle... then just check which rectangle the mouse is within and there you go... it works 100% 2. sendmessage to relay messages is no joke as it would appear... pain in the ass would best describe it... apparently something is blocking any messages from getting through! my guess = vista lol. i tried using microsof spy to watch for any messages in a test program, and i placed my window above it... and spy showed no messages getting through... that's not to say "some" messages don't get through... i did notice doubleclicking on the taskmanager through my form did infact do what double clicking would do to it... but nothing in way of rightclick, or highlights... and the code that sends these messages is same... basically catch alot of mouse messages in my wndproc, and send them to another window... so i'm not sure what to do next. i need another way to send mouse messages :P