Announcement

Collapse
No announcement yet.

Simple DDT Question

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

  • Simple DDT Question

    Folks,

    Is it possible to build a DDT Dialog without the Title Bar?

    Thanks, B

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

  • #2
    You can use the %WS_POPUP style for this, like:
    Code:
      DIALOG NEW 0, "",,, 240, 180, %WS_POPUP, 0 TO hDlg
    Just remember to add a Close button to the dialog, otherwise you will
    have to force it close via task manager (or pull the plug..


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

    Comment


    • #3
      Thanks Borje ------ I thought I tried that

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

      Comment


      • #4
        Think answer was a bit incomplete. Guess you already found out full
        answer, but for eventual lurkers: WS_POPUP alone creates a "flat"
        window without caption and borders, etc. Useful for start-up screens
        and such, when one maybe want to show own picture and not standard
        dialog. To create a 3-D window without caption, combine with for
        example %DS_MODALFRAME, like: %WS_POPUP OR %DS_MODALFRAME


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

        Comment


        • #5
          Another One,

          Can I change the display size of the Title Bar, or better yet,
          can I create another control which recieves and send messages
          as if it were the Title Bar?

          Maybe something like;

          SendMessage LOWRD(CBHNDL),CBMSG,160,0 ???

          I know Borje has a quick answer for this, Thanks, B

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

          After searching the forum, I found many examples referencing
          the Title Bar, But what I was really after, was trying to understand
          the Messaging structure, which I still have yet to grasp, Thanks
          anyway, B


          [This message has been edited by Brad D Byrne (edited September 16, 2001).]

          Comment


          • #6
            Using DDT, just locate a static control at the top of the dialog with CONTROL ADD LABEL. Change text with CONTROL SET TEXT.


            MCM
            (not a big DDT user, so there well could be an easier way).


            Michael Mattias
            Tal Systems Inc. (retired)
            Racine WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Can do simple solution like Michael suggests, but more fun to take full
              control of things. Following sample shows a way. It uses a sub-classed
              label as captionbar. All input is redirected to BarProc, where it handles
              dragging and drawing, etc. Can be customized to become real neat ..
              Code:
              '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              ' Dialog with own caption bar
              '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              #COMPILE EXE
              #INCLUDE "WIN32API.INC"
              %ID_CAPTIONBAR = 20
              GLOBAL ghCaptionBar AS LONG, oldBarProc AS LONG
              GLOBAL flag AS LONG  'global flag for active/inactive status
               
              DECLARE CALLBACK FUNCTION DlgProcedure()
              DECLARE CALLBACK FUNCTION BarProc()
               
              '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              ' MAIN ENTRANCE
              '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              FUNCTION PBMAIN
                LOCAL hDlg AS LONG
               
                DIALOG NEW 0, "MyProg",,, 240, 150, %WS_POPUP OR %WS_DLGFRAME TO hDlg
                ' remove %WS_DLGFRAME style to create flat dialog..
                
                CONTROL ADD BUTTON, hDlg, %IDCANCEL, "&Close", 183, 130, 50, 14
                CONTROL ADD LABEL, hDlg, %ID_CAPTIONBAR, "", 0, 0, 240, 16, %SS_NOTIFY
                CONTROL HANDLE hDlg, %ID_CAPTIONBAR TO ghCaptionBar
                
                'sub-class captionbar label and let BarProc handle it
                oldBarProc = SetWindowLong(ghCaptionBar, %GWL_WNDPROC, CODEPTR(BarProc))
               
                DIALOG SHOW MODAL hDlg CALL DlgProcedure
               
              END FUNCTION
               
              '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              ' MAIN DIALOG PROCEDURE
              '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              CALLBACK FUNCTION DlgProcedure()
               
                SELECT CASE CBMSG
                  CASE %WM_COMMAND
                     SELECT CASE CBCTL
                        CASE %IDCANCEL : DIALOG END CBHNDL
                     END SELECT
               
                  CASE %WM_NCACTIVATE 'active/inactive status recorded here
                     flag = CBWPARAM
                     InvalidateRect ghCaptionBar, BYVAL %NULL, 0 'need to repaint captionbar
                     UpdateWindow ghCaptionBar
               
                  CASE %WM_CTLCOLORSTATIC            'captionbar asks for colors
                     IF CBLPARAM = ghCaptionBar THEN
                        SetBkMode CBWPARAM, %TRANSPARENT
                        IF flag THEN
                           SetTextColor CBWPARAM, GetSysColor(%COLOR_CAPTIONTEXT)
                           FUNCTION = GetSysColorBrush(%COLOR_ACTIVECAPTION)
                        ELSE
                           SetTextColor CBWPARAM, GetSysColor(%COLOR_INACTIVECAPTIONTEXT)
                           FUNCTION = GetSysColorBrush(%COLOR_INACTIVECAPTION)
                        END IF
                     END IF
               
                  CASE %WM_DESTROY
                     IF oldBarProc THEN 'un-subclass captionbar label at exit
                        SetWindowLong ghCaptionBar, %GWL_WNDPROC, oldBarProc
                     END IF
                END SELECT
               
              END FUNCTION
               
              '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              ' SUB-CLASSED CAPTIONBAR LABEL PROCEDURE
              ' Here all painting of captionbar is done, plus handling of eventual dragging
              ' with the mouse. Can be expanded to whatever, like BitBlt'ing a bitmap as
              ' background, do more advanced painting, etc.
              '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              CALLBACK FUNCTION BarProc()
                SELECT CASE CBMSG
                   CASE %WM_INITDIALOG
                      LOCAL hBrush AS LONG, hImg AS LONG, ps AS PAINTSTRUCT, _
                            rc AS RECT, zTxt AS ASCIIZ * 260
               
                   CASE %WM_LBUTTONDOWN 'do dragging if mouse down on caption bar label
                      SendMessage GetParent(CBHNDL), %WM_NCLBUTTONDOWN, %HTCAPTION, BYVAL %NULL
                      FUNCTION = 0 : EXIT FUNCTION
               
                   CASE %WM_PAINT
                      GetClientRect CBHNDL, rc                       'get control's size
                      BeginPaint CBHNDL, ps                          'initiate painting
               
                        hBrush = SendMessage(GetParent(CBHNDL), _
                                 %WM_CTLCOLORSTATIC, ps.hDC, CBHNDL) 'get brush from parent's %WM_CTLCOLORSTATIC
                        FillRect ps.hDC, rc, hBrush                  'paint background
               
                        hImg = LoadIcon(0, BYVAL %IDI_WINLOGO)       'draw an icon in top-left corner (just to show a way to do it)
                        DrawIconEx ps.hDC, 0, -2, hImg, 0, 0, 0, BYVAL 0, %DI_NORMAL
               
                        zTxt = "Click here to drag.."                'draw caption text (here centered)
                        DrawText ps.hDC, zTxt, LEN(zTxt), rc, _
                                 %DT_SINGLELINE OR %DT_CENTER OR %DT_VCENTER
               
                      EndPaint CBHNDL, ps
                      FUNCTION = 0 : EXIT FUNCTION
               
                END SELECT
               
                FUNCTION = CallWindowProc(oldBarProc, CBHNDL, CBMSG, CBWPARAM, CBLPARAM)
              END FUNCTION

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

              Comment


              • #8
                Michael, thanks for response, BTW, learned a lot from your posts, thanks again.

                If anyone is interested, Seman's excellent code:

                #COMPILE EXE
                #REGISTER NONE
                #DIM ALL
                #INCLUDE "win32api.inc"
                GLOBAL hHook AS LONG, pWndProc AS LONG
                CALLBACK FUNCTION WndProc
                SELECT CASE CBMSG
                CASE %WM_NCCREATE
                MSGBOX "NC_Create"
                CASE %WM_NCHITTEST
                DIM lResult AS LONG
                lResult = CallWindowProc(pWndProc, CBHNDL, CBMSG, CBWPARAM, CBLPARAM)
                IF lResult = %HTCLIENT THEN lResult = %HTCAPTION
                FUNCTION = lResult: EXIT FUNCTION
                END SELECT
                FUNCTION = CallWindowProc(pWndProc, CBHNDL, CBMSG, CBWPARAM, CBLPARAM)
                END FUNCTION
                FUNCTION SBProc(BYVAL lMsg AS LONG, BYVAL wParam AS LONG, _
                BYVAL lParam AS LONG) AS LONG
                IF lMsg = %HCBT_CREATEWND THEN
                pWndProc = SetWindowLong (wParam, %GWL_WNDPROC, CODEPTR(WndProc))
                UnhookWindowsHookEx hHook
                END IF
                END FUNCTION

                FUNCTION PBMAIN
                hHook = SetWindowsHookEx(%WH_CBT, CODEPTR(SBProc), GetModuleHandle(BYVAL 0&), _
                GetCurrentThreadId)
                DIM hDlg AS LONG
                DIALOG NEW 0, "Test", , , 100, 35, %WS_POPUP TO hDlg
                CONTROL ADD BUTTON, hDlg, 101, "Nothing", 10, 10, 80, 15
                DIALOG SHOW MODAL hDlg
                END FUNCTION
                '------------------

                clears up many of a beginner's (Me), mis-understandings
                Thanks, SO MUCH, B

                Note: there is no close button so you have to cntrl-alt-del out of it.

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

                Comment


                • #9
                  Thanks Borge,
                  I'll study it to.

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

                  Comment


                  • #10
                    > Note: there is no close button so you have to cntrl-alt-del out of it.

                    Use Alt-F4 to close a dialog (standart keyboard interface)


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

                    Comment


                    • #11
                      Plus, DDT dialogs sends IDCANCEL on Esc key. Not sure if SDK style
                      windows do the same, but sure DDT does it. In other words, even
                      without button, it's possible to trap and handle IDCANCEL under
                      WM_COMMAND, to give option of Esc to close dialog.

                      Plus-plus, it also sends IDOK on Enter key, even in empty dialog..

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


                      [This message has been edited by Borje Hagsten (edited September 16, 2001).]

                      Comment


                      • #12
                        Borge,

                        I want to thank you again for your code, it definatly
                        clearified some things.

                        If anyone is interested, here is a little variation of Seman's code.


                        #COMPILE EXE
                        #REGISTER NONE
                        #DIM ALL
                        #INCLUDE "win32api.inc"
                        GLOBAL hHook AS LONG, pWndProc AS LONG
                        CALLBACK FUNCTION WndProc
                        SELECT CASE CBMSG
                        'CASE %WM_NCCREATE
                        ' MSGBOX "NC_Create"
                        CASE %WM_NCHITTEST
                        DIM lResult AS GLOBAL LONG
                        lResult = CallWindowProc(pWndProc, CBHNDL, CBMSG, CBWPARAM, CBLPARAM)
                        IF lResult = %HTCLIENT THEN lResult = %HTCAPTION
                        FUNCTION = lResult: EXIT FUNCTION
                        END SELECT
                        FUNCTION = CallWindowProc(pWndProc, CBHNDL, CBMSG, CBWPARAM, CBLPARAM)
                        END FUNCTION
                        FUNCTION SBProc(BYVAL lMsg AS LONG, BYVAL wParam AS LONG, _
                        BYVAL lParam AS LONG) AS LONG
                        IF lMsg = %HCBT_SETFOCUS THEN '%HCBT_CREATEWND
                        pWndProc = SetWindowLong (wParam, %GWL_WNDPROC, CODEPTR(WndProc))
                        UnhookWindowsHookEx hHook
                        END IF
                        END FUNCTION

                        FUNCTION PBMAIN
                        hHook = SetWindowsHookEx(%WH_CBT, CODEPTR(SBProc), GetModuleHandle(BYVAL 0&), _
                        GetCurrentThreadId)
                        DIM hDlg AS LONG
                        DIALOG NEW 0, "Test", , , 150,165, %WS_POPUP TO hDlg
                        CONTROL ADD BUTTON, hDlg, 101, "Drag Me / Dbl Clk Me", 35, 40, 80, 15
                        DIALOG SHOW MODAL hDlg
                        END FUNCTION
                        '------------------

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

                        Comment

                        Working...
                        X