Announcement

Collapse
No announcement yet.

Multiple Dialog with DDT, How to?

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

  • Ralph Berger
    replied
    Aisin,

    maybe my MDI wrapper for DDT will do what you need. Pls have a look in the 3rd party forum.

    Ralph

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

    Leave a comment:


  • Jules Marchildon
    replied
    Aisin,

    I did a quick cut and paste to give you the basics. You should be
    able to take it from there. I don't do much in the way of DDT, so there
    may need to be other things to take into consideration like DoEvents.

    Good luck!
    Regards, Jules

    Code:
    '-------------------------------------------------------------------------
    ' Quick Multiple window demo using DDT.
    ' In it's very simplest form.
    '
    ' Compiler: PBDLL60
    ' June 9, 2000
    ' By Jules Marchildon  [url="mailto:[email protected]"]mailto:[email protected][/url][email protected]</A> 
    '------------------------------------------------------------------------
     
    #COMPILE EXE
    #INCLUDE "win32api.inc"
     
    '---
    DECLARE FUNCTION CreateChildDlgs()    AS LONG
     
    '---
    GLOBAL ahDlg    AS LONG       'main parent dialog window
    GLOBAL bhDlg    AS LONG       'child 1 dialog
    GLOBAL chDlg    AS LONG       'child 2 dialog
    GLOBAL result   AS LONG
    GLOBAL ghWndNew AS LONG
     
    Global listhwnd()   As Long   'array of child window handles
     
    '**Flags for window management
    Global AcWinFlag  As Long     'which child window is active?
    %nWcode   =0
    %nWmemory =1
     
    Global BrushBlack    As Long
    Global BrushWhite    As Long
    Global BrushBlue     As Long
     
    'Menu control ID's
    %ID_MENU_CLOSE  = %IDCANCEL
    %ID_MENU_CUT    = 201
    %ID_MENU_COPY   = 202
    %ID_MENU_PASTE  = 203
    %ID_MENU_HELP   = 204
    %ID_MENU_ABOUT  = 205
     
     
    '-------------------------------------------------------
    ' Follow the user's mouse clicks, deactivate old,
    ' activate new.
    '
    '-------------------------------------------------------
    Sub ActivateTittleBar()
     
        '--get the active window and remove the activation bar
     
        If Bit(AcWinFlag,%nWCode) = %True Then
            SendMessage bhDlg, %WM_NCACTIVATE, %FALSE, 0
            Bit Reset AcWinFlag, %nWCode
     
        Else
            SendMessage chDlg, %WM_NCACTIVATE, %FALSE, 0
            Bit Reset AcWinFlag, %nWMemory
     
         End If
     
        '--set the activation bar on the user selected window
        SendMessage ghWndNew, %WM_NCACTIVATE, %TRUE, 0
     
        Select Case ghWndNew
            Case bhDlg
                Bit Set  AcWinFlag,%nWCode
            Case chDlg
                Bit Set  AcWinFlag,%nWMemory
            End Select
     
         '--bring it to the top
         SetWindowPos  ghWndNew, %HWND_TOP, 0, 0, 0, 0, %SWP_NOMOVE Or %SWP_NOSIZE
     
         SetFocus ghWndNew
     
    End Sub
     
     
    '----------------------------------------------------
    ' Seperate call back procedure for child #1
    '
    '
    '----------------------------------------------------
    Callback function ChildOneProc()
     
    LOCAL hDC            AS LONG
    LOCAL ps             AS PAINTSTRUCT
    LOCAL i              AS LONG
    LOCAL rc             AS RECT
    
     
        Select case cbmsg
     
               case %wm_initdialog
     
               case %wm_command
     
               case %wm_paint
     
                    hDC = BeginPaint(cbhndl, ps)
                    hOldFont& = SelectObject(hDC, GetStockObject(%SYSTEM_FIXED_FONT))
                    DIM szLine1    AS ASCIIZ*40
                    DIM szLine2    AS ASCIIZ*40
                    szLine1   =  "1st Child Window."
                    szLine2   =  "    Surprised?"
                    SetBkMode hDC,%TRANSPARENT
                    SetTextColor hDC, RGB(255,0,0)
                    TextOut hDC, 10 , 10 , szLine1, LEN(szLine1)
                    SetTextColor hDC, RGB(0,0,0)
                    TextOut hDC, 10 , 40 , szLine2, LEN(szLine2)
                    SelectObject hDC,hOldFont&
                    EndPaint cbhndl,ps
     
     
               Case %WM_MOUSEACTIVATE
     
                    '*handle active/inactive tittle bar
                    ghWndNew = bhDlg
                    Call ActivateTittleBar()
     
               '*Color the background blue
               Case %WM_CTLCOLORDLG
                    Function = BrushBlue
     
     
        end select
     
    End Function
     
    '----------------------------------------------------
    ' Seperate call back procedure for child  #2
    '
    '
    '----------------------------------------------------
    Callback function ChildTwoProc()
     
    LOCAL hDC            AS LONG
    LOCAL ps             AS PAINTSTRUCT
    LOCAL i              AS LONG
    LOCAL rc             AS RECT
     
     
        Select case cbmsg
     
               case %wm_initdialog
     
               case %wm_command
     
               case %wm_paint
     
                    hDC = BeginPaint(cbhndl, ps)
                    hOldFont& = SelectObject(hDC, GetStockObject(%SYSTEM_FIXED_FONT))
                    DIM szLine1    AS ASCIIZ*40
                    DIM szLine2    AS ASCIIZ*40
                    szLine1   =  "2nd Child Window."
                    szLine2   =  " Surprised Yet?"
                    SetBkMode hDC,%TRANSPARENT
                    SetTextColor hDC, RGB(255,0,0)
                    TextOut hDC, 10 , 10 , szLine1, LEN(szLine1)
                    SetTextColor hDC, RGB(0,0,255)
                    TextOut hDC, 10 , 40 , szLine2, LEN(szLine2)
                    SelectObject hDC,hOldFont&
                    EndPaint cbhndl,ps
     
               Case %WM_MOUSEACTIVATE
     
                    '*handle active/inactive tittle bar
                    ghWndNew = chDlg
                    Call ActivateTittleBar()
     
               '*Color the background black
               Case %WM_CTLCOLORDLG
                    Function = BrushBlack
     
     
        end select
     
    End Function
    
     
     
    '----------------------------------------------------
    ' The main dialog callback procedure:
    '
    '
    '----------------------------------------------------
    Callback function MainDlgProc()
     
    LOCAL  hDC           AS LONG
    LOCAL  ps            AS PAINTSTRUCT
    LOCAL  i             AS LONG
    LOCAL  rc            AS RECT
    Local  Lb            As LOGBRUSH
     
     
        Select case cbmsg
     
               case %wm_initdialog
     
                Lb.lbStyle = %BS_SOLID
                Lb.lbColor = %Black  : BrushBlack = CreateBrushIndirect(Lb)
                Lb.lbColor = %White  : BrushWhite = CreateBrushIndirect(Lb)
                Lb.lbColor = %Blue   : BrushBlue  = CreateBrushIndirect(Lb)
     
     
                Dim listhwnd(1:4)   'set up array for window management
     
                Call CreateChildDlgs()
     
                ' Initialize AcWinFLag
                AcWinFlag = 0
     
                '**Set the activation bar, default to Code Window
                SendMessage bhDLg, %WM_NCACTIVATE, %TRUE, 0
                Bit Set AcWinFlag, %nWCode
     
                'initialize list of child window handles array
                listhwnd(1) = bhDlg
                listhwnd(2) = chDlg
                'listhwnd(3)= dhDlg
                'listhwnd(4)= ehDlg
     
     
               case %wm_command
     
               case %wm_paint
     
                    hDC = BeginPaint(cbhndl, ps)
                    hOldFont& = SelectObject(hDC, GetStockObject(%SYSTEM_FIXED_FONT))
                    DIM szLine1    AS ASCIIZ*40
                    DIM szLine2    AS ASCIIZ*40
                    szLine1   =  "Main Parent Window."
                    szLine2   =  "  Look Below..."
                    SetBkMode hDC,%TRANSPARENT
                    SetTextColor hDC, RGB(255,0,0)
                    TextOut hDC, 10 , 10 , szLine1, LEN(szLine1)
                    SetTextColor hDC, RGB(0,0,255)
                    TextOut hDC, 10 , 40 , szLine2, LEN(szLine2)
                    SelectObject hDC,hOldFont&
                    EndPaint cbhndl,ps
     
               Case %WM_DESTROY
                    DeleteObject BrushBlack
                    DeleteObject BrushWhite
                    DeleteObject BrushBlue
     
              '*Color the background white
              Case %WM_CTLCOLORDLG
                    Function = BrushWhite
     
        end select
     
    End Function
    
     
     
    '----------------------------------------------------
    '  Function two create two child/popup windows
    '  Parented by the main dialog
    '
    '----------------------------------------------------
    FUNCTION CreateChildDlgs() AS LONG
     
     
        '*Try both styles out. Depending if child or popup, activating
        ' the caption bar behaves differently. Using Child style, you will
        ' need to handle this yourself. You can use the same code in my SDK
        ' post in the same maner here.
     
        'style& = %WS_POPUP OR %WS_OVERLAPPEDWINDOW OR %WS_CLIPSIBLINGS
        style& = %WS_CHILD OR %WS_OVERLAPPEDWINDOW OR %WS_CLIPSIBLINGS
     
        DIALOG  NEW ahDlg, "Dialog1", 20, 40,100, 100,style& TO bhDlg
        DIALOG SHOW MODELESS bhDlg Call ChildOneProc() TO result
     
        DIALOG NEW ahDlg, "Dialog2", 140, 60,100, 100, style& TO chDlg
        DIALOG SHOW MODELESS chDlg Call ChildTwoProc() TO result
     
        FUNCTION = 1
     
    END FUNCTION
     
     
    '--------------------------------------------------------
    ' Main window entry point:
    '
    '
    '--------------------------------------------------------
    FUNCTION PBMAIN() AS LONG
     
        REGISTER    hMenu   AS LONG
     
        LOCAL       hPopup1 AS LONG
        LOCAL       hPopup2 AS LONG
        LOCAL       hPopup3 AS LONG
     
        style& = %WS_OVERLAPPEDWINDOW  OR %WS_CLIPCHILDREN 'OR %DS_CENTER
        DIALOG NEW 0, "Main Dialog",100 ,40 ,300, 220 ,style& TO ahDlg
     
        ' Add a menu bar to the GUI
        MENU NEW BAR TO hMenu
     
        ' Create a popup menu
        MENU NEW POPUP TO hPopup1
        MENU ADD STRING, hPopup1, "&Close", %IDCANCEL, %MF_ENABLED
        ' Attach the popup menu to the menu bar
        MENU ADD POPUP,  hMenu,   "&File",  hPopup1,   %MF_ENABLED
     
        ' Create a popup menu
        MENU NEW POPUP TO hPopup3
        MENU ADD STRING, hPopup3, "&Help",  %id_Menu_Help,  %MF_ENABLED
        MENU ADD STRING, hPopup3, "-",      0,              0
        MENU ADD STRING, hPopup3, "&About", %id_Menu_About, %MF_ENABLED
        MENU ADD POPUP,  hMenu,   "&Help",  hPopup3,        %MF_ENABLED
     
        ' Attach the popup menu to the menu bar
        MENU ATTACH hMenu, ahDlg
     
        DIALOG SHOW Modal ahDlg Call MainDlgProc TO result
     
        PBMAIN = 0
    END FUNCTION

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Hi Jules,
    Thanking you in anticipation.
    Regards
    Aisin

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

    Leave a comment:


  • Jules Marchildon
    replied
    See below...

    [This message has been edited by Jules Marchildon (edited June 09, 2000).]

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Multiple Dialog with DDT, How to?

    Multiple Dialog with DDT, How to?

    Hi All,

    I am trying to get Multiple Dialog(Windows) in my application,
    I had write a small test program,but not perfect, can anybody
    correct me? Thank.

    Code:
    #COMPILE EXE
    #INCLUDE "win32api.inc"
    DECLARE FUNCTION MainDlg() AS LONG
    DECLARE CALLBACK FUNCTION winProc() AS LONG
    DECLARE CALLBACK FUNCTION dlgProc() AS LONG
    GLOBAL hDlg AS LONG
    GLOBAL ahDlg AS LONG
    GLOBAL bhDlg AS LONG
    GLOBAL chDlg AS LONG
    
    FUNCTION PBMAIN() AS LONG
    LOCAL  hDlg AS LONG
    
    DIALOG NEW 0, "Main Dialog",0 ,0 ,300, 220 , %WS_SYSMENU TO hDlg
    
    CONTROL ADD BUTTON, hdlg, 101, "Show1", 20, 20, 50, 25, CALL winProc
    CONTROL ADD BUTTON, hdlg, 102, "Show2", 100, 20, 50, 25, CALL dlgProc
    
    ahDlg=hDlg
    DIALOG SHOW MODAL hDlg
    
    END FUNCTION
    
    
    FUNCTION MainDlg() AS LONG
    hDlg=bhDlg
    DIALOG SHOW STATE hDlg,%SW_HIDE
    hdlg=chDlg
    DIALOG SHOW STATE hDlg,%SW_HIDE
    hDlg=ahDlg
    DIALOG SHOW MODAL hDlg
    
    END FUNCTION
    
    
    CALLBACK FUNCTION winProc() AS LONG
    DIALOG NEW hDlg, "Dialog1", 100, 100,300, 250,%WS_SYSMENU  TO hDlg
    CONTROL ADD BUTTON, hDlg, 103, "Show Main", 75, 40, 50, 25,CALL MainDlg
    CONTROL ADD BUTTON, hDlg, 104, "Show 2", 150, 40, 50, 25, CALL dlgProc
    bhDLG=hDlg
    DIALOG SHOW MODELESS hDlg
    
    END FUNCTION
    
    
    CALLBACK FUNCTION dlgProc() AS LONG
    DIALOG NEW hDlg, "Dialog2", 200, 200,340, 280, %WS_SYSMENU TO hDlg
    CONTROL ADD BUTTON, hDlg, 105, "Show 1", 75, 40, 50, 25,CALL winProc
    CONTROL ADD BUTTON, hDlg, 106, "Show Main", 150, 40, 50, 25 CALL MainDlg
    chDlg=hDLG
    DIALOG SHOW MODELESS hDlg
    END FUNCTION
    There is only three dialog, I think if I got more it will be
    more massive, please advise me some good way, I saw the multiple windows example in source code forum, but there are in SDK, I can't really understand it.

Working...
X