Click here to Skip to main content
15,902,445 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Conditionals and RC files Pin
David Crow20-Apr-06 3:59
David Crow20-Apr-06 3:59 
AnswerRe: Conditionals and RC files Pin
rentzk20-Apr-06 5:48
rentzk20-Apr-06 5:48 
QuestionMFC, DLL's Pin
Bram van Kampen19-Apr-06 14:37
Bram van Kampen19-Apr-06 14:37 
AnswerRe: Forwarding API's Pin
Bram van Kampen19-Apr-06 16:02
Bram van Kampen19-Apr-06 16:02 
QuestionCFile::Read Pin
Sam 200619-Apr-06 14:16
Sam 200619-Apr-06 14:16 
AnswerRe: CFile::Read Pin
valikac19-Apr-06 14:51
valikac19-Apr-06 14:51 
GeneralRe: CFile::Read Pin
Sam 200619-Apr-06 17:29
Sam 200619-Apr-06 17:29 
AnswerRe: CFile::Read Pin
Bram van Kampen19-Apr-06 15:56
Bram van Kampen19-Apr-06 15:56 
If you look up the Help Files, you will finf:
CFile::Read
virtual UINT Read( void* lpBuf, UINT nCount );
throw( CFileException );

This will read nCount bytes of raw data from the file object, into your (previously created buffer. I suspect from your question that you already tried this, and somewhere failed to read it back. Easy trap to fall into, takes a bit of history. In the Oldendays, when computers took punchcards, (I punched many a card myself on those rotten noisy machines) a protocol had been established for each computer system, largely and loosely based on the telegraph system. In order to get the machine at the other end of the line to advance to a new line, you had to send two control characters, a Line Feed (LF Char, ASCII 0x0A), to move the Paper forward, and a Carriage Return Char(CR char, ASCII 0x0D)
These could be sent in any order, provided both where sent. You can imagine yourself what would happen if either or both where ommitted, the result I can assure you , was generally not legible.
In came the VDU Display, a forerunner of the screen you are looking at reading this, and everybody took a step back! What should we send at the End of a Line,( the Windows concept that a document could extend beyond the boundaries of a screen was only in it's infancy). The Discussion was: either a Line Feed, or a CR, Or, ignore the new technology, and treath it as a printer, and send it both, or send it another magical incantation, with aq deeper meaning as to how the result was to be displayed on the screen. All this upset took place at the time when Bill Gates was getting together with a couple of friends, to start off a new business venture.Between then and now, learned committees where formed to formulate software standards, and found invariably, that to land on one side of the debate, or on the other, would invalidate either way years of established practice, so, the issue was shied away from. Also, as software developed, it became less important, compiler writers, and library writers adopted a standard, and, as long as one was aware of the problem, it was quite easy to write a small routine to convert from one to the other.

The Weazel code started I think in the ANSI C Library, you open a file as: FILE F =fopen("MyFile.Ext","r+"), and when reading the file thus opened, all twobyte CR-NL chars are converted to a single LF.Conversely, if yoy write a buffer containing a LF, it witt be written to file as a LF-CR combination. This happens automatically, (and as some people would say, underhand). Ofcourse, this sort of modifying things read from, or written to file, would not do if you are reading or writing binary data. To allow for this, the ANSI Standard allows for an alternative way of openeng a file, which will read and write a file exactly as is, without underhand modifications. To get this, you use:
FILE F =fopen("MyFile.Ext","rb+")Note the 'b' for Binary!!

Now, all this is relatively easy to follow, if you have a genuine text file, open it with one of the "r" attributes, if it is Binary, use the "rb" attribute. Strings in memory are always stored with a single CR character to denote a new line.

Bring in MS Wiondows, and its associated text controls, and the confusion is of a babylonian nature again, Some controls expect a single LF char, others expect a single CR, and there are others again who expect both, or attach special meaning to the absence or presence of one or the other. I had to write a number of simple routines to copy a string from one buffer to another, just to suit the case, and in the knowledge that the code would probably need modification to support the next version of MFC. I must admit that Microsoft seems to have been consistent sofar, and very little needed changing. However, it remains a nuisance, and something that can quite easily throw those unaware of this conundrum of the path.

regards

LateNightsInNewry
AnswerRe: CFile::Read Pin
kiran janaswamy19-Apr-06 19:38
kiran janaswamy19-Apr-06 19:38 
GeneralRe: CFile::Read Pin
David Crow20-Apr-06 4:02
David Crow20-Apr-06 4:02 
QuestionCrypto Api - create key with standard RSA rather than strong RSA (for W2K compatibility) Pin
EthannCastell19-Apr-06 13:52
EthannCastell19-Apr-06 13:52 
AnswerRe: Crypto Api - create key with standard RSA rather than strong RSA (for W2K compatibility) Pin
YaronNir20-Apr-06 0:40
YaronNir20-Apr-06 0:40 
QuestionHow I can enforce key length and CSP? Pin
EthannCastell20-Apr-06 2:33
EthannCastell20-Apr-06 2:33 
QuestionProperty Sheet Problem Pin
si_6919-Apr-06 13:11
si_6919-Apr-06 13:11 
AnswerRe: Property Sheet Problem Pin
valikac19-Apr-06 14:57
valikac19-Apr-06 14:57 
GeneralRe: Property Sheet Problem Pin
si_6919-Apr-06 22:32
si_6919-Apr-06 22:32 
GeneralRe: Property Sheet Problem Pin
David Crow20-Apr-06 4:04
David Crow20-Apr-06 4:04 
AnswerRe: Property Sheet Problem Pin
prasad_som19-Apr-06 18:25
prasad_som19-Apr-06 18:25 
GeneralRe: Property Sheet Problem Pin
kiran janaswamy19-Apr-06 19:12
kiran janaswamy19-Apr-06 19:12 
GeneralRe: Property Sheet Problem Pin
si_6919-Apr-06 22:33
si_6919-Apr-06 22:33 
QuestionSetting mask for bitmap for CButton Pin
Andre xxxxxxx19-Apr-06 12:50
Andre xxxxxxx19-Apr-06 12:50 
AnswerRe: Setting mask for bitmap for CButton Pin
Shog919-Apr-06 14:10
sitebuilderShog919-Apr-06 14:10 
QuestionHelp me With My code Pin
ALQallaf19-Apr-06 12:37
ALQallaf19-Apr-06 12:37 
QuestionRe: Help me With My code Pin
David Crow20-Apr-06 4:21
David Crow20-Apr-06 4:21 
GeneralRe: Help me With My code Pin
ALQallaf20-Apr-06 7:20
ALQallaf20-Apr-06 7:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.