Announcement

Collapse
No announcement yet.

Invisible child dialog in DDT

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

  • Invisible child dialog in DDT

    The following child dialog is not visible. Why is that?

    Regards
    Peter
    Code:
        DIALOG NEW hDlg, "",425,5,141,14,%WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS TO hChildDlg       
        CONTROL ADD COMBOBOX, hChildDlg, %IDC_COMBO, sTitle(),0,0, 140, 300, %CBS_DROPDOWNLIST OR %CBS_SORT
        DIALOG SHOW MODELESS hChildDlg CALL DlgProc
     
        ' Message pump
        DO : DIALOG DOEVENTS : LOOP

  • #2
    Peter --
    test x, y in Dialog New. x & y here are offsets in client area of parent dialog, but not screen coordinates.
    If x, y are outside of client area of parent's dialog the child is invisible.
    Take 0, 0 from the beginning.


    [This message has been edited by Semen Matusovski (edited March 07, 2000).]

    Comment


    • #3
      Semen,
      That's not the explenation. The following works OK:

      DIALOG NEW hDlg, "",425,5,141,14,%WS_POPUP TO hChildDlg

      Regards
      Peter

      ------------------

      Comment


      • #4
        Sorry Peter, but Semen is correct.

        In your second example, you're not making the dialog a child so the coordinates are "screen" coordinates. When you make a dialog a child of another window then the coordinates are based on the parent, not the screen.

        --Dave


        ------------------
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Home of the BASIC Gurus
        www.basicguru.com

        Comment


        • #5
          Then the following should work:

          DIALOG NEW hDlg, "",425,5,141,14,%WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS TO hChildDlg

          It does not.

          I should tell that hDlg is a handle to the window of a running application (actually Textpad). I'm trying to add a dialog with a combobox to an existing application. If I make it a popup dialog it works. But if i move Textpad, the dialog is not moving along. The solution is of course to make a child dialog. But i have no luck with that.

          My first strategy was to add the combobox-control directly to Textpad:

          CONTROL ADD COMBOBOX, hTextpad, %IDC_COMBO, sTitle(), 0, 0, 140, 300, %CBS_DROPDOWNLIST OR %CBS_SORT CALL ComboProc

          but that gave a GPF.

          Regards
          Peter


          ------------------

          Comment


          • #6
            Peter --
            I imagine this process approx. so (very dirty code)
            Code:
            #Compile Exe
            #Dim All
            #Register None
            #Include "Win32Api.Inc"
            
            CallBack Function ComboProc
             
            End Function
            
            CallBack Function DlgProc
               Select Case CbMsg
                  Case %WM_Paint
                    
                  Case %WM_ERASEBKGND
                     Function = 1: Exit Function
               End Select
            End Function
            
            Function PbMain()
               Dim x As Long, y As Long, hChildDlg As Long, hDlg As Long, nTest As Long, hfw As Long
               y& = Shell ("G:\Program Files\Windows NT\Accessories\Wordpad.exe") ' On my PC
               For nTest = 1 To 100
                  hDlg = FindWindow(ByVal 0, "Document - WordPad")
                  If hDlg <> 0 Then Exit For
                  Sleep 100
               Next
               If hDlg = 0 Then MsgBox "Not found": Exit Function
               Dim tRect As Rect
               GetClientRect hDlg, tRect
               %IDC_COMBO = 105
               
               Dim sTitle(1 To 3) As String: sTitle(1) = "Power": STitle(2) = "Basic": STitle(3) = "Dll"
               Dialog New hDlg, "", 0, 0, 0, 0, %WS_CHILD Or %WS_VISIBLE Or %WS_CLIPSIBLINGS To hChildDlg
               Dialog Units hChildDlg, 150, 12 To Pixels x&, y&
               SetWindowPos hChildDlg, 0, tRect.nRight - x&, tRect.nTop, x&, y&, 0
               Control Add ComboBox, hChildDlg, %IDC_COMBO, sTitle(), 0, 0, 150, 100, %WS_VISIBLE Or %CBS_DROPDOWNLIST Or %CBS_SORT Call ComboProc
               Dialog Show Modeless hChildDlg Call DlgProc
               Do
                 Dialog DoEvents
                 Dialog Get Size hDlg To x&, y&
                 If x& = 0 Then Exit Do
                 Dialog Get Size hChildDlg To x&, y&
                 If x& = 0 Then Exit Do
              Loop
            End Function
            [This message has been edited by Semen Matusovski (edited March 08, 2000).]

            Comment


            • #7
              Thanks Semen! The Dialog Units/SetWindowPos-lines solved the problem.

              Regards
              Peter


              ------------------
              [email protected]
              www.dreammodel.dk

              Comment


              • #8
                Peter --
                Look last variant - it's better.
                If I understand you correct, you want to demonstrate documents ?
                (I think about using Word to demonstrate text + graphic).

                ------------------

                Comment

                Working...
                X