Thread: Site on Making Common Controls like BUttons

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    69

    Site on Making Common Controls like BUttons

    Can someone tell me how i can make my own custom controls like buttons?

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

    Lightbulb All you do...

    Buttons, editboxes, listboxes, etc. are nothing but child windows of your main window. Here's one for a button:

    //Make this global
    #define ID_MYBUTTON 5000

    in case WM_CREATE:


    CreateWindow(
    "button", // Button class
    "Text", // Button Text
    WS_CHILD | WS_VISIBLE, // Styles
    0, 0, 100, 20, // x pos, y pos, width, height, in pixels
    hwnd, // HWND of main window
    (HMENU)ID_MYBUTTON, // Button ID
    GetModuleHandle(NULL), // HINSTANCE of your application
    0
    );


    in WM_COMMAND:

    /* This will tell you
    if the user clicks
    the button "ID_MYBUTTON"
    */

    case WM_COMMAND:
    switch(LOWORD(wParam))
    {
    case ID_MYBUTTON:
    // Do this
    break;
    }
    break;


    This should work.
    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 xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Well thats kinda correct, if your using buttons your should specify the type of button, like push button, radio button..... So in the style param you would pass BS_PUSHBUTTON for a push button, BS_RADIOBUTTON for a radio button and so on. Look up button styles in MSDN for more info. Aslo if your using buttons you should also specify BS_NOTIFY so that all messages triggered by that button are sent to the parent window's message bandler.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  4. #4
    Registered User Invincible's Avatar
    Join Date
    Feb 2002
    Posts
    210
    "The mind, like a parachute, only functions when open."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making New Site (need games)
    By dayknight in forum Game Programming
    Replies: 5
    Last Post: 02-11-2003, 10:27 PM
  2. common controls
    By neandrake in forum Windows Programming
    Replies: 2
    Last Post: 03-17-2002, 11:52 PM