Announcement

Collapse
No announcement yet.

DIALOG SHOW STATE does not hide entire dialog

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

  • DIALOG SHOW STATE does not hide entire dialog

    Folks,

    I want to create a system tray application that does not show a dialog.
    I've tried to use 'DIALOG SHOW STATE hDlg, %SW_HIDE', but this does not hide the entire dialog.
    A small vertical bar is 'polluting' my screen. Does someone know how to get rid of this thing?


    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

  • #2
    Are you sure that the problem is not the window behind the dialog that is not being updated 100% correctly? I use DIALOG SHOW STATE hDLG, %SW_HIDE a lot in my own apps, and do not recall seeing this effect.

    The only other thing that comes to mind: If this is a modeless dialog, is your message pump running correctly?

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Lance,

      The window behind the dialog is my green desktop, the vertical bar is gray.
      It is not a modeless dialog, b.t.w., but a modal one. If I use MODELESS, the dialog is totally gone.
      I prefer MODAL, though, because I'm not good at all in writing a proper message pump
      for it. This is what I have, so far:
      Code:
      #COMPILE EXE
      #INCLUDE "WIN32API.INC"
      
      CALLBACK FUNCTION DlgCallBck()
      
        SELECT CASE CBMSG
          CASE %WM_INITDIALOG
            DIALOG SHOW STATE CBHNDL, %SW_HIDE
        END SELECT
      END FUNCTION
      
      FUNCTION PBMain() AS LONG
        LOCAL  hDlg AS LONG
      
        DIALOG NEW 0, "", , , 0, 0 TO hDlg
        DIALOG SHOW MODAL hDlg, CALL DlgCallBck
      
      END FUNCTION
      ------------------
      mailto:[email protected][email protected]</A>
      www.basicguru.com/zijlema/



      [This message has been edited by Egbert Zijlema (edited August 02, 2001).]

      Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
      http://zijlema.basicguru.eu
      *** Opinions expressed here are not necessarily untrue ***

      Comment


      • #4
        Egbert,

        I believe the problem is that you are calling SHOW STATE from
        the WM_INITDIALOG handler.

        Try posting a message to WM_USER+xxx (from WM_INITDIALOG) and
        using the SHOW STATE function in the WM_USER+xxx handler.



        ------------------
        Bernard Ertl
        Bernard Ertl
        InterPlan Systems

        Comment


        • #5
          Egbert --
          A problem is not in Show State as it is, but in DDT design.
          Postmessage doesn't actually prevents short-time appearence.

          Try SDK style, something like below (put this module by any name into a directory with PB tray sample).
          Code:
             #Compile Exe
             #Dim All
             #Register None
             #Resource "TRAY.PBR"
             #Include "WIN32API.INC"
          
             %WM_TRAYICON = %WM_USER + 400
          
             CallBack Function DlgProc
                Static hMenu As Long, ti As NOTIFYICONDATA, p As POINTAPI
                Select Case CbMsg
                   Case %WM_CREATE
                      hMenu = GetSubMenu(LoadMenu(GetModuleHandle(""), "POPUPMENU"), 0)
                      ti.cbSize           = SizeOf(ti)
                      ti.hWnd             = CbHndl
                      ti.uID              = GetModuleHandle("")
                      ti.uFlags           = %NIF_ICON Or %NIF_MESSAGE Or %NIF_TIP
                      ti.uCallbackMessage = %WM_TRAYICON
                      ti.hIcon            = LoadIcon(GetModuleHandle(""), "FACE1")
                      ti.szTip            = "Task Tray Example"
                      Shell_NotifyIcon %NIM_ADD, ti
                      DestroyIcon ti.hIcon
          
                   Case %WM_TRAYICON
                      Select Case LoWrd(CbLparam)
                         Case %WM_LBUTTONDOWN, %WM_RBUTTONDOWN
                            GetCursorPos p
                            Select Case TrackPopupMenu (hMenu, %TPM_RETURNCMD, p.x, p.y, 0, CbHndl, ByVal %NULL)
                               Case 1: MsgBox "Sorry, no info"
                               Case 2: PostMessage CbHndl, %WM_SYSCOMMAND, %SC_CLOSE, 0
                            End Select
                      End Select
                    
                   Case %WM_DESTROY
                      Shell_NotifyIcon %NIM_DELETE, ti
                      PostQuitMessage 0
                End Select
                Function = DefWindowProc(CbHndl, CbMsg, CbWparam, CbLparam)
             End Function
          
             Function PbMain
                Local Msg As tagMsg, wndclass As WndClassEx, szAppName As Asciiz * 80, hWnd As Long
          
                szAppName              = "HelloWin"
                wndclass.cbSize        = SizeOf(WndClass)
                wndclass.lpfnWndProc   = CodePtr(DlgProc)
                wndclass.hInstance     = GetModuleHandle(ByVal 0&)
                wndclass.lpszClassName = VarPtr(szAppName)
                RegisterClassEx wndclass
          
                hWnd = CreateWindow(szAppName, "", 0, 0, 0, 0, 0, 0, 0, wndClass.hInstance, ByVal 0&)
                While GetMessage(Msg, %NULL, 0, 0)
                   TranslateMessage Msg
                   DispatchMessage Msg
                Wend      
             End Function

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

          Comment


          • #6
            Hi folks,

            I think, I have triggered the problem.
            The resistant vertical bar on my desktop seems to be the caption bar in its minimal dimensions.
            This due to the fact that the %WS_CAPTION style appears to be the default style for a dialog.
            Since I explicitely add 'NOT %WS_CAPTION' as a style in the DIALOG NEW statement, the problem is gone.
            Good to know: it makes no difference whether I use ShowWindow (API function) or DIALOG SHOW STATE (DDT)
            to hide the dialog.

            So it's not a DDT-bug, my dear Semen!
            Thanks by the way, for posting Power Basic's Tray Example, which I had already. However, I challenged myself to
            write a systemtray oriented app. in plain DDT.
            Code:
            #COMPILE EXE
            #INCLUDE "WIN32API.INC"
             
            CALLBACK FUNCTION DlgCallBck()
             
              SELECT CASE CBMSG
                CASE %WM_INITDIALOG
                  ' ShowWindow CBHNDL, %SW_HIDE
                  DIALOG SHOW STATE CBHNDL, %SW_HIDE
              END SELECT
            END FUNCTION
             
            FUNCTION PBMain() AS LONG
              LOCAL  hDlg AS LONG
             
              DIALOG NEW 0, "", , , 100, 20, NOT %WS_CAPTION TO hDlg            '
              DIALOG SHOW MODAL hDlg, CALL DlgCallBck
            END FUNCTION


            ------------------
            mailto:[email protected][email protected]</A>
            www.basicguru.com/zijlema/

            Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
            http://zijlema.basicguru.eu
            *** Opinions expressed here are not necessarily untrue ***

            Comment


            • #7
              I think that using just the style "NOT %WS_CAPTION" is not quite doing what you may think... on my Win2K system, the dialog is not actually created so the callback does not trigger. Watch it in Task Manager...

              Try this modified version of your app to see the effect:
              Code:
              #COMPILE EXE
              #INCLUDE "WIN32API.INC"
               
              CALLBACK FUNCTION DlgCallBck()
                SELECT CASE CBMSG
                  CASE %WM_INITDIALOG
                    PostMessage CBHNDL, %WM_USER + 999&, 0, 0
               
                  CASE %WM_USER + 999&
                    DIALOG SHOW STATE CBHNDL, %SW_HIDE
                    BEEP
                    SLEEP 3000
                    DIALOG END CBHNDL, 0
                END SELECT
              END FUNCTION
               
              FUNCTION PBMAIN() AS LONG
                LOCAL  hDlg AS LONG
                DIALOG NEW 0, "", , , 0, 0, NOT %WS_CAPTION TO hDlg
                DIALOG SHOW MODAL hDlg, CALL DlgCallBck
              END FUNCTION
              Try the %WS_POPUPWINDOW style in the above code...
              Code:
                DIALOG NEW 0, "", , , 0, 0, %WS_POPUPWINDOW TO hDlg
              ------------------
              Lance
              PowerBASIC Support
              mailto:[email protected][email protected]</A>
              Lance
              mailto:[email protected]

              Comment


              • #8
                Thank you, Lance.
                %WS_POPUPWINDOW performs the trick.
                This style, however, is not described in the on-line helpfile in connection with 'DIALOG NEW'.
                So, how could I know?

                ------------------
                mailto:[email protected][email protected]</A>
                www.basicguru.com/zijlema/

                [This message has been edited by Egbert Zijlema (edited August 02, 2001).]

                Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
                http://zijlema.basicguru.eu
                *** Opinions expressed here are not necessarily untrue ***

                Comment


                • #9
                  Telepathy?

                  Seriously, the existing documentation does have a few style omissions, but next update to the documentation should hopefully sort out such problems.

                  ------------------
                  Lance
                  PowerBASIC Support
                  mailto:[email protected][email protected]</A>
                  Lance
                  mailto:[email protected]

                  Comment


                  • #10
                    POPUP changes nothing. A window remains visible in OS understanding (look app bar).
                    Code:
                       #Compile Exe
                       #Register None
                       #Dim All
                       #Include "WIN32API.INC"
                    
                       Function PbMain() As Long
                          Local  hDlg As Long
                          Dialog New 0, "", , , 0, 0, %WS_POPUPWINDOW To hDlg
                          Dialog Show Modal hDlg  
                       End Function
                    For me is interesting a nature, why ShowWindow ... SW_HIDE doesn't work on initial step.

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

                    Comment


                    • #11
                      The question related to hiding a dialog, and that the dialog did not hide "correctly"...

                      BTW, I could NOT duplicate the problem where a "portion" of the dialog remained on the screen... Egberts original code did not show up that problem for me (tested under Win2k/SP2).

                      Internally, the DDT engine shows the dialog after the %WM_INITDIALOG message is processed by the callbaack (if one exists). Hence the need to use PostMessage(%WM_USER+) to hide the dialog after the %WM_INITDIALOG message.


                      ------------------
                      Lance
                      PowerBASIC Support
                      mailto:[email protected][email protected]</A>
                      Lance
                      mailto:[email protected]

                      Comment


                      • #12
                        Egbert --
                        > it's not a DDT-bug, my dear Semen!

                        As you can see, Lance confirms -
                        "Internally, the DDT engine shows the dialog after the %WM_INITDIALOG message is processed by the callback"

                        In other words, DDT automatic resets a State after WM_INITDIALOG (BTW, fictive; real already occured as result of Dialog New).
                        This behaviour is known. But "bug" means unexpected result. Here is another case - by design.
                        Probably, in future releases it's better do not touch a state or to give a possibility to specify it in Dialog Show Modal.

                        Summary. One wagon of beer for me, and two wagons for Lance



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

                        Comment

                        Working...
                        X