Thread: Button Styles

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

    Button Styles

    Hello, I was wondering how to change the style of a button once the program running?

    Lets say I have a button on a dialog box (made with a resource editor), and I want to have the button be Disabled (grey'd out) until a certain condition is met, at which point I want the button to be usable again.

    Something like

    SendMessage(hButton, BS_DISABLE, 0, 0);

    or something like it (what I wrote isn't real to my knowledge).

    Any idea how to change the Disable flag on buttons? Thanks.
    -Grunt (Malek)

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    The API function you want is EnableWindow.
    BOOL EnableWindow(

    HWND hWnd, // handle to window
    BOOL bEnable // flag for enabling or disabling input
    );
    Parameters

    hWnd

    Identifies the window to be enabled or disabled.

    bEnable

    Specifies whether to enable or disable the window. If this parameter is TRUE, the window is enabled. If the parameter is FALSE, the window is disabled.

    Return Values

    If the window was previously disabled, the return value is nonzero.
    If the window was not previously disabled, the return value is zero. To get extended error information, call GetLastError.
    What you can do is call it like this for a dialog button:
    Code:
    EnableWindow(GetDlgItem(hWnd, ID_BUTTON), 0);
    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

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

    EnableWindow

    Alright, thanks. EnableWindow works perfectly.

    Originally posted by sean345
    The API function you want is EnableWindow.


    What you can do is call it like this for a dialog button:
    Code:
    EnableWindow(GetDlgItem(hWnd, ID_BUTTON), 0);
    - Sean
    -Grunt (Malek)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. elliptical button
    By geek@02 in forum Windows Programming
    Replies: 0
    Last Post: 11-21-2006, 02:15 AM
  2. Win32 API , Windows XP Button styles
    By Rare177 in forum Windows Programming
    Replies: 12
    Last Post: 06-28-2006, 05:28 PM
  3. writing text over a deleted button
    By algi in forum Windows Programming
    Replies: 4
    Last Post: 05-02-2005, 11:32 AM
  4. Button Styles (Specifically Pushbutton)
    By Zeusbwr in forum Windows Programming
    Replies: 4
    Last Post: 04-10-2005, 07:54 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM