No announcement yet.

Question about DDT ZOrder ????????

  • Filter
  • Time
  • Show
Clear All
new posts

  • Question about DDT ZOrder ????????

    I need a explanation of how DDT determines the ZOrder of controls.

    I am used to SDK style coding and with CreateWindowEx the Tab Order and the ZOrder (depth of controls in relation to each other) are the exact same thing. The controls Tab order is defined by the order in which they are created and the ZOrder is the same (the first control will always be on top of the next control created).

    Now, DDT does something different.

    DDT controls use the Tab order OK (in the order they are created), but the ZOrder is another story.

    It looks to me that the ZOrder is the "reverse" of the Tab order (the order of creation of the controls) and the Label (static) controls seem to get pushed Forward in ZOrder, no matter when I create them.

    For example, say I want to have a static control used as a background (a colored rectangle) and then put another static control (label) on top of it, with text in it and also a control that uses Tab Order like an Edit control (Text) on top of the first Label. I can't seem to do it with DDT.

    The example should look like this:

    |                              | <--- Background Label
    |  __________________________  |
    |  |  Label with text        | |
    |  |_________________________| |
    |                              |
    |  __________________________  |
    |  |                         | |
    |  |  Edit control (Text)    | |
    |  |                         | |
    |  |                         | |
    |  |_________________________| |
    |                              |
    The Labels will be using Colors to make it all stand out,
    so I need them.

    Could someone write a simple code block that demonstrates how to Layer the controls above correctly (No colors needed in example) ?

    [This message has been edited by Chris Boss (edited March 13, 2000).]
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"

  • #2
    Chris --
    Pls, explain more detail, about what problems do you talk.
    I reconstructed a little my training code and do not see problems with Z-order (at least, like I understand this word)

    #Compile Exe
    #Dim All
    #Register None
    #Include "Win32Api.Inc"
    %ID_Label1 =  101
    %ID_Label2 =  102
    %ID_Text1 = 201
    %ID_Button1 = 301
    %ID_Button2 = 302
    Global hDlg&
    CallBack Function Cb1()
       Function = 1: Exit Function
    End Function
    CallBack Function hDlg_CB()
       Dim BrushLtBr As Static Long, BrushWhite As Static Long, BrushBlue As Static Long
       Select Case CbMsg
          Case %WM_INITDIALOG
             Control Set Focus CbHndl, %ID_Text1
             Local Lb As LOGBRUSH
             Lb.lbStyle = %BS_SOLID
             Lb.lbColor = &H80C0FF: BrushLtBr = CreateBrushIndirect(Lb)
             Lb.lbColor = %White  : BrushWhite = CreateBrushIndirect(Lb)
             Lb.lbColor = %Blue   : BrushBlue = CreateBrushIndirect(Lb)
             Function = %TRUE
          Case %WM_DESTROY
             DeleteObject BrushLtBr
             DeleteObject BrushWhite
             DeleteObject BrushBlue
          Case %WM_CTLCOLORDLG ' Return the handle of the dialog background brush.
             Function = BrushLtBr
             Select Case GetDlgCtrlId(CbLparam)
                Case %ID_Text1
                   SetTextColor CbWparam, %Blue
                   SetBkColor CbWparam, %White
                   Function = BrushWhite
                Case %ID_Label2
                   SetTextColor CbWparam, %Red
                   SetBkColor CbWparam, %White
                   Function = BrushWhite
                Case %ID_Label1
                   SetTextColor CbWparam, %White
                   SetBkColor CbWparam, %Blue
                   Function = BrushBlue
                End Select
       End Select
    End Function
    Function PbMain ()
      Dialog New 0 ,"Test",,, 105, 100 To hDlg
      Control Add Label, hDlg, %ID_Label1, "", 5, 5, 95, 94, , %WS_EX_CLIENTEDGE
      Control Add Label, hDlg, %ID_Label2, "Label2", 10, 15, 84, 10, %WS_CHILD Or %SS_CENTER Or %DS_CONTROL, %WS_EX_CLIENTEDGE
      Control Add TextBox, hDlg, %ID_Text1,"1. Not nice" + $CRLF + "2. Colors, fonts" + $CRLF + "3. Pardon", 10, 35, 84, 35, %ES_WANTRETURN Or %ES_MULTILINE Or %WS_TABSTOP, %WS_EX_CLIENTEDGE
      Control Add Button, hDlg, %ID_Button1, "Yes", 15, 75, 35, 15
      Control Add Button, hDlg, %ID_Button2, "No", 55, 75, 35, 15
      Dialog Show Modal hDlg, Call hDlg_CB
    End Function


    • #3
      This works... Could it be that when you are changing the color (or something similar to that task) that DDT is then changing the ZOrder?

      #INCLUDE ""
      GLOBAL ghDlg AS LONG
          DIALOG NEW 0, "Layer Test", , , 200, 200, %WS_SYSMENU TO ghDlg
          CONTROL ADD LABEL, ghDlg, 101, "", 5, 5, 188, 174, %SS_SUNKEN
          CONTROL ADD LABEL, ghDlg, 101, "Please type something:", 60, 15, 80, 12
          CONTROL ADD TEXTBOX, ghDlg, 201, "This is a text box  [img][/img]", 10, 30, 178, 146, _
                                      %ES_MULTILINE OR %ES_WANTRETURN, %WS_EX_CLIENTEDGE
          DIALOG SHOW MODAL ghDlg
      Colin Schmidt

      Colin Schmidt & James Duffy, Praxis Enterprises, Canada


      • #4
        I believe part of the problem is with Colors for controls. The Edit control is not displaying properly because I have given it a color.


        Your sample works correctly, but it does not use colors which may be a part of the problem.

        Also, you sample demonstrates that I am correct about DDT and ZOrder. You put the Large Label first, but if I was using the API, the Large Label would be the last control created. This basically means that DDT does the tab order by "First to Last", but does ZOrder (Front to Back) in reverse order (compared to CreateWindowEx).

        Chris Boss
        Computer Workshop
        Developer of "EZGUI"


        • #5
          I think I found my problem:

          I used the following styles for my Dialog:


          I have used them with SDK style code without a problem, but they caused a problem in painting my controls with DDT.

          Thanks for the help !

          Your code made me look at mine for carefully.

          The only question, I would have now, is how come the ZOrder with DDT is Last control (Front) to First control (Back), whereas SDK style code (API CreateWindowEx) is First control (Front) to Last control (Back) ?

          Chris Boss
          Computer Workshop
          Developer of "EZGUI"


          • #6
            Well, I think I solved my ZOrder problem as well.

            My Visual Designer for DDT is not a DDT app, so I have to do a little conversion, when generating code for DDT controls for the user created Dialogs.

            I find all the Static type controls (Labels, Frames, Pictures, Icons) and in reverse order I generate the DDT. so they can layer correctly. Then I go back and find all the other controls and generate the DDT code in normal order (sets the tab order correctly).

            This is very interesting working with DDT !

            Chris Boss
            Computer Workshop
            Developer of "EZGUI"


            • #7
              Chris --

              A reason of DS_CONTROL in your wizard I understood.
              But with WS_CLIPCHILDREN or WS_CLIPSIBLINGS styles for me not so clear.
              1) In Win32.Hlp:
              If a window has either the WS_CLIPCHILDREN or WS_CLIPSIBLINGS style, a slight loss in performance occurs.
              Each window takes up system resources, so an application should not use child windows indiscriminately.

              2) What happends, if to place "big label" first, then elements on it (this is natural order),
              without using WS_CLIPCHILDREN or WS_CLIPSIBLINGS ?
              Like I understand, first Windows will send messages to "big label" (because it's described first).
              During redrawing "big label" covers all "sub-childs".
              But then will be messages to "sub-childs" and all will be redrawn correctly.

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