Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / October 2004

Tip: Looking for answers? Try searching our database.

Multiple Transparent Controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lee - 27 Oct 2004 08:20 GMT
I'm trying to make an interface where the main form is an ellipse shape.
When the user clicks a particular area, another non-rectangular "panel"
slides out from behind the main ellipse (similar to how some of WinAmp's
skinned modes do for control panels).  I'm using a Form as a "canvas" for
these two controls.  The form's BackGroundColor and TransparencyKey are both
set to the same color and the form is borderless/titlebarless.  I have two
UserControls (MainUI and ControlPanel) that are using Bob Powell's technique
for transparent controls (Setting WS_EX_TRANSPARENT (hex 20) in
CreateParams, Overriding OnPaintBackground and doing nothing, invalidating
the parent's rectangle in OnResize and OnMove, and using DrawImage to paint
a .png image in OnPaint).

The MainUI control is 640x480 and the Form is 840x480 (200 wider than
MainUI).  The idea is that I put MainUI against the left side of the form,
and put ControlPanel behind it so it can't be seen.  When the user clicks a
particular place on MainUI, I slide the ControlPanel control to the right on
the (invisible) form until it's right side is against the right side of the
form (sticking out from under MainUI by 200 pixels).  That's the "theory".
Now for the reality.

The first problem I'm having is that as I'm sliding ControlPanel to the
right, it's flickering REAL bad.  In the region where ControlPanel is (even
though it's "behind" MainUI) I see the MainUI control, the whole
ControlPanel control, and the region behind the Form itself (the desktop, or
other windows). It draws all three rapidly every time I move ControlPanel.
When I stop moving ControlPanel, everything is drawn properly.  MainUI is
drawn on top of the portion of ControlPanel that is still "behind" it and
all is good, so I'm assuming that MainUI is being drawn last.

The second problem I'm having is that in order to get MainUI drawn last so
that when I'm done moving ControlPanel (and it's done flickering enough to
cause seizures) MainUI is drawn on top of ControlPanel, I have to put the
MainUI control behind the ControlPanel control on the form.  Now this seems
VERY backwards to me.  It is seemingly drawing the controls from the front
to the back instead of from the back to front.  If I put MainUI in front of
ControlPanel in design mode, then it appears behind ControlPanel at runtime.
And visa-versa.  When I put MainUI behind ControlPanel in design mode then
it appears in front of ControlPanel at runtime.

If anyone can help or point me in the right direction for help, I'd greatly
appreciate it. Bob Powell, if you run across this message... HELP! :)  You
seem to be the god (demi-god?) of GDI+ work... :)

-----
Lee
Lee - 28 Oct 2004 18:16 GMT
I resolved the issue.  Instead of using Bob Powell's
(http://www.bobpowell.net/) method of transparent controls (under Windows
Forms Tips & Tricks/Creating transparent Windows Forms Controls), I used
Mick Doherty's (http://dotnetrix.co.uk/) method (under Tips/Custom Controls)
and the controls redraw themselves properly and respect the design-time
z-order.

Good articles Bob and Mick!  I've learned alot from them!

-----
Lee

> I'm trying to make an interface where the main form is an ellipse shape.
> When the user clicks a particular area, another non-rectangular "panel"
[quoted text clipped - 42 lines]
> -----
> Lee

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.