Very easy I think....

Hi experts...
Some time I see some code that I don't understand...

I love program on windows directly in MSVC++ without MFC.

Well... What does it mean... It is in the code that defines the class window to be registered.
Keep in mind that wcex is a WNDCLASSEX type variable

wcex.lpfnWndProc =(WNDPROC)WndProc;
WndProc is the name of the function that process the msgs.

wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW+1)
wcex.lpszMenuName = (LPCSTR)IDC_MENU;

IDC_MENU is a menu resourse ID.

Can any one explain to me what is the meaning of those "(SomeThing)"
I see things like that everywhere but I don't know how to use it.

I know use the parenthesys in theese situation if (), for (), function (){}But I'm not sure how do they work in thinks like this

something = (OtherThing)AnotherThing.

And where else can I use this kind of code?

Can any C++ expert explain to me?.
Thanks.

LVL 1
MarscAsked:
Who is Participating?
 
olgatConnect With a Mentor Commented:
This (SomeThing) is called typacasting or type cast conversion.
You can find a lot explanations about typecasting in VC documentation.

In brief,
"A type cast provides a method for explicit conversion of the type of an object in a specific situation."
"Casts can be used to convert objects of any scalar type to or from any other scalar type"

I.e. in your example conversion from common HANDLE to the handle of a specific HBRUSH type etc.

Because typecasting is done at the compilation time it is a dangerous thing. You can apply it only when you are absolutely sure, that the type you are converting from and the type you are converting to are fully compatible.

See articles
Cast Operators
Conversions from Other Types
Type Conversions
Type-Cast Conversions

to finf more staff about it, it is a big ussue.
Don't hesitate to ask additional questions.
0
 
MarscAuthor Commented:
Edited text of question.
0
 
MarscAuthor Commented:
Edited text of question.
0
 
MarscAuthor Commented:
Thanks...
I'm using Type Casting now... It is very usefull...

0
 
MarscAuthor Commented:
Thanks...
I'm using Type Casting now... It is very usefull...

0
All Courses

From novice to tech pro — start learning today.