|
dazinth,
I just had a similar problem. When you use CArray<cmyobj, cmyobj&=""> then you need to override SerializeElements (see MSDN). My solution was to store and load the version right before the elements were serialized and then set the object schema member variable as each element was serialized. Hope this helps.
Ted
//////////////////////////////////////////////////////////////////////
// Serialize the FEVface
// necessary because CArray does not provide this function itself
//////////////////////////////////////////////////////////////////////
template <> void AFXAPI SerializeElements <cmyobj> ( CArchive& ar, CMYobj* pNew, int nCount )
{
UINT version;
if (ar.IsLoading() == TRUE) {
ar >> version;
}
else {
ar << CONST_CURVERSION;
}
for ( int i = 0; i < nCount; i++, pNew++ ) {
ar.m_nObjectSchema = version;
pNew->Serialize( ar );
}
}
|
|
|
|
|
Change the Serialize function in your data class as follows
void CMyData::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar.WriteClass(RUNTIME_CLASS (CMyData));
ar << m_szName;
ar << m_szAddress;
}
else
{
try
{
ar.ReadClass(RUNTIME_CLASS (CMyData));
}
catch(CArchiveException *e)
{
AfxMessageBox("invalid file");
e->Delete();
return;
}
ar >> m_szName;
ar >> m_szAddress;
}
}
This will save the schema number properly.
|
|
|
|
|
Are there any office XP menu classes that actually do everything? so far i havent seen any that do the shadow behind the menus. This is what impresses me more than the blue toolbar etc...
I'm not late, I'm just not as early as I could have been.
MSN Messenger address: jonathann4@hotmail.com feel free to chat!
|
|
|
|
|
For the ahadows check this http://www.codeproject.com/menu/shadowmenu.asp, tha flat look, well i'm working on that, but is really hard for me
|
|
|
|
|
Some hints
- See the Fakemenu sample in an older PSDK dsitribution (emulates a menu, capturing mouse)
- In WTL, see http://viksoe.dk, for a flat (no shadows, but flat ) sample.
- Generic
Set a Hook, once again, the WTL files show you how to set the hook and the magic number to detect the menu window (somewhere in CCommandBarCtrlImpl<t,...> , don't remember where)
Regards,
R.
|
|
|
|
|
I am using the following lines in function InitInstance() to associate file types to my application in a MDI architecture:
//Associate the file types
EnableShellOpen();
RegisterShellFileTypes(true);
The procedure is standard MFC and documented in many places.
When I double click my files with extension .spt the application is starting, but I am also getting the following system error message:
Cannot find the file "D:\VC++\MyApp\test1.spt" (or one of its components). Make sure the path and filename are correct and that all required libraries are available.
This message is wrong because the path and filename are correct. Could somebody explain what is happening?
|
|
|
|
|
I've had the same problem in the past when registering the same extension from different programs (or the same prorgam at different locations). Try looking for the occurrences of .spt and related identifiers (Spt.Document , stuff like that) in the registry and deleting them.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I know it has been a while, but did you ever find out what the problem was? I am having the same problem.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
I'm using the following command in my program to close the CD Tray.
::mciSendString("set CDAudio door closed", NULL, 0, NULL)
But the problem is, after closing the CD tray the program is waiting for the CD to be read by windows (i.e. open a autorun file etc.). During this time the program appears to be hung. I was using the same API call in my VB version of the program. It did not have this problem. The app should only wait like this if I had used "notif" or "wait" parameters, right?
What am I missing here?
|
|
|
|
|
What is the reason to have most of ATL source code in .h files? Is there any disadvantage to having template functions in .cpp files? Can anyone point me to good articles on this topic?
|
|
|
|
|
Satheesh wrote:
What is the reason to have most of ATL source code in .h files?
IIRC, this is just so that the functions will be automatically inlined (where possible, of course).
Peace!
-=- James.
|
|
|
|
|
You can't have template functions in CPP.
Now the standard does have the 'extern' keyword to provide the ability to place template functions in CPP files, however, nobody supports this element of the standard.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
You can't have template functions in CPP.
Meaning "Templated Functions"? So I cannot declare them in a CPP file, or I cannot specialize the template in a CPP file? I am asking because I am under the impression that specializing an STL template (like std::vector) creates templated functions (like vector::push_back), and while I do not do it personally (I use typedefs in .H files), I have seen code that specializes templates in CPP files like this:
<br />
std::vector< DWORD > vecDWORDs;<br />
<br />
vecDWords.push_back( 0xFF );<br />
vecDWORDs.push_back( 0xFFFFFFFF );<br />
Or am I misunderstanding you (or templates, for that matter)?
Peace!
-=- James.
|
|
|
|
|
Ok, let me clarify. What you can't do is define a template in an H file, then implement the methods of that template in a CPP file and THEN try to use those routines in another CPP file.
So, you can define templates in a CPP file just fine. But the methods can not be used in a second CPP file. That is why template methods are commonly found in the H file as inline methods.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
Ok, let me clarify. What you can't do is define a template in an H file [...]
OK, now I get it. I do not think I have ever tried that particular scenario, which explains my ignorance of it.
Thanks for clearing that up for me.
Peace!
-=- James.
|
|
|
|
|
Is that 'export' or 'extern'?
|
|
|
|
|
DOH, you are probably right.
I'm getting old.
The mind is umm... what is it... umm... just on the tip...
What was I talking about?
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I am trying to place on of these on a dialog, and it works (somewhat), but here is the interesting thing: the CHtmlEditCtrl class has a protected destructor(!).
Private and protected destructors force you to allocate an object on the heap (or by some other custom method, which I think is a bad idea in this case). OK, fine, I have it allocated off of the heap, but I cannot deallocate/destroy the damn thing, and it does not nuke itself when it gets it's DestroyWindow(...) method called (which is where most CWnd-derived classes that destroy themselves actually destroy themselves, so I leak that object!)
Is there something that I am missing here? There is no exposed method that "self-destructs" the object. So I am at a lost as to explain why in the hell this thing has a protected destructor!
Peace!
-=- James.
|
|
|
|
|
It's a weird thing, kinda shocks me too. For a quick fix, derive from CMyHtmlEditCtrl from CHtmlEditCtrl and use this instead. But this of course doesn't explain why the dtor was protected in the first place.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I have a MFC program that I want to make it to take a path instead of a filename for its calling argument. Something like: AppName c:\docs\SupportFilePath
I noticed that the default action for having an argument in MFC program is it goes to Document::OnOpenFile(). Is there a way to prevent onOpenFile be called, but instead, get a hold of this argument in CMainFrame::CMainFrame()?
Here's what I've figured so far... Is the following an effecient way of getting a hold of the argument and passing it to CMainFrame??
(Inside CApp::InitInstance()
<br />
...<br />
CMainFrame* pMainFrame = new CMainFrame;<br />
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))<br />
return FALSE;<br />
m_pMainWnd = pMainFrame;<br />
<br />
CCommandLineInfo cmdInfo;<br />
<br />
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew;<br />
<br />
pMainFrame->setCustomPath(cmdInfo::m_strFileName);<br />
<br />
ParseCommandLine(cmdInfo);<br />
<br />
if (!ProcessShellCommand(cmdInfo))<br />
return FALSE;<br />
What do you think?
|
|
|
|
|
I'd say this is fine
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Jerry Wang wrote:
CCommandLineInfo cmdInfo;
// still show initial new document window
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew;
// pass cmdInfo file path to CMainFrame
pMainFrame->setCustomPath(cmdInfo::m_strFileName);
ParseCommandLine(cmdInfo);
Hmmmm... I am under the impression that you need to call ParseCommandLine(...) first in order to populate the fields you are manipulating (like cmdInfo::m_strFileName)? Then you can change the m_nShellCommand value to prevent the app from opening the file...?
Peace!
-=- James.
|
|
|
|
|
I think you are right. I wasn't too sure what ParseCommandLine did. Thank you both!
|
|
|
|
|
Hi!
I have to calculate the number of characters an HTREEITEM of tree ctrl can hold. I am not sure what functions can help me with this. I would appreciate any suggestions on this.
Thanks,
NC
|
|
|
|
|
NC wrote:
the number of characters an HTREEITEM of tree ctrl can hold
A HTREEITEM is a handle to a tree item. Like all Windows handles, it is a 32 bit unsigned quantity. Perhaps you meant to ask something else?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|