-
the object properties!
I am learning windows programming and I have programmed in vb for some months.
In vb, if you want to refer to set the property of an object, you just use a dot between the object and the property like this:
object.name = "blahblahblah"
How can I refer to the properties in C++. Let us say I have a button and I want to set its text to "thisistext" I think that I can use this thing
button.text = "thisistext"
I know that you can change the text with the API like this:
SetWindowText(thehwndofbutton, "thisistext");
Do you always use API to set the property of an object?
2)
How do change the fore and back color of a button. I used this to change the backcolor but it does not work:
SetBkColor(hdcofbutton, (HBRUSH)1);
?????:confused:
-
If you use MFC it is similar to VB
Code:
//m_button - control variable
m_button.SetWindowText("text");
//else use API
-
The Windows API isn't object-oriented so everything is done through API. Even wrappers like MFC, WTL, .NET merely call the API for the dirty work.
-
So
So how do I set the backcolor of the button to blue using the API call-- SetBkColor ?
-
I haven't really tried this, but you need to first set the style to BS_OWNDERDRAW, then whenever the WM_DRAW message is fired, you need to process it by drawing the button yourself, wherein you could use SetBkColor or SetTextColor etc.
-
You can set a variable to that object (using the class wizard) and do something like this
Code:
m_textboxvariable = "ererererertvfc";
// Set the control variable attached to the control
UpdateData (FALSE)
// Update the variable, from code to the control, hence we use false.
//If we wanted to get the value in the textbox,
//we would have to use TRUE as the argument. In Vb, it is a lot easier