Announcement

Collapse
No announcement yet.

Control Enable/Disable Efficiency

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

  • Control Enable/Disable Efficiency

    How efficient are the DDT Control Enable/Disable (or the API EnableWindow if you please)
    functions in terms of message generation? IOW, if I send a CONTROL ENABLE to a DDT
    control that is already enabled, does Windows ignore the message or does it process
    it oblivious to the current control state?

    Thanks!

    ------------------
    Mark Newman
    Mark Newman

  • #2
    The messages will always be passed along. Windows can't afford to make
    any assumptions about the state of the window (and, if you think about
    it, there would be even more overhead involved if Windows had to check
    the value first).

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Comment


    • #3
      Thanks Tom, that's about what I expected. I had hoped that with the multitude of
      details that Windows keeps for a window (style bits for example) that it might
      have included a hidden "enabled" bit.

      I'll ask Bill about this the next time I see him.


      ------------------
      Mark Newman
      Mark Newman

      Comment


      • #4
        Mark, tell him I'd like a word with him too...
        Zippety Software, Home of the Lynx Project Explorer
        http://www.zippety.net
        My e-mail

        Comment


        • #5
          WS_DISABLED bit


          ------------------
          E-MAIL: [email protected]

          Comment


          • #6
            Mark --

            > if I send a CONTROL ENABLE to a DDT control...

            CONTROL ENABLE is a function, so your program doesn't really "send a CONTROL ENABLE", and I think that phrasing may have confused the issue a little bit. Tom's comments are pertinent to any message that is sent to a control, but I suspect that CONTROL ENABLE uses the EnableWindow API internally, not SendMessage... WM_ENABLE. The Win32.HLP file says that the EnableWindow API is smart about controls that are already in the desired state...

            If the enabled state of a window is changing, a WM_ENABLE message is sent before the EnableWindow function returns.

            You might want to check MSDN for updated wording, but I think you'll find that EnableWindow works in the way you originally described.

            -- Eric


            ------------------
            Perfect Sync Development Tools
            Perfect Sync Web Site
            Contact Us: mailto:[email protected][email protected]</A>

            [This message has been edited by Eric Pearson (edited June 26, 2001).]
            "Not my circus, not my monkeys."

            Comment


            • #7
              Eric,

              I thought that CONTROL ENABLE was just a wrapper around GetDlgItem() and EnableWindow(),
              but perhaps not. When I ran my app using CONTROL ENABLE the controls were flickering
              on every timer event (I have a 500 mS Timer that checks a number of conditions and
              enables/disables UI elements as needed). I then implemented an array that holds the
              state of the controls and first checks if the control is changing state before using a
              CONTROL ENABLE/DISABLE, but it added 75% more code to the function and is icky to look
              at besides!

              Update
              I tried using GetDlgItem() & EnableWindow() and it works fine without flickering.

              Thanks!

              ------------------
              Mark Newman



              [This message has been edited by Mark Newman (edited June 26, 2001).]
              Mark Newman

              Comment


              • #8
                ...icky to look at besides!
                Is 'icky' one of those technical terms I should learn if I want to make it as a programmer?

                MCM

                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Duh, why didn't I think of this earlier...

                  Code:
                  The IsWindowEnabled function determines whether the specified window is enabled for mouse and keyboard input. 
                  
                  BOOL IsWindowEnabled(
                  
                      HWND  hWnd 	// handle of window to test
                  MCM



                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Is 'icky' one of those technical terms I should learn if I want to make it as a programmer?
                    Yes, but only if you promise never to use the word "robust" when describing code.

                    ------------------
                    Mark Newman

                    [This message has been edited by Mark Newman (edited June 26, 2001).]
                    Mark Newman

                    Comment

                    Working...
                    X