Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Adding CToolbar on CPropertySheet.

Adding CToolbar on CPropertySheet.

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paresh Chitte
    wrote on last edited by
    #1

    Hi, I have a class derived from CPropertySheet. I have added a CToolbar to this property sheet. I have repositioned the toolbar at right top corner of the property sheet. However, the property sheet area covers the toolbar and I am able to see only some portion of the toolbar area. How could I bring the Toolbar on top of property sheet ? (May be at the tabs level but at right side) I have tried putting a CButton control on the property sheet and is working properly. Please refer below code to understand the situation.

    class CMyPropertySheet : public CPropertySheet
    {
    	DECLARE_DYNAMIC(CMyPropertySheet)
    
    public:
    	CMyPropertySheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
    	CMyPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
    	virtual ~CMyPropertySheet();
    
    protected:
    	DECLARE_MESSAGE_MAP()
    
    private:
    	CButton m_Button;
    	CToolBar m_wndToolBar;
    
    public:
    	virtual BOOL OnInitDialog();
    	afx_msg void OnButtonClicked();
    	afx_msg void OnButton1Clicked();
    	afx_msg void OnButton2Clicked();
    	void RepositionToolbars();
    };
    
    BOOL CMyPropertySheet::OnInitDialog()
    {
    	BOOL bResult = CPropertySheet::OnInitDialog();
    
    	// TODO:  Add your specialized code here
    
    	m_Button.Create(_T("New Button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(200,0,300,20), this, ID_BUTTON_ID);
    
    	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT, WS_CHILD | WS_VISIBLE | CBRS_TOP 
    		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    		!m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))
    	{
    		TRACE0("Failed to create toolbar\n");
    		return -1;      // fail to create
    	}
    
    	RepositionToolbars();
    
    
    	return bResult;
    }
    
    void CMyPropertySheet::RepositionToolbars()
    {
    	// Reposition validation toolbar.
    	if(m_wndToolBar)
    	{
    		m_wndToolBar.GetToolBarCtrl().ModifyStyleEx(SWP_NOMOVE | SWP_NOREPOSITION, SWP_SHOWWINDOW);
    
    		// Calculate toolbar width.
    		CSize SizeToolBar;
    		m_wndToolBar.GetToolBarCtrl().GetMaxSize(&SizeToolBar);
    
    		CRect rcDlg;
    		GetClientRect(&rcDlg);
    
    		int iWidth	= 0;
    		int iHeight	= 0;
    
    		iWidth = SizeToolBar.cx;
    		iHeight = SizeToolBar.cy;
    
    		int iX		= rcDlg.right-iWidth;
    		int iY		= 0;
    
    		m_wndToolBar.GetToolBarCtrl().MoveWindow(iX, iY, iWidth, iHeight);
    	}
    }
    

    Any help would be highly appreciable. Regards, Paresh.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups