Results 1 to 6 of 6

Thread: the object properties!

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Wink 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);

    ?????
    Baaaaaaaaah

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    If you use MFC it is similar to VB
    Code:
    //m_button - control variable
    m_button.SetWindowText("text");
    //else use API
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  4. #4

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Post So

    So how do I set the backcolor of the button to blue using the API call-- SetBkColor ?
    Baaaaaaaaah

  5. #5
    Megatron
    Guest
    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.

  6. #6
    New Member
    Join Date
    May 2001
    Posts
    2
    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
    Programming For Ever

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width