Solved

ControlPaint.DrawScrollButton - need this to work with visaul styles

Posted on 2007-11-19
4
631 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
ID: 20314415
0
 
LVL 10

Author Comment

by:smegghead
ID: 20314588
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
ID: 20315806
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
ID: 31409979
Thank you, very good answer. My datetime picker is looking very smoothe now.

Cheers
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

822 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