|
you can't create a CElement simply with {2, 4} for instance, because it is not a struct ... moreover, the members m_na and m_nb are protected and then, can't be accessed from outside the class.
|
|
|
|
|
Are you kidding? You are, right? Why not code I posted works? Class, struct you can use either. Only in 2005 agregatable type like:
CFoo oFooV[] = {{...},{...}, {...}};
can't be declared if CFoo has contructor, virtual function or base class the rest is OK.
And never worry about private or protected members just take "this" pointer and add offset to access to the nesesarry field, and use it. Private, protected is only for compilers and school teachers, they like those restrictions. ))
|
|
|
|
|
Alex_Y wrote: Class, struct you can use either. Only in 2005 agregatable type like:
CFoo oFooV[] = {{...},{...}, {...}};
It worked on older versions of Microsoft's compiler because they didn't meet the standard for this particular case. You cannot set the values of protected/private members directly like this (there are ways to do it, but if you do them, you will quickly be beaten with a stick in any code-review).
Alex_Y wrote: And never worry about private or protected members just take "this" pointer and add offset to access to the nesesarry field, and use it. Private, protected is only for compilers and school teachers, they like those restrictions.
I do hope you are joking. If you truly believe this, never apply for any position if you see I'm the hiring manager.
To answer your original question, when you initialize the array in this manner:
CElement elements[] = { CElement(1, 2), CElement(2, 3), ...};
the elements in the array invoke the copy-assignment operator for each element. Thus, the elements themselves will be destroyed, but the values they hold will be copied into your array. For simple cases like this (where your data is just primitive types), you can get away without creating a copy constructor/copy-assignment operator; however, if you had a pointer to heap memory that your class was controlling, only the pointer value would be copied (and since the data in the original would be cleaned up, the pointer would be looking to a place in memory that was no longer allocated). You should get in the habit of creating copy constructors and copy-assignment operators (even if you mark them as private so they can't be invoked).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
virtual void empty() = 0; // fucntion header
Why is this function header assigned a value of zero?
Is this suppose to mean its a pure virtual function from a derived class with no implementation in it?
like this:
virtual void empty()
{
// empty
}
Thanks,
Jay
|
|
|
|
|
|
Which functions usually have an empty implementation.... is it the Base Class or the Derived Class?
|
|
|
|
|
Base
class CBase //abstract class
{
virtual int Pure(int nA) = 0;
}
class CDerive : public CBase
{
virtual Pure(int nA)
{
return nA+1;
}
}
|
|
|
|
|
Yes, it means it's a pure virtual function with no implementation. That's not the same as a function whose implementation has an empty body.
|
|
|
|
|
Hello , i want to load the .BMP File of Image File in CImageList from my Hard drive , but when i load it to CImageList and reads and copy the Bitmap to a CBitmap Object the program crashes on the Run , can anyone help me in this , i tried to load image list this way -->>:
////////////////////////////////////////////////////
////////////////////////////////////////////
////////////////////////////////////
BOOL CXXXDlg::OnInitDialog()
{
..................
..........
// CImageList to load bitmap from Outside
CImageList m_imgList;
m_imgList.Create("C:\\xxxx.bmp" , 64 , 32, RGB(255,0,255));
//Copies the Single Frame from the Image List to CBitmap
CBitmap mBmp;
GetImageFromList(&m_imgList , 1 , &mBmp);
and
CBitmap *mBmp = new CBitmap;
GetImageFromList(&m_imgList , 1 , mBmp);
...........
.................
}
void CXXXDlg::GetImageFromList(CImageList *lstImages, int nImage,
CBitmap *destBitmap)
{
//First we want to create a temporary image list we can manipulate
CImageList tmpList;
tmpList.Create(lstImages);
//Then swap the requested image to the first spot in the list
tmpList.Copy( 0, nImage, ILCF_SWAP );
//Now we need to get som information about the image
IMAGEINFO lastImage;
tmpList.GetImageInfo(0,&lastImage);
//Heres where it gets fun
//Create a Compatible Device Context using
//the valid DC of your calling window
CDC dcMem; dcMem.CreateCompatibleDC (GetWindowDC());
//This rect simply stored the size of the image we need
CRect rect (lastImage.rcImage);
//Using the bitmap passed in, Create a bitmap
//compatible with the window DC
//We also know that the bitmap needs to be a certain size.
destBitmap->CreateCompatibleBitmap (this->GetWindowDC(),
rect.Width (), rect.Height ());
//Select the new destination bitmap into the DC we created above
CBitmap* pBmpOld = dcMem.SelectObject (destBitmap);
//This call apparently "draws" the bitmap from the list,
//onto the new destination bitmap
tmpList.DrawIndirect (&dcMem, 0, CPoint (0, 0),
CSize (rect.Width (), rect.Height ()), CPoint (0, 0));
//cleanup by reselecting the old bitmap object into the DC
dcMem.SelectObject (pBmpOld);
}
/////////////////////////////////////////////////////////
///////////////////////////////////////////////
/////////////////////////////////////////
and when i run this APP, its crashes ; please tell me whts wrong with the CODE, and tell me how to load Bitmap from the Hard Drive i realyy need it
Thnx...
-- modified at 14:02 Thursday 27th July, 2006
|
|
|
|
|
Do you need to load bitmap?
|
|
|
|
|
does anyone know if a MAKEDWORD macro exsists or a macro that does something similar to a MAKEWORD macro except you take 2 WORDS and make them into a DWORD?
Or am I stuck using bitwise manipulations to put the 2 WORDS together....
Thanks,
Kitty5
|
|
|
|
|
make your own :
#define MAKEDWORD(MSB, LSB) ((MSB << 16) | LSB)
with MSB meaning most significant byte and LSB lower significant byte
|
|
|
|
|
Found it!
it's the MAKELONG macro!
<br />
DWORD MAKELONG(<br />
WORD wLow,<br />
WORD wHigh<br />
);<br />
yeay!
Kitty5
|
|
|
|
|
Hi,
I am facing a strange problem. I have an MS Access database. I have populate a view with the contents of a table. Then I wish to export this information. For this I pop a CFileDialog of the Save type and take the file name input from the user. What happens next is that I cannot connect to the database. I have the proper pointer for the database so I am pointing to it. However I traced the failure to a file atldbcli.h whihc contains a function CreateSession(). This returns E_FAIL. When I hardcode the path for the file everything runs hunky-dory. Can anyone guide me to a solution?
na.nu
|
|
|
|
|
na.nu wrote: When I hardcode the path...
As opposed to what?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
1. What classes are you using to extract data from the database in the first place, and are you, by any chance, opening it exclusively?
2. You are prompting for a file to save to, yes? Is this a text file, or a new database?
If the latter, you need to create an empty database first.
Steve S
Developer for hire
|
|
|
|
|
Hi,
I am using standard accessor classes and using the Microsoft Jet DB engine 4.0. I open a session to the DB. Populate a grid with info from a table. There is a tree view which when clicked loads a different table. The user should be able to edit the contents, so I export the data to a .csv file using CFile and CArchive classes. The thing is I am launching a CFile dialog on clicking a button for exporting this data. What happens is that the application loses the DB connection. So after exporting when I click on the tree I have an error that displays DB connection lost.
Now what is really wierd is that I have functionality for importing data from the file. I have a copy of the database on the desktop and in my debug folder in a nested directory in C:\.. When I export I loose the connection to the Access DB in the debug folder. On importing somehow the DB on the desktop gets updated. The DB's have the same name and contents. I connect to the DB using a initialization string. Is the path of the DB need to passed for connection? If not then why does CFile dialog statement cause the app to loose the connection? I removed the CFile dialog statement and hardcoded a path to C:\XYZ.csv. Worked fine. By the way the code for setting up the connection is in another DLL and not in the executable. Have you faced this problem?
na.nu
|
|
|
|
|
na.nu wrote: What happens is that the application loses the DB connection. So after exporting when I click on the tree I have an error that displays DB connection lost.
This is not the result of a conflict between CFileDialog and the ATLDBCLI/OLEDB stuff.
How do you determine that the app has lost the db connection? Presumably you get errors when you try and access the db (eg clicking on tree)?
There's an AtlTraceError (or something) debugging function you can use which should give you more information on what's going wrong, but my normal rules for diagnosis would seem to apply.
Rule#1: Suspect your own code
Rule#2: Refer to rule#1.
It could be that when you use the CFileDialog, you're not initializing something correctly (like one of the pointers in the OFN structure), and it's trampling on some memory. This is notoriously difficult to diagnose; I generally dump the likely affected parts before and after calling the 'suspect' line.
Steve S
Developer for hire
|
|
|
|
|
In one of our software product, I was told by management to place a menu on one of the dialogs. The menu replaced a bunch of seldom used buttons and cleaned up the interface a bunch. The software was released to Beta recently. One of the guys working here that reviewed the software came up with something that I thought was kind of a bizarre thing to say. He said that "reputable" companies don't put menus on dialogs.
I was kind of shocked at that. I have never heard of such a thing. I searched and could not find any reference to any standard that forbids menus in dialogs.
So, that got me curious to see what other people do. Do you use menus in dialogs? If not why not?
Thanks
Wes
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|
|
Wes Aday wrote: I have never heard of such a thing.
Neither have I. But I've also never heard of non-reputable companies putting menus on dialogs.
Wes Aday wrote: Do you use menus in dialogs? If not why not?
No. They probably have their place, but our product does not warrant them.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I've never had to put a menu on a dialog, but it would be okay to do if it was necessary, especially if the dialog was the main window of an application (like in a dialog based application).
Tell the guy he's full of shit.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
never heard such a thing neither...
and we do (even we program in java), some of our dialogBoxes contains menus. and guess what companie i work for ?? i think Accenture is more than a "reputable" companie, so...
|
|
|
|
|
Sounds pretty silly to meeee too, to say such a thing. But maybe: reputable or not, it would be a good idea to put them buttons on a seondary tab instead, depending on the style of other parts of your app
_____________________________________
Action without thought is not action
Action without emotion is not life
|
|
|
|
|
I've never put a menu on a dialog myself, but I don't see why it should be a problem.
|
|
|
|
|
Don't know about "reputable", but a menu bar on a dialog does look confusing to me. Have you ever seen such a thing in any MS product for instance?
|
|
|
|
|