Solved

CSliderCtrl

Posted on 1998-05-09
7
503 Views
Last Modified: 2013-11-20
I wnat to make ownerdraw on a CSliderCtrl. My bitmaps will be loaded from the ressources. I will have 2 bitmap for the track button and an other for the background. What I want it's just to know how to make ownerdraw on that control.
0
Comment
Question by:fmichaud061597
  • 3
  • 3
7 Comments
 

Author Comment

by:fmichaud061597
ID: 1308908
Adjusted points to 100
0
 

Expert Comment

by:Raffaele
ID: 1308909
You have to handle the WM_DRAWITEM message. Depending if you write your own control derived from the original CSliderCtrl or you want to control the ownderdrwa in another CPP you have to write the handler for either OnDrawItem (WM_DRAWITEM) or OnChildNotify.
To make a test you can create both handlers, put two breakpoint in each, and see where your program break into.

If you choose to trap OnChildNotify you'll have to do something like this:
BOOL CMyView::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult)
{
if(message != WM_DRAWITEM)
            return CListView::OnChildNotify(message, wParam, lParam, pLResult);


You'll have to write your own OnDrawItem handler (WM_DRAWITEM).
PreSubclassWindow(
0
 

Expert Comment

by:Raffaele
ID: 1308910
Could you write a sample code that uses custom bitmaps in ressources?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:fmichaud061597
ID: 1308911
Sorry but during the week I'm in hurry.
Anyway:
The DRAWITEMSTRUCT describe the status of your control so that you know what and where to draw.
With LoadBitmap, you load the Bitmap from resources and than you can BitBlt it to the screen.
If you can fit your image(s) in an ImageList (drawing all the status images in a toolbar resource), you can use CImageList::Draw.

Good luck,
Raffaele
0
 

Expert Comment

by:Raffaele
ID: 1308912
I want a sample code to overdraw the slider.
0
 

Author Comment

by:fmichaud061597
ID: 1308913
Raffaele is completely steering you the wrong way. Slider (aka trackbar) controls don't support ownerdraw, and don't send WM_DRAWITEM messages!

Your only hope is to subclass the control and handle WM_PAINT messages yourself. It's likely that you'll need to completely draw the control from scratch in order to have flashing or artifact problems. The control itself double buffers its image and that means it's painting is completely atomic--you can't let the control paint some visual features and paint other features yourself... you have to overwrite them or clip them.

.B ekiM

0
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
ID: 1308914
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

867 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

17 Experts available now in Live!

Get 1:1 Help Now