Announcement

Collapse
No announcement yet.

Determing the Enabled or Disabled State of a Control

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Determing the Enabled or Disabled State of a Control

    Is it possible to determine programmatically if a control is enabled or disabled?

    CONTROL SHOW STATE does not provide this information as the attached code snippet demonstrates:

    Code:
        CONTROL SHOW STATE hDlg, %Input105, %SW_SHOWNOACTIVATE TO i
        CONTROL SHOW STATE hDlg, %Input106, %SW_SHOWNOACTIVATE TO j
        
        ?"In 1 State: " + FORMAT$(i) + $CR + "In 2 State: " + FORMAT$(j),,"State of In 1 and In 2"
    If you enable %Input105 and disable %Input106 and then call the above code the values of i and j (both are defined as DWORD) will be the same. I would have expected the values of i and j to be different.

  • #2
    Code:
    If IsTrue IsWindowEnabled( GetDlgItem(hDlg, %Input105) ) Then
       ' Enabled
    Else
      ' Not Enabled
    End If
    Paul Squires
    FireFly Visual Designer (for PowerBASIC Windows 10+)
    Version 3 now available.
    http://www.planetsquires.com

    Comment


    • #3
      Visible/Not Visible is not the same as enabled/disabled. Two different things.
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        It certainly pays for programmers to invest some time in learning basic Win API functions. It can make life so much easier. IsWindowEnabled / IsWindowVisible.

        Code:
        If IsTrue IsWindowVisible( GetDlgItem(hDlg, %Input105) ) Then
           ' Enabled
        Else
          ' Not Enabled
        End If
        Paul Squires
        FireFly Visual Designer (for PowerBASIC Windows 10+)
        Version 3 now available.
        http://www.planetsquires.com

        Comment


        • #5
          Many Thanks gentlemen!

          Comment


          • #6
            Many Thanks gentlemen! The IsWindowEnabled function solved the problem.

            Comment

            Working...
            X