|
Why would using a class that comes with MFC cause problems in MFC ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
Why would using a class that comes with MFC cause problems in MFC ?
Multiple inheritance and MFC does not mix particularly well See my answer below for the problem that I found.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Although it shouldn't make a difference, the MSVC++6 compiler was dependent on the order in which the classes appeared in the derivation list for multiple inheritance. Consequently, it often caused very wierd runtime errors if the MFC class was not the first class in the derivation list. As a general rule, make the MFC class the first class in the derivation list (swap the two around in your example above) and it should work fine.
I don't know whether the same problem appears in the .NET 2003 compiler, but I would still put the MFC class first.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
wouldn't the following be better ?
class CPoteauBeton : public CObject {};
class CVerifiPoteau : public CPoteauBeton {};
Serge
|
|
|
|
|
I have to change color of some characters in RichEdit control.
It’s not difficult do with SetSel function and SetSelectionCharFormat.
But I have to change many characters in different colors, and it takes too much time.
How can I do it faster ? Perhaps without using by selection functions.
|
|
|
|
|
scanf wrote:
How can I do it faster ?
You could try using the StreamOut method to get a copy of the raw RTF, modify the RTF (it's just text - not too difficult to process), and then use StreamIn to put the new RTF into the control.
Parsing RTF is a bit tricky, but it will be quicker than using the formatting functions (which have to modify the RTF as well as updating the display)
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Yeah that’s a good direction.
static DWORD CALLBACK <br />
MyStreamOutCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
And really not difficult.
Thank you for help.
|
|
|
|
|
I want to create a shortcut within my Visual C++ program and put it in the All Users Startup directory. Anyone know how? Thanks, GAF
|
|
|
|
|
|
hello friends
plz help me in this problem. i m making an intrusion detection system using vc++, in this output of sniffer has to be written in text file. is there is any function for that.
thanx
bye
|
|
|
|
|
(all platforms) C/C++ functions: fopen, fclose, fwrite, fread, fprintf, fputs, fputc.
(Windows specific) C/C++ functions: CreateFile, CloseHandle, WriteFile, ReadFile.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
thanx for ur reply
but can u send a small module in which it takes an output of exe file and write it in text file
bye
|
|
|
|
|
The functions I listed assumed that the exe file was one that you wrote your self. If not you could probably write a program that uses shell programming to capture the output and copy it to a text file, but that would be the (VERY) hard way. If the exe writes the output to stdio/screen/console (standard I/0), then I would look into using redirection. That is you could add redirection command to the short cut.
I have not used redirection for several years, but this is basicaly how it worked in DOS:
SomeProgram.exe > output.txt
What that does is sends the output to the text file, instead of the screen.
Anyway, maybe you should do a search for redirection on the command line.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Are you using MS-DOS based? or MFC EditBoxes?
MFC EditBox...
<br />
#include "fstream.h"<br />
<br />
CString strE1Input;
CString strFilename;
GetDlgItemText(IDC_EDIT1,strE1Input);
strFilename = "Info.txt";
ofstream a_file ( strFilename );
a_file<< strE1Input;
a_file.close();
**Hope that helps... If ur using MS-DOS (Windows App) let me know**
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
MS-DOS based...
<br />
#include "fstream.h"<br />
#include "iostream.h"<br />
<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
char first[50];<br />
char answer[2];<br />
<br />
cout << "Enter First Name:";
cin>>first;
cout << "Your Name is:" << first << "." << endl;
cout << "Is this Correct? (y/n)" << endl;<br />
cin>>answer;<br />
<br />
if (answer == "y") {<br />
ofstream a_file ( "Names.txt" );
a_file<< first;
a_file.close();
cout << "Saved in Names.txt" <<endl;<br />
}<br />
if (answer == "n") {<br />
}<br />
else {<br />
}<br />
}<br />
Forgive me if this doesnt compile... Just a quick type out...
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
Why didn't you list the way to do it in C++ ? ifstream/ofstream rocks, fopen/fclose totally sucks.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
1) I admire your work!
2) In my opinion, ifstream/ofstream sucks!
3) We are way off the subject of the post (personaly I do not care).
Since he appears to redirect the output to a file.
As for item (2), it is too complicated. If some one does not understand the list I gave (looked it up), then they (all though they could use ifstream/ofstream) they would not understand how it works.
File objects are like every thing else in C++ (only more so!), you need to know 10x as much as you do inorder to do the same thing in C; or to put it anouther way, you are offten - shooting in the dark.
C is straight forward, either you do it right or you do not; there is no in-between.
Do not get me wrong, I love C++ (up to a point). But, it hides to much of the details.
I am a believer in the KISS principle and C++ is based on the the KIC (keep it coplicated) principle.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
John R. Shaw wrote:
File objects are like every thing else in C++ (only more so!), you need to know 10x as much as you do inorder to do the same thing in C; or to put it anouther way, you are offten - shooting in the dark.
Man, I just find that comment bizarre. An instance of an object that exposes an interface is harder to understand than a set of functions that pass handles around ? Besides, all the source code is provided, nothing is hidden.
John R. Shaw wrote:
In my opinion, ifstream/ofstream sucks!
ROTFL. Well, you're entitled to your opinion.
John R. Shaw wrote:
I am a believer in the KISS principle and C++ is based on the the KIC (keep it coplicated) principle.
No, object orientation is based exactly on the idea of keeping it simple, something C finds difficult. The standard library could certainly be easier to learn, but if someone is going to use C++, it's well worth their time to learn it. Once you understand how it works, it is indeed simple, it's also powerful, and extensible to boot. It's certainly a lot nicer than ugly C file handling, at least in my not so humble opinion. It's a pet peeve that ignorant professors teach C with classes instead of C++, meaning that far too many people have no idea the standard library even exists.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
If you find the statement that you need to know 10x as much in C++ than you need to know in C, then we need to talk. (When you look at a C-program, you know what is going to happen. When you look at a C++-prgram, you assume what is going to happen.)
Example:
for( object i=0; i != end; i++ )
What is wrong with the above example? In C (except for the term object) nothing.
C++ is great, but it hides so much that it is rediculus. I, like most peaple, ignore the details (a good part of the time), but the details is what distinguashes those who know and those who don't.
Interesting (A PHD wrote this):
#defined GReAlloc(b,nSize) ((!b)? malloc(nSize):If you find the statement that you need to know 10x as much in C++ than you need to know in C, then we need to talk. (When you look at a C-program, you know what is going to happen. When you look at a C++-prgram, you assume what is going to happen.)
Example:<pre>for( object i=0; i != end; i++ )
What is wrong with the above example? In C (except for the term object) nothing.
C++ is great, but it hides so much that it is rediculus. I, like most peaple, ignore the details (a good part of the time), but the details is what distinguashes those who know and those who don't.
Interesting (A PHD wrote this):
#defined GReAlloc(b,nSize) ((!b)? malloc(nSize):realloc(b,nSize))
)If you're a C programer (Whoops! The above was written in C), that makes almost no since.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Some-thing has went-very wrong here! But I'll leave the above post alone (even though; the posting software, appears to have lost its mind.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
hello friends
plz help me in this problem. i m making an intrusion detection system using vc++, in this output of sniffer has to be written in text file. is there is any function for that.
thanx
|
|
|
|
|
Is this sniffer program a console application? If so, its output can be redirected to a file from the command prompt like:
sniffer.exe > output.txt
If you need something a little more advanced, check out this and this.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I tried FMOD function that calculates floating-point remainder of division of two double v1,v2, but with v1 = 17.2 and v2 = 0.1 returns value f = 0.1 instead of f = 0.0.
Someone know why FMOD returns f = 0.1 ?
Thank you.
|
|
|
|
|
The problem is floating-point precision.
The floating-point system is based on exponent 2, that causes problems when encoding exp-10-digits.
Don't try it, just do it!
|
|
|
|
|
I'm adding IPv6 functionality to an application that has been designed to monitor the hosts by sending periodical ICMP packets (pings).
According to MSDN and the checkv4 utility, the addrinfo structure should be used, which works well when calling Icmp6SendEcho2[^] , however the problems arise when calling the IcmpSendEcho2 [^], because the fifth argument, the DestinationAddress is IPAddr struct type.
So the real question is: Are there any fuctions that will convert an addrinfo structure to an IPAddr or is there another way of doing this? (Using a bunch of if/else statements to check for IPv4/6 is not an option)
|
|
|
|