         title   Create
         .586
         .model flat, stdcall
            option   casemap: none

            include  windows.inc
            include  user32.inc
            include  kernel32.inc
            include  gdi32.inc
            include  comdlg32.inc
            include  advapi32.inc

     include  L:\AsmEdit\include\DSPMACRO.asm

         includelib  user32.lib
         includelib  kernel32.lib
         includelib  gdi32.lib
         includelib  comdlg32.lib
         includelib  advapi32.LIB

WndProc        PROTO :DWORD, :DWORD, :DWORD, :DWORD
SubClass       PROTO :DWORD, :DWORD, :DWORD
ControlButt    PROTO :DWORD, :DWORD, :DWORD, :DWORD
ButtonType     PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
IncLib         PROTO :DWORD, :DWORD, :DWORD, :DWORD
WorkWin        PROTO :DWORD, :DWORD, :DWORD, :DWORD
ReadInput      PROTO :DWORD
WriteOutput    PROTO :DWORD
LoadList       PROTO :DWORD, :DWORD, :DWORD
FindRep        PROTO :DWORD, :DWORD, :DWORD, :DWORD
DrawButt       PROTO :DWORD

MOVmd    MACRO Var1, Var2
          push     Var2
           pop     Var1
          ENDM

.data
AppName        db  'AsmEdit V5.0 - ',0
pTitle         db  'Step By Step Program',0
ClassName      db  'StepByStep',0
Richedit       db  'RichEdit20A',0
Listbox        db  'LISTBOX',0
Button         db  'BUTTON',0
Static         db  'STATIC',0

FontNameMS     db  'MS Sans Serif',0
FontNameCN     db  'Courier New',0

szALL          db  'All Files',0,'*.*',0,0

szError2       db  'The Contents Of The Templates Folder', 0Dh,0Ah
               db  ' Is Missing or Corrupted.',0
szError3       db  'You can not jump ahead for', 0Dh,0Ah
               db  ' the required functions.',0
szError4       db  'If you need to redo the function you must', 0Dh,0Ah
               db  ' select the text that you want to replace.',0
szError5       db  'You can not redo this function.',0
szError6       db  'There was an error creating the resource file.',0
szError7       db  "You have not created the Inc's and Lib's.",0
szError8       db  "You need to create a Menu or Toolbar first.",0

szAsmEdit      db  'Programs\AsmEdit\',0
szMRUFile      db  'MRUFiles.asm',0
szTemplates    db  'Templates\',0
szStepBStep    db  'StepByStep\',0
szProjects     db  'Projects\',0
;szIncInc       db  '            include  F:\masm32\include\',0
;szIncLib       db  '         includelib  F:\masm32\lib\',0
;szIncInc1      db  '            include  F:\masm32\include\',0
;szIncLib1      db  '         includelib  F:\masm32\lib\',0
szIncInc1      db  '            include  ',0
szIncLib1      db  '         includelib  ',0
szIncInc2      db  'include\',0
szIncLib2      db  'lib\',0

szToolClass    db  "ToolClass      db  'ToolbarWindow32',0",0
szhTool        db  'hWndTool       dd  ?', 0Dh,0Ah
               db  'hImageList     dd  ?',0

szDefine       db  '#define',0
szRedit        db  'szRedit        db',0
szConst        db  '.const',0
szDataF        db  '.data',0
szDataQ        db  '.data?',0
szCode         db  '.code',0
szStruct       db  ';---------- [Structures] ----------',0
szInit         db  '        call     InitCommonControls',0
szExit         db  '         mov     MainExit, eax',0
szMenuExit     db  '      MENUITEM "E&xit",         IDM_EXIT',0
sz4901         db  '4901 DIALOGEX',0
szMainMenu     db  'MainMenu  MENU DISCARDABLE',0
szCreate       db  'WM_CREATE',0
szCommandM     db  'WM_COMMAND',0
szNotify       db  '      .elseif wMsg == WM_NOTIFY',0
szClose        db  '      .elseif wMsg == WM_CLOSE',0
szDestroy      db  '      .elseif wMsg == WM_DESTROY',0
szhWnd         db  'hWnd           dd  ?',0
szhREdit       db  'hREdit         dd  ?',0
szFocus        db  '         INVOKE     SetFocus, hREdit',0
szWinMainP     db  'WinMain         PROTO  :DWORD, :DWORD, :DWORD, :DWORD',0
szWndProc      db  'WndProc proc  uses ebx  hwnd:DWORD, wMsg, wParam, lParam',0
szMenuCnt      db  '            mov     MenuCnt, eax',0
szhSMenu       db  '            mov     hSMenu, eax',0
szGetMenu      db  '         INVOKE     GetMenu',0
szMoveSize     db  ';---------- [Move and Size the Control(s)] ----------',0
szSize         db  '      .elseif wMsg == WM_SIZE',0
szSizeEdit     db  ';---------- [Size the Edit Control] ----------',0
szEndSize      db  '         INVOKE     MoveWindow, hREdit, 0, edx, ebx, ecx, TRUE',0

szIfTool       db  '         .if hWndTool',0
szIfStat       db  '         .if hWndStat',0
szEndIf        db  '         .endif',0
szCommand      db  '           cwde',0
szIf           db  '         .if eax == ',0
szElseif       db  '         .elseif eax == ',0
szEndif        db  '         .endif',0
szElse         db  '      .else',0
sz708          db  '708',0
szILC          db  'ILC_COLOR32, 8',0
szCnt          db  'Cnt, 8 ',0
szILCR         db  'ILC_COLOR32, 12',0
szCntR         db  'Cnt, 12',0
szTBButt7      db  '         TBButt     hWndTool, 7, 2001, 0',0
szOperr        db  'operr:',0
szWndProcEnd   db  'WndProc endp',0
szEndOpen      db  'EndOpen:',0
szEndStart     db  'end start',0

szHeadingG     db  'Heading.gen',0
szIncLibG      db  'IncLib.gen',0
szProtoG       db  'ProtoGen.gen',0
szStartG       db  'Start.gen',0
szWinMainG     db  'WinMain.gen',0
szNoMenuG      db  'ResourceNoM.gen',0
szMenuFileBG   db  'MenuFileB.gen',0
szMenuFileOG   db  'MenuFileO.gen',0
szMenuFilePG   db  'MenuFileP.gen',0
szMenuFileOPG  db  'MenuFileOP.gen',0
szMenuEditG    db  'MenuEdit.gen',0
szMenuOptionsG db  'MenuOptions.gen',0
szMenuSearchG  db  'MenuSearch.gen',0
szMainWinG     db  'MainWindow.gen',0
szWinProcG     db  'WinProc.gen',0
szCommands     db  'Commands1.gen',0
szToolbar1G    db  'Toolbar1.gen',0
szToolbar2G    db  'Toolbar2.gen',0
szToolbar3G    db  'Toolbar3.gen',0
szToolbar4G    db  'Toolbar4.gen',0
szToolbar5G    db  'Toolbar5.gen',0
szToolbar6G    db  'Toolbar6.gen',0
szToolbar7G    db  'Toolbar7.gen',0
szToolbar8G    db  'Toolbar8.gen',0
szToolbar9G    db  'Toolbar9.gen',0
szToolbar10G   db  'Toolbar10.gen',0
szStatusbar1G  db  'Statusbar1.gen',0
szStatusbar2G  db  'Statusbar2.gen',0
szStatusbar3G  db  'Statusbar3.gen',0
szStatusbar4G  db  'Statusbar4.gen',0
szWinEditG     db  'EditWindow.gen',0
szWinEdit1G    db  'EditWindow1.gen',0
szWinEdit2G    db  'EditWindow2.gen',0
szWinEdit3G    db  'EditWindow3.gen',0
szWinEdit4G    db  'EditWindow4.gen',0
szWinEdit5G    db  'EditWindow5.gen',0
szWinEdit6G    db  'EditWindow6.gen',0
szWinEdit7G    db  'EditWindow7.gen',0
szWinEdit8G    db  'EditWindow8.gen',0
szWinEdit9G    db  'EditWindow9.gen',0
szWinEdit10G   db  'EditWindow10.gen',0
szEditSub1G    db  'EditSub1.gen',0
szEditSub2G    db  'EditSub2.gen',0
szEditSub3G    db  'EditSub3.gen',0
szEditSub4G    db  'EditSub4.gen',0
szEditSub5G    db  'EditSub5.gen',0
szOpenSave1G   db  'OpenSave1.gen',0
szOpenSave2G   db  'OpenSave2.gen',0
szOpenSave3G   db  'OpenSave3.gen',0
szChoFont1G    db  'ChooseFont1.gen',0
szChoColor1G   db  'ChooseColor1.gen',0
szChoColor2G   db  'ChooseColor2.gen',0
szFindRep1G    db  'FindRep1.gen',0
szFindRep2G    db  'FindRep2.gen',0
szFindRep3G    db  'FindRep3.gen',0
szFindRep4G    db  'FindRep4.gen',0
szFindRep5G    db  'FindRep5.gen',0
szFindRep6G    db  'FindRep6.gen',0
szFindRep7G    db  'FindRep7.gen',0
szFindRep8G    db  'FindRep8.gen',0
szMRU1G        db  'MRU1.gen',0
szMRU2G        db  'MRU2.gen',0
szMRU3G        db  'MRU3.gen',0
szMRU4G        db  'MRU4.gen',0
szMRU5G        db  'MRU5.gen',0
szMRU6G        db  'MRU6.gen',0
szPrint1G      db  'Print1.gen',0
szPrint2G      db  'Print2.gen',0
szRegistry1G   db  'Registry1.gen',0
szRegistry2G   db  'Registry2.gen',0
szRegistry3G   db  'Registry3.gen',0
szRegistry4G   db  'Registry4.gen',0
szRegistry5G   db  'Registry5.gen',0
szRegistry6G   db  'Registry6.gen',0
szRegistry7G   db  'Registry7.gen',0

DlgName1       db  'StepByStep',0
szREGSZ        db  'REG_SZ',0
rDEFr          db  '[Default Root Dir]',0
rDEFb          db  '[Default Bin Dir.]',0

szCmds         db  'Commands',0

szXXXX         db  'xxxx',0
szMasm32V1     db  'Masm32V1',0
szMasm32V1M    db  '\Masm32V1\',0
szInc          db  '.inc',0
szLib          db  '.lib',0
szAsm          db  '.asm',0
szRc           db  '.rc',0
szSlashB       db  '\',0
szComma        db  ',',0
szNull         db  0
szEqu          db  'equ',0
szFill         db  '                ',0
szCR           db  0dh,0
szCRLF         db  0dh,0ah,0
szClr          db  0,0
szErr          db  3,0
szStep         db  6,0

.data?
szFileName     db  100 dup(?)
szWork         db  100 dup(?)
szWork64       db  100 dup(?)
szRoot         db  256 dup(?)
szPath         db  256 dup(?)
szBuff0        db  256 dup(?)
HutchDir       db  256 dup(?)
ButtColor      dd  28  dup(?)

hInst          dd  ?
hWnd           dd  ?
hDefHeap       dd  ?
hBuff          dd  ?
hOutPut        dd  ?
hCommand       dd  ?
hREdit         dd  ?
hButt01        dd  ?
hButt02        dd  ?
hButt03        dd  ?
hButt04        dd  ?
hButt05        dd  ?
hButt06        dd  ?
hButt07        dd  ?
hButt08        dd  ?
hButt09        dd  ?
hButt10        dd  ?
hButt11        dd  ?
hButt12        dd  ?
hButt13        dd  ?
hButt14        dd  ?
hButt15        dd  ?
hButt16        dd  ?
hButt17        dd  ?
hButt18        dd  ?
hButt19        dd  ?
hButt20        dd  ?
hButt45        dd  ?
hin            dd  ?
SPos           dd  ?
EPos           dd  ?
hReset         dd  ?
hSave          dd  ?
hCancelS       dd  ?
SubControl     dd  ?
hFontE         dd  ?
hFontB         dd  ?
Test4          dd  ?

SavName        dd  ?
SavPath        dd  ?
SavReg         dd  ?
SavErr         dd  ?
hEdit          dd  ?
hWndProc       dd  ?
hBR            dd  ?

hIncLib        dd  ?
hWork          dd  ?
hList45        dd  ?

lpType         dd  ?
lpcbData       dd  ?
lpdwDisp       dd  ?

StepSeq        dd  ?
ChkWinProc     dd  ?
ChkMenu        dd  ?
ChkStatus      dd  ?
ChkTool        dd  ?
ChkEdit        dd  ?
ChkEditSub     dd  ?
ChkOpenSav     dd  ?
ChkChoFont     dd  ?
ChkChoColor    dd  ?
ChkFindRep     dd  ?
ChkMRU         dd  ?
ChkPrint       dd  ?
ChkReg         dd  ?

RCLoaded       dd  ?
disFont        dd  ?
disBack        dd  ?
disText        dd  ?

dis            DRAWITEMSTRUCT  <?>

.code

DllEntry PROC hInstance:DWORD, reason:DWORD, reserved1:DWORD
      .if reason == DLL_PROCESS_ATTACH  ; When the dll is loaded
          MOVmd     hInst, hInstance
            mov     eax, TRUE
      .endif
         ret
DllEntry ENDP

;================================================================
StepByStep  PROC   hwnd:DWORD, hinst, hredit, NameAddr, PathAddr, szReg, Err

       MOVmd     hWnd, hwnd
       MOVmd     hin, hinst
       MOVmd     hREdit, hredit
       MOVmd     SavName, NameAddr
       MOVmd     SavPath, PathAddr
       MOVmd     SavReg, szReg
       MOVmd     SavErr, Err
;        call     InitCommonControls         ; Initialize the common ctrl lib
      INVOKE     GetProcessHeap
         mov     hDefHeap, eax

         and     RCLoaded, 0

      INVOKE     lstrcpy, addr szPath, PathAddr
      INVOKE     lstrlen, addr szPath
      INVOKE     lstrcpyn, addr szPath, addr szPath, eax

      INVOKE     lstrlen, addr szPath
         lea     edx, offset szPath
      .while (eax)
         .if byte ptr [edx+eax] == '\'
            .break
         .endif
            dec     eax
      .endw
         inc     eax
      INVOKE     lstrcpy, addr szFileName, addr szPath[eax]
      INVOKE     lstrcat, addr szPath, addr szSlashB

      INVOKE     lstrcpy, SavErr, addr szStep
      INVOKE     CreateDialogParam, hInst, addr DlgName1, hWnd, addr WndProc, 0
         ret

StepByStep  ENDP

;____________________________________________________________________
WndProc proc  uses ebx  hdlg:DWORD, wMsg, wParam, lParam
LOCAL    rect:RECT
LOCAL    pt:POINT
LOCAL    lf:LOGFONT
LOCAL    hReg:DWORD, sw1, Cnt, Reset, ButtOff
LOCAL    szName[64]:BYTE, szBuff1[256], szBuff2[256]

      .if wMsg == WM_INITDIALOG
         INVOKE     LoadIcon, 0, IDI_APPLICATION
         INVOKE     SendMessage, hdlg, WM_SETICON, 1, eax

          MOVmd     hWndProc, hdlg
            and     Reset, 0

         INVOKE     RegCreateKeyEx, HKEY_CURRENT_USER, SavReg, 0, addr szREGSZ, 0,\
                    KEY_WRITE or KEY_READ, 0, addr hReg, addr lpdwDisp
            mov     lpcbData, 250
         INVOKE     RegQueryValueEx, hReg, addr rDEFr, 0, addr lpType, addr szRoot, addr lpcbData
         .if eax == ERROR_SUCCESS
            INVOKE     lstrcpy, addr szBuff0, addr szRoot
            INVOKE     lstrcat, addr szBuff0, addr szTemplates
         .endif
            mov     lpcbData, 250
         INVOKE     RegQueryValueEx, hReg, addr rDEFb, 0, addr lpType, addr HutchDir, addr lpcbData
         INVOKE     RegCloseKey, hReg

         INVOKE     RtlZeroMemory, addr lf, sizeof lf
         INVOKE     lstrcpy, addr lf.lfFaceName, addr FontNameMS
            mov     lf.lfHeight, 14
            mov     lf.lfWeight, 600
         INVOKE     CreateFontIndirect, ADDR lf
            mov     hFontB, eax

         INVOKE     lstrcpy, addr lf.lfFaceName, addr FontNameCN
            mov     lf.lfHeight, -12
            mov     lf.lfWeight, 400
         INVOKE     CreateFontIndirect, ADDR lf
            mov     hFontE, eax

DoReset:
            and     RCLoaded, 0
            and     StepSeq, 0
            and     ChkWinProc, 0
            and     ChkMenu, 0
            and     ChkStatus, 0
            and     ChkTool, 0
            and     ChkEdit, 0
            and     ChkEditSub, 0
            and     ChkOpenSav, 0
            and     ChkChoFont, 0
            and     ChkChoColor, 0
            and     ChkFindRep, 0
            and     ChkMRU, 0
            and     ChkPrint, 0
            and     ChkReg, 0

            xor     eax, eax
            mov     ecx, 20 ;24
         .while (ecx)
            .if eax < 7
               mov     dword ptr ButtColor[eax*4], 008080ffh
            .else
               mov     dword ptr ButtColor[eax*4], 00b8b800h
            .endif
               inc     eax
               dec     ecx
         .endw
            mov     dword ptr ButtColor[eax*4], 00b8b800h
            inc     eax
            mov     dword ptr ButtColor[eax*4], 00c1ffc1h
            inc     eax
            mov     dword ptr ButtColor[eax*4], 00b8b800h
            inc     eax
            mov     dword ptr ButtColor[eax*4], 000000ffh

         .if Reset
               xor     eax, eax
               mov     Cnt, 20
            .while (Cnt)
                 push     eax
;               INVOKE     SendMessage, hButt01[eax*4], WM_MOUSEMOVE, 0, 0
               INVOKE     RedrawWindow, hButt01[eax*4], NULL, NULL, RDW_INVALIDATE or RDW_UPDATENOW
                  pop     eax
                  inc     eax
                  dec     Cnt
            .endw
               jmp     Ret0
         .endif

         INVOKE     SubClass, hdlg, 251, addr hButt01     ; SubClass the Button
         INVOKE     SubClass, hdlg, 252, addr hButt02     ; SubClass the Button
         INVOKE     SubClass, hdlg, 253, addr hButt03     ; SubClass the Button
         INVOKE     SubClass, hdlg, 254, addr hButt04     ; SubClass the Button
         INVOKE     SubClass, hdlg, 255, addr hButt05     ; SubClass the Button
         INVOKE     SubClass, hdlg, 256, addr hButt06     ; SubClass the Button
         INVOKE     SubClass, hdlg, 257, addr hButt07     ; SubClass the Button
         INVOKE     SubClass, hdlg, 258, addr hButt08     ; SubClass the Button
         INVOKE     SubClass, hdlg, 259, addr hButt09     ; SubClass the Button
         INVOKE     SubClass, hdlg, 260, addr hButt10     ; SubClass the Button
         INVOKE     SubClass, hdlg, 261, addr hButt11     ; SubClass the Button
         INVOKE     SubClass, hdlg, 262, addr hButt12     ; SubClass the Button
         INVOKE     SubClass, hdlg, 263, addr hButt13     ; SubClass the Button
         INVOKE     SubClass, hdlg, 264, addr hButt14     ; SubClass the Button
         INVOKE     SubClass, hdlg, 265, addr hButt15     ; SubClass the Button
         INVOKE     SubClass, hdlg, 266, addr hButt16     ; SubClass the Button
         INVOKE     SubClass, hdlg, 267, addr hButt17     ; SubClass the Button
         INVOKE     SubClass, hdlg, 268, addr hButt18     ; SubClass the Button
         INVOKE     SubClass, hdlg, 269, addr hButt19     ; SubClass the Button
         INVOKE     SubClass, hdlg, 270, addr hButt20     ; SubClass the Button
         INVOKE     SubClass, hdlg, 290, addr hReset      ; SubClass the Button
         INVOKE     SubClass, hdlg, 291, addr hSave       ; SubClass the Button
         INVOKE     SubClass, hdlg, 292, addr hCancelS    ; SubClass the Button

         INVOKE     HeapAlloc, hDefHeap, 0, 51200
            mov     hBuff, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 51200
            mov     hOutPut, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 4096
            mov     hCommand, eax
            mov     eax, hCommand
            mov     byte ptr[eax], 0

         INVOKE     GetClientRect, hWnd, addr rect
          MOVmd     pt.x, rect.left
            mov     pt.y, 0
           push     rect.top
         INVOKE     ClientToScreen, hWnd, addr pt
            mov     eax, rect.right
            sub     eax, rect.left
           push     eax
         INVOKE     GetWindowRect, hdlg, addr rect
            mov     ebx, rect.right
            sub     ebx, rect.left
            pop     eax
            sub     eax, ebx
            add     eax, pt.x
            sub     eax, 19
            mov     ecx, rect.bottom
            sub     ecx, rect.top
            pop     edx                                   ; rect.top from hWnd
            add     edx, pt.y
            add     edx, 27
         INVOKE     MoveWindow, hdlg, eax, edx, ebx, ecx, TRUE
            jmp     Ret0
      .endif

      .if wMsg == WM_CTLCOLORDLG
         .if hBR
            INVOKE     DeleteObject, hBR
         .endif
         INVOKE     CreateSolidBrush, 00ffffe0h
            mov     hBR, eax
            ret
      .endif

      .if wMsg == WM_CTLCOLORSTATIC
         INVOKE     SetBkColor, wParam, 00ffffe0h
         INVOKE     SetTextColor, wParam, 00000000h
         .if hBR
            INVOKE     DeleteObject, hBR
         .endif
         INVOKE     CreateSolidBrush, 00ffffe0h
            mov     hBR, eax
            ret
      .endif

      .if wMsg == WM_DRAWITEM
         INVOKE     DrawButt, lParam
            jmp     Ret0
      .endif

      .if wMsg == WM_COMMAND
         INVOKE     lstrcpy, addr szBuff1, addr szBuff0
         INVOKE     lstrcat, addr szBuff1, addr szStepBStep
         .if wParam > 250 && wParam < 271
            .if hIncLib
               INVOKE     MessageBox, NULL, addr szError7, addr pTitle, MB_OK or MB_ICONWARNING or MB_SYSTEMMODAL
                  jmp     Ret0
            .endif
               mov     sw1, 3         ; Error type
               mov     eax, wParam
               sub     eax, 251
               lea     ecx, ButtColor[eax*4]
               mov     ButtOff, ecx
         .endif

         .if wParam > 250 && wParam < 258 ;259
            INVOKE     SendMessage, hREdit, EM_GETSEL, addr SPos, addr EPos
               mov     eax, SPos
               sub     EPos, eax
         .endif

         .if wParam > 262 && wParam < 269
            .if !ChkMenu && !ChkTool
                  mov     sw1, 8
                  jmp     DoError
            .endif
         .endif

;---------- [Heading] ----------
         .if wParam == 251
            .if StepSeq != 0 && !EPos
               .if ButtColor[0] == 00b0b0ffh
                     mov     sw1, 4
               .endif
                  jmp     DoError
            .endif
mov     eax, ButtOff
mov     dword ptr[eax], 00b0b0ffh
               mov     StepSeq, 251
            INVOKE     lstrcpy, addr szBuff2, addr AppName
            INVOKE     lstrcat, addr szBuff2, addr szPath
            INVOKE     lstrcat, addr szBuff2, addr szFileName
            INVOKE     lstrcat, addr szBuff2, addr szAsm
            INVOKE     SendMessage, hWnd, WM_SETTEXT, 0, addr szBuff2

;---------- [Send the path to AsmEdit] ----------
            INVOKE     lstrcpy, addr szBuff2, addr szPath
            INVOKE     lstrcat, addr szBuff2, addr szFileName
            INVOKE     lstrcat, addr szBuff2, addr szAsm
            INVOKE     lstrcpy, SavPath, addr szBuff2

;---------- [Send the file name to AsmEdit] ----------
            INVOKE     lstrcpy, addr szName, addr szFileName
            INVOKE     lstrcat, addr szName, addr szAsm
            INVOKE     lstrcpy, SavName, addr szName

            INVOKE     lstrcat, addr szBuff1, addr szHeadingG
               jmp     BuildIt

;---------- [Include's and Libraries] ----------
         .elseif wParam == 252
            .if !hIncLib
               .if StepSeq != 251 && !EPos
                  .if ButtColor[4] == 00b0b0ffh
                        mov     sw1, 4
                  .endif
                     jmp     DoError
               .endif
                  mov     StepSeq, 252
mov     eax, ButtOff
mov     dword ptr[eax], 00b0b0ffh
               INVOKE     CreateDialogParam, hInst, 4903, hdlg, offset IncLib, 0
                  mov     hIncLib, eax
            .endif

;---------- [PROTO and Data section] ----------
         .elseif wParam == 253
            .if StepSeq != 252 && !EPos
               .if ButtColor[8] == 00b0b0ffh
                     mov     sw1, 4
               .endif
                  jmp     DoError
            .endif
               mov     StepSeq, 253
mov     eax, ButtOff
mov     dword ptr[eax], 00b0b0ffh
            INVOKE     lstrcat, addr szBuff1, addr szProtoG
               jmp     BuildIt

;---------- [Start routine] ----------
         .elseif wParam == 254
            .if StepSeq != 253 && !EPos
               .if ButtColor[12] == 00b0b0ffh
                     mov     sw1, 4
               .endif
                  jmp     DoError
            .endif
               mov     StepSeq, 254
mov     eax, ButtOff
mov     dword ptr[eax], 00b0b0ffh
            INVOKE     lstrcat, addr szBuff1, addr szStartG
               jmp     BuildIt

;---------- [WinMain procedure] ----------
         .elseif wParam == 255
            .if StepSeq != 254 && !EPos
               .if ButtColor[16] == 00b0b0ffh
                     mov     sw1, 4
               .endif
                  jmp     DoError
            .endif
               mov     StepSeq, 255
mov     eax, ButtOff
mov     dword ptr[eax], 00b0b0ffh
            INVOKE     lstrcat, addr szBuff1, addr szWinMainG
               jmp     BuildIt

;---------- [Main Window] ----------
         .elseif wParam == 256
            .if StepSeq != 255 && !EPos
               .if ButtColor[20] == 00b0b0ffh
                     mov     sw1, 4
               .endif
                  jmp     DoError
            .endif
               mov     StepSeq, 256
mov     eax, ButtOff
mov     dword ptr[eax], 00b0b0ffh
            INVOKE     lstrcat, addr szBuff1, addr szMainWinG
               jmp     BuildIt

;---------- [WinProc procedure] ----------
         .elseif wParam == 257
            .if StepSeq != 256 && !EPos
               .if ButtColor[24] == 00b0b0ffh
                     mov     sw1, 4
               .endif
                  jmp     DoError
            .endif
               mov     StepSeq, 257
mov     eax, ButtOff
mov     dword ptr[eax], 00b0b0ffh
               mov     ChkWinProc, 1
            INVOKE     lstrcat, addr szBuff1, addr szWinProcG
               jmp     BuildIt

;---------- [Main Menu] ----------
         .elseif wParam == 258
            .if !ChkWinProc || ChkMenu ;&& !EPos
               .if ButtColor[28] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     StepSeq, 258
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkMenu, 1
            INVOKE     CreateDialogParam, hInst, 4904, hdlg, offset WorkWin, 0

;---------- [Create the Toolbar] ----------
         .elseif wParam == 259
            .if !ChkWinProc || ChkTool ;&& !EPos
               .if ButtColor[32] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     Cnt, 1
               mov     StepSeq, 259
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkTool, 1

            INVOKE     FindRep, hREdit, addr szConst, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szToolbar2G     ; Macros
               jmp     BuildIt
StepT2:
            INVOKE     FindRep, hREdit, addr szDataF, 0, 3
            INVOKE     lstrcpy, hBuff, addr szToolClass
               jmp     BuildIt2
StepT3:
            INVOKE     FindRep, hREdit, addr szhWnd, 0, 3
            INVOKE     lstrcpy, hBuff, addr szhTool
               jmp     BuildIt2
StepT4:
            INVOKE     FindRep, hREdit, addr szWndProc, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szToolbar3G     ; LOCAL's
               jmp     BuildIt
StepT5:
            INVOKE     FindRep, hREdit, addr szCreate, 0, 2
            INVOKE     lstrcat, addr szBuff1, addr szToolbar4G     ; Create the Toolbar
               jmp     BuildIt
StepT6:
            INVOKE     FindRep, hREdit, addr szSize, 0, 2
            INVOKE     lstrcat, addr szBuff1, addr szToolbar5G     ; Size the Toolbar
               jmp     BuildIt
StepT7:
            INVOKE     FindRep, hREdit, addr szNotify, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szToolbar6G     ; Notify Tooltips
               jmp     BuildIt
StepT8:
            INVOKE     FindRep, hREdit, addr szDestroy, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szToolbar7G     ; Destroy the Image list
               jmp     BuildIt
StepT9:
            .if ChkEdit
               INVOKE     FindRep, hREdit, addr szSizeEdit, 0, 9
               INVOKE     lstrcat, addr szBuff1, addr szWinEdit9G  ; Size the Edit control
                 jmp     BuildIt
            .else
                 jmp     BuildIt3
            .endif
StepT10:
            INVOKE     FindRep, hREdit, addr szWinMainP, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szToolbar9G     ; Proto
               jmp     BuildIt
StepT11:
            INVOKE     FindRep, hREdit, addr szEndStart, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szToolbar10G    ; Color bitmaps
               jmp     BuildIt
StepT12:
            .if ChkFindRep
               INVOKE     FindRep, hREdit, addr szTBButt7, 0, 7
               INVOKE     lstrcat, addr szBuff1, addr szFindRep4G
                  jmp     BuildIt
            .else
                 jmp     BuildIt3
            .endif

;---------- [Create the Statusbar] ----------
         .elseif wParam == 260
            .if !ChkWinProc || ChkStatus ;&& !EPos
               .if ButtColor[36] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     Cnt, 1
               mov     StepSeq, 260
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkStatus, 1
            INVOKE     FindRep, hREdit, addr szDataF, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szStatusbar1G
               jmp     BuildIt
StepS2:
            INVOKE     FindRep, hREdit, addr szhWnd, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szStatusbar2G
               jmp     BuildIt
StepS3:
            INVOKE     FindRep, hREdit, addr szCreate, 0, 2
            INVOKE     lstrcat, addr szBuff1, addr szStatusbar3G
               jmp     BuildIt
StepS4:
            INVOKE     FindRep, hREdit, addr szSize, 0, 2
            INVOKE     lstrcat, addr szBuff1, addr szStatusbar4G
               jmp     BuildIt
StepS5:
            .if ChkEdit
               INVOKE     FindRep, hREdit, addr szSizeEdit, 0, 9
               INVOKE     lstrcat, addr szBuff1, addr szWinEdit9G
                 jmp     BuildIt
            .else
                 jmp     BuildIt3
            .endif

;---------- [Create the Edit Control] ----------
         .elseif wParam == 261
            .if !ChkWinProc || ChkEdit ;&& !EPos
               .if ButtColor[40] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     Cnt, 1
               mov     StepSeq, 261
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkEdit, 1
            INVOKE     FindRep, hREdit, addr szDataF, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szWinEdit1G
               jmp     BuildIt
StepE2:
            INVOKE     FindRep, hREdit, addr szDataQ, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szWinEdit2G
               jmp     BuildIt
StepE3:
            INVOKE     FindRep, hREdit, addr szhWnd, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szWinEdit3G
               jmp     BuildIt
StepE4:
            INVOKE     FindRep, hREdit, addr szStruct, 0, 5
            INVOKE     lstrcat, addr szBuff1, addr szWinEdit4G
               jmp     BuildIt
StepE5:
            INVOKE     FindRep, hREdit, addr szInit, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szWinEdit5G
               jmp     BuildIt
StepE6:
            INVOKE     FindRep, hREdit, addr szExit, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szWinEdit6G
               jmp     BuildIt
StepE7:
            INVOKE     FindRep, hREdit, addr szWndProc, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szWinEdit7G
               jmp     BuildIt
StepE8:
            INVOKE     FindRep, hREdit, addr szMoveSize, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szWinEdit8G
               jmp     BuildIt
StepE9:
            INVOKE     FindRep, hREdit, addr szNotify, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szWinEdit9G
               jmp     BuildIt

;---------- [Edit SubClass] ----------
         .elseif wParam == 262
            .if !ChkEdit || ChkEditSub ;&& !EPos
               .if ButtColor[44] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     Cnt, 1
               mov     StepSeq, 262
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkEditSub, 1
            INVOKE     FindRep, hREdit, addr szWinMainP, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szEditSub1G
               jmp     BuildIt
StepC2:
            INVOKE     FindRep, hREdit, addr szhREdit, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szEditSub2G
               jmp     BuildIt
StepC3:
            INVOKE     FindRep, hREdit, addr szFocus, 0, 2
            INVOKE     lstrcat, addr szBuff1, addr szEditSub3G
               jmp     BuildIt
StepC4:
            INVOKE     FindRep, hREdit, addr szEndStart, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szEditSub4G
               jmp     BuildIt

;---------- [Open Save file] ----------
         .elseif wParam == 263
            .if !ChkEdit && ChkMenu || !ChkEdit && ChkTool || ChkOpenSav ;&& !EPos
               .if ButtColor[48] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     Cnt, 1
               mov     StepSeq, 263
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkOpenSav, 1
            INVOKE     FindRep, hREdit, addr szStruct, 0, 4  ;NOTE! was szCode
            INVOKE     lstrcat, addr szBuff1, addr szOpenSave1G
               jmp     BuildIt
StepO2:
            INVOKE     FindRep, hREdit, addr szDataQ, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szOpenSave2G

               jmp     BuildIt
StepO3:
            INVOKE     FindRep, hREdit, addr szEndStart, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szOpenSave3G
               jmp     BuildIt
StepO4:
            INVOKE     FindRep, hREdit, addr szClose, 0, 3



            INVOKE     lstrcat, addr szBuff1, addr szWinEdit10G
               jmp     BuildIt

;---------- [Choose font] ----------
         .elseif wParam == 264
            .if !ChkEdit || !ChkMenu || ChkChoFont ;&& !EPos
               .if ButtColor[52] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     Cnt, 1
               mov     StepSeq, 264
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkChoFont, 1
            INVOKE     FindRep, hREdit, addr szEndStart, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szChoFont1G
               jmp     BuildIt

;---------- [Choose color] ----------
         .elseif wParam == 265
            .if !ChkEdit || !ChkMenu || ChkChoColor ;&& !EPos
               .if ButtColor[56] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     Cnt, 1
               mov     StepSeq, 265
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkChoColor, 1
            INVOKE     FindRep, hREdit, addr szStruct, 0, 4  ;NOTE! was szCode
            INVOKE     lstrcat, addr szBuff1, addr szChoColor1G
               jmp     BuildIt
StepCC2:
            INVOKE     FindRep, hREdit, addr szEndStart, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szChoColor2G
               jmp     BuildIt

;---------- [Find / Replace] ----------
         .elseif wParam == 266
            .if !ChkEdit && ChkMenu || !ChkEdit && ChkTool || ChkFindRep ;&& !EPos
               .if ButtColor[60] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     Cnt, 1
               mov     StepSeq, 266
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkFindRep, 1
            INVOKE     FindRep, hREdit, addr szWinMainP, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szFindRep1G
               jmp     BuildIt
StepFR2:
            INVOKE     FindRep, hREdit, addr szDataQ, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szFindRep2G
               jmp     BuildIt
StepFR3:
            INVOKE     FindRep, hREdit, addr szStruct, 0, 4  ;NOTE! was szCode
            INVOKE     lstrcat, addr szBuff1, addr szFindRep3G
               jmp     BuildIt
StepFR4:
            INVOKE     FindRep, hREdit, addr szStruct, 0, 5
            INVOKE     lstrcat, addr szBuff1, addr szFindRep4G
               jmp     BuildIt
StepFR5:
            .if ChkTool
               INVOKE     FindRep, hREdit, addr szTBButt7, 0, 7
               INVOKE     lstrcat, addr szBuff1, addr szFindRep5G
                  jmp     BuildIt
            .else
                 jmp     BuildIt3
            .endif
StepFR6:
            INVOKE     FindRep, hREdit, addr szEndStart, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szFindRep6G
               jmp     BuildIt

;---------- [MRU] ----------
         .elseif wParam == 267
            .if !ChkEdit || !ChkMenu || !ChkOpenSav || ChkMRU ;&& !EPos
               .if ButtColor[64] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     Cnt, 1
               mov     StepSeq, 267
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkMRU, 1
            INVOKE     FindRep, hREdit, addr szWinMainP, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szMRU1G
               jmp     BuildIt
StepM2:
            INVOKE     FindRep, hREdit, addr szMenuCnt, 0, 5
            INVOKE     lstrcat, addr szBuff1, addr szMRU2G
               jmp     BuildIt
StepM3:
            INVOKE     FindRep, hREdit, addr szCommandM, 0, 3 ;2
            INVOKE     lstrcat, addr szBuff1, addr szMRU3G
               jmp     BuildIt
StepM4:
            INVOKE     FindRep, hREdit, addr szOperr, 0, 2
            INVOKE     lstrcat, addr szBuff1, addr szMRU4G
               jmp     BuildIt
StepM5:
            INVOKE     FindRep, hREdit, addr szEndOpen, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szMRU5G
               jmp     BuildIt
StepM6:
            INVOKE     FindRep, hREdit, addr szCode, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szMRU6G
               jmp     BuildIt

;---------- [Print] ----------
         .elseif wParam == 268
            .if !ChkMenu || !ChkEdit || ChkPrint ;&& !EPos
               .if ButtColor[68] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     Cnt, 1
               mov     StepSeq, 268
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkPrint, 1
            INVOKE     FindRep, hREdit, addr szDataQ, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szPrint1G
               jmp     BuildIt
StepP2:
            INVOKE     FindRep, hREdit, addr szEndStart, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szPrint2G
               jmp     BuildIt

;---------- [Registry] ----------
         .elseif wParam == 269
            .if !ChkEdit || ChkReg ;&& !EPos
               .if ButtColor[72] == 00dcdc00h
                     mov     sw1, 5
               .endif
                  jmp     DoError
            .endif
               mov     Cnt, 1
               mov     StepSeq, 269
mov     eax, ButtOff
mov     dword ptr[eax], 00dcdc00h
               mov     ChkReg, 1
            INVOKE     FindRep, hREdit, addr szWinMainP, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szRegistry1G
               jmp     BuildIt
StepR2:
            INVOKE     FindRep, hREdit, addr szRedit, 0, 5
            INVOKE     lstrcat, addr szBuff1, addr szRegistry2G
               jmp     BuildIt
StepR3:
            INVOKE     FindRep, hREdit, addr szhSMenu, 0, 3
            INVOKE     lstrcat, addr szBuff1, addr szRegistry3G
               jmp     BuildIt
StepR4:
            INVOKE     FindRep, hREdit, addr szGetMenu, 0, 4  ;*****************************
            INVOKE     lstrcat, addr szBuff1, addr szRegistry4G
               jmp     BuildIt
StepR5:
            INVOKE     FindRep, hREdit, addr szDestroy, 0, 3  ;*****************************
            INVOKE     lstrcat, addr szBuff1, addr szRegistry5G
               jmp     BuildIt
StepR6:
            INVOKE     FindRep, hREdit, addr szWndProcEnd, 0, 2
            INVOKE     lstrcat, addr szBuff1, addr szRegistry6G
               jmp     BuildIt
StepR7:
            INVOKE     FindRep, hREdit, addr szEndStart, 0, 4
            INVOKE     lstrcat, addr szBuff1, addr szRegistry7G
               jmp     BuildIt

         .elseif wParam == 290
            INVOKE     SendMessage, hREdit, WM_SETTEXT, 0, addr szNull
            INVOKE     lstrcpy, addr szBuff2, addr AppName
            INVOKE     SendMessage, hWnd, WM_SETTEXT, 0, addr szBuff2
            INVOKE     lstrcpy, SavPath, addr szNull
            INVOKE     lstrcpy, SavName, addr szNull
            INVOKE     SendMessage, hREdit, EM_SETMODIFY, FALSE, 0
               mov     eax, hCommand
               mov     byte ptr[eax], 0
               mov     Reset, 1
               jmp     DoReset

         .elseif wParam == 291
            INVOKE     SendMessage, hWnd, WM_COMMAND, 6004, 0    ; Save file
            INVOKE     lstrcpy, SavErr, addr szClr
               jmp     GetOut

         .elseif wParam == 292
            INVOKE     lstrcpy, SavErr, addr szClr
               jmp     GetOut
         .endif
            jmp     Ret0

BuildIt:
         INVOKE     ReadInput, addr szBuff1
           test     eax, eax
             js     Ret0

BuildIt2:
         INVOKE     lstrcat, hBuff, addr szCRLF
         INVOKE     lstrcpy, hOutPut, hBuff
         INVOKE     SendMessage, hREdit, EM_HIDESELECTION, 1, 0
         INVOKE     SendMessage, hREdit, EM_GETSEL, addr SPos, addr EPos
         INVOKE     SendMessage, hREdit, EM_SETSEL, SPos, EPos
         INVOKE     SendMessage, hREdit, EM_REPLACESEL, TRUE, hOutPut
         INVOKE     SendMessage, hREdit, WM_LBUTTONUP, 0, 0
         INVOKE     SendMessage, hREdit, WM_PAINT, 0, 0
         INVOKE     SendMessage, hREdit, EM_HIDESELECTION, 0, 0
            and     SPos, 0
            and     EPos, 0

BuildIt3:
         .if wParam > 256  ;< 258 ;> 256
            INVOKE     SendMessage, hREdit, EM_HIDESELECTION, 1, 0
            INVOKE     SendMessage, hREdit, WM_GETTEXTLENGTH, 0, 0
            INVOKE     SendMessage, hREdit, EM_SETSEL, eax, eax
            INVOKE     SendMessage, hREdit, EM_HIDESELECTION, 0, 0
         .endif

         .if wParam == 257
;            INVOKE     SendMessage, hREdit, WM_GETTEXTLENGTH, 0, 0
;            INVOKE     SendMessage, hREdit, EM_SETSEL, eax, eax
;            INVOKE     SendMessage, hREdit, EM_REPLACESEL, TRUE, addr szEndStart
            INVOKE     FindRep, hREdit, addr szXXXX, addr szFileName, 6
            INVOKE     SendMessage, hREdit, WM_LBUTTONUP, 0, 0
            INVOKE     SendMessage, hREdit, WM_PAINT, 0, 0
         .endif
         .if wParam == 259
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if Cnt == 1
                  inc     Cnt
                  jmp     StepT2
            .elseif Cnt == 2
                  inc     Cnt
                  jmp     StepT3
            .elseif Cnt == 3
                  inc     Cnt
                  jmp     StepT4
            .elseif Cnt == 4
                  inc     Cnt
                  jmp     StepT5
            .elseif Cnt == 5
                  inc     Cnt
                  jmp     StepT6
            .elseif Cnt == 6
                  inc     Cnt
                  jmp     StepT7
            .elseif Cnt == 7
                  inc     Cnt
                  jmp     StepT8
            .elseif Cnt == 8
                  inc     Cnt
                  jmp     StepT9
            .elseif Cnt == 9
                  inc     Cnt
                  jmp     StepT10
            .elseif Cnt == 10
                  inc     Cnt
                  jmp     StepT11
            .elseif Cnt == 11
                  inc     Cnt
                  jmp     StepT12
            .elseif Cnt == 12
                  inc     Cnt
               .if ChkFindRep
                  INVOKE     FindRep, hREdit, addr szILC, addr szILCR, 6
                  INVOKE     FindRep, hREdit, addr szCnt, addr szCntR, 6
               .endif
                  INVOKE     CreateDialogParam, hInst, 4904, hdlg, offset WorkWin, 1
            .elseif Cnt == 13
                  inc     Cnt
               .if ChkEdit && !ChkStatus
                  INVOKE     FindRep, hREdit, addr szIfStat, 0, 8   ; Remove size Statusbar
               .endif
            .endif
         .endif

         .if wParam == 260
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if Cnt == 1
                  inc     Cnt
                  jmp     StepS2
            .elseif Cnt == 2
                  inc     Cnt
                  jmp     StepS3
            .elseif Cnt == 3
                  inc     Cnt
                  jmp     StepS4
            .elseif Cnt == 4
                  inc     Cnt
                  jmp     StepS5
            .elseif Cnt == 5
                  inc     Cnt
               .if ChkEdit && !ChkTool
                  INVOKE     FindRep, hREdit, addr szIfTool, 0, 8   ; Remove size Toolbar
               .endif
            .endif
         .endif

         .if wParam == 261
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if Cnt == 1
                  inc     Cnt
                  jmp     StepE2
            .elseif Cnt == 2
                  inc     Cnt
                  jmp     StepE3
            .elseif Cnt == 3
                  inc     Cnt
                  jmp     StepE4
            .elseif Cnt == 4
                  inc     Cnt
                  jmp     StepE5
            .elseif Cnt == 5
                  inc     Cnt
                  jmp     StepE6
            .elseif Cnt == 6
                  inc     Cnt
                  jmp     StepE7
            .elseif Cnt == 7
                  inc     Cnt
                  jmp     StepE8
            .elseif Cnt == 8
                  inc     Cnt
                  jmp     StepE9
            .elseif Cnt == 9
                  inc     Cnt
               .if !ChkTool
                  INVOKE     FindRep, hREdit, addr szIfTool, 0, 8
               .endif
               .if !ChkStatus
                  INVOKE     FindRep, hREdit, addr szIfStat, 0, 8
               .endif
               INVOKE     CreateDialogParam, hInst, 4904, hdlg, offset WorkWin, 4
            .endif
         .endif

         .if wParam == 262
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if Cnt == 1
                  inc     Cnt
                  jmp     StepC2
            .elseif Cnt == 2
                  inc     Cnt
                  jmp     StepC3
            .elseif Cnt == 3
                  inc     Cnt
                  jmp     StepC4
            .elseif Cnt == 4
                  inc     Cnt
;               .if !ChkMenu
                  INVOKE     CreateDialogParam, hInst, 4904, hdlg, offset WorkWin, 3
;               .endif
            .endif
         .endif

         .if wParam == 263
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if Cnt == 1
                  inc     Cnt
                  jmp     StepO2
            .elseif Cnt == 2
                  inc     Cnt
                  jmp     StepO3
            .elseif Cnt == 3
                  inc     Cnt
                  jmp     StepO4
            .elseif Cnt == 4
                  inc     Cnt
                  mov     eax, hCommand
                  mov     byte ptr[eax], 0
               INVOKE     CreateDialogParam, hInst, 4904, hdlg, offset WorkWin, 4
            .endif
         .endif

         .if wParam == 264
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if Cnt == 1
                  inc     Cnt
                  mov     eax, hCommand
                  mov     byte ptr[eax], 0
               INVOKE     CreateDialogParam, hInst, 4904, hdlg, offset WorkWin, 4
            .endif
         .endif

         .if wParam == 265
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if Cnt == 1
                  inc     Cnt
                  jmp     StepCC2
            .elseif Cnt == 2
                  inc     Cnt
                  mov     eax, hCommand
                  mov     byte ptr[eax], 0
               INVOKE     CreateDialogParam, hInst, 4904, hdlg, offset WorkWin, 4
            .endif
         .endif

         .if wParam == 266
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if Cnt == 1
                  inc     Cnt
                  jmp     StepFR2
            .elseif Cnt == 2
                  inc     Cnt
                  jmp     StepFR3
            .elseif Cnt == 3
                  inc     Cnt
                  jmp     StepFR4
            .elseif Cnt == 4
                  inc     Cnt
                  jmp     StepFR5
            .elseif Cnt == 5
                  inc     Cnt
                  jmp     StepFR6
            .elseif Cnt == 6
                  inc     Cnt
               INVOKE     FindRep, hREdit, addr szILC, addr szILCR, 6
               INVOKE     FindRep, hREdit, addr szCnt, addr szCntR, 6
               INVOKE     CreateDialogParam, hInst, 4904, hdlg, offset WorkWin, 5
            .endif
         .endif

         .if wParam == 267
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if Cnt == 1
                  inc     Cnt
                  jmp     StepM2
            .elseif Cnt == 2
                  inc     Cnt
                  jmp     StepM3
            .elseif Cnt == 3
                  inc     Cnt
                  jmp     StepM4
            .elseif Cnt == 4
                  inc     Cnt
                  jmp     StepM5
            .elseif Cnt == 5
                  inc     Cnt
                  jmp     StepM6
            .elseif Cnt == 6
                  inc     Cnt
                  mov     eax, hCommand
                  mov     byte ptr[eax], 0
               INVOKE     CreateDialogParam, hInst, 4904, hdlg, offset WorkWin, 6
               INVOKE     FindRep, hREdit, addr szXXXX, addr szFileName, 6
INVOKE     SendMessage, hWnd, WM_COMMAND, 7077, 0
            .endif
         .endif

         .if wParam == 268
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if Cnt == 1
                  inc     Cnt
                  jmp     StepP2
            .elseif Cnt == 2
                  inc     Cnt
                  mov     eax, hCommand
                  mov     byte ptr[eax], 0
               INVOKE     CreateDialogParam, hInst, 4904, hdlg, offset WorkWin, 7
            .endif
         .endif

         .if wParam == 269
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if Cnt == 1
                  inc     Cnt
                  jmp     StepR2
            .elseif Cnt == 2
                  inc     Cnt
                  jmp     StepR3
            .elseif Cnt == 3
                  inc     Cnt
                  jmp     StepR4
            .elseif Cnt == 4
                  inc     Cnt
                  jmp     StepR5
            .elseif Cnt == 5
                  inc     Cnt
                  jmp     StepR6
            .elseif Cnt == 6
                  inc     Cnt
                  jmp     StepR7
            .endif
         .endif

            jmp     Ret0

      .elseif wMsg == WM_CLOSE
         INVOKE     lstrcpy, SavErr, addr szClr

GetOut:
         .if hIncLib
            INVOKE     EndDialog, hIncLib, wParam
               and     hIncLib, 0
         .endif
         .if hWork
            INVOKE     EndDialog, hWork, wParam
               and     hWork, 0
         .endif
         .if hBR
            INVOKE     DeleteObject, hBR
         .endif
         INVOKE     EndDialog, hdlg, 0
            mov     eax, TRUE
            ret
      .endif
         jmp     Ret0

DoError:
      .if sw1 == 3
            INVOKE     MessageBox, NULL, addr szError3, addr pTitle, MB_OK or MB_ICONWARNING or MB_SYSTEMMODAL
      .elseif sw1 == 4
            INVOKE     MessageBox, NULL, addr szError4, addr pTitle, MB_OK or MB_ICONWARNING or MB_SYSTEMMODAL
      .elseif sw1 == 5
            INVOKE     MessageBox, NULL, addr szError5, addr pTitle, MB_OK or MB_ICONWARNING or MB_SYSTEMMODAL
      .elseif sw1 == 8
            INVOKE     MessageBox, NULL, addr szError8, addr pTitle, MB_OK or MB_ICONWARNING or MB_SYSTEMMODAL
      .endif

Ret0:
         xor     eax, eax
         ret

WndProc endp

;=================================================
; Subclass the Control Buttons
;=================================================
SubClass PROC hdlg:DWORD, ID, hButt
      INVOKE     GetDlgItem, hdlg, ID            ; Get the handle of the Button
         mov     ecx, hButt
         mov     [ecx], eax                      ; and save it
;      INVOKE     SetWindowLong, [ecx], GWL_WNDPROC, ControlButt
;         mov     SubControl, eax
         ret
SubClass ENDP

;======================================
; Type of Button
;======================================
ButtInfo PROC BFont:DWORD, BBack, BText

       MOVmd     disFont, BFont
       MOVmd     disBack, BBack
       MOVmd     disText, BText

         ret
ButtInfo ENDP

;======================================
; Owner drawn Buttons
;======================================
DrawButt  PROC uses ebx esi edi disDC:DWORD
LOCAL    disBrush:DWORD, hOldFont
LOCAL    szBuff1[256]:BYTE

         mov     esi, disDC
         lea     edi, dis
         mov     ecx, sizeof dis
         rep     movsb

      .if dis.itemID != -1
;DSPValue hWnd, dis.CtlID, 1, 't'
            mov     eax, dis.hwndItem
         .if eax == hButt01
            INVOKE     ButtInfo, hFontB, ButtColor[0], 00000000h ; Font, BackColor, TextColor
         .elseif eax == hButt02
            INVOKE     ButtInfo, hFontB, ButtColor[4], 00000000h
         .elseif eax == hButt03
            INVOKE     ButtInfo, hFontB, ButtColor[8], 00000000h
         .elseif eax == hButt04
            INVOKE     ButtInfo, hFontB, ButtColor[12], 00000000h
         .elseif eax == hButt05
            INVOKE     ButtInfo, hFontB, ButtColor[16], 00000000h
         .elseif eax == hButt06
            INVOKE     ButtInfo, hFontB, ButtColor[20], 00000000h
         .elseif eax == hButt07
            INVOKE     ButtInfo, hFontB, ButtColor[24], 00000000h
         .elseif eax == hButt08
            INVOKE     ButtInfo, hFontB, ButtColor[28], 00000000h
         .elseif eax == hButt09
            INVOKE     ButtInfo, hFontB, ButtColor[32], 00000000h
         .elseif eax == hButt10
            INVOKE     ButtInfo, hFontB, ButtColor[36], 00000000h
         .elseif eax == hButt11
            INVOKE     ButtInfo, hFontB, ButtColor[40], 00000000h
         .elseif eax == hButt12
            INVOKE     ButtInfo, hFontB, ButtColor[44], 00000000h
         .elseif eax == hButt13
            INVOKE     ButtInfo, hFontB, ButtColor[48], 00000000h
         .elseif eax == hButt14
            INVOKE     ButtInfo, hFontB, ButtColor[52], 00000000h
         .elseif eax == hButt15
            INVOKE     ButtInfo, hFontB, ButtColor[56], 00000000h
         .elseif eax == hButt16
            INVOKE     ButtInfo, hFontB, ButtColor[60], 00000000h
         .elseif eax == hButt17
            INVOKE     ButtInfo, hFontB, ButtColor[64], 00000000h
         .elseif eax == hButt18
            INVOKE     ButtInfo, hFontB, ButtColor[68], 00000000h
         .elseif eax == hButt19
            INVOKE     ButtInfo, hFontB, ButtColor[72], 00000000h
         .elseif eax == hButt20
            INVOKE     ButtInfo, hFontB, ButtColor[76], 00000000h
         .elseif eax == hButt45
            INVOKE     ButtInfo, hFontB, ButtColor[80], 00000000h
         .elseif eax == hReset
            INVOKE     ButtInfo, hFontB, ButtColor[84], 00000000h
         .elseif eax == hSave
            INVOKE     ButtInfo, hFontB, ButtColor[88], 00000000h
         .elseif eax == hCancelS
            INVOKE     ButtInfo, hFontB, ButtColor[92], 00000000h
;         .elseif eax == hCreate
;            INVOKE     ButtInfo, hFontB, 00000000h, 00ffff00h
         .endif

         INVOKE     SelectObject, dis.hdc, disFont
            mov     hOldFont, eax
         INVOKE     SendMessage, dis.hwndItem, WM_GETTEXT, sizeof szBuff1, addr szBuff1
         .if (dis.itemState & ODS_SELECTED)
            INVOKE     SetTextColor, dis.hdc, 00000000h ; Highlight text color
            INVOKE     SetBkColor, dis.hdc, 00929292h   ; Highlight text background color
            INVOKE     CreateSolidBrush, 00929292h      ; Highlight background color
               mov     disBrush, eax
            INVOKE     FillRect, dis.hdc, addr dis.rcItem, disBrush
            INVOKE     DrawEdge, dis.hdc, addr dis.rcItem, EDGE_SUNKEN, BF_RECT
               add     dis.rcItem.left, 2
               add     dis.rcItem.top, 2
               sub     dis.rcItem.bottom, 2

         .else
            INVOKE     SetTextColor, dis.hdc, disText   ; Text color
            INVOKE     SetBkColor, dis.hdc, disBack     ; Text background color
            INVOKE     CreateSolidBrush, disBack        ; Background color
               mov     disBrush, eax
            INVOKE     FillRect, dis.hdc, addr dis.rcItem, disBrush
            INVOKE     DrawEdge, dis.hdc, addr dis.rcItem, BDR_RAISEDOUTER, BF_TOPLEFT
            INVOKE     DrawEdge, dis.hdc, addr dis.rcItem, BDR_RAISEDOUTER, BF_BOTTOMRIGHT
         .endif
         INVOKE     DrawText, dis.hdc, addr szBuff1, -1, addr dis.rcItem,
                    DT_CENTER or DT_SINGLELINE or DT_VCENTER
         .if (dis.itemState & ODS_FOCUS)
               inc     dis.rcItem.left
               inc     dis.rcItem.top
               mov     dis.rcItem.right, 5
               mov     dis.rcItem.bottom, 5
            INVOKE     DeleteObject, disBrush
            INVOKE     CreateSolidBrush, 0000ff00h      ; Background color
               mov     disBrush, eax
            INVOKE     FillRect, dis.hdc, addr dis.rcItem, disBrush
         .endif
         INVOKE     SelectObject, dis.hdc, hOldFont
         INVOKE     DeleteObject, disBrush
      .endif
         mov     dis.itemState, ODS_DEFAULT
         mov     dis.hdc, 0

         ret

DrawButt ENDP

;=======================================
; Includes and Libraries Dialog
;=======================================
IncLib PROC  uses ebx esi edi  hdlg:DWORD, wmsg, wparam, lparam
LOCAL    rect:RECT
LOCAL    FindData:WIN32_FIND_DATA
LOCAL    hFind:DWORD, Cnt, Num
LOCAL    szBuff1[256]:BYTE, szBuff2[256]:BYTE, szName[256]:BYTE, szOutPut1[1024]:BYTE, szOutPut2[1024]:BYTE

      .if wmsg == WM_INITDIALOG                  ; If message is INITDIALOG then
         INVOKE     GetDlgItem, hdlg, 445        ; Get the handle of the Listbox
            mov     hList45, eax                 ; Save it
         INVOKE     SubClass, hdlg, 545, addr hButt45     ; SubClass the Button

;---------- [Fill the List Box] ----------
         INVOKE     lstrcpy, addr szBuff1, addr szBuff0
         INVOKE     lstrcat, addr szBuff1, addr szStepBStep
         INVOKE     lstrcat, addr szBuff1, addr szIncLibG

;---------- [Read file for loading List box] ----------
         INVOKE     ReadInput, addr szBuff1
           test     eax, eax
             js     IncLibDone
         INVOKE     LoadList, hList45, hBuff, 3
         INVOKE     SendMessage, hList45, LB_SETSEL, TRUE, 0
            jmp     IncLibDone

      .elseif wmsg == WM_CTLCOLORDLG || wmsg == WM_CTLCOLORSTATIC
         INVOKE     SetBkColor, wparam, 00ffffe0h
         INVOKE     SetTextColor, wparam, 00000000h
         .if hBR
            INVOKE     DeleteObject, hBR
         .endif
         INVOKE     CreateSolidBrush, 00ffffe0h
            mov     hBR, eax
            ret

      .elseif wmsg == WM_CTLCOLORLISTBOX ||  wmsg == WM_CTLCOLOREDIT
         INVOKE     SetBkColor, wparam, 00000000h   ; Background color is black
         INVOKE     SetTextColor, wparam, 00ffff00h ; Text color of edit box is lt blue
         INVOKE     GetStockObject, BLACK_BRUSH     ; Select the black brush for background
            ret

      .elseif wmsg == WM_DRAWITEM
         INVOKE     DrawButt, lparam
            jmp     IncLibDone

      .elseif wmsg == WM_CLOSE
EndIt:
         INVOKE     EndDialog, hdlg, 0
            mov     eax, TRUE
            and     hIncLib, 0
            jmp     IncLibRet

      .elseif wmsg != WM_COMMAND
            jmp     IncLibDone
      .endif

         mov     eax, wparam
        cwde
      .if eax == 545
            mov     byte ptr szOutPut1, 0
            mov     byte ptr szOutPut2, 0
         INVOKE     SendMessage, hList45, LB_SETSEL, TRUE, 0   ; To make sure Windows.inc is selected
         INVOKE     SendMessage, hList45, LB_GETSELCOUNT, 0, 0
            mov     ebx, eax
         INVOKE     SendMessage, hList45, LB_GETSELITEMS, ebx, addr szName
            mov     Num, eax
            and     Cnt, 0
         .while (Num)
               mov     ecx, Cnt
            INVOKE     SendMessage, hList45, LB_GETTEXT, dword ptr szName[ecx*4], addr szBuff2

;            INVOKE     lstrcat, addr szOutPut1, addr szIncInc
;            INVOKE     lstrcat, addr szOutPut1, addr szBuff2
;            INVOKE     lstrcat, addr szOutPut1, addr szInc
;            INVOKE     lstrcat, addr szOutPut1, addr szCRLF

            INVOKE     lstrcat, addr szOutPut1, addr szIncInc1
            .if !Cnt
               INVOKE     lstrcat, addr szOutPut1, addr szRoot
            .else
               INVOKE     lstrcat, addr szOutPut1, addr HutchDir ;szRoot+3
            .endif
            INVOKE     lstrcat, addr szOutPut1, addr szIncInc2
            INVOKE     lstrcat, addr szOutPut1, addr szBuff2
            INVOKE     lstrcat, addr szOutPut1, addr szInc
            INVOKE     lstrcat, addr szOutPut1, addr szCRLF

            .if Cnt
;               INVOKE     lstrcat, addr szOutPut2, addr szIncLib
;               INVOKE     lstrcat, addr szOutPut2, addr szBuff2
;               INVOKE     lstrcat, addr szOutPut2, addr szLib
;               INVOKE     lstrcat, addr szOutPut2, addr szCRLF

               INVOKE     lstrcat, addr szOutPut2, addr szIncLib1
               INVOKE     lstrcat, addr szOutPut2, addr HutchDir ;szRoot+3
               INVOKE     lstrcat, addr szOutPut2, addr szIncLib2
               INVOKE     lstrcat, addr szOutPut2, addr szBuff2
               INVOKE     lstrcat, addr szOutPut2, addr szLib
               INVOKE     lstrcat, addr szOutPut2, addr szCRLF

            .endif
               inc     Cnt
               dec     Num
         .endw
         INVOKE     lstrcpy, hOutPut, addr szOutPut1
         INVOKE     lstrcat, hOutPut, addr szCRLF
         INVOKE     lstrcat, hOutPut, addr szOutPut2
         INVOKE     lstrcat, hOutPut, addr szCRLF
         INVOKE     SendMessage, hREdit, EM_HIDESELECTION, 1, 0
         INVOKE     SendMessage, hREdit, EM_GETSEL, addr SPos, addr EPos
         INVOKE     SendMessage, hREdit, EM_SETSEL, SPos, EPos
         INVOKE     SendMessage, hREdit, EM_REPLACESEL, TRUE, hOutPut
         INVOKE     SendMessage, hREdit, EM_HIDESELECTION, 0, 0
         INVOKE     SendMessage, hREdit, WM_LBUTTONUP, 0, 0

;---------- [Needed to force Paint] ----------
         INVOKE     GetWindowRect, hIncLib, addr rect
            mov     edx, rect.right
            sub     edx, rect.left
            mov     ecx, rect.bottom
            sub     ecx, rect.top
            sub     rect.left, 1
            add     edx, 1
         INVOKE     MoveWindow, hIncLib, rect.left, rect.top, edx, ecx, TRUE
            jmp     EndIt
      .endif

IncLibDone:
         mov     eax, FALSE           ; Return with FALSE

IncLibRet:
         RET
IncLib ENDP

;=======================================
; Work Window Dialog
;=======================================
WorkWin PROC uses ebx esi edi hdlg:DWORD, wmsg, wparam, lparam
LOCAL    rect:RECT
LOCAL    szBuff1[256]:BYTE, szBuff2[256], szWork1[100]


      .if wmsg == WM_INITDIALOG                        ; If message is INITDIALOG then
          MOVmd     hWork, hdlg
         INVOKE     GetClientRect, hdlg, addr rect
         INVOKE     CreateWindowEx, 0, addr Richedit, 0,
                    WS_CHILD or WS_VISIBLE or ES_MULTILINE or WS_BORDER or\
                    ES_NOHIDESEL or ES_SAVESEL or WS_VSCROLL or ES_AUTOVSCROLL or\
                    WS_HSCROLL or ES_AUTOHSCROLL or ES_SELECTIONBAR,\
                    0, 0, rect.right, rect.bottom, hdlg, 41, hInst, 0
            mov     hEdit, eax
         INVOKE     SendMessage, hEdit, EM_EXLIMITTEXT, 0, 100000
         INVOKE     SendMessage, hEdit, WM_SETFONT, hFontE, 1

;0 = Main Menu
;1 = Toolbar and no Menu
;2 = 
;3 = SubClass
;4 = Reset commands after loading a new resource file
;5 = Add Find/Replace bitmaps and dialogs to the exsisting resource file
;6 = Copy the MRUFiles.asm to the dir
;7 = Reset commands using the exsisting resource file

            mov     eax, hCommand
            mov     byte ptr[eax], 0

         INVOKE     lstrcpy, addr szBuff1, addr szBuff0
         INVOKE     lstrcat, addr szBuff1, addr szStepBStep
         INVOKE     lstrcat, addr szBuff1, addr szNoMenuG    ; No Main Menu
         INVOKE     ReadInput, addr szBuff1
           test     eax, eax
             js     WorkWinDone   ; Do message
         INVOKE     SendMessage, hEdit, WM_SETTEXT, 0, hBuff

         .if ChkMenu
            INVOKE     SendMessage, hEdit, WM_GETTEXTLENGTH, 0, 0
               mov     ebx, eax
               inc     ebx
            INVOKE     SendMessage, hEdit, EM_SETSEL, eax, ebx
            INVOKE     lstrcpy, addr szBuff1, addr szBuff0
            INVOKE     lstrcat, addr szBuff1, addr szStepBStep
            .if !ChkOpenSav && !ChkPrint
               INVOKE     lstrcat, addr szBuff1, addr szMenuFileBG
            .elseif ChkOpenSav && !ChkPrint
               INVOKE     lstrcat, addr szBuff1, addr szMenuFileOG
            .elseif !ChkOpenSav && ChkPrint
               INVOKE     lstrcat, addr szBuff1, addr szMenuFilePG
            .elseif ChkOpenSav && ChkPrint
               INVOKE     lstrcat, addr szBuff1, addr szMenuFileOPG
            .endif
            INVOKE     ReadInput, addr szBuff1
              test     eax, eax
                js     EndIt
            INVOKE     lstrcat, hBuff, addr szCRLF
            INVOKE     SendMessage, hEdit, EM_GETSEL, addr SPos, addr EPos
            INVOKE     SendMessage, hEdit, EM_SETSEL, SPos, EPos
            INVOKE     SendMessage, hEdit, EM_REPLACESEL, TRUE, hBuff

            .if ChkEdit || ChkChoFont || ChkChoColor || ChkFindRep
               .if ChkFindRep
                  INVOKE     FindRep, hEdit, addr szMenuExit, 0, 7
                  INVOKE     lstrcpy, addr szBuff1, addr szBuff0
                  INVOKE     lstrcat, addr szBuff1, addr szStepBStep
                  INVOKE     lstrcat, addr szBuff1, addr szMenuSearchG
                  INVOKE     ReadInput, addr szBuff1
                    test     eax, eax
                      js     EndIt
                  INVOKE     lstrcat, hBuff, addr szCRLF
                  INVOKE     SendMessage, hEdit, EM_GETSEL, addr SPos, addr EPos
                  INVOKE     SendMessage, hEdit, EM_SETSEL, SPos, EPos
                  INVOKE     SendMessage, hEdit, EM_REPLACESEL, TRUE, hBuff
               .endif

               .if ChkChoFont || ChkChoColor
                  INVOKE     FindRep, hEdit, addr szMenuExit, 0, 7
                  INVOKE     lstrcpy, addr szBuff1, addr szBuff0
                  INVOKE     lstrcat, addr szBuff1, addr szStepBStep
                  INVOKE     lstrcat, addr szBuff1, addr szMenuOptionsG
                  INVOKE     ReadInput, addr szBuff1
                    test     eax, eax
                      js     EndIt
                  INVOKE     lstrcat, hBuff, addr szCRLF
                  INVOKE     SendMessage, hEdit, EM_GETSEL, addr SPos, addr EPos
                  INVOKE     SendMessage, hEdit, EM_SETSEL, SPos, EPos
                  INVOKE     SendMessage, hEdit, EM_REPLACESEL, TRUE, hBuff
               .endif

               .if ChkEdit
                  INVOKE     FindRep, hEdit, addr szMenuExit, 0, 7
                  INVOKE     lstrcpy, addr szBuff1, addr szBuff0
                  INVOKE     lstrcat, addr szBuff1, addr szStepBStep
                  INVOKE     lstrcat, addr szBuff1, addr szMenuEditG
                  INVOKE     ReadInput, addr szBuff1
                    test     eax, eax
                      js     EndIt
                  INVOKE     lstrcat, hBuff, addr szCRLF
                  INVOKE     SendMessage, hEdit, EM_GETSEL, addr SPos, addr EPos
                  INVOKE     SendMessage, hEdit, EM_SETSEL, SPos, EPos
                  INVOKE     SendMessage, hEdit, EM_REPLACESEL, TRUE, hBuff
               .endif
            .endif
         .endif
            and     SPos, 0
            and     EPos, 0

;---------- [Create the resource path] ----------
         INVOKE     lstrcpy, addr szBuff2, addr szPath
         INVOKE     lstrcat, addr szBuff2, addr szFileName
         INVOKE     lstrcat, addr szBuff2, addr szRc
         INVOKE     SendMessage, hdlg, WM_SETTEXT, 0, addr szBuff2

         .if lparam == 0 && !ChkTool
            INVOKE     FindRep, hEdit, addr szMasm32V1M, addr HutchDir, 64
         .endif

         .if lparam == 0 && ChkTool || lparam != 0
            .if ChkTool
               .if ChkMenu
                  INVOKE     FindRep, hEdit, addr szMainMenu, 0, 4
               .else
                  INVOKE     SendMessage, hEdit, WM_GETTEXTLENGTH, 0, 0
                     mov     ebx, eax
                     inc     ebx
                  INVOKE     SendMessage, hEdit, EM_SETSEL, eax, ebx
               .endif
               INVOKE     lstrcpy, addr szBuff1, addr szBuff0
               INVOKE     lstrcat, addr szBuff1, addr szStepBStep
               INVOKE     lstrcat, addr szBuff1, addr szToolbar1G  ; General bitmaps
               INVOKE     ReadInput, addr szBuff1
                 test     eax, eax
                   js     EndIt
               INVOKE     lstrcat, hBuff, addr szCRLF
               INVOKE     lstrcpy, hOutPut, hBuff
               INVOKE     SendMessage, hEdit, EM_GETSEL, addr SPos, addr EPos
               INVOKE     SendMessage, hEdit, EM_SETSEL, SPos, EPos
               INVOKE     SendMessage, hEdit, EM_REPLACESEL, TRUE, hOutPut

               .if !ChkFindRep 
                  INVOKE     lstrcpy, addr szWork64, addr szRoot+3
                  INVOKE     lstrlen, addr szWork64
                  INVOKE     lstrcpyn, addr szWork64, addr szWork64, eax
                  INVOKE     lstrlen, addr szRoot
                  INVOKE     lstrcpyn, addr szWork, addr szRoot, eax
                  INVOKE     lstrcpy, addr szWork1, addr szWork+3
                  INVOKE     lstrlen, addr szWork1
                     mov     ecx, eax
                     and     esi, 0
                     and     edi, 0
                  .while (ecx)
                        mov     al, byte ptr szWork1[esi]
                        mov     byte ptr szWork[edi], al
                     .if al == '\'
                           inc     edi
                           mov     byte ptr szWork[edi], al
                     .endif
                        inc     esi
                        inc     edi
                        dec     ecx
                  .endw
                     mov     byte ptr szWork[edi], 0
INVOKE     lstrcpy, addr szWork64, addr szWork
;                  INVOKE     FindRep, hEdit, addr szMasm32V1M, addr HutchDir, 64 ;szWork
                  INVOKE     FindRep, hEdit, addr szMasm32V1M, addr szWork, 64
               .endif

;---------- [Do Tooltips] ----------
               .if ChkMenu
                  INVOKE     FindRep, hEdit, addr szMainMenu, 0, 4
               .else
                  INVOKE     SendMessage, hEdit, WM_GETTEXTLENGTH, 0, 0
                     mov     ebx, eax
                     inc     ebx
                  INVOKE     SendMessage, hEdit, EM_SETSEL, eax, ebx
               .endif
               INVOKE     lstrcpy, addr szBuff1, addr szBuff0
               INVOKE     lstrcat, addr szBuff1, addr szStepBStep
               INVOKE     lstrcat, addr szBuff1, addr szToolbar8G
               INVOKE     ReadInput, addr szBuff1
                 test     eax, eax
                   js     EndIt
               INVOKE     lstrcat, hBuff, addr szCRLF
               INVOKE     lstrcpy, hOutPut, hBuff
               INVOKE     SendMessage, hEdit, EM_GETSEL, addr SPos, addr EPos
               INVOKE     SendMessage, hEdit, EM_SETSEL, SPos, EPos
               INVOKE     SendMessage, hEdit, EM_REPLACESEL, TRUE, hOutPut
                  and     SPos, 0
                  and     EPos, 0
            .endif

;---------- [Add Popup menu to the resource file] ----------
            .if ChkEditSub
               INVOKE     SendMessage, hEdit, WM_GETTEXTLENGTH, 0, 0
                  mov     ebx, eax
                  inc     ebx
               INVOKE     SendMessage, hEdit, EM_SETSEL, eax, ebx
               INVOKE     lstrcpy, addr szBuff1, addr szBuff0
               INVOKE     lstrcat, addr szBuff1, addr szStepBStep
               INVOKE     lstrcat, addr szBuff1, addr szEditSub5G
               INVOKE     ReadInput, addr szBuff1
                 test     eax, eax
                   js     EndIt
               INVOKE     lstrcat, hBuff, addr szCRLF
               INVOKE     lstrcpy, hOutPut, hBuff
               INVOKE     SendMessage, hEdit, EM_GETSEL, addr SPos, addr EPos
               INVOKE     SendMessage, hEdit, EM_SETSEL, SPos, EPos
               INVOKE     SendMessage, hEdit, EM_REPLACESEL, TRUE, hOutPut
                  and     SPos, 0
                  and     EPos, 0
            .endif

;---------- [Add Bitmaps and Dialogs to the resource file] ----------
            .if ChkFindRep 
.if ChkTool
               INVOKE     FindRep, hEdit, addr sz708, 0, 7
               INVOKE     lstrcpy, addr szBuff1, addr szBuff0
               INVOKE     lstrcat, addr szBuff1, addr szStepBStep
               INVOKE     lstrcat, addr szBuff1, addr szFindRep7G  ; Find/Replace bitmaps
               INVOKE     ReadInput, addr szBuff1
                 test     eax, eax
                   js     EndIt
               INVOKE     lstrcat, hBuff, addr szCRLF
               INVOKE     SendMessage, hEdit, EM_GETSEL, addr SPos, addr EPos
               INVOKE     SendMessage, hEdit, EM_SETSEL, SPos, EPos
               INVOKE     SendMessage, hEdit, EM_REPLACESEL, TRUE, hBuff
.endif

               INVOKE     SendMessage, hEdit, WM_GETTEXTLENGTH, 0, 0
                  mov     ebx, eax
                  inc     ebx
               INVOKE     SendMessage, hEdit, EM_SETSEL, eax, ebx
               INVOKE     lstrcpy, addr szBuff1, addr szBuff0
               INVOKE     lstrcat, addr szBuff1, addr szStepBStep
               INVOKE     lstrcat, addr szBuff1, addr szFindRep8G
               INVOKE     ReadInput, addr szBuff1
                 test     eax, eax
                   js     EndIt
               INVOKE     lstrcat, hBuff, addr szCRLF
               INVOKE     lstrcpy, hOutPut, hBuff
               INVOKE     SendMessage, hEdit, EM_GETSEL, addr SPos, addr EPos
               INVOKE     SendMessage, hEdit, EM_SETSEL, SPos, EPos
               INVOKE     SendMessage, hEdit, EM_REPLACESEL, TRUE, hOutPut

               INVOKE     lstrcpy, addr szWork64, addr szRoot+3
               INVOKE     lstrlen, addr szWork64
               INVOKE     lstrcpyn, addr szWork64, addr szWork64, eax

               INVOKE     lstrlen, addr szRoot
               INVOKE     lstrcpyn, addr szWork, addr szRoot, eax
               INVOKE     lstrcpy, addr szWork1, addr szWork+3
               INVOKE     lstrlen, addr szWork1
                  mov     ecx, eax
                  and     esi, 0
                  and     edi, 0
               .while (ecx)
                     mov     al, byte ptr szWork1[esi]
                     mov     byte ptr szWork[edi], al
                  .if al == '\'
                        inc     edi
                        mov     byte ptr szWork[edi], al
                  .endif
                     inc     esi
                     inc     edi
                     dec     ecx
               .endw
                  mov     byte ptr szWork[edi], 0
INVOKE     lstrcpy, addr szWork64, addr szWork
               INVOKE     FindRep, hEdit, addr szMasm32V1M, addr szWork64, 64 ;szMasm32V1 szWork
                  and     SPos, 0
                  and     EPos, 0
            .endif

            INVOKE     SendMessage, hdlg, WM_GETTEXT, 255, addr szBuff1
            INVOKE     SendMessage, hEdit, WM_GETTEXT, 51100, hOutPut
            INVOKE     WriteOutput, addr szBuff1
            INVOKE     FindRep, hEdit, addr szDefine, 0, 1

            .if lparam == 6
;---------- [Create the MRU file path and copy to dir] ----------
               INVOKE     lstrcpy, addr szBuff1, addr szRoot
         INVOKE     lstrcat, addr szBuff1, addr szAsmEdit
               INVOKE     lstrcat, addr szBuff1, addr szMRUFile
               INVOKE     ReadInput, addr szBuff1
                 test     eax, eax
                   js     WorkWinDone   ; Do message
               INVOKE     SendMessage, hEdit, WM_SETTEXT, 0, hBuff
               INVOKE     SendMessage, hEdit, WM_GETTEXT, 51100, hOutPut
               INVOKE     lstrcpy, addr szBuff1, addr szPath
               INVOKE     lstrcat, addr szBuff1, addr szMRUFile
               INVOKE     WriteOutput, addr szBuff1
            .endif
.if !RCLoaded
;INVOKE     MessageBox, NULL, addr szBuff1, addr AppName, MB_OK
      mov     RCLoaded, 1
   INVOKE     SendMessage, hWnd, WM_COMMAND, 7077, 0
.endif
;INVOKE     ShowWindow, hdlg, SW_SHOW
;DSPValue hWnd, 9999, 1, 'm'
               jmp     EndIt
         .else
               jmp     WorkWinDone
         .endif

      .elseif wmsg == WM_CLOSE

EndIt:
;---------- [Needed to force Paint] ----------
         INVOKE     GetWindowRect, hdlg, addr rect
            mov     edx, rect.right
            sub     edx, rect.left
            mov     ecx, rect.bottom
            sub     ecx, rect.top
            sub     rect.left, 1
            add     edx, 1
         INVOKE     MoveWindow, hdlg, rect.left, rect.top, edx, ecx, TRUE

         INVOKE     DestroyWindow, hEdit
         INVOKE     DestroyWindow, hdlg
            mov     eax, TRUE
            and     hWork, 0
            jmp     WorkWinRet

      .elseif wmsg != WM_COMMAND
            jmp     WorkWinDone
      .endif

         mov     eax, wparam
        cwde
      .if eax == 1044
         INVOKE     SendMessage, hdlg, WM_GETTEXT, 255, addr szBuff1
         INVOKE     SendMessage, hEdit, WM_GETTEXT, 51100, hOutPut
         INVOKE     WriteOutput, addr szBuff1
         .if !ChkTool
            INVOKE     FindRep, hEdit, addr szDefine, 0, 1
         .endif
.if !RCLoaded
      mov     RCLoaded, 1
   INVOKE     SendMessage, hWnd, WM_COMMAND, 7077, 0
.endif
            jmp     EndIt

      .elseif eax == 1045
            jmp     EndIt
      .endif
         jmp     WorkWinDone

WorkWinDone:
         mov     eax, FALSE           ; Return with FALSE

WorkWinRet:
         ret
WorkWin ENDP

;===================================
; Read file Procedure
;===================================
ReadInput PROC  uses ebx esi  Input:DWORD
LOCAL    hFile:DWORD, BytesRead

         mov     esi, Input
      INVOKE     CreateFile, esi,\
                 GENERIC_READ or GENERIC_WRITE ,\
                 FILE_SHARE_READ or FILE_SHARE_WRITE,\
                 0, OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE, 0
      .if eax == -1
         INVOKE     MessageBox, NULL, addr szError2, addr pTitle, MB_OK or MB_ICONWARNING or MB_SYSTEMMODAL
            mov     eax, -1
      .else
            mov     hFile, eax
         INVOKE     ReadFile, hFile, hBuff, 51100, addr BytesRead, NULL
            mov     eax, hBuff
            mov     ebx, BytesRead
            mov     byte ptr [eax+ebx], 0
         INVOKE     CloseHandle, hFile
      .endif
         RET
ReadInput ENDP

;===================================
; Write file Procedure
;===================================
WriteOutput PROC  uses ebx esi  Output:DWORD
LOCAL    hFile:DWORD, BytesRead

         mov     esi, Output
      INVOKE     CreateFile, esi,\
                 GENERIC_READ or GENERIC_WRITE ,\
                 FILE_SHARE_READ or FILE_SHARE_WRITE,\
                 NULL, CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE, NULL
      .if !eax
         INVOKE     MessageBox, NULL, addr szError6, addr pTitle, MB_OK or MB_ICONWARNING or MB_SYSTEMMODAL
            ret
      .endif
         mov     hFile, eax
      INVOKE     SendMessage, hEdit, WM_GETTEXTLENGTH, 0, 0
         mov     ebx, eax
      INVOKE     WriteFile, hFile, hOutPut, ebx, addr BytesRead, NULL
      INVOKE     CloseHandle, hFile
         RET
WriteOutput ENDP

;===================================
; Load List/Combo Box Procedure
;===================================
LoadList PROC  uses esi  hList:DWORD, Input, TypeBox
LOCAL    Len:DWORD, sw1
LOCAL    szBuff[64]:BYTE

         and     sw1, 0
         mov     esi, Input
         xor     eax, eax

Getlen:
      .if byte ptr[esi+eax] == 0dh

RunOut:
            mov     Len, eax
            inc     Len
         INVOKE     lstrcpyn, addr szBuff, esi, Len
         .if TypeBox < 2
            INVOKE     SendMessage, hList, CB_ADDSTRING, 0, addr szBuff
         .else
            INVOKE     SendMessage, hList, LB_ADDSTRING, 0, addr szBuff
         .endif
            cmp     sw1, 4
             je     AllDone
            inc     Len
            add     esi, Len
            xor     eax, eax
            jmp     Getlen
      .elseif byte ptr[esi+eax] == 0h
         .if byte ptr[esi+eax-1] == 0ah
               jmp     AllDone
         .else
               mov     sw1, 4
               jmp     RunOut
         .endif
      .endif
         inc     eax
         jmp     Getlen

AllDone:
         ret
LoadList ENDP

;===================================
; Find Replace Procedure
;===================================
FindRep PROC  uses esi edi ebx  hCtrl:DWORD, Input, RepText, TypeOper
LOCAL    cr:CHARRANGE
LOCAL    ft:FINDTEXT
LOCAL    Cnt:DWORD
LOCAL    szBuff1[256]:BYTE, szName[30], szWork1[100], szWork2[100], szWork3[1024*2]:BYTE

;      INVOKE     LockWindowUpdate, hCtrl  ; Lock parent to avoid flicker
      INVOKE     SendMessage, hREdit, EM_HIDESELECTION, 1, 0
         and     Cnt, 0
         mov     byte ptr szWork3, 0
         mov     eax, hOutPut
         mov     byte ptr[eax], 0

FindFirst:
         mov     ft.chrg.cpMin, 0
         mov     ft.chrg.cpMax, -1
         mov     eax, Input
         mov     ft.lpstrText, eax

FindNext:
      INVOKE     SendMessage, hCtrl, EM_FINDTEXT, FR_DOWN, addr ft
      .if eax != -1
            mov     ft.chrg.cpMin, eax
            inc     ft.chrg.cpMin
            mov     cr.cpMin, eax
            mov     cr.cpMax, eax
         .if TypeOper == 2 || TypeOper == 3
            INVOKE     lstrlen, Input
               inc     eax
            .if TypeOper == 2
                  inc     eax
            .endif
               add     cr.cpMin, eax
               add     cr.cpMax, eax
               jmp     SetSel
         .endif
         .if TypeOper == 4
               jmp     SetSel
         .endif
         .if TypeOper == 5
            INVOKE     SendMessage, hREdit, EM_LINELENGTH, eax, 0
               inc     eax
               add     cr.cpMin, eax
               add     cr.cpMax, eax
               jmp     SetSel
         .endif
         .if TypeOper == 6
            INVOKE     lstrlen, Input
               add     cr.cpMax, eax
            INVOKE     SendMessage, hCtrl, EM_EXSETSEL, 0, addr cr
            INVOKE     SendMessage, hCtrl, EM_REPLACESEL, TRUE, RepText
               jmp     FindNext
         .endif
         .if TypeOper == 64
            INVOKE     lstrlen, Input
               add     cr.cpMax, eax
            INVOKE     SendMessage, hCtrl, EM_EXSETSEL, 0, addr cr
            .if cr.cpMin < 150
               INVOKE     SendMessage, hCtrl, EM_REPLACESEL, TRUE, addr HutchDir ;szWork64
            .else
   inc     cr.cpMin
   dec     cr.cpMax
INVOKE     SendMessage, hCtrl, EM_EXSETSEL, 0, addr cr
               INVOKE     SendMessage, hCtrl, EM_REPLACESEL, TRUE, addr szWork64 ;RepText
            .endif
add     ft.chrg.cpMin, 8
               jmp     FindNext
         .endif
         .if TypeOper == 7
            INVOKE     SendMessage, hCtrl, EM_LINELENGTH, eax, 0
               inc     eax
               add     cr.cpMax, eax
               jmp     SetSel
         .endif
         .if TypeOper == 8
               lea     eax, offset szEndIf
               mov     ft.lpstrText, eax
            INVOKE     SendMessage, hREdit, EM_FINDTEXT, FR_DOWN, addr ft
            .if eax != -1
                  mov     cr.cpMax, eax
               INVOKE     SendMessage, hREdit, EM_LINELENGTH, eax, 0
                  inc     eax
                  add     cr.cpMax, eax
               INVOKE     SendMessage, hREdit, EM_EXSETSEL, 0, addr cr
               INVOKE     SendMessage, hREdit, EM_REPLACESEL, TRUE, addr szNull
               INVOKE     SendMessage, hREdit, WM_GETTEXTLENGTH, 0, 0
               INVOKE     SendMessage, hREdit, EM_SETSEL, eax, eax
            .endif
               jmp     AllDone
         .endif
         .if TypeOper == 9
               lea     eax, offset szEndSize
               mov     ft.lpstrText, eax
            INVOKE     SendMessage, hREdit, EM_FINDTEXT, FR_DOWN, addr ft
            .if eax != -1
                  mov     cr.cpMax, eax
               INVOKE     SendMessage, hREdit, EM_LINELENGTH, eax, 0
                  inc     eax
                  inc     eax
                  add     cr.cpMax, eax
               INVOKE     SendMessage, hREdit, EM_EXSETSEL, 0, addr cr
            .endif
               jmp     AllDone
         .endif

         INVOKE     SendMessage, hCtrl, EM_EXLINEFROMCHAR, 0, cr.cpMin ;eax
            mov     ecx, eax
            mov     word ptr szBuff1, 250
         INVOKE     SendMessage, hCtrl, EM_GETLINE, ecx, addr szBuff1
            mov     byte ptr szBuff1[eax], 0
         INVOKE     lstrlen, Input
           push     eax
         INVOKE     lstrlen, addr szBuff1
            pop     ebx
            sub     eax, ebx
            lea     edx, szBuff1
         .while (eax)
            .if byte ptr [edx+ebx] != ' '
               .break
            .endif
               inc     ebx
               dec     eax
         .endw
         INVOKE     lstrcpy, addr szWork1, addr szBuff1[ebx]

         INVOKE     lstrlen, addr szWork1
            xor     ebx, ebx
         .while (eax)
            .if byte ptr szWork1[ebx] == ' '
               .break
            .endif
               inc     ebx
               dec     eax
         .endw
           push     ebx
            inc     ebx
         INVOKE     lstrcpyn, addr szWork2, addr szWork1, ebx
         .if !Cnt
               mov     Cnt, 1
            INVOKE     lstrcat, addr szWork3, addr szIf
         .else
            INVOKE     lstrcat, addr szWork3, addr szElseif
         .endif
         INVOKE     lstrcat, addr szWork3, addr szWork2
         INVOKE     lstrcat, addr szWork3, addr szCRLF
         INVOKE     lstrcat, addr szWork3, addr szCRLF
         INVOKE     lstrcat, hCommand, addr szWork2
         INVOKE     lstrcat, hCommand, addr szComma
            pop     ebx
           push     ebx
            mov     eax, 16
            sub     eax, ebx
         INVOKE     lstrcpyn, addr szWork2[ebx], addr szFill, eax
         INVOKE     lstrcat, addr szWork2, addr szEqu
            pop     ebx

         .while byte ptr szWork1[ebx] == ' '
               inc     ebx
         .endw
           push     ebx
         INVOKE     lstrlen, addr szWork2
            mov     ebx, eax
            mov     eax, 20
            sub     eax, ebx
         INVOKE     lstrcpyn, addr szWork2[ebx], addr szFill, eax
            pop     ebx

         INVOKE     lstrcat, addr szWork2, addr szWork1[ebx]
         INVOKE     lstrcat, hOutPut, addr szWork2
            jmp     FindNext
      .endif
      .if TypeOper > 1
            jmp     AllDone
      .endif

      INVOKE     lstrcat, addr szWork3, addr szEndif
      INVOKE     lstrcat, addr szWork3, addr szCRLF
      INVOKE     lstrcat, hCommand, addr szNull
         and     Cnt, 0

DoCommands:
         mov     ft.chrg.cpMin, 0
         mov     ft.chrg.cpMax, -1
      .if Cnt == 0
            lea     eax, offset szConst
      .else
            lea     eax, offset szCommand
      .endif
         mov     ft.lpstrText, eax
      INVOKE     SendMessage, hREdit, EM_FINDTEXT, FR_DOWN, addr ft
      .if eax != -1
            mov     cr.cpMin, eax
         INVOKE     SendMessage, hREdit, EM_LINELENGTH, eax, 0
            inc     eax
            add     cr.cpMin, eax
          MOVmd     ft.chrg.cpMin, cr.cpMin
         .if Cnt == 0
               lea     eax, offset szDataF
         .else
               lea     eax, offset szClose
         .endif
            mov     ft.lpstrText, eax
         INVOKE     SendMessage, hREdit, EM_FINDTEXT, FR_DOWN or FR_WHOLEWORD, addr ft
         .if eax != -1
               dec     eax
               mov     cr.cpMax, eax
         .else
               jmp     AllDone
         .endif
         INVOKE     SendMessage, hREdit, EM_EXSETSEL, 0, addr cr
         .if Cnt == 0
            INVOKE     SendMessage, hREdit, EM_REPLACESEL, TRUE, hOutPut
         .else
            INVOKE     SendMessage, hREdit, EM_REPLACESEL, TRUE, addr szWork3
         .endif
         INVOKE     SendMessage, hREdit, WM_GETTEXTLENGTH, 0, 0
         INVOKE     SendMessage, hREdit, EM_SETSEL, eax, eax
      .endif

      .if !Cnt
            mov     Cnt, 1
            jmp     DoCommands
      .endif

      INVOKE     lstrcpy, addr szBuff1, addr szBuff0
      INVOKE     lstrcat, addr szBuff1, addr szStepBStep
      INVOKE     lstrcat, addr szBuff1, addr szCommands
         mov     ft.chrg.cpMin, 3000     ; Change this to start at the start: label
         mov     ft.chrg.cpMax, -1
         mov     esi, hCommand
         lea     edi, szName
      .while (byte ptr[esi] != 0)
            mov     al, byte ptr[esi]
         .if al != ','
               mov     byte ptr[edi], al
               inc     esi
               inc     edi
         .else
               mov     byte ptr[edi], 0
              push     esi
            INVOKE     GetPrivateProfileString, addr szCmds, addr szName, addr szNull, addr szWork3, 2047, addr szBuff1
              test     eax, eax
                jz     Pass
            INVOKE     lstrlen, addr szWork3
            .while (eax)
               .if byte ptr szWork3[eax] == '>'
                     mov     byte ptr szWork3[eax], 0ah
               .elseif byte ptr szWork3[eax] == '<'
                     mov     byte ptr szWork3[eax], 0dh
               .endif
                  dec     eax
            .endw
            .if !ChkEdit && byte ptr szName+4 == 'N' && byte ptr szName+5 == 'E' ||\
                !ChkEdit && byte ptr szName+4 == 'C' && byte ptr szName+5 == 'U' ||\
                !ChkEdit && byte ptr szName+4 == 'C' && byte ptr szName+5 == 'O' ||\
                !ChkEdit && byte ptr szName+4 == 'P' && byte ptr szName+5 == 'A'
                  jmp     Pass
            .endif
            .if !ChkEdit && byte ptr szName+4 == 'D' && byte ptr szName+5 == 'E' ||\
                !ChkEdit && byte ptr szName+4 == 'S' && byte ptr szName+5 == 'E'
                  jmp     Pass
            .endif
            .if !ChkOpenSav && byte ptr szName+4 == 'O' && byte ptr szName+5 == 'P' ||\
                !ChkOpenSav && byte ptr szName+4 == 'S' && byte ptr szName+5 == 'A' ||\
                !ChkChoFont && byte ptr szName+4 == 'C' && byte ptr szName+10 == 'F' ||\
                !ChkChoColor && byte ptr szName+4 == 'C' && byte ptr szName+10 == 'C'
                  jmp     Pass
            .endif
            .if !ChkFindRep && byte ptr szName+4 == 'F' && byte ptr szName+5 == 'I' ||\
                !ChkFindRep && byte ptr szName+4 == 'R' && byte ptr szName+6 == 'P' ||\
                !ChkPrint && byte ptr szName+4 == 'P' && byte ptr szName+5 == 'R'
                  jmp     Pass
            .endif
            INVOKE     lstrcat, addr szWork3, addr szCRLF
               lea     eax, szName
               mov     ft.lpstrText, eax
            INVOKE     SendMessage, hREdit, EM_FINDTEXT, FR_DOWN, addr ft
            .if eax != -1
                  mov     cr.cpMin, eax
                  mov     cr.cpMax, eax
               INVOKE     lstrlen, addr szName
                  inc     eax
                  add     cr.cpMin, eax
                  add     cr.cpMax, eax
               INVOKE     SendMessage, hREdit, EM_EXSETSEL, 0, addr cr
               INVOKE     SendMessage, hREdit, EM_REPLACESEL, TRUE, addr szWork3
            .endif

Pass:
               pop     esi
               lea     edi, szName
               inc     esi
         .endif
      .endw
      INVOKE     SendMessage, hREdit, WM_LBUTTONUP, 0, 0
      INVOKE     SendMessage, hREdit, WM_PAINT, 0, 0
         jmp     AllDone

SetSel:
      INVOKE     SendMessage, hCtrl, EM_EXSETSEL, 0, addr cr

AllDone:
      INVOKE     SendMessage, hREdit, EM_HIDESELECTION, 0, 0
;      INVOKE     LockWindowUpdate, 0  ; Unlock parent
         ret
FindRep ENDP

End DllEntry

;INVOKE     MessageBox, NULL, addr szBuff1, addr pTitle, MB_OK
