|
Tarun Jha wrote: length = a.length + b.length ;
[Trivial] note that this actually should be:
length = a.length + b.length - 1;
(And please add a destructor. As a pure FYI, since I assume this is for learning hence not using std::string, you could use std::unique_ptr for name, avoiding the need for anything but a default destructor.)
|
|
|
|
|
I'm trying to use Boost serialization in a C++ project, and my code has triggered the assertion on line 103 of this file. That's the line
BOOST_ASSERT(false); in the bottom-most function in the file. What kinds of things can cause this failure?
The context is that I have a class called Board, whose serialize() overload starts by trying to serialize the member
std::array<Piece*, 16>m_whiteArmy where Piece is another of my own classes. Trying to serialize m_whiteArmy is what triggers the assert. I've tried putting a breakpoint at the top of Piece's serialize() overload. The assertion triggers before it's reached.
I would include a compileable example, but when I've tried writing a toy program to replicate the problem, the toy program has worked. The two most suspicious things I can think of that my attempts at toy programs haven't replicated are that the Board object I'm trying to serialize is a global, and the project is spread over multiple files. Piece is a base class, and m_whiteArmy stores pointers to derived Piece objects, so maybe it matters which file I use
BOOST_CLASS_EXPORT_GUID to register the derived classes in, and I've chosen the wrong one?
Maybe this is all irrelevant - I have no idea where to begin.
modified 6-Mar-18 4:21am.
|
|
|
|
|
Start by having a look at the full code containing the assert statement:
BOOST_ARCHIVE_DECL(const basic_serializer *)
basic_serializer_map::find(
const boost::serialization::extended_type_info & eti
) const {
const basic_serializer_arg bs(eti);
map_type::const_iterator it;
it = m_map.find(& bs);
if(it == m_map.end()){
BOOST_ASSERT(false);
return 0;
}
return *it;
} The assertion is thrown when the specified element can't be found in the container (see map::find - C++ Reference[^] ). Locate where the find function is called in your code and check the passed argument.
|
|
|
|
|
I found that what displayed when I hovered my cursor over the variable eti just before the assert triggered while debugging contained, among other things, the string "rook". That's the string I had associated with the derived Piece class I would expect the first element of m_whiteArmy to point to an element of using BOOST_CLASS_EXPORT_GUID, so I figured there was something wrong with how I did that association. I tried moving my calls of that macro from the top of the Piece cpp file to the top of the main file, and the assertion has gone away. I wish I knew why this is correct and what I'd done before wasn't, but it least it seems to be working now.
|
|
|
|
|
Hello,
How can I handle double click event on Progress bar?
|
|
|
|
|
What kind of platform: WinForms, WebUI, WPF, ...?
ProgressBar for WinForms supports double-click event.
|
|
|
|
|
For Dialog based.
There are WM_ for double click but not working. Any idea?
|
|
|
|
|
Fedrer wrote: ...but not working. Care to share (the code)?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Try to subclass this control and add the double click notification in the derived class.
|
|
|
|
|
Hi Everyone.
I am working on a MFC application with a requirement of creating multiple views. So, as part of this, i have created an application and created 4 views ( different windows) using CSplitterWnd class as follows:
BOOL bStatus = GetSplitterObj()->CreateStatic
(
this,
2,
3
);
bStatus = GetSplitterObj()->CreateView
(
0,
0,
RUNTIME_CLASS (CVisMdiAllView),
sizeView,
pContext
);
bStatus = GetSplitterObj()->CreateView
(
0,
2,
RUNTIME_CLASS (CVisMdiAllView),
sizeView,
pContext
);
bStatus = GetSplitterObj()->CreateView
(
1,
2,
RUNTIME_CLASS (CVisMdiAllView),
sizeView,
pContext
);
bStatus = GetSplitterObj()->CreateView
(
1,
0,
RUNTIME_CLASS (CVisMdiAllTextView),
sizeView,
pContext
);
bStatus = GetSplitterObj()->CreateView
(
1,
1,
RUNTIME_CLASS(CMyTabClass),
sizeView,
pContext
);
The above piece of code created 5 different views (windows) in my application. Now my requirement is in one of the views (window) i need to add tabs dynamically. I tried as follows:
CMFCTabCtrl tab;
if (!tab.Create(CMFCTabCtrl::STYLE_FLAT, CRect(150, 100, 0, 0), GetSplitterObj()->GetPane(1, 1), 1))
{
TRACE0("Failed to create output tab window\n");
return -1;
}
On Pane(1,1) i need to add tabs, and hence i added above piece of code to create MFC tab. Creation of tab is successful. It returned TRUE, but tab is not visible on that view(window).
May i know what mistake i done in adding a tab to that CView window?
modified 5-Mar-18 5:01am.
|
|
|
|
|
Member 10253026 wrote:
CMFCTabCtrl tab;
if (!tab.Create(CMFCTabCtrl::STYLE_FLAT, CRect(150, 100, 0, 0), GetSplitterObj()->GetPane(1, 1), 1))
{
TRACE0("Failed to create output tab window\n");
return -1;
}
On Pane(1,1) i need to add tabs, and hence i added above piece of code to create MFC tab. Creation of tab is successful. It returned TRUE, but tab is not visible on that view(window).
May i know what mistake i done in adding a tab to that CView window?
Your CMFCTabCtrl tab; is defined locally. So it goes out of scope after you return from the method where you create the Views.
Try to make the CMFCTabCtrl tab; the class member.
|
|
|
|
|
It does not help. I even tried to create a button as follows:
if (!but.Create(_T("Test"),BS_PUSHBUTTON,CRect(0,0,0,0), GetSplitter0()->GetPane(1, 1),101))
{
TRACE0("Failed to create output tab window\n");
return -1; // fail to create
}
CButton but is declared in header file. But still then button is not appeared on view neither the tab.
Do i need to do anything extra?
|
|
|
|
|
You could try changing the style parameter to something like WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON and put some non-zero values into the CRect object.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
I did all the work flows but the tab control is not getting added on CSplitter Window in my application.
First of all is it possible to add any controls on CSplitter windows?
|
|
|
|
|
"First of all is it possible to add any controls on CSplitter windows?"
Yes, inside of CSplitter you can insert CCtrlView which can host any MFC control.
|
|
|
|
|
Then what's wrong in my code (provided above) which is not creating any control on it?
|
|
|
|
|
First of all, create an CTabbedView derived from CTabView.
class CTabbedView : public CTabView
{
protected: CTabbedView();
DECLARE_DYNCREATE(CTabbedView)
...
};
Then, in OnCreate:
int CTabbedView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CTabView::OnCreate(lpCreateStruct) == -1)
return -1;
m_wndTabs.DestroyWindow();
if (! m_wndTabs.Create(CMFCTabCtrl::STYLE_3D, CRect(0, 0, 0, 0), this, 1, CMFCTabCtrl::LOCATION_BOTTOM))
{
TRACE(_T("Failed to create output tab window\n"));
return -1;
}
m_wndTabs.SetFlatFrame();
m_wndTabs.SetTabBorderSize(0);
m_wndTabs.AutoDestroyWindow(TRUE);
AddView(RUNTIME_CLASS(CYourView1), _T("Title 1"));
AddView(RUNTIME_CLASS(CYourView2), _T("Title 2"));
return 0;
}
and in your childframe, where you create the view inside your splitter, you can put this CTabbedView as any CView:
if(! m_wndSplitterTab.CreateView(1, 0, RUNTIME_CLASS(CTabbedView), CSize(0, 0), pContext))
{
m_wndSplitterTab.DestroyWindow();
return FALSE;
}
Tell me if is not clear.
|
|
|
|
|
Thank you very much.
It does not work even i followed the same code which you posted now and earlier. You can find the attached image which shows how i created the 5 views in my application using csplitterwnd class. In view 5 i need to add some tabs. I written a class CMyTabClass which derives from CTabView. i given this class as a RUNTIME_CLASS to view 5 as follows:
bStatus = SpliterObj()->CreateView
(
1,
1,
RUNTIME_CLASS(CMyTabClass),
sizeView,
pContext
);
In CMyTabClass i created the tab as follows:
if (!tab.Create(CMFCTabCtrl::STYLE_FLAT, CRect(150, 524, 250, 366), GetSplitter0()->GetPane(0, 0), 1))
{
TRACE0("Failed to create output tab window\n");
return -1; // fail to create
}
Some times i feel the coordinates may be wrong(150,524,250,366) and hence the tab is located out side the view. I changed many times but still the tab is not visible in view 5.
Click below for image Link:
[^]
|
|
|
|
|
Could you reproduce more accurate my example in your code ? For instance, in my example CRect has 0 value ... and there is more.
|
|
|
|
|
I created a sample MFC application with single document template and added the Class which derived from CTabView and created another class which derives from CView.
class MyTabClass : public CTabView
{
//this class created a window with tab control below. But not tab exactly.
//Now i added below piece of code to create a tab.
int OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CTabView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
AddView(RUNTIME_CLASS(CView1), _T("View1"));
return 0;
}
}
The above code created a single tab on window as shown in below image.
[^]
But all i need to know is how to create this same tab on Splitter Window which is shown in my first image.
A great thanks for you in quick response and support. Please let me know what wrong i did in adding the tab on csplitter window.
modified 6-Mar-18 6:33am.
|
|
|
|
|
My sample code was for splitter case ... do you want to add tab views inside an frame, or inside an splitter ?
|
|
|
|
|
Message Closed
modified 7-Mar-18 2:10am.
|
|
|
|
|
Dear member, in order to read easily, please format your code (use "code" button from above edit area).
And, yes, m_tab.Create(...) return TRUE, but further more, you do nothing ...
|
|
|
|
|
Hey sorry for the wrong indentation. Its working absolutely fine with same piece of code. The problem is what i mentioned earlier i.e., the coordinates what i provided does not show the tab control in my split window. I changed the values with hit and trail and some portion of tab control is visible on split window.
if (!m_tab.Create(CMFCTabCtrl::STYLE_3D, CRect(500, -500, 900, 300), this, 1, CMFCTabCtrl::LOCATION_BOTTOM))
{
TRACE(_T("Failed to create output tab window\n"));
return -1;
}
The values 500,-500,900,300 shown the control on my window. I need to write logic to show this control at the bottom of split window.
Thanks for your support. Now, i will tweak this and try to add tabs to it. In case of any block i will post it back.
|
|
|
|
|
Sure. In my code I give it an empty CRect, and it work fine.
|
|
|
|
|