deleting buttons

This is a discussion on deleting buttons within the Windows Programming forums, part of the Platform Specific Boards category; iif i have a button on the screen that paints a rectangle over it once it's clicked i noticed you ...

  1. #1
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161

    deleting buttons

    iif i have a button on the screen that paints a rectangle over it once it's clicked i noticed you can still click on the spot and the button will appear. Is there anyway of deleting buttons, so that it can't be clicked again.
    I started out with nothing and I still have most of it left.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Check out EnableWindow().

    Kuphryn

  3. #3
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161
    how do i use it
    I started out with nothing and I still have most of it left.

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    EnableWindow(hwnd);

    hwnd is the hwnd of the button... but that will only make the button disabled and not gone..

    i think that maybe:

    ShowWindow(hwnd, SW_HIDE);

    should work better.. use SW_SHOW to show it again

  5. #5
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161
    it doesn't seem to work. Do i put it in WM_COMMAND:
    I started out with nothing and I still have most of it left.

  6. #6
    Registered User
    Join Date
    Jul 2004
    Posts
    5
    I think also you can use

    getdlgitem(hwnd)->EnableWindow(false)

    I am not sure of it .. anyone correct me if i am not right

  7. #7
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    EnableWindow takes 2 parameters:

    Code:
    EnableWindow( hwndButton, FALSE ); // disable your button
    To get rid of the button altogether, use DestroyWindow.

    Code:
    DestroyWindow( hwndButton ); // this destroys your button

  8. #8
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161
    it doesn't seem to delete them. Am i suppsoed to be putting them in WM_COMMAND:
    I started out with nothing and I still have most of it left.

  9. #9
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    it doesn't seem to delete them. Am i suppsoed to be putting them in WM_COMMAND
    Put it wherever you want, as long as the window handle you're passing is valid.

  10. #10
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    oh yeah sorry about that, EnableWindow does take two parameters..

  11. #11
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    EnableWindow() will make the control not respond to user input but still be visible (appear 'greyed').

    ShowWindow will make a control/dialog appear or disappear (and not respond if hidden).

    >>if i have a button on the screen that paints a rectangle over it once it's clicked

    Instead of painting the rectangle (in the WM_COMMAND, BN_CLICKED handler for IDC_THIS_BUTTON)

    I would hide the button

    ShowWindow( GetDlgItem(hWnd, IDC_THIS_BUTTON), SW_HIDE);
    "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

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