-
March 1st, 2011, 10:31 AM
#1
Problem with dropdown button with image and check in toolbar on windows seven
Hello, I am using a CToolBar to display a button with a dropdown list composed of image with a check on left.
The following source code work well on xp and failed to display checks on seven.
Here is an example of :
- success on windows xp :
- failure on windows seven
- sucess on windows seven but with strings in place of images :
Is there something wrong with my code or is their something to do to make it works on seven ?
Code:
BOOL CTestBtnMenuDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// create the toolbar
m_toolbar.Create(this, WS_CHILD|WS_VISIBLE|CBRS_TOP, IDR_TOOLBAR1);
m_toolbar.LoadToolBar(IDR_TOOLBAR1);
m_toolbar.SetBarStyle(m_toolbar.GetBarStyle() |
CBRS_TOOLTIPS |
CBRS_FLYBY |
CBRS_GRIPPER |
CBRS_SIZE_DYNAMIC);
m_toolbar.MoveWindow(0, 0, 200, 40);
// set style of first button to dropdown
UINT uiBtnStyle = m_toolbar.GetButtonStyle(0);
uiBtnStyle |= BTNS_DROPDOWN;
m_toolbar.SetButtonStyle( 0, uiBtnStyle );
// allow draw arrows
m_toolbar.GetToolBarCtrl().SetExtendedStyle( TBSTYLE_EX_DRAWDDARROWS );
}
HMENU CTestBtnMenuDlg::CreatePopupMenu()
{
CBitmap bmpItemMenu;
// create a popup menu
CMenu mnuPopup;
mnuPopup.CreatePopupMenu();
// load bitmap 1 for drop down list
bmpItemMenu.LoadBitmapA(IDB_BITMAP1);
mnuPopup.AppendMenu(MFT_BITMAP, 0, &bmpItemMenu );
bmpItemMenu.Detach();
// load bitmap 2 for drop down list
bmpItemMenu.LoadBitmapA(IDB_BITMAP2);
mnuPopup.AppendMenu(MFT_BITMAP, 1, &bmpItemMenu );
bmpItemMenu.Detach();
return mnuPopup.Detach();
}
void CTestBtnMenuDlg::OnToolbarDropDown( NMHDR* pnmtb, LRESULT *plr )
{
// create popup menu
HMENU hMnuPopup = CreatePopupMenu();
// select checked item
static int idx=0;
if (idx == 0)
idx = 1;
else
idx = 0;
::CheckMenuItem( hMnuPopup, idx, MF_CHECKED );
// display popup menu
CRect rcPosItem;
rcPosItem.top = 25;
rcPosItem.bottom = 100;
rcPosItem.left = 0;
rcPosItem.right = 100;
ClientToScreen(&rcPosItem);
::TrackPopupMenu( hMnuPopup, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL,
rcPosItem.left, rcPosItem.top, 0, GetSafeHwnd(),
&rcPosItem );
}
Thanks in advance.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|