|
-
May 20th, 1999, 06:41 AM
#1
Insert a ToolBar in a Dialog based app
Hi..
I was wondering how I could add a ToolBar to one of my Dialog Based MFC App...I could easily add a Menu bar, but I can't find the way to add a ToolBar...Could someone help me ?
-
May 20th, 1999, 08:12 AM
#2
Re: Insert a ToolBar in a Dialog based app
If you embed a CToolBar object as a member of the dialogue class, then add a handler for the WM_CREATE message, then in the OnCreate() method it generates add these lines (stolen from CMainFrame as generated by AppWizard):
--- if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
---
(where IDR_MAINFRAME is a toolbar resource).
This should work. Does it help?
-
May 20th, 1999, 09:56 AM
#3
Re: Insert a ToolBar in a Dialog based app
You should also add the following code after you have loaded the toolbar
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
There is one problem , if you are calling your dialog from some other dialog/view then the second time you call it the toolbar does not load ... any solutions
-
May 21st, 1999, 06:38 AM
#4
Re: Insert a ToolBar in a Dialog based app
Hi..thank you for your help..but well, I can't make it work...the toolbar doesn't appear in the dialog box..Maybe by adding the line talal tayyab just said, then it works...I'll try as soon I'm at home..I hope it'll work then..
Thanks again 4 ur help both u jason and talal tayyab.. 
-
May 21st, 1999, 07:39 AM
#5
Re: Insert a ToolBar in a Dialog based app
You'll be pleased to know that with Talal's added comment, it WILL work - but you will have to shift all controls on the dialogue box DOWN by the height of the toolbar.
Normally, a frame window has the toolbar attached to one side and then places a client window (the view) inside the area left after the toolbar and status bar have been positioned; because the dialogue box puts controls directly onto its surface rather than on a client window placed inside the frame, the controls overlap the toolbar. It is, however, a simple thing to move them all down {:v).
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
|