|
Hi, I have an MFC MDI app. If one user, running one instance of the app opens a file using OnOpenDocument then another user, running another instance of the same app opens the same file, MFC reports "Failure to open document". The app does not edit the file, it's just a viewer, so I don't care if many people are opening the document. How can I tell this to MFC?
thanks,
Kristian.
|
|
|
|
|
I've made an empty MFC app using wizard, added some serialization, and can't reproduce the behavior you're describing - two instances can open the same file. Did you override OnOpenDocument? If this is the case, please post the code.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
BOOL CSaturn2Doc::OnOpenDocument(LPCTSTR lpszPathName)
{
// the following line fails. The serialize function is empty.
if (!COleServerDoc::OnOpenDocument(lpszPathName))
return FALSE;
blah blah blah...
}
My document is derived from COleServerDoc.
|
|
|
|
|
Oooooh - you're using OLE. My experience is limited in this area, all I can advise is stepping inside COleServerDoc::OnOpenDocument and checking which call fails - probably it'll be call to something like StgOpenStorage.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
That's right, in COleDocument::OnOpenDocument() the call to StgIsStorageFile() fails. I guess I could work around this by copying every document I intend to open to a temporary file but that sucks.
|
|
|
|
|
|
I see where you are going with this. I found a call to EnableCompoundFile() in my document class, which I changed to EnableCompoundFile(FALSE). Now everything is groovy. Thanks.
|
|
|
|
|
I need iphlpapi.h when doing tasks with
Ip Helper.
I have to install SDK in order to get this iphlpapi.h.
Everybody tell me that i had to install SDK from microsoft.com but i cant do this...
THE QUESTION IS:
WHERE CAN I FIND SDK BUT MICROSOFT.COM.
DOES VISUAL STUDIO HAVE INTEGRATED THE SDK?
PLEASE, I NEED YOUR HELP...
|
|
|
|
|
I'm sorry to say that there is no other place to get the SDK. Visual Studio comes with the SDK as it stood at the time of release, the point of ongoing releases is that they are able to update the headers and add new stuff like GDI+. Downloading the SDK is a major pain, even with a decent connection, and I'm afraid ordering the CD can be a bit slow. Even if I emailed you this header, it is unlikely to help you, it almost certainly requires other headers and .lib files. I'm afraid you have no choice but to source a copy of the SDK.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Please, Christian can you e-mail me that iphlpapi.h, iptypes.h,ipexport.h and iphlapi.lib?
I've been tring to solve this problem for 3 days. I feel that ai get mad.
I HAVE WIN98 SE ON MY COMPUTER. SHOULD BE A PROBLEM?
You are a real help for everybody, Christian. Thank you very much.
My e-mail address is: dvisan@forte.ro
|
|
|
|
|
|
Thank you for your reply... but I asked something else.
|
|
|
|
|
I can see from a later post that you have gotten your header files, so this is just out of curiosity: Why can't you download the SDK from the MS site?
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
My transfer rate is about 1 kb/s.
I suppose there are a lot of mega to download. Am i wrong?
|
|
|
|
|
Ah, I see. There's 355 megs so you'd be screwed. Why is the transfer rate so slow? Maybe you should try Download Accelerator to see if it can speed things up. On my modem (56K) it doesn't really help because the modem is setting the limit (app. 6 Kb/s), but maybe your problem is different.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hi,
How can I save a CString to a text file?
I've tried CFile::Write to write the CString for CString.GetLength(),
and although this saves the file, there are usually around 3 garbage characters at the end of the file.
Any ideas?
Many thanks.
|
|
|
|
|
The following works perfectly for me, with no extra characters.
file.Write(string.GetBuffer(string.GetLength()), string.GetLength);
string.ReleaseBuffer();
Were you calling GetBuffer, or just passing in the CString ?\
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Christian, this will work too and it's actually a little quicker:
file.Write((LPVOID)(LPCTSTR)string, string.GetLength());
Regards,
Alvaro
|
|
|
|
|
Thanks, but I'm afraid that made no difference. I'm using this code:
void CTestDlg::WriteFile(CString strFile, CString strText)
{
CStdioFile file;
if (!file.Open(strFile, CFile::modeCreate | CFile::modeWrite | CFile::typeText))
{
return;
}
file.Write(strText.GetBuffer(strText.GetLength()), strText.GetLength());
strText.ReleaseBuffer();
file.Close();
}
>
<ë é
Happens with any string, on three different computers, Win98 and Win2k, although the last 7 (\n and \r) characters (the garbage) are always random.
Thanks.
|
|
|
|
|
Try getting rid of CStdioFile and replacing with CFile. The, when you're writing to the CString make sure you use \r\n where you'd normally use \n . Also, use Alvaro's with GetBuffer - it's easier and the copied buffer is un-needed.
--
Andrew.
|
|
|
|
|
If u use Struct for storing the file ,u will see the garbage actually it store the data in binary format and if i user open the file in text mode and it looks like garbage when u read from the file the garbage shows u the actual data.
World of Life
|
|
|
|
|
Is there anyone who could tell me how to save a custom binary resource item as a binary file to disk? I want to include some data in my final exe which should be written to disk when the program first runs (sort of sfx). TIA.
|
|
|
|
|
If you have a pointer to the item, CFile allows you to write a chunk of data by specifying the start address and length - see my exmaple to the question above this one, it works just as well for any pointer you want to pass it.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
i downloaded an old cpp program and it uses something like textcolor fn.
but my cpp help doesnt know it at all.
what do i have to include ? or where do i find it?
|
|
|
|
|
Is it a console program ? I believe some other compilers had stuff for this sort of thing, from memory someone else asked about it. It's certainly not a standard function under Visual C++. If you can explain exactly what it needs to do ( i.e. is it in a window or a console, is it just setting the colour for a block of text, etc. ), I'm sure we can help more.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|