Print Page | Close Window

SliderCtrl:missing selection highlight

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Skin Framework
Forum Description: Topics Related to Codejock Skin Framework
URL: http://forum.codejock.com/forum_posts.asp?TID=7993
Printed Date: 27 November 2024 at 4:08am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: SliderCtrl:missing selection highlight
Posted By: collabear
Subject: SliderCtrl:missing selection highlight
Date Posted: 13 September 2007 at 6:51am

Slider ctrl missing selection highlight when apply a skin, how to add it?



Replies:
Posted By: Ark42
Date Posted: 28 September 2007 at 12:50pm

You must code it yourself when using Windows XP themes or Office 2007 skin with Codejock - it's not a Codejock issue really, but a design choice of Windows XP.

Without Codejock, you can just derive from CSliderCtrl to fix this:

void CMySliderCtrl::OnCustomDraw(NMHDR *pNotifyStruct, LRESULT *result)
{
    NMCUSTOMDRAW *pNmcd = (NMCUSTOMDRAW *)pNotifyStruct;

    switch( pNmcd->dwDrawStage ) {
    case CDDS_PREPAINT:
        if( GetStyle() & TBS_ENABLESELRANGE ) {
            *result = CDRF_NOTIFYITEMDRAW;
        }
        break;
    case CDDS_ITEMPREPAINT:
        switch( pNmcd->dwItemSpec ) {
        case TBCD_CHANNEL: {
            CDC *pDC = CDC::FromHandle(pNmcd->hdc);
            CRect rcChannel;
            GetChannelRect(&rcChannel);
            rcChannel.DeflateRect(6, 3);

            int min, max, selmin, selmax;
            GetRange(min, max);
            GetSelection(selmin, selmax);
            max -= min;
            selmin = (int)(((double)(selmin - min) / max * rcChannel.Width()) + 0.5) + rcChannel.left;
            selmax = (int)(((double)(selmax - min) / max * rcChannel.Width()) + 0.5) + rcChannel.left;
            rcChannel.left = selmin;
            rcChannel.right = selmax;

            pDC->FillSolidRect(rcChannel, static_cast<CXTPMDIFrameWnd *>(AfxGetMainWnd())->GetCommandBars()->GetPaintManager()->GetXtremeColor(COLOR_HIGHLIGHT));
            pDC->ExcludeClipRect(rcChannel);
            *result = CDRF_DODEFAULT | CDRF_NOTIFYPOSTPAINT;
            break; }
        }
        break;
    case CDDS_ITEMPOSTPAINT:
        switch( pNmcd->dwItemSpec ) {
        case TBCD_CHANNEL: {
            CDC *pDC = CDC::FromHandle(pNmcd->hdc);
            pDC->SelectClipRgn(NULL);
            break; }
        }
        break;
    }
}

But with Office 2007 skin and such, Codejock does not support CDRF_NOTIFYITEMDRAW in 11.2.  A patch for 11.2.1 adds support though.




Posted By: collabear
Date Posted: 01 October 2007 at 11:33pm
Thank you very much!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net