Solved

ControlPaint.DrawScrollButton - need this to work with visaul styles

Posted on 2007-11-19
4
624 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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 …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 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

23 Experts available now in Live!

Get 1:1 Help Now