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 Tech Support » CExtBarColorButton behaviour Collapse All
Subject Author Date
Neville Franks Nov 24, 2005 - 1:40 PM

Hi,


I’m using a CExtBarColorButton toobar button using the same code as in your StyleEditor sample app. I want to separate out the action performed when the users clicks the icon and when the click the drop down arrow. At present clicking on either one drops down the color pallete.


Instead what I want is when the user clicks on the icon I apply the current color and the color pallete window *does not* appear. If they click on the drop down arrow the color pallete window works as in the sample app. How can I do this?


Also is there a way to specify the colors used in the color pallete drop down window?


Thanks, Neville

Technical Support Nov 26, 2005 - 10:56 AM

Yes, the StyleEditor sample application features simple drop-down buttons. To add a separate drop-down part on the right of the button, just find the following lines in the CMainFrame::OnCreate() method in the sample

    pCmdItem = g_CmdManager->CmdGetPtr( pApp->m_pszProfileName, ID_SE_TEXT_COLOR );
    pCmdItem->StateSetColor();
    pCmdItem->StateSetColorBtnDefault();
    pCmdItem->StateSetColorBtnCustom();
    pCmdItem->StateSetNoRotateVL();
    //pCmdItem->StateSetSeparatedDD();
and uncomment the last line. Then please remove the HKEY_CURRENT_USER\Software\Foss\StyleEditor registry key, under which the application state is stored, build the StyleEditor project and run it. The text color button should now have a separate drop-down part and act as you described.

It is also possible to set up a custom color palette, dimension and size for the color button. This is demonstrated in the ProfUIS_Controls sample application (starting from version 2.50). For instance, you can invoke a context menu over the Popup Menus page to see four different color picker menus there. The CPagePopupMenus::OnContextMenu() method in the ProfUIS_Controls sample application handles the WM_CONTEXTMENU standard windows message and initializes color picker menus in the context menu. Initialization of each color popup menu invokes the methods below:

1) CExtPopupColorMenuWnd::RemoveAllColors() removes the color palette entries initialized by default.

2) CExtPopupColorMenuWnd::SetColorsInRow() sets the number of color buttons in each line.

3) CExtPopupColorMenuWnd::AddColor() appends the color button to the color picker menu.

To customize the color pickers in your application, please handle the CExtPopupMenuWnd::g_nMsgPrepareOneMenuLevel registered windows message. This message is sent by each popup menu sublevel before it appears on the screen. You should use the following message map entry and handler method:
    ON_REGISTERED_MESSAGE(
        CExtPopupMenuWnd::g_nMsgPrepareMenuOneLevel,
        OnExtMenuPrepareOneLevel
        )
LRESULT CMainFrame::OnExtMenuPrepareOneLevel(WPARAM wParam, LPARAM lParam)
{
    lParam;
CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
        reinterpret_cast
        < CExtPopupMenuWnd::MsgPrepareMenuData_t * >
        ( wParam );
    ASSERT( pData != NULL );
CExtPopupMenuWnd * pPopup = pData->m_pPopup;
    ASSERT( pPopup != NULL );
CExtPopupColorMenuWnd * pColorPopup =
        DYNAMIC_DOWNCAST( CExtPopupColorMenuWnd, pPopup );
    if( pColorPopup != NULL )
    {
        CExtCustomizeCmdTreeNode * pNode = pColorPopup->_CmdNodeGet()
        ASSERT_VALID( pNode );
        if( pNode->GetCmdID(false) == ID_YOUR_COLOR_COMMAND )
        {
            pColorPopup->RemoveAllColors();
            // TO-DO: INITIALIZE COLOR PALETTE HERE
            . . .
    }
    return TRUE;
}