Buttons

This is a discussion on Buttons within the Windows Programming forums, part of the Platform Specific Boards category; Hi, New to the world of Windows programming, im using MSVC++6 and i would like to know how to make ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    34

    Question Buttons

    Hi, New to the world of Windows programming, im using MSVC++6 and i would like to know how to make the buttons that you see on others software, the ones that are rounded at the edges and have an orange border around them when the mouse passes over them as aposed to the standard (flat) buttons?
    Do i need VC.net to do this?

    Also, how do you make roll over buttons that turn pale blue on mouse over like in MS word?

    See images:

    Regs,

    joe
    #
    http://www.kybert.com/buttons1.jpg
    http://www.kybert.com/buttons2.jpg

  2. #2
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I WANT THIS!!
    sorry, mommy can't afford to buy this for you...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    34

    sorry, mommy can't afford to buy this for you...
    So you cant do it either then! Beleive me, any software i need to do it, the company will pay for. ANYTHING!

    Joe
    #

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    draw a bitmap where the button should be, catch any wm_mousemove messages and check if the mouse is over the bitmap. If it is, set a bool to true; otherwise set it to false. If the bool is true, draw the bitmap with orange edges, otherwise draw it with blue. Then catch any wm_lmousedown messages and see if the bool is true; if it is, do what the button should have done.

    That is the method I would use off the top of my head; there's probably a better way but I don't care because I'm using windows98 and not XP. IF you're using windows98, you might as well give up on the standard way because 98 doesn't have those buttons. So if you're using 98 use the bitmaps; don't blame me if it doesn't work, because you're a n00b and couldn't do any better anyways.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    Check this site out: http://www.codejock.com/
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    34
    That's great!

    Cant get the eval version to work, but when i do, will purchase!

    Are there any other options before i do?

    joe
    #

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Whenever a button is going to be drawn, Windows sends a WM_CTLCOLORBTN message to the parent. Intercept it and you can fiddle with the colours before it gets drawn - this is fairly easy.

    A second, more flexible way is to use "owner draw" buttons where you can pretty much do whatever you like, but if you are new, I would avoid this for the time being.

    Making buttons non-standard is not generally a good idea. The whole point of a standard UI is that users not familiar with your application will know that THAT is a button, I can click it - if it doesn't look like a button, they could be sitting there scratching their head.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>Whenever a button is going to be drawn, Windows sends a WM_CTLCOLORBTN message to the parent. Intercept it and you can fiddle with the colours before it gets drawn - this is fairly easy.<<

    From 'Programming Windows 5th ed. by C. Petzold(p375):
    Here's the problem with WM_CTLCOLORBTN: only the push buttons and owner-draw buttons respond to the parent window processing of the message using the brush for coloring the background. This is fairly useless because the parent window is responsible for drawing owner-draw buttons anyway.
    Sorry for the pedantry but I recall having a hell of a time trying to get something to happen with WM_CTLCOLORBTN, thinking all the time it was something I was doing wrong until I read that paragraph from Petzold.

  9. #9
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    The "I WANT THIS ->" button in this picture:
    http://www.kybert.com/buttons1.jpg

    Is the standard Windows XP Button, there has to be some way to get them without using bitmaps, (MS didnt use bitmaps, unless they have some sort of:

    if(os == WinXP)
    // draw cool button
    else
    // draw normal one
    )
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  10. #10
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    They do though.

    Lots of the way windows apps looks / reacts are to do with the OS version and the versions of the dlls installed. eg EnumPrinters() uses different structures depending on OS version.

    Don't your apps use GetVersionEx() to determine how they will act?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  11. #11
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    ...um...sure they do - are you kidding? /*...furiously typing...*/

    Naw I just ship it jist like MS does - no compatibility expressed or implied
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 04-09-2009, 02:31 AM
  2. Ownerdraw buttons (2)
    By maes in forum Windows Programming
    Replies: 7
    Last Post: 09-11-2003, 05:50 AM
  3. Radio Buttons in Visual C++ 6
    By Ripper1 in forum Windows Programming
    Replies: 22
    Last Post: 05-16-2003, 07:54 AM
  4. (Ken Fitlike) buttons
    By jdinger in forum C++ Programming
    Replies: 4
    Last Post: 03-15-2002, 12:21 PM
  5. Grouping radio buttons
    By Bazz in forum Windows Programming
    Replies: 1
    Last Post: 08-28-2001, 07:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21