Announcement

Collapse
No announcement yet.

Simple DDT-Question

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

  • Simple DDT-Question

    Code:
    Is it possible to change a DDT-dialog from Modeless to Modal on the fly?
    or is there some NONO-s involved here
    
    --Example-------- 
       Dialog New %HWND_DESKTOP, "Modless Dialog",,,100,100,Style&,ExStyle& To hDlg&
       ---
       Dialog show modeless hDlg&
       ---more code
       Dialog Doevents
       ---more code
       Dialog show modal hDlg& call DlgProc
    --EndofExample---
      
    If One DDT-dialog have multiple child-dialogs, is this the correct way to
    handle that situation?
     
    --Example----------
       Dialog New %HWND_DESKTOP, "Modal Dialog",,,100,100,Style&,ExStyle& To hDlg&
       Dialog New hDlg&, "Child1", 0, 0,50,100,%WS_CHILD To hDlg1&
       Dialog New hDlg&, "Child2",50, 0,50,100,%WS_CHILD To hDlg2&
       Dialog show modeless hDlg1& call DlgProc
       Dialog show modeless hDlg2& call DlgProc
       Dialog show modal hDlg& call DlgProc
    --EndOfExample-----
      
    [i]Using Dialog Show State instead of Dialog Show Modeless will not paint correctly
    that is, messages seems not to be processed in parent dlgProc[/i]

    ------------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se


    [This message has been edited by Fred Oxenby (edited September 30, 2000).]
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

  • #2
    Fred --
    > Is it possible to change a DDT-dialog from Modeless to Modal on the fly?
    Can't understand a purpose.
    Difference between Modal & Modeless is in DOEVENTS LOOP.
    Make all dialogs Modeless.
    Start initial "parent" dialog - Dialog Show Modeless ...
    Then
    Do
    Dialog DoEvents To Count
    If Count = 0 Then Exit Do
    Loop






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

    Comment


    • #3
      I did that.

      I showed the ddt dialog modelles than after a while (doing some stuff) show it as modal.

      Works OK!

      Visa versa not poss i guess.

      If you want to leave a dialog doevents, just send a wm_quit.
      The pump is left and catched by the following modal loop..


      ------------------
      [email protected]
      hellobasic

      Comment


      • #4
        Between the modeless and modal you'll need suficient doevents.
        There a more messages than one doevents handles.

        The approach is not good is my guess.

        ------------------
        [email protected]
        hellobasic

        Comment


        • #5
          Code:
          Semen, there are a legitime purpose for modeless to modal dialog.
          To show the dialog to the user, before the load-operation is completed.
          There are times when network-operations are so slow, that it is necessary
          to show some action..
          --
          Edvin, yes I use a loop [i]For i& = 1 to 200 :Dialog Doevents:next[/i]
          depending on the expected need for the dialog
          If any work is done in the dialogProc I need to direct that in the
          'Dialog Show Modless hDlg& Call DlgProc' instruction
          --Example two--
          Parent Dialog with multiple child-dialogs
          The question was aimed at PB support.
          The [i]built-in DDT-messagehandler[/i] in PB is supposed to handle all messages for 
          dialogs created in that thread.
          When I need 'child-dialogs' as parent to group of controls I have to show this
          'child-dialog' modeless with a 'call dlgproc' directive.
          (This is required to handle some buttonstyles (AutoRadioButton/pushlike) f.i.)

          ------------------
          Fred
          mailto:[email protected][email protected]</A>
          http://www.oxenby.se



          [This message has been edited by Fred Oxenby (edited October 01, 2000).]
          Fred
          mailto:[email protected][email protected]</A>
          http://www.oxenby.se

          Comment


          • #6
            Fred --
            look this possible way
            Code:
               #Compile Exe
               #Register None
               #Dim All
               #Include "WIN32API.INC"
            
               Global StopFlag As Long, hDlg As Long
               Sub DoQueryEvents
                  Static Msg As tagMsg
                  While PeekMessage(Msg, %NULL, %NULL, %NULL, %PM_REMOVE)
                     If IsDialogMessage (hDlg, Msg) Then
                     Else
                        TranslateMessage Msg
                        DispatchMessage Msg
                     End If
                  Wend
               End Sub
            
               Sub StartModeless
                  Dim i As Long, k As Long
                  StopFlag = 0
                  While StopFlag = 0
                     DoQueryEvents
                     For i = 1 To 1000000: Next
                     Incr k: SetWindowText hDlg, Format$(k)
                  Wend
               End Sub
               
               CallBack Function DlgProc
                  Select Case CbMsg
                     Case %WM_INITDIALOG
                        Control Add TextBox, CbHndl, 101, "", 10, 5, 180, 12
                        Control Add Button,  CbHndl, 102, "Demo Modeless", 10, 25, 80, 12
                        Control Add Button,  CbHndl, 103, "Stop Modeless", 110, 25, 80, 12
                     Case %WM_COMMAND
                        If CbCtl = 102 Then StartModeless
                        If CbCtl = 103 Then StopFlag = 1
                     Case %WM_DESTROY
                        StopFlag = 1  
                  End Select
               End Function
               
               Function PbMain
                  Dialog New 0, "Test", , , 200, 45, %WS_CAPTION Or %WS_SYSMENU To hDlg
                  Dialog Show Modal hDlg Call DlgProc
               End Function
            ------------------
            E-MAIL: [email protected]

            Comment


            • #7
              Code:
              Semen, I am not questioning that it is working...
              I am trying to discuss strict Dynamic Dialog Tools-functions, 
              and understand how PB is expecting us,using this tool, to handle situation 
              where we do need child-dialogs.
              One of this situations are 'SysTabControl32'
              I have almost in every project need for it. (Thats why I am not normally using DDT)
              And since PB does not with one word (almost right) mention dialogs with style=%WS_CHILD
              in its documentation, this matter is 'your guess is as good as mine'
              The only guidance I have found in the help file, but missing in the printed doc is this
               [quote]
              %DS_CONTROL	The (modeless) dialog is able to operate as a child window of a tab control 
              (the parent must be the tab-control’s owner, not the tab control itself).  
              This style permits the TAB key to move from control to control in both the parent and 
              the modeless dialog seamlessly.
              [/quote]
              PB probably intended it to work like my example.But why is it missing from  the printed doc?
              and why am I getting a GPF when using this style %DS_CONTROL
              This GPF happens randomly when using Dialog end on a child dialog  
              This GPF is avoided if I let the parent dialog destroy the child dialog
              --
              As far as I can understand..
               style %DS_CONTROL works as described in help-file.
               PB intended you to be able to 'Dialog New..' with style %WS_CHILD
               With 'Dialog Show Modless hCild Call ChildProc' gave you the option to handle the messages to the child
               With 'Dialog Show Modal hParent Call ParentProc' gave you a message pump and a dialog-handler
              --

              ------------------
              Fred
              mailto:[email protected][email protected]</A>
              http://www.oxenby.se

              Fred
              mailto:[email protected][email protected]</A>
              http://www.oxenby.se

              Comment


              • #8
                I've built quite a few DDT based apps with tab controls. Each modeless dialog that form the "pages" of the tab control should include the %DS_CONTROL style. The parent dialog should also include the extended style %WS_EX_CONTROLPARENT.

                I sent some of my DDT tab control code to a few people about a year ago, and as a result, there have been a number of examples posted to the Source Code forum based on my original code. My usual approach is to use modeless dialogs for the whole thing, not just the tab page dialogs.


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

                Comment


                • #9
                  Code:
                  Thank you Lance, for your replay.
                  I read your documentation. And I notice that either in Help-file
                  nor in printed doc Dialog New statement list %WS_CHILD as a style.
                  All other style is there.
                  %DS_CONTROL is in the Help file, not in the printed Doc.
                  As the printed doc is 'newer' than the help file my interpretation is that
                  it is deliberately REMOVED
                  -------
                  I think It is a legitimate question if PowerBasic regard 
                  Dialog New....,%WS_CHILD or %DS_CONTROL ...
                  Dialog Show Modeless ...call ...
                  as an [b]undocumented feature[/b] of PB/DLL 32 bit compiler
                  meaning [i]Use it your own risk[/i]
                  or if it is [i]only a mistake in the documentation[/i]
                  -------
                  Even if I see others posting code using this technic, and I, myself use it, 
                  It is not evident that it is meant to work.
                  I also in rare circumstances earn some GPF-points,
                  especially when explicit destroy one among several Child-dialogs with DIALOG END statement

                  ------------------
                  Fred
                  mailto:[email protected][email protected]</A>
                  http://www.oxenby.se

                  Fred
                  mailto:[email protected][email protected]</A>
                  http://www.oxenby.se

                  Comment


                  • #10
                    %WS_CHILD is quite "legal".

                    I do not know why it was not included in the doc's, but I'll ask the Documentation Department to add it into the next update. Thanks for pointing it out!

                    BTW, Fred, can you avoid using [code] tags for plain text in your messages? It makes your messages very hard to read and they do not wrap correctly. Thanks!

                    Regarding the occasional GPF... I never experience these in this area, so I have to assume that you have some other problem... if you have an example that can clearly show this, then please post it or send it to me.

                    Thanks!


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

                    Comment

                    Working...
                    X