i am currently learning VC++ with MFC. But i am quite confused now. My dilemma is whether to use structures (which i guess are used extensively at Win32 API level) or their equivalent MFC objects.
let me elaborate it. For example i want an array of points to use it somewhere. I gathered that i have two options to do so - either to use POINT structure array or array of CPoint objects. Now, which one should i use?
Being MFC programming should i stick to CPoint or should i take the liberty to use POINT array? Note that i dont have any use of supposed member functions of CPoint in case if i should use it..
Same goes with some other things like RECT and CRect.
So please throw some light on this.. :|

Another question :
i am also quite confused with the use of GDI function ::GetStockObject(). Being a non-MFC function (i guess so), i think it shouldnt be used much around an MFC code.
But i need to use it at certain points like :

Frame::Frame()   // Frame::CFrameWnd class
{
   HBRUSH brush;
   brush = (HBRUSH) ::GetStockObject (WHITE_BRUSH);
   LPCTSTR className;
   className = AfxRegisterWndClass (NULL, AfxGetApp()->LoadStandardCursor(IDC_CROSS),
brush,
AfxGetApp()->LoadStandardIcon(IDI_ERROR));

   Create (className, "XYZ");
}

i think the another way might go like this (using CBrush):

Frame::Frame()
{
	defaultCursor_ = AfxGetApp()->LoadCursor (IDC_CURSOR1);
//	defaultBrush_ = (HBRUSH) ::GetStockObject (WHITE_BRUSH);
	defaultIcon_ = AfxGetApp()->LoadStandardIcon (IDI_ERROR);

//     here defaultBrush_ is  : CBrush defaultBrush_;
        defaultBrush_.CreateSolidBrush(RGB (0,0,255));
	HBRUSH	tempBrush;
	tempBrush = (HBRUSH) defaultBrush_;

	LPCTSTR className;
	className = ::AfxRegisterWndClass (NULL, defaultCursor_, tempBrush, defaultIcon_);
	Create (className, "BHOOT"); 
}

so which way to follow here? Should i take the liberty of using GetStockObject?
or am i just confusing myself here? Is there any other better way out?
please help me. :|

IMO use MFC objects when available. In the two cases you cited it doesn't really matter to the compiler, it just makes your program more consistent if you use the MFC objects.

IMO use MFC objects when available. In the two cases you cited it doesn't really matter to the compiler, it just makes your program more consistent if you use the MFC objects.

ok..but i doubt one thing..doesnt efficiency affect here? i mean using a structure and using a class with lots of member functions - both are different thing..or am i just exaggerating this thing? :|

>>or am i just exaggerating this thing?
You are misunderstanding the difference. The presence of a lot of member functions has nothing to do with efficiency. If you just want to use structures and pure win32 api then IMO write a C program, not C++.

MFC itself is pretty in-efficient. Its a handy set of c++ classes, but not very efficient. So to quibble about the difference of using RECT or CRect isn't really very productive. If your program requires efficiency and speed, then ditch MFC and use something else, such as wxWidgets.

>>or am i just exaggerating this thing?
You are misunderstanding the difference. The presence of a lot of member functions has nothing to do with efficiency. If you just want to use structures and pure win32 api then IMO write a C program, not C++.

MFC itself is pretty in-efficient. Its a handy set of c++ classes, but not very efficient. So to quibble about the difference of using RECT or CRect isn't really very productive. If your program requires efficiency and speed, then ditch MFC and use something else, such as wxWidgets.

ohkk...i got your point..thanks for guidance.. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.