views:

146

answers:

2

I'm using the following code to make my form entirely transparent so that clicks can go "through" it to other windows.

SetWindowPos( handle, HWND_TOPMOST, 0, 0, 0,0,
                   SWP_NOSIZE or SWP_NOMOVE );
SetWindowLong(form1.handle,GWL_EXSTYLE,WS_EX_TOPMOST or WS_EX_LAYERED);
SetLayeredWindowAttributes(form1.handle,RGB(0,0,0),200,LWA_ALPHA or LWA_COLORKEY);

My problem is that when I begin drawing on the form, these drawings can be clicked on and the Delphi form will take focus. I want to be able to draw without these drawings being "clickable".

I hope I was clear enough. Any help is appreciated.

+1  A: 

You need to set the WS_EX_TRANSPARENT extended window style too.

mghie
Thanks so much! It's been bugging me for the longest time.
Chris
+1  A: 

Either give your window the WS_EX_TRANSPARENT window style, or handle the WM_NCHITTEST message and return HTTRANSPARENT. see this related post for an example http://stackoverflow.com/questions/2301089/windows-api-wm-paint-mouse-problems/2301173#2301173

John Knoeller