Inform ActiveX about change of host's picture property?

_Mark_
03-21-2003, 03:55 PM
Hi,

Is there a way to inform an ActiveX control of a change of its container's picture property (assuming the container supports that property)?

I am using the container's background color and background picture to achieve a transparency effect for my control. Using the AmbientProperties object I can respond to changes of the backcolor property of the container and adjust the DrawItem procedure for my control.

The AmbientProperties-Object doesn't include a picture property. I suppose I could subclass the host and redraw my control whenever the container receives a WM_ERASEBKGND message. That seems to be a bit expensive though.

Thank you for your help.

Mark

AndreRyan
03-21-2003, 04:24 PM
have you tried Me.Refresh

Baz
03-21-2003, 04:25 PM
Hi,

Is there a way to inform an ActiveX control of a change of its container's picture property (assuming the container supports that property)?

I am using the container's background color and background picture to achieve a transparency effect for my control. Using the AmbientProperties object I can respond to changes of the backcolor property of the container and adjust the DrawItem procedure for my control.

The AmbientProperties-Object doesn't include a picture property. I suppose I could subclass the host and redraw my control whenever the container receives a WM_ERASEBKGND message. That seems to be a bit expensive though.

Thank you for your help.

Mark

I reckon you should use the repaint event in the container if supported (if not then you must subclass to get a handle to the event) and each time the event is fired examine the picture property for a change, if changed the inform your activex control.

Or ... If you dont want to have any code in the Client as I think you do, I think you must subclass messages to the parent window.

<edit for clarity>

_Mark_
03-22-2003, 03:11 AM
AndreRyan: I can't see what you are hinting at. Try me.refresh where?

Baz:

Thanks for your suggestion. That should work.

I can't obtain a valid handle to the parent window [ ... GetParent(usercontrol.hwnd) ... ] in the ReadProperties-Event of my usercontrol though - only when I initiate the subclassing of the parent in the Show-Event of the control, I will get a proper handle. ReadProperties happens before the Load-Event of the parent form, which I guess is the reason that at that time I can't get a handle to the parent window.

I am not fond of initiating the subclassing in the Show-Event of the control, since this event also fires every time the visibility of the control is set from false to true - therefore making it necessary to check whether the parent is already subclassed and so on...

Is there a better way to do this?

Thank's!

Banjo
03-22-2003, 03:37 AM
You can setup your subclassing in the initialise event (make sure you don't do it if in design mode ;)) using the UserControl.Parent.hWnd value.

_Mark_
03-22-2003, 06:13 AM
Thanks Banjo, problem resolved.

For the educational value of it: Do you know why GetParent(usercontrol.hwnd) fails whereas usercontrol.parent.hwnd works?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum