|
-
May 1st, 2001, 05:54 PM
#1
Thread Starter
PowerPoster
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);
?????
-
May 2nd, 2001, 09:01 AM
#2
Frenzied Member
If you use MFC it is similar to VB
Code:
//m_button - control variable
m_button.SetWindowText("text");
//else use API
-
May 2nd, 2001, 12:31 PM
#3
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 2nd, 2001, 04:34 PM
#4
Thread Starter
PowerPoster
So
So how do I set the backcolor of the button to blue using the API call-- SetBkColor ?
-
May 2nd, 2001, 06:06 PM
#5
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.
-
May 3rd, 2001, 01:04 AM
#6
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|