Problem with dropdown button with image and check in toolbar on windows seven
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: Problem with dropdown button with image and check in toolbar on windows seven

Threaded View

  1. #1
    Join Date
    Mar 2011
    Posts
    1

    Unhappy 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.
    Attached Images Attached Images    

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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center