|
A helluva idea... I'll try that one, 10x
|
|
|
|
|
I am facing problem during remote debugging. If i start the process from host machine ( the one having Visual Studio) by pressing F5, i can debug the process successfully. But if some other application is going to start my process on remote machine and i want to debug the same process then how do i do it? Can somehow debugger window started on host machine when the process is running on remote machine and some error occurs on remote machine? Plz reply as soon as possible.
|
|
|
|
|
How to calculate the memory size of HBITMAP after loading it.As the size of Bitmap depends upon the system settings(Pexels, color etc.)
-- modified at 4:37 Tuesday 16th May, 2006
|
|
|
|
|
Can you be more specific
WhiteSky
|
|
|
|
|
Hi,
Use GetObject API
The GetObject function retrieves information for the specified graphics object.
int GetObject(
HGDIOBJ hgdiobj, // handle to graphics object
int cbBuffer, // size of buffer for object information
LPVOID lpvObject // buffer for object information
);
|
|
|
|
|
try this one.
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP1);
BITMAP bm;
bitmap.GetBitmap( &bm );
bmWidth = bm.bmWidth;
bmHeight = bm.bmHeight;
this will work.
-Sarath
|
|
|
|
|
Use:
HBITMAP hBitmap = LoadBitmap(...);
BITMAP bmp;
GetObject(hBitmap, sizeof(bmp), &bmp);
int nWidth = bmp.bmWidth;
int nHeight = bmp.bmHeight;
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hi guys,
I have been teaching myself c++/mfc, and I was wondering if there is a way to read and write to a file at the same time?
Like read the file first and if it encounters this text, replace that text with a new text (so write to the file)?
I observed that we can only read to a file first, close it, then write to it, or vice versa. But is there a way to do both? I did not want to use fseek() since my number of bytes per line are not fixed.
I'd appreciate all the help I can get. And if I got a concept wrong, please do correct me.
Thanks a lot!
The Buggy
|
|
|
|
|
waxie wrote: we can only read to a file first, close it, then write to it,
Who said this ?
we can both, read and write to a file at the same ..For this u must open the file in read-write mode..
nave
|
|
|
|
|
Really? can you give me a snippet of the working code please?
Thanks!
TheBuggy
|
|
|
|
|
if ur using CFile in MFC open the file as follows..
CFile File;
File.Open( _T("C:\\out.txt"),CFile::modeReadWrite );
Now u can use both Read and Write function CFile..
nave
|
|
|
|
|
I wonder... why doesn't this code work?
CString csCurrLine;
while(oFile.ReadString(csCurrLine))
{
if(csCurrLine==_T("String"))
{
oFile.WriteString(_T("Overwrite String"));
break;
}
}
oItemListFile.Close();
TheBuggy
|
|
|
|
|
First:
Beacuse the file pointer is placed on the character after "String" in the file, so that's where you will be writing "Overwrite String"
You will have to position the file pointer to the beginning of "String" before writing to the file.
Second:
Since "Overwrite String" is longer than "String", if the file pointer was placed at the beginning of "String", the "String " would be overwritten, *but* also the 10 characters after "String" in the file.
Pls read my post.
|
|
|
|
|
Yeah, OK, say the pointer is really not in the right position.
But why doesn't my 'overwriting' string appear in any parts of the text file? Am I correct to assume that it should appear? Say, on the next line?
Thanks so much for all your replies.
|
|
|
|
|
If you did open the file for reading and writing (see Naveen's post), then it should be writtened to the file, immediately after "String".
-- modified at 4:51 Tuesday 16th May, 2006
That is, provided the expression
if(csCurrLine==_T("String")) evaluates to a value != 0
|
|
|
|
|
Honestly, it really does not work. My new string does not appear anywhere in the file - or as expected, after the old string.
|
|
|
|
|
OK, I beleive you!
I can think of two things:
First:
Does the expression
if(csCurrLine==_T("String")) evaluate to a value != 0
That is, does your program find "String" in your present file?
Second:
Do you check the return code of the write-statement?
|
|
|
|
|
Yes, the program finds the evaluated string. I'm sure with that.
And yes, it can write coz i tried writing to a file without reading and it does write. WriteString doesn't have a return value - it returns void.
|
|
|
|
|
OK, it doesn't have a return value, but it does throw an exception for error conditions? Does it?
There simply must be a reason why the file won't change after Write.
|
|
|
|
|
Can u give more details.. What happened?
did the execution comes to
oFile.WriteString(_T("Overwrite String")); ..
more over.. When u read usinf ReadString, the filepointer advance to the next line..So before writting u musk seek back to the staring of the line that u have to replace..
nave
|
|
|
|
|
Why does WriteString() fail?
TRY
{
oFile.WriteString(_T("Overwrite String"));
}
CATCH(CFileException, pEx)
{
AfxMessageBox(_T("Exception encountered."));
}
END_CATCH
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Hello.
You can see a file as a number of bytes. There are no intervening spaces or "records" in it.
You can open a file for both reading and writing, but then you (usually) has to fseek between read and writes.
You can overwrite parts of a file, but you can't insert (or delete) new bytes in the beginning or middle of an existing file. (Acually, you can, but that means you have to write the "move" code yourself, and it won't be very effective).
The only way you can change an existing file is at the end. You can append to the file or remove (by setting the file length to a shorter value than before.
The easiest way to change the contents of a file (other than overwriting a fix number of bytes) is to create a temp file, and then rename the temp file to the name of the original file.
|
|
|
|
|
Hi this is ramu
I got a problem in transwering the image buffer. Actually the problem is at receiving side. The receive statement not receiving the whole data sent.
Some body advised to send the length as a heder first and get it at the client side and make a loop untill the whole length is received.
But i dont know how to make the length as heade in serverside to send and
how to put the receive statement in loop.
So please some body help me out in this problem.
Thank you.
Ramu
|
|
|
|
|
There are several ways. An easy way could be by sending i.e. an unsigned long (if has the capacity needed) as the first data.
Kind of like this:
Sending side
<br />
unsigned long datalength = imageLength;<br />
Send(&datalength, sizeof(unsigned long));<br />
while(moreDataToSend) {<br />
send(data);<br />
}<br />
At the receiving side (assuming that the Read function returns the number of bytes read from the socket):
<br />
unsigned long receivedDataLength;<br />
Read(&receivedDataLength, sizeof(unsigned long));<br />
<br />
unsigned long receivedBytes = 0L;<br />
<br />
while(receivedBytes < receivedDataLength) {<br />
receivedBytes += (unsigned long) Read(buffer, sizeof(buffer);<br />
}<br />
If an unsigned long isn't enough, the use some other variable type. Just make sure it's the same on both sides.
|
|
|
|
|
Hi,
Can we tell me as to create ActiveX control from MutiDocument/View project????
Because I have project which is create on MultiDocument/View architecture and I need reconstruct on ActiveX...
Thanks
|
|
|
|