|
I'm not sure how safe it would be. If you can link to the extension DLL and it runs then great.
The behavior, at best, would be undefined for any MFC extended classes that you derive from in
your client app though. Old MFC may allocate stuff the new MFC doesn't free, member variables
could be different, etc. Lots of room for things to go wrong
|
|
|
|
|
plus...
Two different MFC frameworks loaded at the same time, global variables for the two are different,
it goes on and on.
|
|
|
|
|
In MSDN, Write() function of CFile class follow:
virtual void Write( const void* lpBuf, UINT nCount );
throw( CFileException );
Remarks
Writes data from a buffer to the file associated with the CFile object.
Write throws an exception in response to several conditions, including the disk-full condition.
But in fact, when disk full and application try write to disk then an unhandled exception occur.(CFileException didn't catch)
What is cause of this problem?
-----------------
Best Regards,
Le Thanh Cong
|
|
|
|
|
Le Thanh Cong wrote: But in fact, when disk full and application try write to disk then an unhandled exception occur.(CFileException didn't catch)
Looking at the CFile::Write() source code, it only throws CFileException (unless maybe you pass
invalid parameters to the function).
How are you catching the exception? Like this?
try
{
file.Write(...);
}
catch (CFileException *e)
{
e->Delete();
}
|
|
|
|
|
I catched the exception follow:
try
{
file.Write(...);
}
catch (CFileException*)
{
AfxMessageBox("xxx");
}
But message didn't display
-----------------
Best Regards,
Le Thanh Cong
|
|
|
|
|
Then the disk isn't full?
Step into CFile::Write() and see if the ::WriteFile(...) call succeeds.
|
|
|
|
|
Thank you, maybe I found cause of this problem.
In normal conditions, CFileException will be thrown.
But in some special conditions, as multi-thread, communication with devices as USB I/O … then other exception has thrown before that.
-----------------
Best Regards,
Le Thanh Cong
|
|
|
|
|
MFC application will be automatically called InitCommonControls() function, so to enable XP visual style we only need add manifest file to resource. That is right or wrong?
-----------------
Best Regards,
Le Thanh Cong
|
|
|
|
|
Ok, this is my 2nd post about C++/CLI.
The answers for the first took me to the right tools needed to learn C++/CLI.
So, I got everything to start to learn C++/CLI: a book, Visual C++ Express Edition and a lot of energy
But, suddenly, a question comes to me and makes me doubt about all this.
Why write with C++/CLI instead of C# in example, (or any .NET language).??
What else I got with C++/CLI??
I understand why to programm in C++, (using MFC, ATL, STL, WTL....) to get a native exe, but I can't see the differents between C++/CLI and C#, (besides the language it self).
What I could see, (maybe I can be wrong), is that it took a lot of headheaches to Microsoft Team to include C++ into the .NET languages, (that's why, first, we have MC++ and then C++/CLI). In other side two languages like C# and VB NET were born and they expose the NET framework naturally.
So, should I spend my money and time to learn C++/CLI?
Do you understand what I mean? (my english, maybe, is not too good enough).
I really appreciate your help.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
|
In my humble opinion, one of the most important differences is that you may mix native (ISO/ANSI) C++ code with C++/CLI code in the same source file. No other .NET languages can do that.
Best,
Jun
|
|
|
|
|
C++/CLI is great for people who already know how to program in C++. And, if you have a lot of legacy C++ codes lying around, you can easily use them in C++/CLI. As for me, i use C++/CLI to build mixed mode programs, whereby part of the program (the GUI etc) is built using managed C++, and performance critical parts are programmed using pure C++ (compiled as native code). That amount of flexibility is really powerful.
|
|
|
|
|
Don't you think it should compile?
<br />
int val = 44;<br />
int* a = &val;<br />
int* b = &a;
and here comes error (occurs in the third line of the above code):
error C2440: 'initializing' : cannot convert from 'int **__w64 ' to 'int *'
Unless I use "int **__w64" type how can it possibly need a convertion and what is exactly "int **__w64"?
Thanks in advance
watherby 33
|
|
|
|
|
watherby33 wrote: Don't you think it should compile?
No, it should not compile. You are using different levels of indirection.
int val = 44;
int *a = &val;
int **b = &a;
int ***c = &b;
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
|
|
Demian Panello wrote: 1 - Is C++/CLI available in NET framework 1.1?, or is it just called Managed C++?.
You can access the .NET framework using Managed C++
Demian Panello wrote: 2- If it's not, could I install the NET framework 2.0 to be able to use it in my current Visual Studio enviroment??
No you can't use .NET 2.0+ framework in VC++ 2003. You need 2005 for that.
You can learn C++/CLI in 2003, no problem. BUT, the managed extensions used in 2003 were rolled
into the the C++ language proper in 2005 so the syntax of most managed extensions changed.
Here's the document describing the changes:
Managed Extensions for C++ Syntax Upgrade Checklist[^]
If you have 2005 then it's worthwile to install it and start there. Otherwise, all the code
you write in 2003 is eventually going to have to be ported to the new syntax.
Mark
|
|
|
|
|
Ok, thank you Mark.
I'm trying to download the Visual C++ 2005 Express edition from Microsoft, but I can't.
Do you know some alternate address??
(forget it, I found an alternate address)
-- modified at 17:13 Sunday 29th October, 2006
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Demian Panello wrote: Is C++/CLI available in NET framework 1.1?, or is it just called Managed C++?.
Managed C++ uses a different syntax to C++/CLI.
Demian Panello wrote: I don't want to install the new Visual Studio 2005 enviroment but I want to learn C++/CLI.
You can just install the compile and use the command line, if you want.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I have a SDI MFC application in CFormView.
Is there any way I can automatically activate the Edit -Copy/Paste/Undo that is added by default to the main menu without adding any additional coding?
Thanks.
Fortitudine Vincimus!
|
|
|
|
|
Tara14 wrote: without adding any additional coding?
No, the only way to activate those menu items is to add code that handles them
|
|
|
|
|
Hi all,
this is the code i am using to open the address book (using MAPI)
USES_CONVERSION;
LPADRLIST lpadrlist = NULL;
LPTSTR rglpszDestTitles[1];
ULONG rgulDestComps[1];
ULONG ulUIParam = 0;
rglpszDestTitles[0] = (LPWSTR) T2A(_T("To"));
rgulDestComps[0] = MAPI_TO;
ADRPARM adrparm;
adrparm.cbABContEntryID = 0;
adrparm.lpABContEntryID = NULL;
adrparm.ulFlags = (DIALOG_MODAL | AB_SELECTONLY | AB_RESOLVE);
adrparm.lpReserved = NULL;
adrparm.ulHelpContext = 0;
adrparm.lpszHelpFileName = NULL;
adrparm.lpfnABSDI = NULL;
adrparm.lpfnDismiss = NULL;
adrparm.lpvDismissContext = NULL;
adrparm.lpszCaption = (LPWSTR) T2A(_T("Select Outlook contacts"));
adrparm.lpszNewEntryTitle = (LPWSTR) T2A(_T("For this dialog"));
adrparm.lpszDestWellsTitle = (LPWSTR) T2A(_T("Selected Recipients:"));
adrparm.cDestFields = 1;
adrparm.nDestFieldFocus = 0;
adrparm.lppszDestTitles = rglpszDestTitles;
adrparm.lpulDestComps = rgulDestComps;
adrparm.lpContRestriction = NULL;
adrparm.lpHierRestriction = NULL;
HRESULT hr = (pAdrBook->Address( &ulUIParam, &adrparm, &lpadrlist));
the address book opens ok, but sometimes, it failed and the hresult is 0x8007000E....
haven't seen any documentation on this error, or what it means....
can any1 help?
thanks
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
YaronNir wrote: it failed and the hresult is 0x8007000E
If you use the "Error Lookup" tool that comes with VS (Usually listed under the 'Tools' menu) you can find out what the error code means. For 0x8007000E it returns "Not enough storage is available to complete this operation."
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Hello all. I have posted what i have done so far
But that is not what i want it to do. i am a newbie to C++ so it would be great if you help me
What i want to do is to add records to the end of file. that is the records in the file must be like :
David,kurek,Omalley park,566645
Sandra,pegan,John st,5666898
:
:
and so on. the problem is that in this program it does not add the new record to the next line. when i enter the new record it places on the previouse record in the file so u always have one Record being saved on the file
and the next problem is that i want it to receive spaces as well but i cant go it with Get and cin :?
and i hope i can write the rest by knowing what to use from this part :-> cant promise myself
Please dont write something too complex that i dont underestand cause in that case it would be same as not knowing my answer ... i am still in the beginning of course
Thanx and i am waiting
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
#include <io.h>
#include<iomanip.h>
#include<cstdlib.h>
char menu_select();
class stInfo{
public:
char name[80];
char family[80];
char address[80];
char stID[40];
};
// Functions
class functions{
public:
// list of functions
void add_rec();
};
void functions::add_rec(){
stInfo student;
//char *p = student.name;
char ch;
ifstream out_stream("f:rec.dat",ios::out| ios::binary);
out_stream.seekg (0, ios::end);
if(!out_stream) cout<<"cannot open file";
do{
out_stream.get(ch);
if (ch=='$')
{
cout<< "name: ";
cin>>student.name;
cout<<"\n";
cout<< "Family name: ";
cin>>student.family;
cout<<"\n";
cout<< "Address: ";
cin>>student.address,80;
cout<<"\n";
cout<< "student ID: ";
cin>>student.stID;
cout<<"\n";
//out_stream.seekg(eof);
ofstream out_stream("f:rec.dat");
out_stream<
|
|
|
|
|
Some problems I see are:
You're reading from and writing to rec.dat at the same time.
You have more than one variable called out_stream
Each time you write to the file inside the loop, it's replacing the contents of the file with the one record.
|
|
|
|