CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2001
    Location
    County Durham, England
    Posts
    238

    API Calls - Check if a Button is Enabled/Disabled

    Afternoon All,

    Probably a simple answer but I cannot seem to find it 8-(

    I want to check if a button on a dialog is Enabled or Disabled, I'm nearly There...

    I've located the Dialog Window, found the handle for the button and I can simulate the button click all using API. But I need to check whether the btton is Enabled before I simulate the button click.

    Does anybody know how to check the buttons enabled property in API once you have the handle ?

    Cheers

    Ken

  2. #2
    Join Date
    Mar 2001
    Location
    County Durham, England
    Posts
    238

    Re: API Calls - Check if a Button is Enabled/Disabled

    Its ok I found it !

    Private Declare Function IsWindowEnabled Lib "user32.dll" (ByVal hwnd As Long) As Long


  3. #3
    Join Date
    Dec 2003
    Location
    Northern Ireland
    Posts
    1,362

    Re: API Calls - Check if a Button is Enabled/Disabled

    EnableWindow should do the enabling for you, and IsWindowEnabled can check if the button is enabled or not. Both are members of User32.

    HTH

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: API Calls - Check if a Button is Enabled/Disabled

    '****
    As not said: tested again - iswindowenabled worked
    just fine!!
    '****
    Or you can try with GetwindowLong
    but you might have to find out if the byte I test
    for Vb CommandButton is the same for the control
    of the software you are looking at - as it might not
    be the same...

    Let us know if any solution works (I tried the
    IsWindowEnabled but it does not seem to work...)
    Attached Files Attached Files
    Last edited by Cimperiali; November 26th, 2004 at 10:24 AM.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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