|
MFC has a data type of _int64 but I just found out I can't serialize it...
I can read the low and high words and serialize them seperatly, but that's too much work.
Shay
|
|
|
|
|
Shay Harel wrote:
I can read the low and high words and serialize them seperatly, but that's too much work.
If MFC does not searialize _int64 you must do it seperatly.
John
|
|
|
|
|
Shay Harel wrote:
MFC has a data type of _int64...
This should read "Microsoft has a data type of _int64..."
Shay Harel wrote:
I can read the low and high words and serialize them seperatly, but that's too much work.
Actually I believe those are DWORDs, which CArchive does know how to handle, but here's a piece of code that might work for you:
char szNum[64];
if (ar.IsStoring())
{
sprintf(szNum, "%I64u", m_i64MyBigNumber);
ar.Write(szNum, sizeof(szNum));
}
else
{
ar.Read(szNum, sizeof(szNum));
m_i64MyBigNumber = _atoi64(szNum);
}
|
|
|
|
|
I use the << and >> operators.
What I did is tricky, I just broke it to 2 ints and serialized them one after the other, but I will try your stuff as well.
|
|
|
|
|
You can always call the Read and Write methods of CArchive, passing a pointer to your int64. EX:
void CMyClass::Serialize(CArchive &ar)
{
if (ar.IsStoring())
{
ar.Write((void *)&m_i64MyBigInt,sizeof(_int64));
}
else
{
ar.Read((void *)&m_i64MyBigInt,sizeof(_int64));
}
}
Using the Read and Write methods allows you to serialize "non-serializable" data (non-mfc data containers).
onwards and upwards...
|
|
|
|
|
Hello,
I am working on an application where I get passed a list of line segments. I want to convert the line segments into polygons. Anybody have a reference to an algorithm or code fragment that can do this? Anybody have a quick sketch of an algorithm to do this. Thanks for any ideas.
Craig
|
|
|
|
|
BOOL Polygon(
HDC hdc, // handle to DC
CONST POINT *lpPoints, // polygon vertices
int nCount // count of polygon vertices
);
or am I missing something?
INTP
|
|
|
|
|
John R. Shaw wrote:
or am I missing something?
Nope. That would be my suggestion as well
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"
|
|
|
|
|
If only it were that ease... Yup, you are missing something. The lines are from a wire mesh drawing, there are thousands of lines and they make up hundereds of polygons. The trick is to figure out what lines grouped together make up a polygon.
Craig
|
|
|
|
|
Search for "3D Graph ActiveX Control" at codeprject. I have not studied the code but it should help. There is no lack of graphics related sites on the www.
INTP
|
|
|
|
|
Hello All,
I am working on a drawing package. The user can drag and drop shapes (i.e. rect, elipse, star,...) and text into defined boxes on the screen. One requirement is to allow the user to rotate the shapes within the boxes. I have the rotation code down, but I am having trouble keeping the rotated shape in the box. For example when the user drops an elipse (tall and narrow) into a box. When I rotate this elipse 45 degrees it becomes bigger than the bounding box.
Any ideas on how to allow the rotation but still keep the shape in the bounding box. Thanks!
Craig
|
|
|
|
|
Do you want to make the shape smaller so it fits, or clip the shape to the size of the box?
To make it smaller, you'll need to use your maths and recalculate the size of the shape.
To clip the shape to the box, use CRgn::CreateRectRgn() and CDC::SelectClipRgn() to create a rectangular region and clip the drawing to that region.
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"
|
|
|
|
|
I want to make the shape smaller so it fits in the box, I guess I'll get out the geometry text books...
Craig
|
|
|
|
|
Yeah, and when you figure it out, think about writing an article to post. That would be cool
It shouldn't be too difficult, but will depend on the shape you're working with. If you're dealing with a polygon, you can calculate the distance out of the box for each point, and scale all the points so that the furthest one fits in the box. Sounds complex, but I don't think it is really, just takes a bit of thought
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"
|
|
|
|
|
Hi, is there anybody can help me on my problem of pipes and process. I create two pipes for stdin, stdout/stderr, and CreateProcess a cmd.exe. After entering "exit" to the pipe, cmd.exe terminates. But the parent process does not know the child has terminated. It can read characters from the pipe and WriteFile to the pipe of the child. Of course, there is no reading from the other pipe from the child. So, the information loop is deadlocked. Is there any way to know the child terminates? I know in UNIX, once the child close the pipe, the parent will receive a signal when it reads/writes to the pipe. How about Windows? I am new to Windows.
Please reply me by email. Thank you in advance!
Qin An (anqin@leadinghr.com)
|
|
|
|
|
Hi,
does anybody know how to download ActiveX from Apache Server and not from IIS. What should be the HTML Script and where should I put the ActiveX (dll) on Apache Server.
thanks
|
|
|
|
|
This really isn't the right forum for this question, but we're forgiving here...
Doing it twice risks the Wrath Of BOB!
As the ActiveX control is run client side, it really makes no difference which
web server you use. From the server point of view, it is a file delivered
using the HTTP protocol. No different to an HTML page, jpeg, or gif.
So use the same HTML for either server, and put the control in the equivalent
place on either server.
Iain.
|
|
|
|
|
Iain Clarke wrote:
we're forgiving here
Really?
Iain Clarke wrote:
Doing it twice risks the Wrath Of BOB!
Perhaps you could have told him the Web Development forum is more appropriate
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"
|
|
|
|
|
Iain Clarke wrote:
we're forgiving here
Ryan Binns wrote:
Really?
OK, I'm forgiving. Not like Mr Binns. He's no help to anyone!
Iain Clarke wrote:
Doing it twice risks the Wrath Of BOB!
We need a smiley... And one with a pitchfork...
Perhaps you could have told him the Web Development forum is more appropriate.
Nah. I'm not that helpful!
Iain.
|
|
|
|
|
Iain Clarke wrote:
Not like Mr Binns. He's no help to anyone!
Absolutely. I never help anybody. Muahahaha :evil-smiley:
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"
|
|
|
|
|
I know I have been stuck on the same problem for the last few days but, I have to get this to work or my rpogram won't function correctly. Like I need it to.
I am using the getline() function to read in a file. I need to put the first word on each line in a char array.
<br />
string name, unit,min,max,value; <br />
<br />
for(int i=0; i<45; i++){<br />
getline(fin, name, ',');<br />
<br />
if(name == "STOP")<br />
break;<br />
getline(fin, unit, ',');<br />
getline(fin, min, ',');<br />
getline(fin, max, ',');<br />
getline(fin, value);<br />
<br />
cout<<endl<<name<<"\n";<br />
strcpy(TSimHeader_arr[0].Name, (char*)name.c_str());<br />
strcpy(TSimHeader_arr[0].Name, name); <br />
strcpy(TSimHeader_arr[0].Name[i],name.c_str());<br />
TSimSignal_arr[0].Value[i] = atof(value.c_str());<br />
<br />
<br />
cout<<endl<<"names......."<<"\n"<<TSimHeader_arr[0].Name[i];<br />
<br />
<br />
sig_count ++;<br />
<br />
}
All of the above are ways that I have tried. I don't get the correct word put in the char array.
I know the words are getting read in from the file correctly.
They are just not getting put in the char[] correctly.
Is there another way that I could go about doing this?
Is this the best wat to read in a file and put the words in a char[]?
I have to use a char[] because of certain requirements that my boss has given me.
I would love to use a vector, but it won't work
Thanks for your help,
Steven
|
|
|
|
|
If I remember your structure correctly, the first strcpy() method will work (you don't need the cast, though):
strcpy(TSimHeader_arr[0].Name, name.c_str()); What won't work is the method you're using to print it out:
cout<<endl<<"names......."<<"\n"<<TSimHeader_arr[0].Name[i]; You need to print out what you store to:
cout<<endl<<"names......."<<"\n"<<TSimHeader_arr[0].Name; Your version was only printing one character, right?
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"
|
|
|
|
|
You are right it was only printing ouot 1 character.
But, if later on I need to access the array of names and get Names[15] how can I do that?
I just tried to print out TSimHeader_arr[0].Names[15] and it printed out <null>
Are the words getting put in the char Names[]?
Sorry, but I just don't quite understand.
Thanks, Steven
|
|
|
|
|
At their core, strings are an array of characters. The string "Hello" has 5 characters (plus a terminating NULL character), so it will need a 6-character array.
Your Names array is declared as char Names[45] , which means that it holds 45 characters, ie one string that can be up to [edit]44[/edit] characters long. If you are wanting to store more than one string, this won't work - an array of char s can only store one string.
To store multiple strings you'll need to use a 2-dimensional array - an array of arrays of characters (think about it, it does make sense )
I think you're wanting to store 45 strings. If each string is at most 10 characters long, then you'll need to declare Names as
char Names[45][11]; This is an array that holds 45 arrays of 11 characters, ie. it holds 45 strings that are up to 10 characters long each (remember the terminating NULL?). You'll have to work out how big to make the arrays to fit your strings (change the 11 to whatever is necessary to fit the string in). To write to these strings, use the code
strcpy(TSimHeader_arr[0].Names[0], name.c_str());
strcpy(TSimHeader_arr[0].Names[1], name.c_str());
strcpy(TSimHeader_arr[0].Names[44], name.c_str()); To display the strings, use
cout << TSimHeader_arr[0].Names[0] << endl;
cout << TSimHeader_arr[0].Names[1] << endl;
Hope this helps,
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"
|
|
|
|
|
Ryan,
That makes sense. Which would take up less space an array of
char Names[45][10] or string[45]?
I am trying to use the least amount of space.
Thanks,
Steven
|
|
|
|