Putting CMFCToolBar in CFormView problem
-
Hi Guys,
Need help in the current task..
I was trying to put a CMFCToolBar inside the CFormView and i thought will have no problems and used the code bellow. Now this form view is to be kept a Dockable pane. But while doing this i got few problems. To put the toolbar in the FormView, i did this..
The TOOLBAR in the RC File is like this..IDR_TOOLBAR1 TOOLBAR 16, 16
BEGIN
BUTTON IDC_BTN_1
BUTTON IDC_BTN_2
BUTTON IDC_BTN_3
ENDThe InitialUpdate of the FormView Derived class is like this: -
void CMyFormView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
CWnd *pWnd = NULL;
CRect rcPos;
if(!m_wndToolView.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_TOOLBAR1))
{
TRACE0("Failed to Create Dialog Toolbar\n");
}
m_wndToolView.LoadToolBar(IDR_TOOLBAR1, 0, 0, TRUE /* Is locked */);
m_wndToolView.CleanUpLockedImages();
m_wndToolView.LoadBitmap(IDR_TOOLBAR1, 0, 0, TRUE /* Locked */);
m_wndToolView.SetPaneStyle(m_wndToolView.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | WS_CHILD | WS_TABSTOP);
m_wndToolView.SetPaneStyle(m_wndToolView.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
m_wndToolView.SetOwner(this);
CSize szToolBar = m_wndToolView.CalcFixedLayout( FALSE, TRUE ); // returning CSize(69,24).. which should have been CSize(48, 16)
}Now a few problems i am getting are: -
1. The Toolbar images are not coming proper
2. The Update of the Toolbar items is not coming.HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
-
Hi Guys,
Need help in the current task..
I was trying to put a CMFCToolBar inside the CFormView and i thought will have no problems and used the code bellow. Now this form view is to be kept a Dockable pane. But while doing this i got few problems. To put the toolbar in the FormView, i did this..
The TOOLBAR in the RC File is like this..IDR_TOOLBAR1 TOOLBAR 16, 16
BEGIN
BUTTON IDC_BTN_1
BUTTON IDC_BTN_2
BUTTON IDC_BTN_3
ENDThe InitialUpdate of the FormView Derived class is like this: -
void CMyFormView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
CWnd *pWnd = NULL;
CRect rcPos;
if(!m_wndToolView.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_TOOLBAR1))
{
TRACE0("Failed to Create Dialog Toolbar\n");
}
m_wndToolView.LoadToolBar(IDR_TOOLBAR1, 0, 0, TRUE /* Is locked */);
m_wndToolView.CleanUpLockedImages();
m_wndToolView.LoadBitmap(IDR_TOOLBAR1, 0, 0, TRUE /* Locked */);
m_wndToolView.SetPaneStyle(m_wndToolView.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | WS_CHILD | WS_TABSTOP);
m_wndToolView.SetPaneStyle(m_wndToolView.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
m_wndToolView.SetOwner(this);
CSize szToolBar = m_wndToolView.CalcFixedLayout( FALSE, TRUE ); // returning CSize(69,24).. which should have been CSize(48, 16)
}Now a few problems i am getting are: -
1. The Toolbar images are not coming proper
2. The Update of the Toolbar items is not coming.HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
May be also done as following :)
// class CDiaFrame : public CFrameWnd
int CDiaFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;ModifyStyle(0, WS_CLIPCHILDREN);
ModifyStyleEx(WS_EX_CLIENTEDGE, 0);m_cToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP, 1);
m_cToolBar.SetPaneStyle(m_cToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
m_cToolBar.SetPaneStyle(m_cToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
m_cToolBar.LoadToolBar(IDR_DIATOOLBAR, 0, 0, TRUE);return 0;
}void CDiaFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);static CSize sizeToolBar(m_cToolBar.CalcFixedLayout(TRUE, TRUE));
CRect crClient;
GetClientRect(crClient);crClient.bottom = sizeToolBar.cy;
m_cToolBar.MoveWindow(crClient);
}And then - create/size this frame in a docable pane. Of course you have to define the frame's reactions/updates for all commands from your bar as well :)
They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)
-
May be also done as following :)
// class CDiaFrame : public CFrameWnd
int CDiaFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;ModifyStyle(0, WS_CLIPCHILDREN);
ModifyStyleEx(WS_EX_CLIENTEDGE, 0);m_cToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP, 1);
m_cToolBar.SetPaneStyle(m_cToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
m_cToolBar.SetPaneStyle(m_cToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
m_cToolBar.LoadToolBar(IDR_DIATOOLBAR, 0, 0, TRUE);return 0;
}void CDiaFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);static CSize sizeToolBar(m_cToolBar.CalcFixedLayout(TRUE, TRUE));
CRect crClient;
GetClientRect(crClient);crClient.bottom = sizeToolBar.cy;
m_cToolBar.MoveWindow(crClient);
}And then - create/size this frame in a docable pane. Of course you have to define the frame's reactions/updates for all commands from your bar as well :)
They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)
Thanks for the relpy Eugen Podsypalnikov, however i have done the same in my code its not working :( and i have no clues why is it so.. the bitmaps are still improper, buttons are disabled and i am getting no update message for them..
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
-
Thanks for the relpy Eugen Podsypalnikov, however i have done the same in my code its not working :( and i have no clues why is it so.. the bitmaps are still improper, buttons are disabled and i am getting no update message for them..
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
You can try to go from a level to another, here would be a possible check list :) : 1. Own dockable pane 2. Own frame window 2a. Embedding of the frame into the pane (what can you see at this stage ?) 3. Own toolbar 3a. Embedding of the bar into the frame 4. Implementing of the frame's update/reactions functions
They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)