|
Fine, Thanks! I had not too much time to wander on CP in the last days! (heavy work load this last days ) The week-end was fine however. And you ? How is your new job ? Are your new colleagues nice ?
By the way, I see at the TV there is a lot of troubles in India because of floods due the rain season. I hope everything is OK for you and your family.
|
|
|
|
|
I want resize a bitmap and save it again
how can do it?
|
|
|
|
|
If u mean at run time you have to use OnSize();
/\|-||\/|/\|)
|
|
|
|
|
Try to load the BMP into a CBitmap/CImage object, attach it to a CDC
and then you can use CDC.StrechBlt, now come back to the CImage and save it!
Let me know. Bye bye
|
|
|
|
|
Hello,
I'm experiancing some trouble with an MMF. I've created a class that manages one MMF and one view of that file. I've also created another class that manages some cache using the MMF class.
The MMF class has no problems of its own that I'm aware of, but the caching class has a problem when a new view has to be created. After I cross the view boundraries (and map a new view), one pointer in the heap becomes invalid. The data it holds is still the same, but operator delete[] asserts with an invalid heap pointer exception.
I must also note that the base address of the view is almost the same as the variable. The base address = 0x01b40000. The address of the variable is: 0x01c0e988 and the size is 72 bytes. To me it seems that the variable is not in the view, but I don't know why my pointer is corrupted.
After the initial write I perform some validation checks: IsBadReadPointer() to be precise and it succeeds.
Did anybody experiance something like this before? Anybody has any idea what might be the problem?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Well, I solved the problem. The problem was not in unmapping the view, not in mapping the view, it was in the function which calculated the offset of the data in the view. The offset was reset when a new MMF was created, but not when a new view of a MMF was created. This lead to writing outside the view, which in turn corrupted the heap.
I guess that a complete heap check is done after each allocation and deallocation.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Respected all
Regards!
how i can read data from a data file which has extenstion is *.Dat which is in the follwing format
---------------------------
filename.dat
data file
genertaed from the processing of the control system
XLOC YLOC INDIX
45 56 2344
56 67 1245
50 90 4562
45 87 9337
-----------------------------
and in the given data file i have to read only the data of columns under XLOC,YLOC,INDIX and the file always is in this format.
So please guide me.
waiting for + response.
david
|
|
|
|
|
Use an ifstream. Once you get past the first lines, declaring an int and using >> will work fine, so long as you have some error handling code if the file is corrupted.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
There are many ways to approach this. One, although not the most efficient, looks something like:
FILE *pFile;
int XLOC, YLOC, INDIX;
char szLine[128];
pFile = fopen("filename.dat", "rt");
fgets(szLine, sizeof(szLine), pFile);
fgets(szLine, sizeof(szLine), pFile);
fgets(szLine, sizeof(szLine), pFile);
fgets(szLine, sizeof(szLine), pFile);
fgets(szLine, sizeof(szLine), pFile);
fgets(szLine, sizeof(szLine), pFile);
while (! feof(pFile))
fscanf(pFile, "%d %d %d", &XLOC, &YLOC, &INDIX);
fclose(pFile); A similar MFC solution exists.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hello David
If you think that you've got only half the answer you need... you are not the only one! Often I get very well intentioned replies but full with the assumption that we are all engineers... Anyway, here's what I use to read realtively small files. If reading the file takes more than a few minutes, the decision to use this method or any other depends on how many times during the execution of the program you have to read the file. If you only read it once, go check the scores of the latest soccer games while the computer works. If you need to read the file many times, then it is better to transform your data file into a binary file (if you need it I can also send you code for that). You'll have to wait once while the file is converted but once your data is in binary, reading it from your program is lightning fast. OK, here's the code to read a text file regardless of the file extension. Note that I made the code general so that the first header lines can be one or more. You can choose to change the cin inputs if you know in advance what the will always be (i.e. one header line). Also, please note that the data being read by this program is comma separated. If you don't have commas, use the next commented line. If your data files have a variable amount of lines (e.g. you don't always have the same amount of rows) use a vector container to store your data. Don't hesitate to ask if you have more questions.
#include <fstream>
#include <iostream>
using namespace std;
int main()<br />
{<br />
char stuff[100];<br />
int period, stufflines;<br />
double dat1, dat2, dat3, dat4, integ, fraction;<br />
char separator;<br />
int counter;<br />
<br />
cout << " " << endl;<br />
cout << "how many lines with stuff at the beginning?" << endl;<br />
cin >> stufflines;<br />
cout << " " << endl;<br />
<br />
ifstream FileIn("C:\\SampleData\\divedata.dat");<br />
if(!FileIn.is_open())<br />
cout << "Could not open the file! Check directory..." << endl;<br />
else<br />
cout << "You're good, input file opened!" << endl;<br />
<br />
counter = 1;<br />
while(!FileIn.eof())<br />
{<br />
if(counter <= stufflines)<br />
FileIn.getline (stuff, 100);<br />
else<br />
{<br />
FileIn >> dat1 >> separator >> dat2 >> separator >> dat3 >><br />
separator >> dat4;<br />
}<br />
counter++;<br />
}<br />
return 0;<br />
}<br />
Good luck
Carlos
|
|
|
|
|
|
hi all..I want to make a dialog that can be resize with HScroll and VScroll. But when I tried the program, the dialog window can be resized, but the scroll doesn't work(I added the scroll using class wizard by right-clicking the dialog window, go to properties, and checked horizontal scroll and vertical scroll). Pls help...
thx.
|
|
|
|
|
Scroll doesn't work by itself, you need to catch the scroll events, and make sure your code adjusts it's display accordingly. You also need to set the range of the scroll bars.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
how to implement it? Can u give some tutorials,articles,or some link that can be helpful..pls
thx
|
|
|
|
|
What version of VC are you using ? Whatever it is, you can set an event handler for each of the two scroll events ( but if I know which one, I can tell you exactly where ), and then you force a redraw with Invalidate(), and your drawing code takes the scroll position into account. I don't know of any tutorials, off hand, sorry. I'd be surprised if this site didn't have any.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm using VC 6.0. I already make the event handler. On where I should write my drawing code? Btw...what is the keyword for finding thw tutorials(I try "repainting window" keyword, but I didn't find any suitable articles)
thx...
|
|
|
|
|
firebolt77 wrote:
On where I should write my drawing code
Drawing code is ALWAYS in OnPaint. Invalidate(); is all the code you need to put in a scroll event to force a repaint.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thx...but I'm still confuse on the drawing code
I'm still new in MFC so I'm still lack of knowledge in MFC
thx anyway..
|
|
|
|
|
Well, what are you drawing ? How do you draw it now ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
just ordinary dialog box with tab control, tree control, button, edit box, etc. I want the dialog box can be resize to smaller size, and I can use the scroll bar to see all of the frame. Sorry for the bad english...but I hope you understand what I mean
thx..
|
|
|
|
|
Oh, OK. Well, I'd have thought a CFormView would handle that by itself. There's no painting involved here - your controls all need to be on some sort of control that you can position, otherwise you need to call SetWindowPos on all of them to move them, which is kind of ugly.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hmm..but I'm using CDialog base class. Can I use the method?
thx..
|
|
|
|
|
Yeah, I guessed that. You need to do what I said as an alternative, get a blank control ( that is, one that gives you a surface, but nothing on it, probably the control base class ), set out all your controls on that, and move it's location using SetWindowPos in response to the scroll bars. So the scroll range for X is the width of your control - the width of the window, and the same for the Y. Then when your scroll event occurs, you set the window position of the control to be the offset of the scroll pos, so if hte X scrollbar is set to 20, then the X position is -20, so the first twenty pixels of the control are to the left of the left edge of the main window.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Hi geeks... I mean guys guys...
I need to use a very large integer that does not fit in a long. So I attempted using _int64 and the values are at least stored in the declared variable. However if I try to send it to the screen, it gives me this compiler error...
error C2593: 'operator <<' is ambiguous
Can anyone give me a simple explanation and solution? Is there any other place I need to be aware of where I'll run into trouble if using this data type?
Thanks a bunch!!!
|
|
|
|
|