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 General / September 2004

Tip: Looking for answers? Try searching our database.

A developer's NIGHTMAIRE: paint sequence in a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
news.microsoft.com - 08 Sep 2004 19:44 GMT
Can someone give me a suggestion about how WinForm handle the sequence of
controls paint and user paint graphic object ?

the problem:
1. use the winform wizard to generate an application.
2. Drop a few buttons on the form.
3. In mouseup event, call Invalidate()
4. In the Paint event, add this line:
   e.Graphics.DrawRectangle(new Brush(Color.LightBlue, 3), 5, 5, 50, 50);

the new rectangle is always drawn under the button controls. How can I draw
a rectangle above button controls?

Cheers
Mike
Herfried K. Wagner [MVP] - 08 Sep 2004 20:20 GMT
* "news.microsoft.com" <lelehehe@yahoo.com> scripsit:
> Can someone give me a suggestion about how WinForm handle the sequence of
> controls paint and user paint graphic object ?
[quoted text clipped - 8 lines]
> the new rectangle is always drawn under the button controls. How can I draw
> a rectangle above button controls?

You simply cannot.  Buttons are separate windows that are placed on the
form like pictures on a wall.  Painting the wall won't change the
appearance of the pictures.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/

Bob Powell [MVP] - 10 Sep 2004 12:16 GMT
The button controls are windows in their own right and so the areas they
occupy are clipped out of the form client drawing area.

You _can_ draw on the desktop but it's a messy and problem-fraught process.

You can also use a layered control but it's a bit complex.

Why do you want to draw on top of controls? It's very bad practice...

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml

> Can someone give me a suggestion about how WinForm handle the sequence of
> controls paint and user paint graphic object ?
[quoted text clipped - 11 lines]
> Cheers
> Mike
Michael - 10 Sep 2004 22:02 GMT
Thanks for replying my email.

Here is the story:

I am trying to build something similar to MS ListView control in Thumbnail
mode. I also want to give user the ability to use mouse to do group
selection.

In ListView control Thumbnail mode, if you click on the view and drag your
mouse, you will see the rectangle that is drawn above the items.

My problem is: how can I implement the same function?

Cheers
Mike

> The button controls are windows in their own right and so the areas they
> occupy are clipped out of the form client drawing area.
[quoted text clipped - 23 lines]
>> Cheers
>> Mike

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.