Click to See Complete Forum and Search --> : How to attach a ToolBar to the main parent window


gpurusho
June 23rd, 1999, 01:24 AM
Iam not using MFC AppWizard. I need to know How to attach a ToolBar to the main parent window.Can someone please help me out?

Fabi Pantera
June 23rd, 1999, 01:35 AM
Try this one (I used a CReBar...) on the CMainFrame::OnCreate:

[if (!m_wndReBar.Create(this))
{
TRACE0("Failed to create rebar\n");
return -1; // fail to create
}
if (!m_wndToolBar1.CreateEx(this) ||
!m_wndToolBar1.LoadToolBar(IDR_STANDARD))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
} ]
where :
[ CToolBar m_wndToolBar6;
CReBar m_wndReBar;]
If you need a special toolbar with some big buttons (like IE), you have a sample in the MSDN, called MSIE. Please let me know if it works or if you still have some problems.
Regards,
Fabi

gpurusho
June 23rd, 1999, 02:19 AM
Hi Fabi,
I have a problem now. I have loaded this toolbar with a couple of buttons and one of them starts my application by creating a child window. ZThe problem is this child window HIDES MY LOADED TOOLBAR.

Fabi Pantera
June 23rd, 1999, 02:34 AM
How can a window hide your toolbar? Anyway using the last code, you can add this:
[ m_wndReBar.AddBar(&m_wndToolBar);]
After this you can show a band with m_wndReBar.ShowBand(0);//now it has be visible. It is(reply)?

Best regads,
Fabi

gpurusho
June 23rd, 1999, 02:49 AM
Sorry I didn't tell you that Iam not Using CReBar but CToolBar. So I guess I cannot use AddBar() function.

Fabi Pantera
June 23rd, 1999, 02:53 AM
Try with : toolbar.ShowWindow(SW_SHOW). Ok?

gpurusho
June 23rd, 1999, 03:52 AM
Nope!! Does,t work. Show I use GetClientRect() to reposition my child window or is there some other way. If you want to see my code ( to get a clear picture) I can email you.(if you have time for it)

Fabi Pantera
June 23rd, 1999, 04:12 AM
Ok, send me your code. Try to make it shortly.

Fabi Pantera
June 23rd, 1999, 04:16 AM
I forgot!!!!
Let me eat your code, a couple of hours. I have a break. I'll eat it after. Ok?

gpurusho
June 23rd, 1999, 04:25 AM
But I need your email address for send you the code or do you want me to post them here itself?

Fabi Pantera
June 23rd, 1999, 04:30 AM
My e-mail : fabiant@stc.sibnet.ro. Ok?