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 » bitmap on built-in combobox text field Collapse All
Subject Author Date
Chris Thomas Jun 23, 2005 - 2:02 PM

How to display a bitmap on the text field of a built-in owerdraw combobox?

Technical Support Jun 24, 2005 - 7:14 AM

You task can be divided into two parts:

1) How to display a bitmap inside the built-in combo/edit field in a toolbar button?

Create a CExtBarTextFieldButton-derived class and override the Paint() virtual method, which should be similar to the parent class method but draw the image you wish. You also need to override the OnInplaceControlCalcRect() virtual method, which should call the parent method and return a rectangle adjusted for the image. This rectangle is used for creating the in-place editor window.

To use you custom field in the Prof-UIS customization system, override the CExtCustomizeSite::OnCreateToolbarButton() virtual method in your main frame window like:

CExtBarButton *  CMainFrame::OnCreateToolbarButton(
    CExtToolControlBar * pBar,
    CExtCustomizeCmdTreeNode * pNodeI,
    CExtCustomizeCmdTreeNode * pNodeC
    )
{
    ASSERT_VALID( this );
    ASSERT_VALID( pNodeC );
    ASSERT_VALID( pBar );
UINT nCmdID = pNodeC->GetCmdID( false );
CExtCmdItem * pCmdItem =
    g_CmdManager->CmdGetPtr(
        g_CmdManager->ProfileNameFromWnd( pBar->m_hWnd ),
        nCmdID
        );
bool bTextField = pCmdItem->StateIsTextField();
bool bCombo = pCmdItem->StateIsCombo();
    if( bTextField || bCombo )
    {
        if( nCmdID == ID_YOUR_TEXT_OR_COMBO_FIELD )
        {
            CExtBarTextFieldButton * pTextFieldTBB =
                    new CExtBarTextFieldButton(
                        bCombo,
                        nTextFieldWidth,
                        pBar,
                        nCmdID,
                        0
                        );
            pTextFieldTBB->m_nDropDownWidth =
                pNodeC->DropDownWidthGet();
            pTextFieldTBB->m_nDropDownHeightMax =
                pNodeC->DropDownHeightMaxGet();
            pTextFieldTBB->m_bTextFieldIsNotEditable =
                ( pNodeC->GetFlags() & __ECTN_TBB_TF_NE ) ? true : false;
            bool bNoRotateVL = pTextFieldTBB->GetNoRotateVerticalLayout();
            if( bNoRotateVL )
                pNodeC->ModifyFlags( __ECTN_TBB_NO_ROTATE_VL );
            if( pNodeI != NULL )
            {
                pTextFieldTBB->SetBasicCmdNode( pNodeI );
                pTextFieldTBB->OnCustomizeUpdateProps( pNodeI );
            }
            else
                pTextFieldTBB->OnCustomizeUpdateProps( pNodeC );
            pTextFieldTBB->SetCustomizedCmdNode( pNodeC );
            if( pNodeC->GetFlags() & __ECTN_TBB_HIDDEN )
                pTextFieldTBB->ModifyStyle( TBBS_HIDDEN, 0 );
            else
                pTextFieldTBB->ModifyStyle( 0, TBBS_HIDDEN );
            return pTextFieldTBB;
        }
    }
    return CExtCustomizeSite::OnCreateToolbarButton( pBar, pNodeI, pNodeC );
}

2) How to display a bitmap inside the built-in combo/edit field in a menu item?

The solution for menus should be based on the owner-drawn menu items:
ON_REGISTERED_MESSAGE(
    CExtPopupMenuWnd::g_nMsgPopupDrawItem,
    OnDrawPopupMenuItem
    )
 
LRESULT CPagePopupMenus::OnDrawPopupMenuItem(WPARAM wParam, LPARAM lParam)
{
    wParam;
CExtPopupMenuWnd::DRAWITEMDATA * pDrawItemData =
        reinterpret_cast < CExtPopupMenuWnd::DRAWITEMDATA * > ( lParam );
    ASSERT( pDrawItemData != NULL );
    UINT nCmdID = pDrawItemData->GetCmdID();
    if( nCmdID == ID_YOUR_TEXT_OR_COMBO_FIELD )
    {
        pDrawItemData->PaintDefaultBk();
        . . .
    }
    return !0;
}

Chris Thomas Jun 28, 2005 - 1:56 PM

Thank you