Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » BUG: ownerdraw CExtCombox Collapse All
Subject Author Date
Ulrich Heinicke Jan 6, 2008 - 4:58 AM

Hi,
i used some function from the ultimate toolbox (which is now open source and can be downloaded from http://www.codeproject.com to rewrite the openfile-dialog. For the combobox you must set the flag to CBS_OWNERDRAWVARIABLE or CBS_OWNERDRAWFIXED. The problem is that the combobox will draw like
http://www.ibh-software.org/combobox1.png
instead of
http://www.ibh-software.org/combobox2.png
when to mouse move the first time over the control.
You can see this behaviour when you execute the testprogam http://www.ibh-software.org/shellcontrols.exe (Prof-UIS 2.82 and VS 2008).
How can i solve this problem?
Thanks
Ulrich

Technical Support Jan 11, 2008 - 8:30 AM

Yes, this is an appropriate solution.

Ulrich Heinicke Jan 10, 2008 - 5:00 AM

To only remove the WM_PAINT handler from COXComboPickerCtrl will be draw the control not like http://www.ibh-software.org/combobox2.png.
But i find a way to solve that problem, i overwrite into the COXComboPickerCtrl the function _OnDrawComboImpl and remove the WM_PAINT handler.
Here is the overwrite function:
void COXComboPickerCtrl::_OnDrawComboImpl(bool bPressed, bool bHover, CDC * pDC)
{
    bool bCallReleaseDC = false;
    if( pDC == NULL )
    {
        pDC = GetDC();
        ASSERT( pDC != NULL );
        bCallReleaseDC = true;
    }

    CRect rectClient;
    GetClientRect(rectClient);

    CBrush BkBrush (GetSysColor (COLOR_WINDOW));

    pDC->FillRect (&rectClient, &BkBrush);

    // draw dropdown button
    CRect rectDropdownButton=GetDropdownButtonRect();

    HFONT hFont = OnQueryFont();
    if( ! PmBridge_GetPM()->AdjustControlFont(
        hFont,
        this
        )
        )
    {
        LOGFONT _lf;
        ::memset( &_lf, 0, sizeof(LOGFONT) );
        ::GetObject( (HGDIOBJ)hFont, sizeof(LOGFONT), (LPVOID) &_lf );
        _lf.lfWeight =
            (_lf.lfWeight > FW_BOLD)
            ? _lf.lfWeight
            : FW_BOLD;
        hFont = ::CreateFontIndirect( &_lf );
    }
    ASSERT( hFont != NULL );
    CFont _fontDestructor;
    _fontDestructor.Attach( hFont );

    CExtPaintManager::PAINTPUSHBUTTONDATA _ppbd(
        this,                                        
        true,
        rectDropdownButton,
        _T(""),
        NULL,
        false,
        bHover,
        false,
        false,
        true,
        true,
        false,
        false,
        false,
        hFont,
        false,
        0,
        false
        );

    PmBridge_GetPM()->PaintPushButton( *pDC, _ppbd );

    CRect rcDDButtonGlyph( rectDropdownButton );
    //    if( m_bPushed )
    rcDDButtonGlyph.OffsetRect(1,1);

    // paint arrow down
    CExtPaintManager::glyph_t * pGlyph =
        CExtPaintManager::g_DockingCaptionGlyphs[ CExtPaintManager::__DCBT_ARROW_DOWN ];
    ASSERT( pGlyph != NULL );
    COLORREF ColorValues[2] =
    {
        RGB(0,0,0),
            ::GetSysColor( COLOR_BTNTEXT )
    };
    PmBridge_GetPM()->PaintGlyphCentered(
        *pDC,
        rcDDButtonGlyph,
        *pGlyph,
        ColorValues
        );

    // draw border
    pDC->Draw3dRect(rectClient,::GetSysColor(COLOR_3DSHADOW),
        ::GetSysColor(COLOR_3DHILIGHT));
    rectClient.DeflateRect(1,1);
    pDC->Draw3dRect(rectClient,::GetSysColor(COLOR_3DDKSHADOW),
        ::GetSysColor(COLOR_3DFACE));
    rectClient.DeflateRect(1,1);

    // adjust for dropdown button
    rectClient.right=rectDropdownButton.left-1;
    rectClient.DeflateRect(1,1);
    // do default painting
    DRAWITEMSTRUCT dis={ sizeof(&dis) };
    dis.CtlType=ODT_COMBOBOX;
    dis.CtlID=GetDlgCtrlID();
    dis.itemID=0;
    dis.itemAction=ODA_DRAWENTIRE;
    dis.hwndItem=GetSafeHwnd();
    dis.hDC=pDC->GetSafeHdc();
    dis.rcItem=rectClient;
    dis.itemData=0;
    dis.itemState=((::GetFocus()==GetSafeHwnd() && !GetDroppedState()) ? ODS_FOCUS : 0);
    DrawItem(&dis);

    if( bCallReleaseDC )
        ReleaseDC( pDC );
}
Now it’s work ok.
Ulrich

Technical Support Jan 10, 2008 - 2:58 AM

You derived your class COXComboPickerCtrl from CExtComboBox. The latter paints its content itself. So you should remove the WM_PAINT handler from COXComboPickerCtrl.


Ulrich Heinicke Jan 9, 2008 - 10:22 AM

Sorry, the correct link of the source i http://www.ibh-software.org/shellcontrols.rar

Ulrich Heinicke Jan 9, 2008 - 10:21 AM

Hi,
you have misunderstand me. I don’t subclass any dialog, i create a new one with some classes from the ultimate toolbox. Look at the screenshot of the testprogram
http://www.ibh-software.org/shellcontrol.png
You can look also into the source of the testprogram http://www.ibh-software.rg/shellcontrols.rar
Ulrich

Technical Support Jan 9, 2008 - 6:34 AM

Actually the combo box on the File Dialog is an extended version of the simple combo box control which provides support for image lists (CComboBoxEx). So it is incorrect to subclass it with the CExtComboBox class which is derived from the simple CComboBox. We spent a lot of time to create the Prof-UIS skinned extended combo box but failed. It simply ignores the WM_PAINT message and draws itself in some other way. If you find a way how to create a skinned version of CComboBoxEx then you will be able to use it in the File Dialog window.

If you are creating these dialogs from scratch and encounter this error, please send us the source code so we can test it on our side and find out what is wrong.