Announcement

Collapse
No announcement yet.

Dialog Disabled?

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

  • Dialog Disabled?

    Hi,

    My program calls print routines from 2 different dialogs that are
    both created and running. One or the other is disabled while the
    other does it's thing.
    Need to know which one is NOT disabled, for a "Dialog redraw hDlg"
    or "Dialog redraw hDlg54".
    This msgbox: ? "hDlg= "+str$(hDlg)+" hDlg54= "+str$(hDlg54),
    returns numbers: 5111992 and 1835468. What do they mean?
    Can one tell which dialog is active and which one is "Disabled"?
    Can use a global flg variable to tell routine, which dialog called
    it, but was wondering if better way?

    Thanks,

    Brent

  • #2
    IsWindowEnabled?
    Regards,
    Peter

    "Simplicity is a prerequisite for reliability"

    Comment


    • #3
      Peter,

      Thanks for responding so quickly. Doesn't work for me?
      I Get 0 whether disabled or enabled 1=enabled, 0=disabled
      Visible = IsWindowVisible(GetDlgItem(hWnd, hDlg54)) 'hDlg)) '(hDlg, id&))
      ? "Visible= "+STR$(visible) ' = 0 - 1=enabled, 0=disable
      Enabled = IsWindowEnabled(GetDlgItem(hWnd, hDlg54)) 'hDlg)) '(hDlg, id&))
      ? "Enabled= "+STR$(Enabled)

      Comment


      • #4
        Or - assuming the 'active' dialog is the one which called the printing function - pass the CBHNDL of the dialog to the printing function, then you don't even have to know...

        Code:
        FUNCTION PrintingFunction (BYVAL hDlg AS LONG, other params) 
        
        ....
          DIALOG REDRAW hDlg
        END FUNCTION
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Doesn't work for me?
          You will need to change your code.

          I would say your visible code check fails as well.

          You should not be using GetDlgItem for actual dialogs. GetDlgItem should only be used when you do not have the Window Handle to a control. hDlg (or CBHNDL) is actually a valid Windows Handle.
          Adam Drake
          PowerBASIC

          Comment


          • #6
            Adam,

            Thanks, I was looking at wrong example. The following code
            seems to work correctly. Sometimes though, both dialogs are
            enabled, but ofcourse only 1 showing. Is it still OK to do
            a "Dialog redraw" for both dialogs?

            rem 1=enabled, 0=disabled
            Enabled = IsWindowEnabled(hDlg54)
            ? "Enabled 54= "+STR$(Enabled)
            IF Enabled = 1 THEN
            DIALOG REDRAW hDlg54
            END IF
            Enabled = IsWindowEnabled(hDlg)
            ? "Enabled= "+STR$(Enabled)
            IF Enabled = 1 THEN
            DIALOG REDRAW hDlg
            END IF

            Thanks,

            Brent

            Comment


            • #7
              Won't hurt anything, but could cause a little bit of 'flicker'. Why do you need to redraw the entire dialog?
              Adam Drake
              PowerBASIC

              Comment


              • #8
                Adam,

                Using "Visible" instead of enable. Below code works.

                rem Test Visible Dialog
                Visible = IsWindowVisible(hDlg54)
                rem ? "Visible hDlg54= "+STR$(visible) ' = 0 - 1=visible, 0=not visible
                IF Visible = 1 THEN
                DIALOG REDRAW hDlg54
                ELSE
                rem Visible = IsWindowVisible(hDlg)
                rem ? "Visible hDlg= "+STR$(Visible)
                DIALOG REDRAW hDlg
                END IF

                After further testing, don't really need "Dialog redraw". The problem is from popup dialogs for selecting printer and tray options and other message boxes.
                If user presses the <enter> key(to execute a OK button), it leaves a "Black Shadow" on maindialog. The solution for my program which uses a keyhook, is to simply use a global variable that tells the keyhook function, if the <enter> key is pressed, keypress equals 32 <spacebar>. This does away with shadow caused
                by pressing the <enter> key.

                Comment


                • #9
                  If user presses the <enter> key(to execute a OK button), it leaves a "Black Shadow" on maindialog
                  The "black shadow" thing almost sounds like you are trying to do too much whilst processing a message and not doing it in another thread of execution.

                  Except I usually get a "white empty box" when I do that.
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    I've seen that problem before, and if memory serves, it had something to do with either handling (or NOT handling) something along the lines of WM_PAINT, or erase background (or a function similar).

                    So you may want to check your code there.
                    Engineer's Motto: If it aint broke take it apart and fix it

                    "If at 1st you don't succeed... call it version 1.0"

                    "Half of Programming is coding"....."The other 90% is DEBUGGING"

                    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                    Comment

                    Working...
                    X