Solved

ControlPaint.DrawScrollButton - need this to work with visaul styles

Posted on 2007-11-19
4
609 Views
Last Modified: 2010-04-21
Hi,

I'm overriding the DateTimePicker to add some features, this involves me manually drawing the control.

When I initially draw, it displays fine, I'm using

ControlPaint.DrawScrollButton (for the drop-down on the right)
and
ControlPaint.DrawCheckBox (if it has the ShowCheckBox property set)

It draws the scroll button on the right (the drop-down), in the default style, but when I click on the drop-down, the control itself draws the 3d version (coming from windows themes).

Is there a way of either drawing the ScrollButton in 3d, or disabling the automatic drawing of the button when clicked ?

Cheers
Smg.
0
Comment
Question by:smegghead
  • 2
4 Comments
 
LVL 10

Expert Comment

by:dkloeck
Comment Utility
0
 
LVL 10

Author Comment

by:smegghead
Comment Utility
No, my problem is that my application already draws using visual styles (I have the above statement in my application), but when I draw it manually using

ControlPaint.DrawScrollButton

It draws the scrollbutton without using visual styles... but then when I dropdown, it draws over the top of it with the 3d version... this doesn't look very professional.

Even though I'm 'owner-drawing' tihs control, the 'scrollbutton' is being drawn by the control, not by my inherited version. It only draws this when I click on the drop-down. I guess this is because the calendar that appears is a separate hWnd, and for some reason it draws the 'drop-down/scroll button'
0
 
LVL 3

Accepted Solution

by:
wizrr earned 250 total points
Comment Utility
Hi.
If you using .NET 1.0/1.1 this is possible to use uxTheme.dll. See pinvokes from http://pinvoke.net/default.aspx/uxtheme.DrawThemeBackground site.

If your program compiled under .NET 2.0 you can use classes from System.Windows.Forms.VisualStyles namespace.

Try something like this:
Graphics graphicsWhereToDraw = ...;

VisualStyleRenderer renderer =

                new VisualStyleRenderer(VisualStyleElement.ScrollBar.ArrowButton.DownDisabled);

renderer.DrawBackground(graphicsWhereToDraw, new Rectangle(0, 0, 10, 10));

// done

Open in new window

0
 
LVL 10

Author Closing Comment

by:smegghead
Comment Utility
Thank you, very good answer. My datetime picker is looking very smoothe now.

Cheers
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now