|
I use this:
CFileException exc;
if(!newFile.Open(strFileName, CFile::modeCreate | CFile::modeReadWrite | CFile::typeText, &exc) ) {
exc.ReportError();
return;
}
Next, I fill the file... And then I try to overwrite the same file.
Hello World!!!
from Raphaël
|
|
|
|
|
Sorry, I've missed that Read/Write in Your source code.
But the problem is quite strange. I doubt I'll be able to help, but please take a look at my question above (about CMenu), maybe You could help me with this.
[ CoY0te ]
|
|
|
|
|
Shouldn't you add modeNoTruncate to the flags?
If you use modeCreate only, then the file will be truncated to zero length.
Cheers,
Fredrik
<right>Sonork ID: 100.11430:PhatBoy
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
I don't have to add this flag because I fill the file with caracters first (after his creation), and then I overwrite it.
Thus, initially empty or not it's not a problem.
Hello World!!!
from Raphaël
|
|
|
|
|
Then what is your problem? You are a bit unclear.
Do you get exceptions, if so, what do they say?
Cheers,
Fredrik
<right>Sonork ID: 100.11430:PhatBoy
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
I don't have any Error or Warning and no more exceptions...
My goal is simply a partial rewriting of a text file. Thus some line change but keep the same number of caracters...
My question is: How to do that?
Hello World!!!
from Raphaël
|
|
|
|
|
You had code for that, right?
So I ask again: what part is not working?
Cheers,
Fredrik
<right>Sonork ID: 100.11430:PhatBoy
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
An idea: can't you just append the CRC to the end of the file? (::SeekToEnd() and then ::Write())
Cheers,
Fredrik
<right>Sonork ID: 100.11430:PhatBoy
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
No I must respect the RBT file format (it's a text file) because this file is used by another program (who program the Flash component of an electronic board)...
yeap...
Hello World!!!
from Raphaël
|
|
|
|
|
The code:
CStdioFile newFile;
CFileException exc;
if(!newFile.Open(strFileName, CFile::modeCreate | CFile::modeReadWrite | CFile::typeText, &exc) ) {
exc.ReportError();
return;
}
newFile.SeekToBegin();
for(i = 0; i < 9; i++) {
if(!newFile.ReadString(str, MAX_BUFFER_SIZE)) {
MessageBox("End of file prematurely detected");
return;
}
}
newFile.WriteString(strCRC + "\n");
newFile.Close();
Compilation is OK...
Finaly the 9th line (of the file) is not rewrited. Why?
Hello World!!!
from Raphaël
|
|
|
|
|
I change my method... I'll create a buffer then I'll copy this buffer inside the file...
Thanks neverthless
Hello World!!!
from Raphaël
|
|
|
|
|
The code above positions to the start of the 10th line. It reads the first 9. If you really want to position to the 9th line, try for (i=0;i<8 ...
|
|
|
|
|
Yes but my first line is the 0th line... Thus that's OK because the 9th line is the 10th in the reality (As you say)...
But, concerning the overwriting of a file, my conclusion is that "that doesn't work" because you must be at the end of the file, and thus you can only Add line to a file (in the end). The reason is that the Write and Read methods are both sequential. What's strange is that no error was detected (for the compilation and execution). Moreover is that in the watch window, during the debug, the pointeur to the file shows well that he wrote(overwrote). But after the execution, when I open the file, no modification was found.... Strange... but it's the live...
Thanks...
Hello World!!!
from Raphaël
|
|
|
|
|
Hi,
I meet one problem, That is, i have a bmp image displayed under
a ruler. Now the ruler can be resized with the changes of the x-axis and/or y-axis. I would like to see the bmp image also changed in length or height when the ruler is changed.
But
how to change the length of the bmp image displayed on a button
arbitrary? Is there any method for doing this?
Thanks in advance!
chen
|
|
|
|
|
how do u display ur bitmap? use BitBlt?
if use StretchBlt, u can do u want.
includeh10
|
|
|
|
|
Thanks for your reply.
But there is no StretchBlt() function in my used CDib class, where
can i find a proper one of this function?
Thanks in advance!
chen
|
|
|
|
|
Hi,
I have a dialog based application, in which when the user clicks a particular button, a time consuming process gets executed. Till the process completes, the user should not be allowed to operate any other button on the dialog.
Step 1
So, in the handle for the button click I add code like:
OnButton()
{
CWaitCursor myCursor;
//Long processing
}
But now, if the application is minimized, it cannot be seen again, ie the dialog becomes completely unresponsive.
Step2
So I created a thread to do the long processing. But the problem is I have to wait for the thread to finish before exiting the button handle...
Step 3
Then to be able to process message, after the AfxBeginThread, I added a message loop. Now the final code looks like:
OnButton()
{
AfxBegindThread()
while( WaitForSingleObjecT(handle, 2) = timeout || getmessage())
{
dispatchmessage()
}
}
But still this does not seem to work. Can any one help me with this?
Thanks !
|
|
|
|
|
Anyone figure out how to get the movie rect for an ActiveMovie4 window?
|
|
|
|
|
In my initialupdate in the view I have this:
m_editright.SetSel(-1,1);
THe first thing that happens is that I see the gui, with the selection unmarked as I want. Then a Open File dialog box pops up
Just before SetSEl is a postmessage that brings up a dlg box (Open CFileDialog)). If I cancel this,the box goes away but the selection gets marked again. Why does this happen? How do I get around it? the setsel happens last in my oninitialupdate, right after PostMessage.
Thanks,
ns
|
|
|
|
|
Its a side effect of the control having SetFocus() after the open dialog is dismissed called on it.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Is this okay? I dont need to tab to this box so I unchecked tabstop in the designtime properties, and the focus never gets there now. It was the last ctrl on the form so I wonder where the focus is since I forced it not be be on my last ctrl. Is it possible for no control to have focus? SOmething must have the focus!
thanks,
ns
|
|
|
|
|
When you layout a dialog box in the resource editor, you should really set the tab order for the controls. You can do this by hitting Ctrl+D. You then click on the controls of the form in the order you would want the focus to move.
Your CEdit control was probably getting the focus because is was probably the first control you added to the form.
You should always set the tab order for controls on a dialog so that the sequence makes scence to the user.
Use Ctrl+T to test the dialog.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
As I saw in a previous message I need to work with a CD-RW.
I can retrieve the list of all system drives then I can determinate which of them are a CD-ROM unit (both CD reader and CD reader/writer).
How can i determinate which of the is the CD-RW unit ??
Thanks a lot !!
Cristiano Galeazzi
|
|
|
|
|
I'm trying to connect to IE events, and made quick & dirty demo ( it's here ). TROUBLE: when I'm getting document object of the IE frame, in which loaded document from another domain (not the same as top-level frame), an error occurs. And I can't to handle it correctly!! In debug mode message box with kernel exception popups...
Demo Usage:
1) Run IE
2) Type address of page with frames from different domains ( www.search.msn.com for ex. )
3) Press "Connect to OnMouseMove Button".
When connected, if you will track mouse hover the doc, you woll listen short beeps.
Help me to correctly handle an error in debug mode, when trying to access documents at search.msn.com and similar sites!!!
Thanks!
|
|
|
|
|
Hello
I am looking for a PDF generation control that is not dependent on Adobe distiller or Adobe PDFWriter. The control should be standalone and should be able to create PDF files with text, images etc.
It should be able to handle multiple threads at the same time, where two or more clients might use the control to generate a PDF at the same time.
Commercial or Shareware - no problem! Even cost is not an issue.
I did some searching, but I want the best! And if someone who has used a similar control in the past can give any suggestions, I'd be extremely grateful!
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|