Is there a simple answer?

This is a discussion on Is there a simple answer? within the C++ Programming forums, part of the General Programming Boards category; Hi i'm trying to input a question in a window program. The box can either be pressed or not pressed ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    28

    Is there a simple answer?

    Hi i'm trying to input a question in a window program. The box can either be pressed or not pressed but how do i find out what state it is in (pressed or not). I got some help from another web page but the example they gave me only let you tick the box and untick it:
    //create a push button
    CreateWindowEx(0, //more or 'extended' styles
    TEXT("BUTTON"), //'class' of control to create
    TEXT("PUSH BUTTON"), //the control caption
    WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, //control style: how it looks
    10, //control position: left
    50, //control position: top
    200, //control width
    30, //control height
    hwnd, //parent window handle
    NULL, //control's ID
    hInst, //application instance


    Please Help.
    Thanks Jamazon
    ...

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    If you're creating a button with the above code, then it will send a WM_COMMAND message with the buttons id as the WPARAM whenever it's pushed. If you want to check for this then you'll have to give it an id when creating it -

    CreateWindowEx(0, //more or 'extended' styles
    TEXT("BUTTON"), //'class' of control to create
    TEXT("PUSH BUTTON"), //the control caption
    WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, //control style: how it looks
    10, //control position: left
    50, //control position: top
    200, //control width
    30, //control height
    hWnd, //parent window handle
    (HMENU)1, //control's ID
    hInst,0); //application instance

    and then test for it being pushed with -

    case WM_COMMAND:
    switch(wParam)
    {
    case 1: //Do something
    break;//etc
    }
    zen

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    28

    Thanks

    How do i know what state the button is in, toggled on non-toggled. The example above will work when you just press the button on or off, how do I do it so that it works only when the button is on?
    ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tic Tac Toe program...
    By Kross7 in forum C++ Programming
    Replies: 12
    Last Post: 04-12-2007, 03:25 PM
  2. simple question, anyone can answer me..
    By jayhor in forum C++ Programming
    Replies: 6
    Last Post: 11-01-2006, 04:20 AM
  3. simple 2d "putpixel" api for windows?
    By spiky in forum C Programming
    Replies: 2
    Last Post: 10-27-2005, 02:44 PM
  4. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 02:00 AM
  5. Simple simple graphics
    By triplem in forum C Programming
    Replies: 2
    Last Post: 05-19-2003, 02:52 AM

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