|
-
Aug 18th, 2010, 01:15 PM
#2
Re: Drawing on Windowless Usercontrols
Welcome to the forums.
1. This is an excellent reference for usercontrols. Note that I'm having trouble accessing the site at the moment, but it's been up for years. Directly addresses VB5 but VB6 is not that different in this case.
2. Windowless controls can have their own DC or not (HasDC property).
a. Own DC: You draw on to the DC (same size as control) and VB transfers it to the form automatically
b. No DC: During the control's Paint event, VB passes you a clipped DC that you draw on directly. That DC is the control's parent's DC. Before the DC is sent to you, anything lower in the zOrder of your control that occupies the same space as your control is already drawn, including the background color as applicable.
3. Drawing text or anything on the control is done by drawing to the DC.
a. Has DC: use UserControl.hDC value. The Paint event is not called if AutoRedraw is True. If True, .Refresh control after drawing
b. No DC: use UserControl.hDC only in the control's Paint event. Accessing it outside of the event can/will produce an error since the control has no DC allocated. AutoRedraw cannot be set on DC-less controls.
Edited: The "No DC" option is how you can ensure transparency. Other methods include using the MaskPicture and MaskColor properties but are somewhat limited.
Regarding subclassing. Each usercontrol has a containerHwnd property.
Hope this clears up some issues.
Last edited by LaVolpe; Aug 18th, 2010 at 01:30 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|