CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    23

    disabling pushbutton through code

    Hi,
    how to disable a push button control through code. If anyone knows please inform. Thank you bye.


  2. #2
    Join Date
    May 1999
    Location
    WA
    Posts
    65

    Re: disabling pushbutton through code

    Assuming that the button's control ID is IDC_MYBUTTON, you can do the following:

    GetDlgItem(IDC_MYBUTTON)->EnableWindow(FALSE);

    If you want to completely hide the button from view, you can do this:

    GetDlgItem(IDC_MYBUTTON)->ShowWindow(SW_HIDE);

    And to restore the button to view, do this:

    GetDlgItem(IDC_MYBUTTON)->ShowWindow(SW_SHOW);


    Hope this helps! Good luck!



    - Troy

  3. #3
    Join Date
    Apr 1999
    Location
    Frankfurt, Germany
    Posts
    113

    Re: disabling pushbutton through code

    Hi,
    connect Your button with a member variable of Your dialogclass (assuming You're using a dialog...) and call ModifyStyle(0, WS_DISABLED). The next time the button is drawn, it is drawn as disabled (You might want to redraw it immediately, because until then it IS disabled even if it doesn't look so).
    HTH
    Rudolf


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured