|
Your post is a little hard to understand due to the fact that you haven't selected the "Ignore HTML" check, as Christian pointed out.
You need to provide the three canonical ctors (default, copy and assignment, this latter is not technically a ctor, but works similarly) for SDataRecord :
struct SDataRecord{
SDataRecord()
{
}
SDataRecord(const SDataRecord& r):
csID(r.csID)
{
DataArray.Copy(r.DataArray);
}
SDataRecord& operator=(const SDataRecord& r)
{
csID=r.csID;
DataArray.Copy(r.DataArray);
return *this;
}
CString csID;
CArray <SSingleData, SSingleData> DataArray;
}; Why is this so? Well, the discussion is a little technical, but I think you might find it worth knowing. In C++, if you don't provide a copy ctor (the same goes for the assignment operator), then the compiler makes up one for you automatically. This default copy ctor simply copies all the members of the class one by one (what's called memberwise copy): so it's easy to figure out how to copy members of built-in types line int s, pointers and the like. With respect of members of non-primitive types (classes), the compiler uses their respective copy ctors if available: again, these copy ctors can be explicitly defined by the programmer of automatically generated.
What's happening to your SDataRecord ? When the compiler tries to generate its copy ctor, first it deals with csID, and finds no problem, then it tries to locate the copy ctor for DataArray , whose type is CArray <SSingleData, SSingleData> , but CArray does not have a copy ctor (it derives from CObject which explicitly forbids copying between its instances). Conclusion: SDataRecord does not get an automatically generated copy ctor, and it's your task to write it yourself (same for the operator asignment). Altough CArray does not have copy ctor, its member function Copy does the same job.
One more subtlety: Once you define any ctor, the compiler does not provide an automatic default (no arguments) for you (as it's the case in SSingleData , for instance), so you have to include the definition for the default ctor as well.
PS: I second Christian's suggestion about quitting MFC containers and using instead std::vector and its merry STL companions.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have drawn some lines etc. on a CDC , now can I save this drawing to a Bmp File ?? How ?
Thanks in advance !
Abhishek Narula
"Learn to appreciate others ... World would appreciate you"
|
|
|
|
|
Do you want to save a file (.bmp)?
If so, this question is very very very often shown here on the message board!
Try CXImage in the Bitmaps & Palettes section here on CodeProject!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
You've actually drawn lines on a bitmap *selected* into a CDC, and has been pointed out, this question is addressed in the FAQ.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Okay so you mean by GetCurrentBitmap() I ll get the bitmap of what ever is drawn on the screen ... so now how do i save this to a file ??
If you dont mind please give me the URL of FAQ , I am some what new to this Forum !
Regards,
Abhishek Narula
"Learn to appreciate others ... World would appreciate you"
|
|
|
|
|
Here it is :-
The Mike and Maunder FAQ
http://www.codeproject.com/useritems/cppforumfaq.asp
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Thanks Buster !! you have always been a great help ! thanks
Abhishek Narula
"Learn to appreciate others ... World would appreciate you"
|
|
|
|
|
Abhishek Narula wrote:
I am some what new to this Forum
In that case, welcome.
As you've drawn onto this bitmap yourself, I presume you created the CDC, and selected the bitmap into it. So where is the confusion in getting hold of the bitmap, if you created it ? If you're talking about a screen DC, which MFC passed to you with a bitmap in it, you can use GetCurrentBitmap, or create a new CDC select a new bitmap into it and copy across.
As for the URL, cast your eyes upward from my post and just under the banner ad for Visual Assist ( try it if you haven't got it, it rules ), is a row of links. The left most link is to the FAQ.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I think you have understood my problem !!
I have made some drawing on my CDC , using LineTo etc .. functions ..
now I want to save this drwaing as Bitmap file which I can open in MS-Paint.
Can I do this ?? rather I am sure we can do this .. but How ? thats the question.
Any way thanks a lot for all the pains that you have taken to reply !!
Abhishek Narula
"Learn to appreciate others ... World would appreciate you"
|
|
|
|
|
I am sorry in the first line i meant that you have not understood my problem , a typing mistake !
Abhishek Narula
"Learn to appreciate others ... World would appreciate you"
|
|
|
|
|
Abhishek Narula wrote:
I think you have understood my problem !!
I think I have to, but I don't think you've understood my replies...
Abhishek Narula wrote:
I have made some drawing on my CDC , using LineTo etc .. functions ..
now I want to save this drwaing as Bitmap file which I can open in MS-Paint.
So.... if you created the CDC, and selected a bitmap into it ( and if you created a CDC and DIDN'T select a bitmap into it, then the CDC contains a 1x1x1 bitmap ), then you already have the CBitmap, if you got the CDC from OnPaint or similar ( it's the background of a dialog box, say ), then you need to either call GetCurrentBitmap or create a new CDC/CBitmap pair to copy this bitmap across. Also, if you're creating the bitmap, creating a DIBSection will allow you to save it at any bit depth, instead of just that of the screen. You can do that with Chris Maunders DIBSection class, which is on CP.
Abhishek Narula wrote:
Can I do this ?? rather I am sure we can do this .. but How ? thats the question.
Both Nish and I have pointed you to the FAQ, he even kindly looked up the URL ( I was too lazy ). The whole point of having a FAQ would be negated if we went off and quoted it to people unwilling to read it, don't you think ?
If you've read the FAQ and are still confused, please explain which bit is not making sense to you, and I'll be happy to clarify. You can also look up my GDI+ articles or the CXImage class here on CP, two solutions offered on this site ( some of the solutions in the FAQ are not on CP ).
Abhishek Narula wrote:
Any way thanks a lot for all the pains that you have taken to reply !!
I am always glad to help. If you are stuck after reading the FAQ, don't hesitate to ask again.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Hi,
I created one Dialog based Application .When ever I am pressing the enter key the Dialog Box is being closed.How could I remove this?
Then How can I track the enter key is pressed?
SSN
|
|
|
|
|
Hi
You have the OK button default, therefore when ENTER pressed, than your Dialog is being closed!
1. You can override the OnOk() function, and if you don't want close the Dialog, you don't must call the CDialog::OnOk() metod.
2. You can override PreTranslateMessage() function, and catching WM_KEYDOWN message.
Best regards,
Eugene Pustovoyt
Sonork ID 100.10002:Yaumen
|
|
|
|
|
|
http://www.codeproject.com/dialog/pretransdialog01.asp
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Anyone care to clear this up for me?
"To wonder is to begin to understand"
|
|
|
|
|
Ever1234 wrote:
Anyone care to clear this up for me?
An OR returns 1 if either of two binary values is 1, an XOR returns 1 if one and only one value is 1. What else did you want to know ?
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Exclusive or is the binary equivalent of the old "chinese addition" used by the spies of old, which involves adding digits but ignoring any "carry" numbers.
So you'd get (with the decimal version)
29232 +
56299 =
75421
the binary version would go like:
1011110 xor
0111010 =
1100101
It allows your data to be combined with a random stream of numbers so that it can be easilly retrieved by someone who has the same random stream of numbers. The convenience is that if you xor twice with the same data you get back to the original.
This, of course, is the easy bit. The hard part is to ensure that the sender and the intended recipient have the same encoding stream and the bad guys don't. In the old days the spies had "one time pads", basically pages of random numbers which they had to smuggle physically and which they were supposed to destroy after use. These days we tend to generate pseudo-random sequences from seed codes like pass phrases.
|
|
|
|
|
Okay, I wrote some code and it is bug free, exept that the danged compiler generated code has some many bugs it wont compile. Its a 5 line proggy, none of the errors come from the code that I wrote. WHAT IS UP WITH THAT? How can I get it to accept my code. Where can I get a compiler that works?
"To wonder is to begin to understand"
|
|
|
|
|
Hmm....
Ever1234 wrote:
How can I get it to accept my code.
If you want some advice, I suggest you post your code.
Ever1234 wrote:
Where can I get a compiler that works?
I've got five bucks here that says the problem is with your five lines of code, unless they exploit a known bug like the \t\t thing.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
How can I read data from Excel file?
|
|
|
|
|
Hi,
Any idea on “How to paste clipboard data to DOS/CONSOLE window” would be appreciated.
Thanks
|
|
|
|
|
I've been reading (again) Jeff Prosise's Programming Windows 95 with MFC. In it he says that MDI is not recommended for Win95. The book is really dated, as we've had many new Win versions since then, but I'm curious. Is that still valid advice for the WIndows platform in general?
Of all the things I've lost in life, I miss my mind the most
|
|
|
|
|
MDI is not recommended *by Microsoft*. Witness Excel/Word, they start another instance when you open a new document. MDI is perfectly valid, and I think it's often a *good* idea.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
A good point - why do they tell their developers not to use this capability, then release products that depend upon it? We may never know...
|
|
|
|