Solved

ControlPaint.DrawScrollButton - need this to work with visaul styles

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

749 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