|
Hi there,
I have an application that has upwards of 20 classes and a lot of these
classes need to use a method in one another to get the whole thing going.
I was wondering whether the following practice of mine is considering
bad programming/design habit and there is a better way of doing it:
I tend to include header files of any class i need in any given file
and then, call the member functions of the class as following:
CClass2 x2;
x2.print();
I was wondering if I do this too many times, whether it would cause
a problem somewhere in the code or is this an acceptable practice?
|
|
|
|
|
Without knowing what the default CClass2 constructor does, your question cannot be answered. Generally speaking, there is no harm in declaring a class as a local variable. In fact, IMHO, that is the sort of design you should generally strive for. However, if your default ctor is doing a lot of work initializing the class you might rather have it as a member of the class so that it is only initialized once.
class myclass
{
private:
CClass2 m_x2;
};
void myclass::somemethod()
{
m_x2.print();
}
"Want to know what makes me mad? Everything!" The Ranting Swede.
|
|
|
|
|
Hi,
I've created a button dynamically but I only know how to respond to the button by assigning a handler using the wizard, but how do I go about it now?!
/Tommy
|
|
|
|
|
WM_COMMAND will recieve a BN_CLICKED message which includes the ID of the button and so on. I've been doing it in Win32, but I'm sure you can override WM_COMMAND in MFC, or otherwise do it through PreTranslateMessage otherwise ( the last resort ;0)
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I dont know what help i'm asking for.I know how to do the first few part of my project but not so sure about the rest.I just need someone to take a look at my project questions.I will email those who wants it.Thanks alot.
|
|
|
|
|
I could be wrong, but I think you would have better luck posting your questions here rather than expecting someone to become your personal free tutor.
"Want to know what makes me mad? Everything!" The Ranting Swede.
|
|
|
|
|
Fair dinkum - how often are you going to keep posting this non-question instead of asking what it is you want to know ? I would hope no-one here would do your homework for you, but everyone would be happy to help if you ask some specific questions about where you are stuck or what you do not understand. Post the damn questions, and I know I will not be alone in being glad to comment. But you should also post your attempts at answers - no-one is going to do your homework for you, and if they did they would be doing you a grave injustice.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
There is an article located here:
http://www.codeproject.com/listctrl/headerctrlex.asp
It explains how to create a multiline header control. I
tried implementing this article for a CFormView, but I
can't get it to work. Too many errors. Can someone
show me how to implement this article for a CFormView?
Please, please, any response any one can give me
me will be greatly appreciated. Demo projects are
beloved.
My email address is brinasas@yahoo.com
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Is there any way of loading a bitmap to a CBitmap from file? I've got a lot of images and don't want to load them with the resource editor.
Thanks.
|
|
|
|
|
Yes, LoadImage
HANDLE LoadImage(
HINSTANCE hinst,
LPCTSTR lpszName,
UINT uType,
int cxDesired,
int cyDesired,
UINT fuLoad
);
using the value LR_LOADFROMFILE in the Load Flags.
Then use CBitmap::FromHandle
Carlos Antollini.
|
|
|
|
|
if "bitmap" means "BMP", try ::LoadImage
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
In ADO you usually get all your values as Variants, Is there a easy way to convert any type into a string or BSTR
|
|
|
|
|
Yes,
var.bstrVal returns a BSTR type.
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
No!
I meant is there functionality that can convert any variant type e.g. int, long, double, currency to a BSTR.
A microsoft Example has a CrackStrVariant function, but this does not cover all types.
|
|
|
|
|
I came across this problem recently, and found the perfect solution
use _variant_t wrapper class
e.g. converting a long to a BSTR
_variant_t vLongVal((long)100);
vLongVal.ChangeType(VTV_BSTR);
_bstr_t vBstrValue(vLongVal.valbstr);
This can be applied to any type
I hope this helps
|
|
|
|
|
Look for this article in the MSDN:
VARIANT and VARIANTARG
Best Regards!!!
Carlos Antollini.
|
|
|
|
|
visit at:
http://www.ucancode.net
|
|
|
|
|
buy a banner like everyone else, jerk.
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
You crack me up, Chris! I'm so sick of that UCanCode crap!
|
|
|
|
|
Hi,
How is possible to create a Bitmap with different bits per pixel.
I've tryed with CreateDIBSection but when I select the Bitmap into the DC and then draw into it, nothing is happened.
Is there any example of this?
10x
|
|
|
|
|
i want to get a recordset from server database using ADO command which calls stored procedure.
the subroutine source code is following...
with a global connection and a global recordset pointer,
////////////////////////
try
{
_CommandPtr pCommand ;
HRESULT hr = pCommand.CreateInstance( __uuidof(Command) );
if( FAILED(hr) ) return FALSE;
pCommand->ActiveConnection = GetConnection();
pCommand->CommandText = proc; // stored procedure parameter : @roomNo smallint
pCommand->CommandType = adCmdStoredProc;
pRecordset = pCommand->Execute( NULL, argv, adCmdStoredProc );
// pRecordset->Open((IDispatch *) pCommand, argv, adOpenStatic,adLockOptimistic, CmdStoredProc);
}
catch(...)
/////////////////////////
when returns from the above subroutine, the global recordset becomes closed.
so, can not get a record by using pRecordset->GetCollect(0L).
why this occurs ????
somebody help me.....
thanks in advance.
|
|
|
|
|
Are you sure your Execute is working ?
try adding a
catch(_com_error e)
and see if it catch these com errors, If it does then see the error description
|
|
|
|
|
I have a CFile member variable who seems angry with me because doesn't do what I want.
Here's the code
in MyClass.h:
public:
CFile* myFile;
in MyClass.cpp:
CMyClass::CMyClass()
{
myFile = new CFile;
}
CMyClass::~CMyClass()
{
delete myFile;
}
//My class is derived from CPropertyPage
BOOL CMyClass::OnInitDialog()
{
if (myFile->Open("some.file", CFile::modeRead))
{
//Dosomecode
myFile->Close();
}
}
And I get:
Debug Assertion Failed!
// More things
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
// More things
Since I'm learning C++ and I don't understand what is happening, I need somebody to help me and show that stupid file who is the programmer and not to crash again.
Thanks in advance,
|
|
|
|
|
The assertion happens when you delete right?
(2b || !2b)
|
|
|
|
|
Yes, I think so.
The application opens a property page and it crashes when I close it, but if I debug it it goes to HandleMap::DeleteTemp or something like that.
|
|
|
|