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;
}