Thread: buttons

  1. #1
    Registered User canine's Avatar
    Join Date
    Sep 2001
    Posts
    125

    Smile buttons

    If you make a button in createwindow() function how can you tell if it has been pressed also is there any way to have a button title be a icon/bitmap?
    In a perfect world every dog would have a home and every home would have a dog.
    Visit My Web Site, Canine Programming
    I use Win32 API

  2. #2
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Post You do this...

    Before anything:

    #define ID_OF_BUTTON 23

    And when you create the button use the (HMENU):

    CreateWindow(
    "button",
    "Text",
    WS_CHILD | WS_VISIBLE,
    0, 0,
    100, 20,
    hwnd,
    (HMENU)ID_OF_BUTTON,
    0,
    NULL
    );

    Where you have the break; from WM_CREATE:, do this:

    case WM_COMMAND:
    switch(LOWORD(wParam))
    {
    case ID_OF_BUTTON:
    // Do what you want in here when the button is pressed
    break;
    }
    break;

    I HOPE THIS HELPS!
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  3. #3
    Registered User canine's Avatar
    Join Date
    Sep 2001
    Posts
    125
    Thank You! Now just about the picture on a button thing.
    In a perfect world every dog would have a home and every home would have a dog.
    Visit My Web Site, Canine Programming
    I use Win32 API

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I would check the 'resource.h' file to ensure that the value I defined for the button will not clash with the number ID's the compiler is going to/has assigin.
    This file contains all the resouce editors control ID's hash defined.

    Here is a section of a resource.h from MSVC

    #define IDS_LIST 50006
    #define IDS_LISTVIEW 50007

    // Next default values for new objects
    //
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_NEXT_RESOURCE_VALUE 125
    #define _APS_NEXT_COMMAND_VALUE 40050
    #define _APS_NEXT_CONTROL_VALUE 1007
    #define _APS_NEXT_SYMED_VALUE 101

    The controls (ie buttons ect ) are in the 1000's. I would use 2000's for mine.

    SyntaxBubble's hwnd is the HWND of the parent window.
    To this windows callback the msg generated by the button will be sent (if you have more than one callback).

    Bitmaps/icons are possible but require you to process WM_PAINT and use HDC's.
    "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

  5. #5
    Registered User canine's Avatar
    Join Date
    Sep 2001
    Posts
    125
    So you mean create an hdc from the button hdc just like it was the main window? I undestand now! Thank You!
    In a perfect world every dog would have a home and every home would have a dog.
    Visit My Web Site, Canine Programming
    I use Win32 API

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, 01:21 PM
  5. Grouping radio buttons
    By Bazz in forum Windows Programming
    Replies: 1
    Last Post: 08-28-2001, 07:15 AM