|
When deriving from a Base through a virtual intermediate, it is your responsibiliy to construct the object base --none of the constructors supplied by the derived virtual classes is applied. If you don't specify a constructor, default is used.
Apart from this, the syntax you using is incorrect. It should be like:
X::X(char a, int j): A(j)
{
char temp = a;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Okay. Thanks.
Please give an example of how to construct the base from that example.
Kuphryn
|
|
|
|
|
When inheriting from a virtual baseclass, it's always the responsibility of the "most derived" class to invoke the constructor of the virtual baseclass. The way you invoke initialization from a constructor is well documented.
I suggest, and I do this to be nice, you don't try to use virtual baseclasses until you learn and understand at least the syntax and semantics for initialization. To give you a starting point; you initialize anything from a C++ constructor like:
class A
{
A() : v(0) {}
int v;
};
|
|
|
|
|
Okay. I admit the sample had code errors. You could look up syntax in a reference book. I wanted to understand the concept.
Kuphryn
|
|
|
|
|
I have a CStringArray with filenames, and I want to run through these and open a new MDI child for each file.
I can open a file through 'File->Open', but don't get how to achieve this without bringing up the SelectFile Dialog.
Is there a just message I need to send?
TIA,
BW
{insert witty/thought-provoking saying here}
|
|
|
|
|
Use CWinApp::OpenDocumentFile method.
Pavel
Sonork 100.15206
|
|
|
|
|
Thanks, still not quite there, though.
I've implemented this:
CDocument* pDoc = AfxGetApp()->OpenDocumentFile(Filename);<br />
if(pDoc != NULL)<br />
pDoc->UpdateAllViews(NULL);
and get an exception error assigning pDoc.
BW
{insert witty/thought-provoking saying here}
|
|
|
|
|
Your code worked for me OK using Copy&Paste.
In CMainFrame menu command handler.
Where are you using it in your app hierarchy?
Are the document templates initialized (in InitInstance)?
Pavel
Sonork 100.15206
|
|
|
|
|
Pavel Klocek wrote:
Your code worked for me OK using Copy&Paste
So I'm not completely lost, then.
Pavel Klocek wrote:
Where are you using it in your app hierarchy?
void CMainFrame::PVCSGet(CString Filename)<br />
{<br />
...<br />
CDocument* pDoc = AfxGetApp()->OpenDocumentFile(Filename);<br />
...<br />
}
documents are getting initialized, I can open documents from File->Open.
BW
{insert witty/thought-provoking saying here}
|
|
|
|
|
Have you only one type of document?
I suppose, the file extension matches the one defined for the document in resources.
I'm out of imagination.
You tried to go inside of OpenDocumentFile in debugger?
Pavel
Sonork 100.15206
|
|
|
|
|
Pavel Klocek wrote:
Have you only one type of document?
Yes
Maybe a clear head on Monday will make it obvious to me.
Thanks very much for your help!
Enjoy the weekend!!
BW
{insert witty/thought-provoking saying here}
|
|
|
|
|
brianwelsch wrote:
Maybe a clear head on Monday will make it obvious to me.
Yes, it often helps.
brianwelsch wrote:
Enjoy the weekend!!
Thanks, you too .
Pavel
Sonork 100.15206
|
|
|
|
|
In a create function of a modeless dlg I have an Images class object (my custom class) which puts a pointer into the member set variable:
image.pZoomSet.insert(this);
Now I have several modeless dlgs spawned, each with a unique image object (which has a <set> member called ZoomSet):
BOOL CZoom::Create(UINT nID, CWnd *pWnd, CString& trioIndex, CImages& image)
I close these 'Czoom' class modeless dlgs like this m_pImage = &image )
void CZoom::OnClose()
{
std::set<CZoom*>::iterator it = m_pImage->pZoomSet.find(this);
m_pImage->pZoomSet.erase(it);
}
If I have say four of these zooms up , three will close (no visible pattern), the fourth wil crash
at the find(this), but sometimes its not even the fourth one - might be the second one - that crashes when I close it. How do I debug this? I cant "see" into the iterators etc
|
|
|
|
|
What you explain so far seems OK. Are you messing around with image somewhere else? I've I understood it right this object is unique --CZoom s only hold a pointer to it in order to acces it in OnClose .If so, where is the object stored?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
you might want to verify that "it" actually represents to a valid object (test that it's not equal to mycollection.end() )
also, since the iterator is just a reference to whatever your set is holding, you can create a variable, assign it to the iterator and look at that:
myobject temp = (*it);
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
I thougtht of that, but my set is holding pointers to CZoom objects (which are CDialog derived basically). SO i really dont know how to look at this pointer..I will go and test to see if find is returning .end() though, so thanks. However, its not illegal to return end if not found,,,and it doesnt get past the find. I checked to see what (this) had and its something non-null. Thanks for the help,
ns
|
|
|
|
|
My first question is there a guide to threads somewhere on the web? Something that takes a novice user into account? (ie hand holding) I have the basics down I think. Correct me if I am wrong.
1 Add a member function static UINT WorkerThread(LPVOID lParam)
2. Add the code you want to call in the thread to the implementation of WorkerTHread(...)
3. Call AfxBeginThread(WorkerThread, yourParam);
My question, is there a way to be notified upon completion of the thred? Can you tell if the thread is still running? How do you kill a thread if it is out of control? Questions questions questions!! Thanks for your help.
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
those are the basic steps for launching a thread, yep.
as for the Q... well, there are tons of ways to do it. you can use the synchronization classes that are built into windows: Events, Mutexes, etc.. or you can do it the "manual" way by sharing a flag between your thread and the owner: pass a pointer to a bool (best to mark it volatile : volatile bool b; ) into your thread proc, then have the thread set that bool when it's done; the parent thread would periodically look at the bool to see if the thread has changed it.
testing for deadlocks can be simple: have the thread periodically set some variable to a random/increasing/decreasing value. the parent can just look at this value and note if it hasn't changed in the past X seconds. if it hasn't changed, the thread might be hung.
there are a articles on this site that cover both methods in gory detail. look in the "threads" section.
-c
Greenspun's Tenth Rule of Programming:
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
|
|
|
|
|
Hello,
I want to change the font of all the Frame Static controls on my dialog.
The following code will loop through all the dialog's controls and change all their fonts.
CWnd* pwndChild = GetWindow(GW_CHILD);
while (pwndChild)
{
pwndChild->SetFont( &MyNewFont, FALSE );
pwndChild = pwndChild->GetNextWindow();
}
Could somebody tell me how I can identify if the window is a static frame type.
Thanks,
John
|
|
|
|
|
You can do this so:
TCHAR buf[50];
GetClassName(pwndChild->GetSafeHwnd(),buf,50);
if(strcmp(buf,"Static")==0)
{
...
}
But I don't think it's a good practice.
Pavel
Sonork 100.15206
|
|
|
|
|
Thanks Pavel,
The Static Frame control's ClassName is 'Button' so now I have to work out how to differentiate between it and other Button types.
|
|
|
|
|
I want to create a wrapper for sprintf , a function that uses variable arguments.
Mu function should look something like this:
void extra_sprintf(const char* lpText,...)
{
char buf[256];
sprintf(buf,lpText,...); // ... exact same arguments from extra_sprintf
// some extra code
}
How can I call the regular sprintf function inside my extra_sprintf function, as simple as possible?
tnx
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
|
|
|
|
|
Check va_arg, va_start, va_end and va_list.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
I can do something like:
va_list args
va_start(args,lpText)
...
va_end(args)
But then, how can I pass the list to sprintf in just one call? If I pass args, it will not work, nor with lpText
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
|
|
|
|
|
Grote Smurf wrote:
But then, how can I pass the list to sprintf in just one call?
Use vsprintf.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|