Click to See Complete Forum and Search --> : Can Transparent ActiveX Control Response the MouseMove Event?


Bon La Lay
August 2nd, 2001, 05:32 AM
I'm trying to make a label like ActiveX Control. Default the BackStyle of usercontrol will be Opaque

The actions added in the Usercontrol_MouseMove will work fine. But when I change the BackStyle to
Transparent, the Usercontrol_mousemove event never fire again! That's a big problem!

You know if you set the BackStyle of a Label control in VB to Transparent, it still can response all
the mouse actions ( move, click ... ). Why the Usercontrol can not? Anybody give me some clues. Thanks!


//-----------------------------------------\\
Where there's a wire , there's a way
\\-----------------------------------------//

Clearcode
August 2nd, 2001, 07:10 AM
The label controls (and all other lightweight controls) are not true controls but rather are drawn by the parent form and the form sends MouseMove events etc on behalf of the "control".

This is technically a bug in VB - transparent controls should be transparent to the mouse as well as the viewer. However it is a quite useful bug.
In order to emulate for your controls you could subclass the form and when it generates a WM_LMOUSEDOWN followed by a WM_MOUSEUP then check if the mouse was over your control and if it was prevent the form_click() and instead send a control_click() event.
This can be a tricky thing to do, but if you get the ImageMapVB code from Merrion Computing website and modify that you should be able to achieve this...
Alternatively you can get the background of the form and paint this onto you control (with Transparent=False) to pretend to be transparent.

Hope this helps,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.

Bon La Lay
August 2nd, 2001, 09:05 PM
Thanks.

But I want to make it a activex control, anyway or noway?

//-----------------------------------------\\
Where there's a wire , there's a way
\\-----------------------------------------//

Clearcode
August 3rd, 2001, 02:27 AM
If the entire of you control is transparent then it shouldn't respond to mouse clicks, as per my earlier reason as to why the fact that labels do respond is a bug.

However, if you want part of the control to be blank, outline this part in regions using one or more of:

private Declare Function CreateRectRgnApi Lib "gdi32" Alias "CreateRectRgn" (byval X1 as Long, byval Y1 as Long, byval X2 as Long, byval Y2 as Long) as Long
private Declare Function CreatePolygonRgnApi Lib "gdi32" Alias "CreatePolygonRgn" (lpPoint as POINTAPI, byval nCount as Long, byval nPolyFillMode as Long) as Long
private Declare Function CreateEllipticRgnApi Lib "gdi32" Alias "CreateEllipticRgn" (byval X1 as Long, byval Y1 as Long, byval X2 as Long, byval Y2 as Long) as Long



and then use SetWindowRgn() to make a shaped window. The part of the control which is inside the shape will be visible and respond to mouse clicks where that outside it will not.

Hope this helps,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.