|
As error indicates, case should be constant, not a variable as in your case. Probably, you wanted to modify your code like this,
class A
{
const FRAME_TYPE FrameType0;
const FRAME_TYPE FrameType1;
enum FRAME_TYPE{EMPTY_FRAME,TABLEVIEW};
AddFrame(const FRAME_TYPE tFrameType);
};
AddFrame(const FRAME_TYPE tFrameType)
{
switch (tFrameType)
{
case EMPTY_FRAME :
int g=1;
break;
case TABLEVIEW :
int g=2;
break;
}
}
|
|
|
|
|
I have created an MFC dockable toolbar, and put a combobox control as the
last element in the toolbar, the toolbar won't size correctly when i dynamically resize it when it is un-docked. I mean, the combobox will not be visible after resize.
Any Solutions.
Thanks
|
|
|
|
|
|
I will try using CalcDynamicLayout().
Thank you very much for nice link.
|
|
|
|
|
|
Programm3r wrote: I know that all perform the same function
They don't.
FIRST checks if functionOne is equal to 0
SECOND and THIRD checks if functionOne is less than 0
I can't see any reason to use THIRD, it's just confusing. Why assign a value from one variable to another, just to check its value? Anyway, the optimizer would omit the assignment, provided that the value of rc and functionOne isn't assigned another value later on in the code.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Programm3r wrote: I know that all perform the same function:
Actually, the above sentence it's not true.
Of course
if (functionOne<0)
...
int rc = functionOne;
if (rc<0)
...
Performs the same (i.e. do things if functionOne return value is less than zero). On the other hand,
if (!functionOne)
...
(i.e. do things if functionOne return value is equal to zero) it's completely different.
That said, I think THIRD it's a bit redundant, but handy to inspect functionOne return value when debugging.
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
CPallini wrote: but handy to inspect functionOne return value when debugging
What's wrong with just putting the cursor on functionOne while debugging?
That will show it's value in VS.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
kakan wrote: What's wrong with just putting the cursor on functionOne while debugging?
There's nothing wrong, of course.
However maybe handy (handy, I repeat), if putting the cursor on functionOne is not that easy (suppose the function is inside a DLL...).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
True. I missed that functionOne is a function, and not a variable.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Thank you for clearing that one up ... So if I understand correctly:
bool a = false;
if (!a)
int b = -2;
if (!b)
CPallini wrote: Hope that helps.
Yes it did, thanks again.
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
Well...
When it comes to bool values, they are defined as this (if I remember it correctly):
false is always 0, zero.
true is any other value, can be -1 (VARIANT_BOOL) or 1 (true, TRUE).
But stricly, if it has got any other value than 0, it's true.
So if you want to follow the rules, while working with bool variables, always test for zero or not zero.
Test for zero/false:
if (!a), or if(0 == a), or if(a == 0)
Test for true:
if (a), or if(0 != a), or if(a != 0)
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
You're a bit confused, anymore.
if b is declared as an int , then
if ( ! b )
{
}
executes the code inside the block if and only if b==0 , because C/C++ consider a non-zero valued int as true (a zero valued int as false ) and ! is the logical negation operator.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Another trap I have seen beginners make is
int b;
if (b == TRUE)
{
}
is different to
if (b)
{
}
.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Actually, both previous answers are wrong: you don't evaluate the result of the function but the address of the function itself.
Oops, you probably wanted to write:
if (!functionOne())
Sorry, I'm tired, stupid joke
|
|
|
|
|
Good point!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Cedric Moonen wrote: // FIRST if (!functionOne())
Sorry ... my bad, forgot to put the "()" in.
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
HI,
How can i get IP adress of my system thru a VC++ application,
thanx in advance..
birajendu
CyberG India
Delhi
India
|
|
|
|
|
you can use GetAdaptersInfo function
|
|
|
|
|
birajendu wrote: How can i get IP adress of my system thru a VC++ application,
Use gethostbyname or getaddrinfo .
|
|
|
|
|
use IPM_GETADDRESS Message
Retrieves the address values for all four fields in the IP address control.
Syntax
To send this message, call the SendMessage function as follows.
lResult = SendMessage( // returns LRESULT in lResult
(HWND) hWndControl, // handle to destination control
(UINT) IPM_GETADDRESS, // message ID
(WPARAM) wParam, // = 0; not used, must be zero
(LPARAM) lParam // = (LPARAM) (LPDWORD) pdwAddr;
);
|
|
|
|
|
How do I enable out-of-bounds memory checking for dynamically allocated memory (new/delete) in VC++ 2003? /RTC options enable stack-based checks, which I've got turned on, but that doesn't cover heap-based allocations.
|
|
|
|
|
Simply you cannot (AFAIK).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Well, I was hoping for a configurable option. Overloading operator new and delete is my backup plan, which will work because I only use new/delete.
|
|
|
|
|
Can you do that?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|