-
March 22nd, 2002, 10:24 AM
#1
Floating toolbar
Every time i wanna float my newly added toolbar, i just can't because i've got
a CRASH message Debug assertion fail. My member var for the toolbar is m_wndControlBar of type CToolBar linked to the resource toolbar IDR_CONTROLTOOLBAR. The codes from mainfrm.cpp and mainfrm.h are below. Please can you tell me what's wrong
---->MainFrm.cpp<----
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndDlgBar.Create(this, IDR_MAINFRAME,
CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR))
{
TRACE0("Failed to create dialogbar\n");
return -1; // fail to create
}
if (!m_wndReBar.Create(this) ||
!m_wndReBar.AddBar(&m_wndToolBar) ||
!m_wndReBar.AddBar(&m_wndDlgBar))
{
TRACE0("Failed to create rebar\n");
return -1; // fail to create
}
//New toolbar (controls) is added here
if(!m_wndControlBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |
WS_VISIBLE | CBRS_GRIPPER |CBRS_TOP | CBRS_TOOLTIPS |
CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_FLOAT_MULTI) ||
!m_wndControlBar.LoadToolBar(IDR_CONTROLTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1;
}
//end adding toolbar
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Remove this if you don't want tool tips
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY);
//Float the toolbar
FloatControlBar(m_wndControlBar, CPoint(4, 4), CBRS_ALIGN_TOP);
return 0;
}
and the declaration for the m_wndControlBar
----->MainFrm.h<-----
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
CReBar m_wndReBar;
CDialogBar m_wndDlgBar;
CToolBar m_wndControlBar;
-
March 22nd, 2002, 11:24 AM
#2
Re: Floating toolbar
I guess u missed these :
m_wndControlBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
But I am not sure! try it.
Good Luck!
Narayana Murty!
Rate this post if it helpd you!
-
March 22nd, 2002, 11:29 AM
#3
Re: Floating toolbar
Oh! Sorry, you want floating bar.
Still I am not sure!
FloatControlBar(&m_wndControlBar, CPoint(4, 4), CBRS_ALIGN_TOP);
//instead of
FloatControlBar(m_wndControlBar, CPoint(4, 4), CBRS_ALIGN_TOP); // you missed & before m_wndControlBar?
Good Luck!
Narayana Murty
-
August 19th, 2002, 03:40 AM
#4
If you want to create a floating ToolBar,call EnableDocking with a parameter of 0. Then call CFrameWnd::FloatControlBar.
Try to use the following code to float your toolbar
m_wndMyToolBar.EnableDocking(0);
FloatControlBar(&m_wndMyToolBar,(0,0));
I think you have probably settled this problem,Because this thread has already posted.
But I hope My Answer can help people have the same question as you.
Last edited by numen; August 19th, 2002 at 04:25 AM.
Live and learn
-
September 26th, 2002, 01:14 PM
#5
osrtstream and Carriage Returns
After filling a buffer using oststream,
ostrstream ostrIPF(b_IPFHeader, sizeof b_IPFHeader);
ostrIPF << "IPFversion 1 2 timestamp " << strTime
<< " fps 30.446 single FPI" << ends;
I write this out to file, the problem with this is it's all on one line!
e.g IPF version 1 2 timestamp Thu Sep 26 18:56:52 2002 fps 30.446 single FPI
what I want is the actual output in the file to look like
IPF
version 1 2
timestamp
Thu Sep 26 18:56:52 2002
fps 30.446 single FPI
Is there any way to add in a Carriage return to this stream, how about the ascii control code 0x0d? could/how would, I add that to the stream?
I've tried putting \n at the relevant intersections but Notepad doesn't recognise it! and just display's a black square.
Any body point me in the right direction?
If god is love, and love is blind, it follows that Stevie Wonder is God!
-
September 26th, 2002, 01:15 PM
#6
Mistake
Sorry Guy's I was looking at this post and clicked Post Reply instead of New Thread
Appologies
If god is love, and love is blind, it follows that Stevie Wonder is God!
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
|