Solved

ControlPaint.DrawScrollButton - need this to work with visaul styles

Posted on 2007-11-19
4
644 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

737 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