;==========================================================================================================================================
; WinBatch Studio Tool
; Edit Dialog in WIL Dialog Editor
;------------------------------------------------------------------------------------------------------------------------------------------
; This WB Studio macro copies WIL Dialog template code lines from WB Studio Editor to the Clipboard.
; Then the WIL Dialog Editor will be started and loads the Dialog template automagically from the Clipboard data.
;
; Before starting this copy process the cursor should be positioned anywhere within the Dialog code block.
; After returning from WIL Dialog Editor the cursor is placed one line down the Dialog() function call.
;
; To copy the current template from within the WIL Dialog Editor as code lines back into the WB Studio Editor,
; you have to do it from within the WIL Dialog Editor.
; Open the "File" menu and choose "Save to Clipboard" resp. press [Alt+F], then [T].
; Then make WB Studio Editor the active window by pressing [Alt+Tab] or so ...
; and answer the "Waiting ..." message dialog with "OK" or "Abort" resp. press [Enter] or [Esc].
;------------------------------------------------------------------------------------------------------------------------------------------
; Inspired by ...
; Topic:  Dialog Editor Save File Extension
; Conf:  WinBatch Dialogs
; From:  kdmoyers admin@guden.com
; Date:  Friday, February 11, 2011 01:13 PM
;------------------------------------------------------------------------------------------------------------------------------------------
; Detlev Dalitz.20110213.
;==========================================================================================================================================

Edit &Dialog in WIL Dialog Editor
    ; Remove active selection, if any.
    wClearSel ()

    ; Locate start of Dialog, search backward.
    wFind ('Format *= *`WWWDLGED,6.', @FALSE, @TRUE, @TRUE, @FALSE) ; Forward?,matchcase?,regex?,wrap?
    wHome ()
    intDlgStartLine = wGetLineNo ()

    ; Locate end of Dialog, search forward.
    wFind ('= *Dialog *\(', @TRUE, @TRUE, @TRUE, @FALSE) ; Forward?,matchcase?,regex?,wrap?
    wHome ()
    wDownLine ()
    wInsLine ("; *** Dialog is in edit mode ***") ; The CRLF of this info line provides consistent behaviour for all return cases to WB Studio editor.

    ; Select lines to copy.
    wStartSel ()
    wGotoLine (intDlgStartLine)
    wEndSel ()
    wCopy ()

    strAppDlg = "WIL Dialog Editor"
    strAppExe = DirHome () : strAppDlg : ".exe"
    If AppExist (strAppExe) Then WinActivate ("~" : strAppDlg)
       Else RunZoom (strAppExe, "/clipboard") ; Wait for closing manually.
    intResult = DllCall (DirWindows (1) : "User32.dll", long:"MessageBoxA", long:DllHwnd (""), lpstr:"Press OK when ready.", lpstr:"Waiting for Dialog code on clipboard ...", long:1|64) ; OKCANCEL = 1; INFO = 64.
    If intResult == 1 Then wPaste ()
    wClearSel ()

    ; Go to the line following the Dialog block.
    wGotoLine (intDlgStartLine)
    wFind ('= *Dialog *\(', @TRUE, @TRUE, @TRUE, @FALSE) ; Forward?,matchcase?,regex?,wrap?
    wHome ()
    wDownLine ()

    ; Remove info line.
    wStartSel ()
    wDownLine ()
    wEndSel ()
    wDelete ()
    wClearSel ()
    Return
;==========================================================================================================================================