         title   Toolbar Build

         .586
         .model flat, stdcall
         option casemap:none   ; Case sensitive

            include  G:\WebPage\AsmEdit\include\Windows.inc
            include  user32.inc
            include  kernel32.inc
            include  gdi32.inc
            include  comctl32.inc
            include  comdlg32.inc
            include  advapi32.inc

   include  G:\WebPage\AsmEdit\include\DSPMACRO.asm

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

;======================================================
; PROTO, MACRO, and Data section
;======================================================
WinMain         PROTO  :DWORD, :DWORD, :DWORD, :DWORD
GetData         PROTO  :DWORD, :DWORD, :DWORD
ToolBarDlg      PROTO  :DWORD, :DWORD, :DWORD, :DWORD
RichEditProc    PROTO  :DWORD, :DWORD, :DWORD, :DWORD
BuildR          PROTO  :DWORD
AsciiBase       PROTO  :DWORD, :DWORD
ChgBmpColor     PROTO  :DWORD, :DWORD

TBSep   MACRO hTool
          mov     tbb.iBitmap, 0
          mov     tbb.idCommand, 0
          mov     tbb.fsState, TBSTATE_ENABLED
          mov     tbb.fsStyle, TBSTYLE_SEP
       INVOKE     SendMessage, hTool, TB_ADDBUTTONS, 1, addr tbb
         ENDM

;TBButt  MACRO hTool, BmpID, CmdID, Text
TBButt  MACRO hTool, BmpID, CmdID, State, Text
          mov     tbb.iBitmap, BmpID    ; Button image number
          mov     tbb.idCommand, CmdID  ; Command ID number
          mov     tbb.fsState, State    ; Button state
          mov     tbb.fsStyle, TBSTYLE_BUTTON
          mov     tbb.dwData, 0
          mov     tbb.iString, Text
       INVOKE     SendMessage, hTool, TB_ADDBUTTONS, 1, addr tbb
         ENDM

MOVmd    MACRO Var1, Var2
         push     Var2
          pop     Var1
         ENDM

.const
IDM_NEW        equ 1001
IDM_OPEN       equ 1002
IDM_SAVE       equ 1003
IDM_CUT        equ 1004
IDM_COPY       equ 1005
IDM_PASTE      equ 1006
IDM_DELETE     equ 1007
IDM_FIND       equ 1008
IDM_FINDNEXT   equ 1009
IDM_FINDPREV   equ 1010
IDM_REPLACE    equ 1011
IDM_EXIT       equ 1012
IDM_SELALL     equ 3001
IDM_TOOLBAR    equ 8001
IDM_MENU       equ 8002
IDM_TAB        equ 8003
IDM_DIALOG     equ 8040

IDD_DLG01      equ 7000
IDC_STATIC01   equ 7001
IDC_STATIC02   equ 7002
IDC_STATIC03   equ 7003
IDC_STATIC04   equ 7004
IDC_STATIC05   equ 7005
IDC_STATIC06   equ 7006
IDC_STATIC07   equ 7007
IDC_GRP01      equ 7008
IDC_GRP02      equ 7009
IDC_STATIC08   equ 7010
IDC_STATIC09   equ 7011

IDC_LISTBOX01  equ 2001
IDC_LISTBOX02  equ 2002
IDC_LISTBOX03  equ 2003
IDC_RITIMID    equ 2004
IDC_RNAME      equ 2005
IDC_BINSERT    equ 2006
IDC_BADD       equ 2007
IDC_BREMOVE    equ 2008
IDC_BMOVEU     equ 2009
IDC_BMOVED     equ 2010
IDC_BSTYLESU   equ 2011
IDC_BSTYLESR   equ 2012
IDC_BRESTORE   equ 2013
IDC_BBUILD     equ 2014
IDC_BCHANGEW   equ 2015
IDC_BCHANGEH   equ 2016
IDC_CHK01      equ 2017
IDC_CHK02      equ 2018
IDC_CHK03      equ 2019
IDC_CHK04      equ 2020
IDC_CHK05      equ 2021
IDC_CHK06      equ 2022
IDC_CHK09      equ 2023
IDC_CHK10      equ 2024
IDC_ETOOLTEXT  equ 2025
IDC_ETOOLTIP   equ 2026
IDC_EIDNAME    equ 2027
IDC_ESTARTID   equ 2028
IDC_ECHANGEW   equ 2029
IDC_ECHANGEH   equ 2030
IDC_COMBO01    equ 2031
IDC_COMBO02    equ 2032

.data
AppName        db  'Create Toolbar Control',0
ClassName      db  'Toolbar Control',0
RichEdit       db  'RichEdit20A',0
RichEdDLL      db  'RICHED20.DLL',0
StatClass      db  'msctls_statusbar32',0
ToolClass      db  'ToolbarWindow32',0
FloatTBClass   db  'FloatToolbar32',0
ListboxClass   db  'listbox',0
FontNameCN     db  'Courier New',0
FontNameAR     db  'Arial',0 ;'MS Sans Serif',0
FontNameMS     db  'MS Sans Serif',0
FontNameQT     db  'Quick Type',0

szDividerE     db  ' **** Extended Styles ****         ',0
szES01         db  'WS_EX_DLGMODALFRAME   equ 00000001h',0
szES02         db  'WS_EX_WINDOWEDGE      equ 00000100h',0
szES03         db  'WS_EX_CLIENTEDGE      equ 00000200h',0
szES04         db  'WS_EX_STATICEDGE      equ 00020000h',0
szDividerW     db  ' **** Window Styles ****           ',0
szWS01         db  'WS_CHILD              equ 40000000h',0
szWS02         db  'WS_VISIBLE            equ 10000000h',0
szWS03         db  'WS_BORDER             equ 00800000h',0
szWS04         db  'WS_TABSTOP            equ 00010000h',0
szWS05         db  'WS_GROUP              equ 00020000h',0
szDividerC     db  ' **** CCS Styles ****              ',0
szCS01         db  'CCS_TOP               equ 00000001h',0
szCS02         db  'CCS_NOMOVEY           equ 00000002h',0
szCS03         db  'CCS_BOTTOM            equ 00000003h',0
szCS04         db  'CCS_NORESIZE          equ 00000004h',0
szCS05         db  'CCS_NOPARENTALIGN     equ 00000008h',0
szCS06         db  'CCS_ADJUSTABLE        equ 00000020h',0
szCS07         db  'CCS_NODIVIDER         equ 00000040h',0
szCS08         db  'CCS_VERT              equ 00000080h',0
szCS09         db  'CCS_LEFT              equ 00000081h',0  ;CCS_VERT or CCS_TOP
szCS10         db  'CCS_RIGHT             equ 00000083h',0  ;CCS_VERT or CCS_BOTTOM
szCS11         db  'CCS_NOMOVEX           equ 00000082h',0  ;CCS_VERT or CCS_NOMOVEY
szDividerT     db  ' **** Control Styles ****          ',0
szTS01         db  'TBSTYLE_BUTTON        equ 00000000h',0
szTS02         db  'TBSTYLE_SEP           equ 00000001h',0
szTS03         db  'TBSTYLE_CHECK         equ 00000002h',0
szTS04         db  'TBSTYLE_GROUP         equ 00000004h',0
szTS05         db  'TBSTYLE_CHECKGROUP    equ 00000006h',0  ;TBSTYLE_GROUP or TBSTYLE_CHECK
szTS06         db  'TBSTYLE_TOOLTIPS      equ 00000100h',0
szTS07         db  'TBSTYLE_WRAPABLE      equ 00000200h',0
szTS08         db  'TBSTYLE_ALTDRAG       equ 00000400h',0
szTS09         db  'TBSTYLE_FLAT          equ 00000800h',0
szTS10         db  'TBSTYLE_LIST          equ 00001000h',0
szTS11         db  'TBSTYLE_CUSTOMERASE   equ 00002000h',0
szTS12         db  'TBSTYLE_REGISTERDROP  equ 00004000h',0
szTS13         db  'TBSTYLE_TRANSPARENT   equ 00008000h',0

MenuName       db  'MainMenu',0
PopupMenu      db  'PopupMenu',0
szMenu1        db  'Hide Dialog',0
szMenu2        db  'Show Dialog',0
szSep          db  'Seperator',0
szPart1        db  'Part 1',0
szPart3        db  'Part 3',0
FontHeight     dd  -12
FontW          dd  400
szCRLF         db  0dh,0ah,0
szNull         db  0
szSlashB       db  '\',0
szAll          db  '*.*',0
szClear        db  '                    ',0
szSpace        db  ' ',0
szQuote        db  '"',0
szQuoteS       db  "'",0
szZero         db  '0',0
szComma        db  ',',0
szOR           db  ' or ',0
szSZ           db  'sz',0
szDB           db  'db  ',0
szBmp          db  '.bmp',0
szIDM          db  'IDM_',0
szM1           db  '-1',0
szM2           db  '-2',0
szNNNN         dd  'NNNN',0
szWWWW         dd  'WWWW',0
szHHHH         dd  'HHHH',0
szLLLL         dd  'LLLL',0
szTTTT         dd  'TTTT',0
szRRRR         dd  'RRRR',0
szBBBB         dd  'BBBB',0
szTBLL         db  'TBLL',0
szTBTT         db  'TBTT',0
szTBWW         db  'TBWW',0
szTBHH         db  'TBHH',0

szOffset       db  ' offset ',0

szTemp         db  'Temp.txt',0

szEqu          db  'equ ',0
szTBSep        db  '          TBSep     hWndTool',0
szTBButt       db  '         TBButt     hWndTool, ',0
szTBButtF      db  '         TBButt     hWndToolF, ',0
szResr1        db  '    BITMAP  DISCARDABLE  "',0
szResr2        db  'Res',0
szFill         db  '                   ',0

szToolbarRes   db  ';***** [Place in the Resource file (.rc)] *****',0dh,0ah,0

szDefine       db  '#define   ',0

szToolbarTip   db  'STRINGTABLE DISCARDABLE',0dh,0ah
               db  'BEGIN',0dh,0ah
               db  '/* toolbar tips */',0dh,0ah,0

szEnd          db  'END',0dh,0ah
               db  ';***** [End of resource definitions] *****',0dh,0ah,0

szToolbarMac   db  ';***** [Place in the Application or Include F:\masm32\include\file] *****',0dh,0ah
               db  'ChgBmpColor      PROTO :DWORD',0dh,0ah,0dh,0ah
               db  ';---------- [Toolbar structure macros] ----------',0dh,0ah
               db  'TBSep    MACRO hTool',0dh,0ah
               db  '           mov     tbb.iBitmap, 0',0dh,0ah
               db  '           mov     tbb.idCommand, 0',0dh,0ah
               db  '           mov     tbb.fsState, TBSTATE_ENABLED',0dh,0ah
               db  '           mov     tbb.fsStyle, TBSTYLE_SEP',0dh,0ah
               db  '        INVOKE     SendMessage, hTool, TB_ADDBUTTONS, 1, addr tbb',0dh,0ah
               db  '          ENDM',0dh,0ah
               db  0dh,0ah
               db  'TBButt   MACRO hTool, BmpID, CmdID, State, Style, Text',0dh,0ah
               db  '           mov     tbb.iBitmap, BmpID    ; Button image number',0dh,0ah
               db  '           mov     tbb.idCommand, CmdID  ; Command ID number',0dh,0ah
               db  '           mov     tbb.fsState, State',0dh,0ah
               db  '           mov     tbb.fsStyle, Style',0dh,0ah
               db  '           mov     tbb.dwData, 0',0dh,0ah
               db  '           mov     tbb.iString, Text',0dh,0ah
               db  '        INVOKE     SendMessage, hTool, TB_ADDBUTTONS, 1, addr tbb',0dh,0ah
               db  '          ENDM',0dh,0ah,0dh,0ah
               db  '.const',0dh,0ah,0

szToolbarDat1  db  ';***** [Place in the Application file (.asm)] *****',0dh,0ah
               db  '.data',0dh,0ah
               db  "ToolClass      db  'ToolbarWindow32',0",0dh,0ah,0
szFloatClass   db  "FloatTBClass   db  'FloatToolbar32',0",0dh,0ah,0

szToolCustom1  db  "TextC01        db  'New',0",0dh,0ah
               db  "TextC02        db  'Open',0",0dh,0ah
               db  "TextC03        db  'Save',0",0dh,0ah
               db  "TextC04        db  'Save All',0",0dh,0ah
               db  "TextC05        db  'Cut',0",0dh,0ah
               db  "TextC06        db  'Copy',0",0dh,0ah
               db  "TextC07        db  'Paste',0",0dh,0ah
               db  "TextC08        db  'Delete',0",0dh,0ah
               db  "TextC09        db  'Undo',0",0dh,0ah
               db  "TextC10        db  'Redo',0",0dh,0ah
               db  "TextC11        db  'Find',0",0dh,0ah
               db  "TextC12        db  'FindN',0",0dh,0ah
               db  "TextC13        db  'FindP',0",0dh,0ah
               db  "TextC14        db  'Rep',0",0dh,0ah
               db  "TextC15        db  'MultiI',0",0dh,0ah
               db  "TextC16        db  'Exit',0",0dh,0ah
               db  'szTextC        dd  TextC01,TextC02,TextC03,TextC04,TextC05,TextC06,',0dh,0ah
               db  '                   TextC07,TextC08,TextC09,TextC10,TextC11,TextC12,',0dh,0ah
               db  '                   TextC13,TextC14,TextC15,TextC16',0dh,0ah,0dh,0ah
               db  "szSpace        db  ' ',0",0dh,0ah,0dh,0ah,0

szToolbarDat2  db  '.data?',0dh,0ah
               db  'hWndTool       dd  ?',0dh,0ah
               db  'hImageList     dd  ?',0dh,0ah,0
szToolbarDatG  db  'hImageListG    dd  ?',0dh,0ah,0
szToolbarDat3  db  'LeftOn         dd  ?',0dh,0ah
               db  'TopOn          dd  ?',0dh,0ah
               db  'RightOn        dd  ?',0dh,0ah
               db  'BottomOn       dd  ?',0dh,0ah
               db  'TBLeft         dd  ?',0dh,0ah
               db  'TBTop          dd  ?',0dh,0ah
               db  'TBWth          dd  ?',0dh,0ah
               db  'TBHgt          dd  ?',0dh,0ah,0dh,0ah,0

szToolbarDat4  db  'hWndDock       dd  ?',0dh,0ah
               db  'hWndFloat      dd  ?',0dh,0ah
               db  'hWndToolF      dd  ?',0dh,0ah
               db  'Styles         dd  ?',0dh,0ah
               db  'DockW          dd  ?',0dh,0ah
               db  'DockH          dd  ?',0dh,0ah
               db  'ToolW          dd  ?',0dh,0ah
               db  'ToolH          dd  ?',0dh,0ah
               db  'FloatLock      dd  ?',0dh,0ah
               db  'LockOn         dd  ?',0dh,0ah
               db  'SysParm        dd  ?',0dh,0ah,0dh,0ah,0

szToolCustom2  db  'SavID          dd  ?',0dh,0ah
               db  'szTextA        db  32  dup(?)',0dh,0ah,0dh,0ah
               db  'tbi            TBBUTTONINFO <>',0dh,0ah,0dh,0ah,0

szWinMain      db  ';===================================================',0dh,0ah
               db  '; WinMain procedure',0dh,0ah
               db  ';===================================================',0dh,0ah
               db  'WinMain proc  uses ebx  hinst:DWORD, hPrevInst, CmdLine, CmdShow',0dh,0ah
               db  'LOCAL    wc:WNDCLASSEX',0dh,0ah
               db  'LOCAL    msg:MSG',0dh,0ah,0dh,0ah

               db  ';---------- [Float/Dock Toolbar Class] ----------',0dh,0ah
               db  '          or     wc.style, CS_DBLCLKS',0dh,0ah
               db  '         mov     wc.lpfnWndProc, offset FloatWndProc',0dh,0ah
               db  '         mov     wc.lpszClassName, offset FloatTBClass',0dh,0ah
               db  '         mov     wc.lpszMenuName, NULL',0dh,0ah
               db  '      INVOKE     RegisterClassEx, addr wc',0dh,0ah,0dh,0ah,0

szWinProc      db  ';======================================================',0dh,0ah
               db  '; WinProc procedure',0dh,0ah
               db  ';======================================================',0dh,0ah
               db  'WndProc proc  uses ebx  hwnd:DWORD, wMsg, wParam, lParam',0dh,0ah,0dh,0ah,0

szToolbarLoc   db  'LOCAL    tbb:TBBUTTON',0dh,0ah
               db  'LOCAL    tbab:TBADDBITMAP',0dh,0ah
               db  'LOCAL    bSize:DWORD, hTbBmp, ID, Cnt, Len, Incr, xPos, yPos, WWth, WHgt',0dh,0ah,0
szToolCusLoc   db  'LOCAL    SavState:BYTE, SavStyle:BYTE',0dh,0ah,0

szToolbarWnd1  db  '      .if wMsg == WM_CREATE',0dh,0ah,0dh,0ah

               db  ';---------- [Create the Toolbar Window] ----------',0dh,0ah
               db  '         INVOKE     CreateWindowEx, 0, addr ToolClass, 0,\',0dh,0ah,0

szToolbarWnd2  db  '                    0, -2, 1200, 26, hwnd, 0, hInst, 0',0dh,0ah
               db  '            mov     hWndTool, eax',0dh,0ah,0dh,0ah,0

szToolbarCre1  db  ';---------- [Create the ImageList] ----------',0dh,0ah
               db  '         INVOKE     ImageList_Create, 16, 16, ILC_COLOR32, NNNN, 0',0dh,0ah
               db  '            mov     hImageList, eax',0dh,0ah,0dh,0ah

               db  ';---------- [Load The Bitmaps] ----------',0dh,0ah
               db  '            mov     ID, 701           ; Bitmap ID',0dh,0ah
               db  '            mov     Cnt, NNNN',0dh,0ah
               db  '         .while (Cnt)',0dh,0ah
               db  '            INVOKE     LoadImage, hInst, ID, IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR',0dh,0ah
               db  '            INVOKE     ChgBmpColor, eax',0dh,0ah
               db  '               mov     hTbBmp, eax',0dh,0ah
               db  '            INVOKE     ImageList_Add, hImageList, hTbBmp, NULL',0dh,0ah
               db  '            INVOKE     DeleteObject, hTbBmp',0dh,0ah
               db  '               inc     ID',0dh,0ah
               db  '               dec     Cnt',0dh,0ah
               db  '         .endw',0dh,0ah,0dh,0ah

               db  '         INVOKE     SendMessage, hWndTool, TB_BUTTONSTRUCTSIZE, sizeof TBBUTTON, 0',0dh,0ah
               db  '         INVOKE     SendMessage, hWndTool, TB_SETIMAGELIST, 0, hImageList',0dh,0ah,0dh,0ah,0

szToolbarCreG  db  ';---------- [Create the Gray ImageList] ----------',0dh,0ah
               db  '         INVOKE     ImageList_Create, 16, 16, ILC_COLOR32, NNNN, 0',0dh,0ah
               db  '            mov     hImageListG, eax',0dh,0ah,0dh,0ah

               db  ';---------- [Load The Bitmaps] ----------',0dh,0ah
               db  '            mov     ID, 801           ; Bitmap ID',0dh,0ah
               db  '            mov     Cnt, NNNN',0dh,0ah
               db  '         .while (Cnt)',0dh,0ah
               db  '            INVOKE     LoadImage, hInst, ID, IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR',0dh,0ah
               db  '            INVOKE     ChgBmpColor, eax',0dh,0ah
               db  '               mov     hTbBmp, eax',0dh,0ah
               db  '            INVOKE     ImageList_Add, hImageListG, hTbBmp, NULL',0dh,0ah
               db  '            INVOKE     DeleteObject, hTbBmp',0dh,0ah
               db  '               inc     ID',0dh,0ah
               db  '               dec     Cnt',0dh,0ah
               db  '         .endw',0dh,0ah,0dh,0ah

               db  '         INVOKE     SendMessage, hWndTool, TB_SETIMAGELIST, 0, hImageListG',0dh,0ah
               db  '         INVOKE     SendMessage, hWndTool, TB_SETHOTIMAGELIST, 0, hImageList',0dh,0ah,0dh,0ah,0


szToolbarCre2  db  ';---------- [Size the Bitmap and Button] ----------',0dh,0ah
               db  '            mov     ecx, 16  ; loword = bitmap Width',0dh,0ah
               db  '            mov     eax, 16  ; hiword = bitmap Height',0dh,0ah
               db  '            shl     eax, 16',0dh,0ah
               db  '            mov     ax, cx',0dh,0ah
               db  '            mov     bSize, eax',0dh,0ah
               db  '         INVOKE     SendMessage, hWndTool, TB_SETBITMAPSIZE, 0, bSize',0dh,0ah
               db  '            mov     eax, WWWW  ; loword = button Width',0dh,0ah
               db  '            mov     ecx, HHHH  ; hiword = button Height',0dh,0ah
               db  '            shl     ecx, 16',0dh,0ah
               db  '            mov     cx, ax',0dh,0ah
               db  '         INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, ecx',0dh,0ah,0dh,0ah

               db  ';---------- [Create the Toolbar structures] ----------',0dh,0ah,0

szToolbarFloat db  ';---------- [Create the FloatToolbar] ----------',0dh,0ah
               db  '         INVOKE     CreateWindowEx, WS_EX_TOOLWINDOW or WS_EX_WINDOWEDGE, addr FloatTBClass,',0dh,0ah
               db  '                    0, WS_POPUP or\',0dh,0ah
               db  '                    WS_VISIBLE or WS_THICKFRAME, 346, 305, 31, 250,',0dh,0ah
               db  '                    hwnd, NULL, hInst, NULL',0dh,0ah
               db  '            mov     hWndFloat, eax',0dh,0ah,0dh,0ah

               db  '         INVOKE     CreateWindowEx, 0, addr ToolClass, 0,',0dh,0ah
               db  '                    WS_CHILD or WS_VISIBLE or TBSTYLE_TOOLTIPS or CCS_NOPARENTALIGN or\',0dh,0ah
               db  '                    CCS_NORESIZE or CCS_ADJUSTABLE or TBSTYLE_FLAT or\',0dh,0ah
               db  '                    TBSTYLE_WRAPABLE or CCS_NODIVIDER,\',0dh,0ah
               db  '                    -1, -1, 1200, 26, hWndFloat, 0, hInst, 0',0dh,0ah
               db  '            mov     hWndToolF, eax',0dh,0ah,0dh,0ah

               db  '         INVOKE     SendMessage, hWndToolF, TB_BUTTONSTRUCTSIZE, sizeof TBBUTTON, 0',0dh,0ah
               db  '         INVOKE     SendMessage, hWndToolF, TB_SETIMAGELIST, 0, hImageList',0dh,0ah,0dh,0ah

               db  ';---------- [Size the Bitmap and Button] ----------',0dh,0ah
               db  '            mov     ecx, 16  ; loword = bitmap Width',0dh,0ah
               db  '            mov     eax, 16  ; hiword = bitmap Height',0dh,0ah
               db  '            shl     eax, 16',0dh,0ah
               db  '            mov     ax, cx',0dh,0ah
               db  '            mov     bSize, eax',0dh,0ah
               db  '         INVOKE     SendMessage, hWndToolF, TB_SETBITMAPSIZE, 0, bSize',0dh,0ah
               db  '            mov     eax, WWWW  ; loword = button Width',0dh,0ah
               db  '            mov     ecx, HHHH  ; hiword = button Height',0dh,0ah
               db  '            shl     ecx, 16',0dh,0ah
               db  '            mov     cx, ax',0dh,0ah
               db  '         INVOKE     SendMessage, hWndToolF, TB_SETBUTTONSIZE, 0, ecx',0dh,0ah,0dh,0ah

               db  ';---------- [Create the Float Toolbar structures] ----------',0dh,0ah,0

szSetDropdown  db  ';---------- [Set Dropdown] ----------',0dh,0ah
               db  '         INVOKE     SendMessage, hWndTool, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS',0dh,0ah,0dh,0ah,0

szSetValues    db  ';---------- [Set various values] ----------',0dh,0ah
               db  '            mov     LeftOn, LLLL',0dh,0ah
               db  '            mov     TopOn, TTTT',0dh,0ah
               db  '            mov     RightOn, RRRR',0dh,0ah
               db  '            mov     BottomOn, BBBB',0dh,0ah
               db  '            mov     TBLeft, TBLL',0dh,0ah
               db  '            mov     TBTop, TBTT',0dh,0ah
               db  '            mov     TBWth, TBWW',0dh,0ah
               db  '            mov     TBHgt, TBHH',0dh,0ah,0dh,0ah,0
szToolCustom3  db  '            mov     tbi.cbSize, sizeof tbi',0dh,0ah,0dh,0ah,0

szRemoveParm   db  ';---------- [Remove effects parm] ----------',0dh,0ah
               db  '         INVOKE     SystemParametersInfo, SPI_GETDRAGFULLWINDOWS, 0, addr SysParm, 0',0dh,0ah
               db  '         .if SysParm',0dh,0ah
               db  '            INVOKE     SystemParametersInfo, SPI_SETDRAGFULLWINDOWS, 0, 0, SPIF_UPDATEINIFILE',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah,0

szToolSiz1     db  ';---------- [Move and Size the Control(s)] ----------',0dh,0ah
               db  '      .elseif wMsg == WM_SIZE',0dh,0ah,0dh,0ah

               db  ';---------- [AutoSize the Toolbar Control] ----------',0dh,0ah
               db  '         INVOKE     SendMessage, hWndTool, TB_AUTOSIZE, 0, 0',0dh,0ah
               db  '         INVOKE     MoveWindow, hWndStat, 0, 0, 0, 0, TRUE',0dh,0ah,0dh,0ah

               db  ';---------- [Size the Edit Toolbar Controls] ----------',0dh,0ah
               db  '            xor     eax, eax             ; Zero out toolbar height',0dh,0ah
               db  '         .if hWndTool',0dh,0ah
               db  '            INVOKE     GetClientRect, hWnd, addr rect ; Rectangle of main window',0dh,0ah
               db  '               mov     eax, rect.right',0dh,0ah
               db  '               mov     WWth, eax',0dh,0ah
               db  '            .if TopOn || BottomOn',0dh,0ah
               db  '                  inc     eax',0dh,0ah
               db  '                  mov     TBWth, eax',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '               mov     eax, rect.bottom',0dh,0ah
               db  '               mov     WHgt, eax',0dh,0ah
               db  '            INVOKE     GetWindowRect, hWndTool, addr rect ; Rectangle of toolbar',0dh,0ah
               db  '               mov     eax, rect.bottom',0dh,0ah
               db  '               sub     eax, rect.top',0dh,0ah
               db  '               mov     TBHgt, eax',0dh,0ah
               db  '            .if LeftOn || RightOn',0dh,0ah
               db  '                  mov     eax, WHgt',0dh,0ah
               db  '                  mov     TBHgt, eax',0dh,0ah
               db  '                  xor     eax, eax',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '           push     eax                  ; Save height of toolbar',0dh,0ah,0dh,0ah

               db  '            xor     eax, eax             ; Zero out statusbar height',0dh,0ah
               db  '         .if hWndStat',0dh,0ah
               db  '            INVOKE     GetWindowRect, hWndStat, addr rect ; Rectangle of statusbar',0dh,0ah
               db  '               mov     eax, rect.bottom',0dh,0ah
               db  '               sub     eax, rect.top     ; eax = height of statusbar',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah

               db  '            pop     edx                  ; edx = height of toolbar',0dh,0ah
               db  '         .if BottomOn',0dh,0ah
               db  '               and     edx, 0',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '            mov     ebx, lParam          ; Width of new client area',0dh,0ah
               db  '            and     ebx, 0ffffh          ; ebx = width',0dh,0ah
               db  '            mov     ecx, lParam',0dh,0ah
               db  '            shr     ecx, 16              ; Height of new client area',0dh,0ah
               db  '            sub     ecx, eax             ; Edit window - height of statusbar',0dh,0ah
               db  '            sub     ecx, edx             ; Edit window - height of toolbar',0dh,0ah
               db  '         .if edx                         ; If toolbar',0dh,0ah
               db  '               sub     edx, 2            ; For border',0dh,0ah
               db  '               add     ecx, 2            ; For border',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '         .if eax                         ; If statusbar',0dh,0ah
               db  '               add     ecx, 2            ; For border',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah

               db  '            and     xPos, 0',0dh,0ah
               db  '         .if LeftOn',0dh,0ah
               db  '               mov     eax, TBWth',0dh,0ah
               db  '               mov     xPos, eax',0dh,0ah
               db  '               sub     ebx, TBWth',0dh,0ah
               db  '               mov     TBHgt, ecx',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '         .if RightOn',0dh,0ah
               db  '               mov     xPos, 0',0dh,0ah
               db  '               sub     ebx, TBWth',0dh,0ah
               db  '               mov     TBHgt, ecx',0dh,0ah
               db  '               mov     TBLeft, ebx',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '         .if BottomOn',0dh,0ah
               db  '               sub     ecx, TBHgt',0dh,0ah
               db  '               add     ecx, 20      ; Statusbar height',0dh,0ah
               db  '               mov     TBTop, ecx',0dh,0ah
               db  '         .endif',0dh,0ah, 0

szToolDock     db  '         .if hWndDock',0dh,0ah
               db  '               mov     edx, 0',0dh,0ah
               db  '               add     ecx, TBHgt',0dh,0ah
               db  '               sub     ecx, 2',0dh,0ah
               db  '         .endif',0dh,0ah,0

szToolFloat1   db  '         .if FloatLock',0dh,0ah
               db  '               mov     eax, ToolW',0dh,0ah
               db  '            .if ToolH > eax',0dh,0ah
               db  '                  add     eax, 6',0dh,0ah
               db  '                  mov     xPos, eax',0dh,0ah
               db  '                  sub     ebx, ToolW',0dh,0ah
               db  '                  sub     ebx, 6',0dh,0ah
               db  '            .else',0dh,0ah
               db  '                  mov     xPos, 0',0dh,0ah
               db  '                  add     edx, ToolH',0dh,0ah
               db  '                  add     edx, 6',0dh,0ah
               db  '                  sub     ecx, ToolH',0dh,0ah
               db  '                  sub     ecx, 6',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '         .endif',0dh,0ah,0

szToolSiz2     db  '         INVOKE     MoveWindow, hREdit, xPos, edx, ebx, ecx, TRUE',0dh,0ah
               db  '         INVOKE     MoveWindow, hWndTool, TBLeft, TBTop, TBWth, TBHgt, TRUE',0dh,0ah,0dh,0ah,0

szSizeFloat    db  ';---------- [Size the Floating Toolbar] ----------',0dh,0ah
               db  '         .if hWndFloat && !ToolH',0dh,0ah
               db  '            INVOKE     GetWindowRect, hWnd, addr rect',0dh,0ah
               db  '               add     rect.left, 195',0dh,0ah
               db  '               add     rect.top, -29',0dh,0ah
               db  '               mov     rect.right, 94',0dh,0ah
               db  '               mov     rect.bottom, 0',0dh,0ah
               db  '               mov     ToolH, 1',0dh,0ah
               db  '            INVOKE     MoveWindow, hWndFloat, rect.left, rect.top, rect.right, rect.bottom, TRUE',0dh,0ah,0dh,0ah

               db  '         .elseif hWndFloat && FloatLock',0dh,0ah
               db  '            INVOKE     GetWindowRect, hREdit, addr rect',0dh,0ah
               db  '               mov     eax, rect.left',0dh,0ah
               db  '               sub     rect.right, eax',0dh,0ah
               db  '               mov     eax, rect.top',0dh,0ah
               db  '               sub     rect.bottom, eax',0dh,0ah
               db  '               mov     ecx, ToolW',0dh,0ah
               db  '            .if ecx < ToolH',0dh,0ah
               db  '                  add     ecx, 6',0dh,0ah
               db  '                  sub     rect.left, ecx',0dh,0ah
               db  '                  mov     edx, rect.bottom',0dh,0ah,0dh,0ah

               db  '            .else',0dh,0ah
               db  '                  mov     edx, ToolH',0dh,0ah
               db  '                  add     edx, 6',0dh,0ah
               db  '                  sub     rect.top, edx',0dh,0ah
               db  '                  mov     ecx, rect.right',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '            INVOKE     MoveWindow, hWndFloat, rect.left, rect.top, ecx, edx, TRUE',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah,0

szSizeDock     db  ';---------- [Size the Docking Toolbar] ----------',0dh,0ah
               db  '         .if hWndDock',0dh,0ah
               db  '            INVOKE     SendMessage, hWndTool, TB_BUTTONCOUNT, 0, 0',0dh,0ah
               db  '               mov     Cnt, eax',0dh,0ah
               db  '               mov     ecx, Cnt',0dh,0ah
               db  '               dec     ecx',0dh,0ah
               db  '            INVOKE     SendMessage, hWndTool, TB_GETITEMRECT, ecx, addr rect',0dh,0ah
               db  '              push     rect.right',0dh,0ah
               db  '               pop     DockW',0dh,0ah
               db  '               add     DockW, 8',0dh,0ah
               db  '              push     rect.bottom',0dh,0ah
               db  '               pop     DockH',0dh,0ah
               db  '               add     DockH, 24',0dh,0ah
               db  '               inc     rect.right',0dh,0ah
               db  '               add     rect.bottom, 3',0dh,0ah,0dh,0ah

               db  '            INVOKE     MoveWindow, hWndTool, 0, -2, rect.right, rect.bottom, TRUE',0dh,0ah
               db  '            INVOKE     GetWindowRect, hWndDock, addr rect',0dh,0ah
               db  '              push     rect.left',0dh,0ah
               db  '              push     rect.top',0dh,0ah
               db  '            INVOKE     GetWindowRect, hWnd, addr rect',0dh,0ah
               db  '               pop     edx',0dh,0ah
               db  '               pop     ecx',0dh,0ah
               db  '            .if ecx == 0 || edx == 0',0dh,0ah
               db  '                  add     rect.left, 6',0dh,0ah
               db  '                  add     rect.top, 44',0dh,0ah
               db  '            .else',0dh,0ah
               db  '                  mov     rect.left, ecx',0dh,0ah
               db  '                  mov     rect.top, edx',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '            INVOKE     MoveWindow, hWndDock, rect.left, rect.top, DockW, DockH, TRUE',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah,0

szMovAct       db  ';---------- [MOVE Msg] ----------',0dh,0ah
               db  '      .elseif wMsg == WM_MOVE',0dh,0ah
               db  '         .if FloatLock || LockOn',0dh,0ah
               db  '               mov     FloatLock, 1',0dh,0ah
               db  '               mov     LockOn, 1',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '           call     SetSize',0dh,0ah,0dh,0ah

               db  ';---------- [ACTIVATEAPP Msg] ----------',0dh,0ah
               db  '      .elseif wMsg == WM_ACTIVATEAPP',0dh,0ah
               db  '         INVOKE     DefWindowProc, hWnd, WM_NCACTIVATE, wParam, 0',0dh,0ah
               db  '            ret',0dh,0ah,0dh,0ah

               db  '      .elseif wMsg == WM_NCACTIVATE',0dh,0ah
               db  '            mov     eax, TRUE',0dh,0ah
               db  '            ret',0dh,0ah,0dh,0ah,0

szNotify       db  ';---------- [Get Tooltips] ----------',0dh,0ah
               db  '      .elseif wMsg == WM_NOTIFY',0dh,0ah
               db  '            mov     ebx, lParam          ; Get pointer to NMHDR',0dh,0ah
               db  '            mov     eax, (NMHDR ptr [ebx]).code',0dh,0ah
               db  '         .if eax == TTN_NEEDTEXT',0dh,0ah
               db  '               mov     eax, (NMHDR ptr [ebx]).idFrom ; Resource id',0dh,0ah
               db  '               mov     ecx, eax',0dh,0ah
               db  '            INVOKE     LoadString, hInst, ecx, addr szBuff, lengthof szBuff',0dh,0ah
               db  '               mov     ebx, lParam                   ; Get the buffer addr',0dh,0ah
               db  '               lea     eax, szBuff',0dh,0ah
               db  '               mov     (TOOLTIPTEXT ptr [ebx]).lpszText, eax',0dh,0ah
               db  '               mov     eax, FALSE',0dh,0ah
               db  '               ret',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah,0

szOpenDock     db  ';---------- [Activate Docking Toolbar] ----------',0dh,0ah
               db  '         .if eax == NM_RDBLCLK && !hWndDock',0dh,0ah
               db  '            INVOKE     GetWindowLong, hWndTool, GWL_STYLE',0dh,0ah
               db  '               mov     Styles, eax',0dh,0ah
               db  '            .if (Styles & WS_BORDER)',0dh,0ah
               db  '                  xor     Styles, WS_BORDER',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '            INVOKE     SetWindowLong, hWndTool, GWL_STYLE, Styles',0dh,0ah
               db  '            .if FloatLock',0dh,0ah
               db  '                  mov     LockOn, 1',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '              call     DockToolbar',0dh,0ah
               db  '            INVOKE     SetFocus, hWndDock',0dh,0ah
               db  '               jmp     Ret0',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah,0

szToolCustom4  db  ';---------- [Customize the Toolbar] ----------',0dh,0ah
               db  '         .if eax == TBN_BEGINADJUST',0dh,0ah
               db  '               mov     eax, TRUE',0dh,0ah
               db  '               ret',0dh,0ah,0dh,0ah

               db  '; Add to Windows.inc Comctl32.dll version 5.80 or later- Removes the help button',0dh,0ah
               db  '         .elseif eax == TBN_FIRST-23 ;TBN_INITCUSTOMIZE',0dh,0ah
               db  '               mov     eax, 1        ;TBNRF_HIDEHELP',0dh,0ah
               db  '               ret',0dh,0ah,0dh,0ah

               db  '         .elseif eax == TBN_QUERYINSERT',0dh,0ah
               db  '               mov     eax, TRUE',0dh,0ah
               db  '               ret',0dh,0ah,0dh,0ah

               db  '         .elseif eax == TBN_QUERYDELETE',0dh,0ah
               db  '               mov     eax, TRUE',0dh,0ah
               db  '               ret',0dh,0ah,0dh,0ah

               db  '         .elseif eax == TBN_GETBUTTONINFO',0dh,0ah
               db  '               mov     eax, [ebx.TBNOTIFY].iItem ; Item num',0dh,0ah
               db  '            .if eax <= NNNN                    ; Num of images',0dh,0ah
               db  '                 push     ebx',0dh,0ah
               db  '                 push     eax',0dh,0ah
               db  '                  mov     Incr, eax',0dh,0ah
               db  '               INVOKE     SendMessage, hWndTool, TB_BUTTONCOUNT, 0, 0',0dh,0ah,0dh,0ah

               db  ';---------- [Find matching bitmap ID] ----------',0dh,0ah
               db  '                  and     ID, 0',0dh,0ah
               db  '                  and     Len, 0',0dh,0ah
               db  '                  mov     Cnt, eax',0dh,0ah
               db  '               .while (Cnt)',0dh,0ah
               db  '                  INVOKE     SendMessage, hWndTool, TB_GETBUTTON, ID, addr tbb',0dh,0ah
               db  '                     mov     eax, Incr',0dh,0ah
               db  '                  .if eax == tbb.iBitmap && tbb.fsStyle != TBSTYLE_SEP',0dh,0ah
               db  '                        mov     edx, tbb.idCommand',0dh,0ah
               db  '                        mov     al, tbb.fsState',0dh,0ah
               db  '                        mov     SavState, al',0dh,0ah
               db  '                        mov     al, tbb.fsStyle',0dh,0ah
               db  '                        mov     SavStyle, al',0dh,0ah
               db  '                     .break',0dh,0ah
               db  '                  .endif',0dh,0ah
               db  '                  .if tbb.fsStyle != TBSTYLE_SEP',0dh,0ah
               db  '                        inc     Len',0dh,0ah
               db  '                  .endif',0dh,0ah
               db  '                     inc     ID',0dh,0ah
               db  '                     dec     Cnt',0dh,0ah
               db  '               .endw',0dh,0ah
               db  '               .if !Cnt',0dh,0ah
               db  '                     xor     edx, edx',0dh,0ah
               db  '                     xor     esi, esi',0dh,0ah
               db  '               .endif',0dh,0ah
               db  '                  pop     eax',0dh,0ah
               db  '                  pop     ebx',0dh,0ah
               db  '               .if !edx                    ; No matching ID',0dh,0ah
               db  '                  mov     edx, eax',0dh,0ah
               db  '                     inc     edx',0dh,0ah
               db  '                     add     edx, 6900',0dh,0ah
               db  '                     mov     SavState, TBSTATE_ENABLED',0dh,0ah
               db  '                     mov     SavStyle, TBSTYLE_BUTTON',0dh,0ah
               db  '               .endif',0dh,0ah,0dh,0ah

               db  '                 push     eax',0dh,0ah
               db  '                  mov     [ebx.TBNOTIFY.tbButton].iBitmap, eax',0dh,0ah
               db  '                  mov     [ebx.TBNOTIFY.tbButton].idCommand, edx',0dh,0ah
               db  '                  mov     al, SavState',0dh,0ah
               db  '                  mov     [ebx.TBNOTIFY.tbButton].fsState, al',0dh,0ah
               db  '                  mov     al, SavStyle',0dh,0ah
               db  '                  mov     [ebx.TBNOTIFY.tbButton].fsStyle, al',0dh,0ah
               db  '                  mov     [ebx.TBNOTIFY.tbButton].dwData, 0',0dh,0ah
               db  '                  pop     eax',0dh,0ah,0dh,0ah

               db  '                  lea     ecx, szSpace',0dh,0ah
               db  '                  xor     esi, esi',0dh,0ah
               db  '               .if eax < 16                ; Number of predefined names',0dh,0ah
               db  '                  pushad',0dh,0ah
               db  '                  INVOKE     lstrcpy, addr szTextA, szTextC[eax*4]',0dh,0ah
               db  '                   popad',0dh,0ah
               db  '                     lea     esi, szTextA',0dh,0ah
               db  '               .endif',0dh,0ah,0dh,0ah

               db  '               .if esi',0dh,0ah
               db  '                     mov     ecx, esi',0dh,0ah
               db  '                  pushad',0dh,0ah
               db  '                     mov     tbi.dwMask, TBIF_TEXT',0dh,0ah
               db  '                     mov     tbi.pszText, ecx',0dh,0ah
               db  '                     mov     SavID, edx    ; Save the command ID for TBN_TOOLBARCHANGE',0dh,0ah
               db  '                  INVOKE     SendMessage, hWndTool, TB_SETBUTTONINFO, edx, addr tbi',0dh,0ah
               db  '                   popad',0dh,0ah
               db  '               .endif',0dh,0ah
               db  '                  mov     [ebx.TBNOTIFY].cchText, 32',0dh,0ah
               db  '                  mov     [ebx.TBNOTIFY].pszText, ecx',0dh,0ah
               db  '                  mov     eax, TRUE',0dh,0ah
               db  '                  ret',0dh,0ah
               db  '            .else',0dh,0ah
               db  '                  mov     eax, FALSE',0dh,0ah
               db  '                  ret',0dh,0ah
               db  '            .endif',0dh,0ah,0dh,0ah

               db  '         .elseif eax == TBN_TOOLBARCHANGE',0dh,0ah
               db  '               lea     ecx, szTextA',0dh,0ah
               db  '               mov     tbi.dwMask, TBIF_TEXT',0dh,0ah
               db  '               mov     tbi.pszText, ecx',0dh,0ah
               db  '            INVOKE     SendMessage, hWndTool, TB_SETBUTTONINFO, SavID, addr tbi',0dh,0ah
               db  '               mov     eax, FALSE',0dh,0ah
               db  '               ret',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah,0

szToolDrop     db  ';---------- [Toolbar Dropdown Notify] ----------',0dh,0ah
               db  '         .if eax == TBN_DROPDOWN',0dh,0ah
               db  '               mov     eax, [ebx.NMTOOLBAR].iItem ; Item num',0dh,0ah
               db  '            INVOKE     SendMessage, hWndTool, TB_COMMANDTOINDEX, eax, 0',0dh,0ah
               db  '               mov     ecx, eax',0dh,0ah
               db  '            INVOKE     SendMessage, hWndTool, TB_GETITEMRECT, ecx, addr rect',0dh,0ah
               db  '              push     rect.top',0dh,0ah
               db  '              push     rect.left',0dh,0ah
               db  '            INVOKE     GetWindowRect, hWndTool, addr rect',0dh,0ah
               db  '               pop     eax',0dh,0ah
               db  '               add     rect.left, eax',0dh,0ah
               db  '               pop     eax',0dh,0ah
               db  '               add     eax, 28',0dh,0ah
               db  '               add     rect.top, eax',0dh,0ah
               db  '            INVOKE     TrackPopupMenu, hSMenu, TPM_LEFTALIGN or TPM_LEFTBUTTON,\',0dh,0ah
               db  '                       rect.left, rect.top, 0, hWnd, 0',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah,0

szToolbarDes   db  ';---------- [Destroy the ImageList] ----------',0dh,0ah
               db  '      .elseif wMsg == WM_DESTROY',0dh,0ah
               db  '         INVOKE     ImageList_Destroy, hImageList',0dh,0ah,0
szToolbarDesG  db  '         INVOKE     ImageList_Destroy, hImageListG',0dh,0ah,0
szResetParm    db  '         .if SysParm',0dh,0ah
               db  '            INVOKE     SystemParametersInfo, SPI_SETDRAGFULLWINDOWS, 1, 0, SPIF_UPDATEINIFILE',0dh,0ah
               db  '         .endif',0dh,0ah,0

szChgBmpColor  db  ';===================================================',0dh,0ah
               db  '; ChgBmpColor procedure',0dh,0ah
               db  ';===================================================',0dh,0ah
               db  'ChgBmpColor PROC hBitmap:DWORD',0dh,0ah
               db  'LOCAL    mDC:DWORD, hBrush, hOldBmp, Fill, hOldBrush',0dh,0ah

               db  '      INVOKE     CreateCompatibleDC, NULL',0dh,0ah
               db  '         mov     mDC, eax',0dh,0ah
               db  '      INVOKE     SelectObject, mDC, hBitmap',0dh,0ah
               db  '         mov     hOldBmp, eax',0dh,0ah
               db  '      INVOKE     GetSysColor, COLOR_BTNFACE',0dh,0ah
               db  '      INVOKE     CreateSolidBrush, eax',0dh,0ah
               db  '         mov     hBrush, eax',0dh,0ah
               db  '      INVOKE     SelectObject, mDC, hBrush',0dh,0ah
               db  '         mov     hOldBrush, eax',0dh,0ah
               db  '         mov     Fill, 00c0c0c0h',0dh,0ah
               db  '      INVOKE     ExtFloodFill, mDC, 0, 0, Fill, FLOODFILLSURFACE',0dh,0ah
               db  '      INVOKE     ExtFloodFill, mDC, 0, 15, Fill, FLOODFILLSURFACE',0dh,0ah
               db  '      INVOKE     ExtFloodFill, mDC, 15, 0, Fill, FLOODFILLSURFACE',0dh,0ah
               db  '      INVOKE     ExtFloodFill, mDC, 15, 15, Fill, FLOODFILLSURFACE',0dh,0ah
               db  '      INVOKE     SelectObject, mDC, hOldBrush',0dh,0ah
               db  '      INVOKE     DeleteObject, hBrush',0dh,0ah
               db  '      INVOKE     SelectObject, mDC, hBitmap',0dh,0ah
               db  '        push     eax',0dh,0ah
               db  '      INVOKE     DeleteDC, mDC',0dh,0ah
               db  '         pop     eax',0dh,0ah

               db  '         ret',0dh,0ah
               db  'ChgBmpColor ENDP',0dh,0ah,0dh,0ah,0

szDockProc    db  ';======================================================',0dh,0ah
               db  '; Create Docking Toolbar PROCEDURE',0dh,0ah
               db  ';======================================================',0dh,0ah
               db  'DockToolbar PROC',0dh,0ah
               db  'LOCAL    rect:RECT',0dh,0ah,0dh,0ah

               db  '      .if hWndDock',0dh,0ah
               db  '         INVOKE     DestroyWindow, hWndDock',0dh,0ah
               db  '      .endif',0dh,0ah,0dh,0ah

               db  '      INVOKE     CreateWindowEx, WS_EX_TOOLWINDOW, addr FloatTBClass,',0dh,0ah
               db  '                 0, WS_POPUPWINDOW or WS_CAPTION or\',0dh,0ah
               db  '                 WS_VISIBLE or WS_THICKFRAME, 0, 0, 0, 0,\',0dh,0ah
               db  '                 hWnd, NULL, hInst, NULL',0dh,0ah
               db  '         mov     hWndDock, eax',0dh,0ah,0dh,0ah

               db  '      INVOKE     SetParent, hWndTool, hWndDock',0dh,0ah
               db  '      INVOKE     GetClientRect, hWnd, addr rect',0dh,0ah
               db  '         mov     edx, rect.bottom',0dh,0ah
               db  '         shl     edx, 16',0dh,0ah
               db  '         mov     ecx, rect.right',0dh,0ah
               db  '         mov     dx, cx',0dh,0ah
               db  '      INVOKE     SendMessage, hWnd, WM_SIZE, 0, edx',0dh,0ah,0dh,0ah

               db  '         ret',0dh,0ah
               db  'DockToolbar ENDP',0dh,0ah,0dh,0ah,0


szFloatProc    db  ';===================================================',0dh,0ah
               db  '; FloatWndProc procedure',0dh,0ah
               db  ';===================================================',0dh,0ah
               db  'FloatWndProc PROC  uses ebx esi edi hwnd:DWORD, wmsg, wparam, lparam',0dh,0ah
               db  'LOCAL    rect:RECT',0dh,0ah
               db  'LOCAL    rectE:RECT',0dh,0ah
               db  'LOCAL    rectF:RECT',0dh,0ah
               db  'LOCAL    wp:WINDOWPLACEMENT',0dh,0ah
               db  'LOCAL    Cnt:DWORD, WH, Var, swOn',0dh,0ah
               db  'LOCAL    szBuff[64]:BYTE',0dh,0ah,0dh,0ah

               db  '      .if wmsg == WM_MOVE || wmsg == WM_SIZE',0dh,0ah
               db  '            mov     wp.iLength, sizeof wp',0dh,0ah
               db  '         INVOKE     GetWindowPlacement, hWnd, addr wp',0dh,0ah
               db  '         .if wp.showCmd == SW_SHOWMINIMIZED || wp.showCmd == SW_MINIMIZE',0dh,0ah
               db  '            INVOKE     SetFocus, hREdit',0dh,0ah
               db  '               mov     eax, 1',0dh,0ah
               db  '               ret',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '      .endif',0dh,0ah,0dh,0ah,0

szDock         db  '         mov     eax, hwnd',0dh,0ah
               db  '      .if eax == hWndDock',0dh,0ah
               db  '         .if wmsg == WM_CLOSE || wmsg == WM_RBUTTONDBLCLK',0dh,0ah
               db  '            INVOKE     SetParent, hWndTool, hWnd',0dh,0ah
               db  '            INVOKE     DestroyWindow, hWndDock',0dh,0ah
               db  '               and     hWndDock, 0',0dh,0ah
               db  '            INVOKE     GetWindowLong, hWndTool, GWL_STYLE',0dh,0ah
               db  '               mov     Styles, eax',0dh,0ah
               db  '            .if !(Styles & WS_BORDER)',0dh,0ah
               db  '                  xor     Styles, WS_BORDER',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '            INVOKE     SetWindowLong, hWndTool, GWL_STYLE, Styles',0dh,0ah
               db  '            .if FloatLock',0dh,0ah
               db  '               INVOKE     GetWindowRect, hWndFloat, addr rectF',0dh,0ah
               db  '               INVOKE     GetWindowRect, hREdit, addr rectE',0dh,0ah
               db  '                  mov     eax, rectE.left',0dh,0ah
               db  '                  add     eax, 6',0dh,0ah
               db  '                  sub     rectE.right, eax',0dh,0ah
               db  '                  mov     eax, rectE.top',0dh,0ah
               db  '                  add     eax, 6',0dh,0ah
               db  '                  sub     rectE.bottom, eax',0dh,0ah

               db  '                  mov     eax, rectF.left',0dh,0ah
               db  '                  sub     rectF.right, eax',0dh,0ah
               db  '                  mov     eax, rectF.top',0dh,0ah
               db  '                  sub     rectF.bottom, eax',0dh,0ah,0dh,0ah

               db  '                  add     rectF.top, 26',0dh,0ah
               db  '                  mov     eax, rectF.right',0dh,0ah
               db  '               .if rectF.bottom > eax',0dh,0ah
               db  '                     sub     rectF.top, 3',0dh,0ah
               db  '                     sub     rectF.bottom, 26',0dh,0ah
               db  '               .endif',0dh,0ah
               db  '                  mov     LockOn, 1',0dh,0ah
               db  '               INVOKE     MoveWindow, hWndFloat, rectF.left, rectF.top, rectF.right, rectF.bottom, TRUE',0dh,0ah
               db  '                  mov     FloatLock, 1',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '              call     SetSize',0dh,0ah,0dh,0ah

               db  '               mov     eax, 1',0dh,0ah
               db  '               ret',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '            jmp     DefWin',0dh,0ah
               db  '      .endif',0dh,0ah,0dh,0ah,0

szFloat        db  '      .if wmsg == WM_NCLBUTTONDBLCLK',0dh,0ah
               db  '         INVOKE     PostMessage, hWndFloat, WM_NCLBUTTONDOWN, HTCAPTION, 0',0dh,0ah
               db  '      .endif',0dh,0ah
               db  '         mov     eax, hwnd',0dh,0ah
               db  '      .if eax != hWndFloat',0dh,0ah
               db  '            mov     eax, 1',0dh,0ah
               db  '            ret',0dh,0ah
               db  '      .endif',0dh,0ah,0dh,0ah

               db  '      .if wmsg == WM_MOVE',0dh,0ah
               db  '         INVOKE     SetFocus, hREdit',0dh,0ah
               db  '         .if !ToolW',0dh,0ah
               db  '               mov     eax, TRUE',0dh,0ah
               db  '               ret',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '            and     swOn, 0',0dh,0ah
               db  '         INVOKE     GetWindowRect, hWndFloat, addr rectF ; Rectangle of Float',0dh,0ah
               db  '         INVOKE     GetWindowRect, hREdit, addr rectE ; Rectangle of Edit',0dh,0ah,0dh,0ah

               db  '            mov     eax, lparam       ; Get xPos',0dh,0ah
               db  '            and     eax, 0ffffh       ; Lowword',0dh,0ah
               db  '            mov     ecx, lparam       ; Get yPos',0dh,0ah
               db  '            shr     ecx, 16           ; Hiword',0dh,0ah,0dh,0ah

               db  '            add     rectE.left, 6',0dh,0ah
               db  '            add     rectE.top, 6',0dh,0ah,0dh,0ah

               db  '         .if eax < 5 || eax > 7fffh || ecx > 7fffh',0dh,0ah
               db  '            .if eax > 5',0dh,0ah
               db  '                 push     eax',0dh,0ah
               db  '               INVOKE     GetWindowRect, hWndFloat, addr rectF ; Rectangle of Float',0dh,0ah
               db  '                 push     rectF.left',0dh,0ah
               db  '                 push     rectF.top',0dh,0ah
               db  '               INVOKE     GetClientRect, hWndFloat, addr rectF ; Rectangle of Float',0dh,0ah
               db  '                  pop     ecx',0dh,0ah
               db  '                  pop     edx',0dh,0ah
               db  '                  pop     eax',0dh,0ah
               db  '               .if eax > 7fffh',0dh,0ah
               db  '                     mov     rectF.top, ecx',0dh,0ah
               db  '               .else',0dh,0ah
               db  '                     mov     rectF.left, edx',0dh,0ah
               db  '               .endif',0dh,0ah
               db  '                  add     rectF.right, 6',0dh,0ah
               db  '                  add     rectF.bottom, 6',0dh,0ah
               db  '               INVOKE     MoveWindow, hWndFloat, rectF.left, rectF.top, rectF.right, rectF.bottom, TRUE',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '            .if FloatLock && LockOn',0dh,0ah
               db  '                  mov     eax, 1',0dh,0ah
               db  '                  ret',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '               and     FloatLock, 0',0dh,0ah
               db  '               xor     eax, eax',0dh,0ah
               db  '               ret',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah

               db  '            mov     ebx, eax',0dh,0ah
               db  '         .if eax > 9',0dh,0ah
               db  '            sub     eax, 10',0dh,0ah
               db  '            .else',0dh,0ah
               db  '            xor     eax, eax',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '            add     ebx, 10',0dh,0ah
               db  '            mov     edx, ecx',0dh,0ah
               db  '            sub     ecx, 10',0dh,0ah
               db  '            add     edx, 10',0dh,0ah,0dh,0ah

               db  '         .if eax < rectE.left && ebx > rectE.left &&\',0dh,0ah
               db  '             ecx < rectE.top && edx > rectE.top || LockOn',0dh,0ah
               db  '               and     LockOn, 0',0dh,0ah
               db  '               mov     FloatLock, 1',0dh,0ah
               db  '            INVOKE     GetClientRect, hWndFloat, addr rectF',0dh,0ah
               db  '            INVOKE     GetWindowRect, hREdit, addr rectE',0dh,0ah
               db  '               mov     eax, rectE.left',0dh,0ah
               db  '               add     eax, 6',0dh,0ah
               db  '               sub     rectE.right, eax',0dh,0ah
               db  '               mov     eax, rectE.top',0dh,0ah
               db  '               add     eax, 6',0dh,0ah
               db  '               sub     rectE.bottom, eax',0dh,0ah

               db  '               mov     eax, rectF.right',0dh,0ah
               db  '            .if eax > rectF.bottom',0dh,0ah
               db  '                  mov     WH, 1',0dh,0ah
               db  '                  mov     eax, 22  ; Height',0dh,0ah
               db  '                 push     rectE.right',0dh,0ah
               db  '                 push     eax',0dh,0ah
               db  '            .else',0dh,0ah
               db  '                  mov     WH, 2',0dh,0ah
               db  '                  mov     eax, 23  ; Width',0dh,0ah
               db  '                 push     rectE.bottom',0dh,0ah
               db  '                 push     eax',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '               jmp     NewPos',0dh,0ah,0dh,0ah

               db  '         .else',0dh,0ah
               db  '            INVOKE     GetClientRect, hWndFloat, addr rectF',0dh,0ah
               db  '               and     FloatLock, 0',0dh,0ah
               db  '              call     SetSize',0dh,0ah
               db  '            INVOKE     GetWindowRect, hWndFloat, addr rect',0dh,0ah
               db  '            INVOKE     SendMessage, hWndToolF, TB_BUTTONCOUNT, 0, 0',0dh,0ah
               db  '               mov     Cnt, eax',0dh,0ah
               db  '            .if rectF.right == 23 || rectF.bottom == 22',0dh,0ah
               db  '               .if rectF.right == 23',0dh,0ah
               db  '                    imul     eax, 22',0dh,0ah
               db  '                     mov     rectF.bottom, eax',0dh,0ah
               db  '               .elseif rectF.bottom == 22',0dh,0ah
               db  '                    imul     eax, 23',0dh,0ah
               db  '                     mov     rectF.right, eax',0dh,0ah
               db  '               .endif',0dh,0ah,0dh,0ah

               db  '                  mov     WH, 1',0dh,0ah
               db  '                 push     rectF.right',0dh,0ah
               db  '                 push     rectF.bottom',0dh,0ah
               db  '                  jmp     NewPos',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '            mov     eax, TRUE',0dh,0ah
               db  '            ret',0dh,0ah
               db  '      .endif',0dh,0ah,0dh,0ah

               db  '      .if wmsg == WM_SIZE',0dh,0ah
               db  '         INVOKE     SendMessage, hWndToolF, TB_BUTTONCOUNT, 0, 0',0dh,0ah
               db  '            mov     Cnt, eax',0dh,0ah
               db  '         .if !eax',0dh,0ah
               db  '               jmp     DefWin',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '         INVOKE     GetWindowRect, hREdit, addr rectE',0dh,0ah
               db  '            mov     eax, rectE.left',0dh,0ah
               db  '            add     eax, 6',0dh,0ah
               db  '            sub     rectE.right, eax',0dh,0ah
               db  '            mov     eax, rectE.top',0dh,0ah
               db  '            add     eax, 6',0dh,0ah
               db  '            sub     rectE.bottom, eax',0dh,0ah,0dh,0ah

               db  '         INVOKE     GetWindowRect, hWndFloat, addr rect',0dh,0ah
               db  '            mov     eax, lparam       ; Get width',0dh,0ah
               db  '            and     eax, 0ffffh       ; Lowword',0dh,0ah
               db  '            mov     ebx, lparam       ; Get height',0dh,0ah
               db  '            shr     ebx, 16           ; Hiword',0dh,0ah,0dh,0ah

               db  '         .if !ToolW',0dh,0ah
               db  '               mov     ToolW, eax',0dh,0ah
               db  '               mov     ToolH, ebx',0dh,0ah
               db  '               dec     ToolW',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah

               db  '            and     swOn, 0',0dh,0ah
               db  '            xor     edx, edx',0dh,0ah
               db  '         .if FloatLock && ebx == ToolH && eax != ToolW',0dh,0ah
               db  '               mov     WH, 1',0dh,0ah
               db  '               mov     eax, 22  ; Height',0dh,0ah
               db  '              push     rectE.right',0dh,0ah
               db  '              push     eax',0dh,0ah
               db  '               mov     swOn, 1',0dh,0ah
               db  '               jmp     NewPos',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '         .if FloatLock && eax == ToolW && ebx != ToolH',0dh,0ah
               db  '               mov     WH, 2',0dh,0ah
               db  '               mov     eax, 23  ; Width',0dh,0ah
               db  '              push     rectE.bottom',0dh,0ah
               db  '              push     eax',0dh,0ah
               db  '               mov     swOn, 2',0dh,0ah
               db  '               jmp     NewPos',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah

               db  '         .if eax != ToolW || ebx != ToolH',0dh,0ah
               db  '               mov     WH, 1',0dh,0ah
               db  '               mov     ecx, 22',0dh,0ah
               db  '            .if ebx != ToolH',0dh,0ah
               db  '                  mov     WH, 2',0dh,0ah
               db  '                  mov     ecx, 23',0dh,0ah
               db  '                  mov     eax, ebx',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '               div     ecx',0dh,0ah
               db  '            .if edx',0dh,0ah
               db  '                  inc     eax',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '            .if eax > Cnt',0dh,0ah
               db  '                  mov     eax, Cnt',0dh,0ah
               db  '            .endif',0dh,0ah,0dh,0ah

               db  'DoAgain:',0dh,0ah
               db  '            .if !eax',0dh,0ah
               db  '                  mov     eax, 1',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '               mov     ebx, eax',0dh,0ah,0dh,0ah

               db  '               mov     Var, 22',0dh,0ah
               db  '            .if WH == 1',0dh,0ah
               db  '                  mov     Var, 23',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '              imul     eax, Var',0dh,0ah,0dh,0ah

               db  '              push     eax           ; W if WH == 1',0dh,0ah
               db  '               xor     edx, edx',0dh,0ah
               db  '               mov     eax, Cnt',0dh,0ah
               db  '               div     ebx',0dh,0ah
               db  '            .if !eax',0dh,0ah
               db  '                  inc     eax',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '            .if edx',0dh,0ah
               db  '                  inc     eax',0dh,0ah
               db  '            .endif',0dh,0ah,0dh,0ah

               db  '            .if WH == 2 && eax == 2 || WH == 2 && eax == 3',0dh,0ah
               db  '              imul     ebx, eax',0dh,0ah
               db  '               .if ebx > Cnt',0dh,0ah
               db  '                  .if eax == 3',0dh,0ah
               db  '                        pop     eax',0dh,0ah
               db  '                        xor     edx, edx',0dh,0ah
               db  '                        mov     eax, Cnt',0dh,0ah
               db  '                        mov     ebx, 3',0dh,0ah
               db  '                        div     ebx',0dh,0ah
               db  '                        jmp     DoAgain',0dh,0ah
               db  '                  .endif',0dh,0ah
               db  '                     pop     eax',0dh,0ah
               db  '                     mov     eax, Cnt',0dh,0ah
               db  '                     jmp     DoAgain',0dh,0ah
               db  '               .endif',0dh,0ah
               db  '            .endif',0dh,0ah,0dh,0ah

               db  '               mov     Var, 23',0dh,0ah
               db  '            .if WH == 1',0dh,0ah
               db  '                  mov     Var, 22',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '              imul     eax, Var',0dh,0ah
               db  '              push     eax           ; H if WH == 1',0dh,0ah,0dh,0ah

               db  'NewPos:',0dh,0ah
               db  '            INVOKE     GetWindowRect, hWndFloat, addr rect',0dh,0ah
               db  '            .if WH == 1',0dh,0ah
               db  '                  pop     eax',0dh,0ah
               db  '                  pop     ebx',0dh,0ah
               db  '            .else',0dh,0ah
               db  '                  pop     ebx',0dh,0ah
               db  '                  pop     eax',0dh,0ah
               db  '            .endif',0dh,0ah,0dh,0ah

               db  '               mov     ToolW, ebx',0dh,0ah
               db  '               mov     ToolH, eax',0dh,0ah
               db  '               mov     rect.right, ebx',0dh,0ah
               db  '               mov     rect.bottom, eax',0dh,0ah
               db  '               add     rect.right, 6',0dh,0ah
               db  '               add     rect.bottom, 6',0dh,0ah,0dh,0ah

               db  '            .if FloatLock',0dh,0ah
               db  '                  and     FloatLock, 0',0dh,0ah
               db  '                 call     SetSize',0dh,0ah
               db  '                  mov     FloatLock, 1',0dh,0ah
               db  '               INVOKE     GetWindowRect, hREdit, addr rectE',0dh,0ah
               db  '                MOVmd     rect.left, rectE.left',0dh,0ah
               db  '                MOVmd     rect.top, rectE.top',0dh,0ah
               db  '                  mov     eax, rectE.left',0dh,0ah
               db  '                  add     eax, 6',0dh,0ah
               db  '                  sub     rectE.right, eax',0dh,0ah
               db  '                  mov     eax, rectE.top',0dh,0ah
               db  '                  add     eax, 6',0dh,0ah
               db  '                  sub     rectE.bottom, eax',0dh,0ah
               db  '               .if swOn',0dh,0ah
               db  '                  .if swOn == 1',0dh,0ah
               db  '                        jmp     sw01',0dh,0ah
               db  '                  .else',0dh,0ah
               db  '                        jmp     sw02',0dh,0ah
               db  '                  .endif',0dh,0ah
               db  '                     jmp     PressOn',0dh,0ah
               db  '               .endif',0dh,0ah
               db  '               INVOKE     GetClientRect, hWndFloat, addr rectF',0dh,0ah
               db  '                  mov     eax, rectF.right',0dh,0ah
               db  '               .if eax > rectF.bottom',0dh,0ah
               db  'sw01:',0dh,0ah
               db  '                     mov     rect.bottom, 22  ; Height',0dh,0ah
               db  '                     mov     ToolH, 22',0dh,0ah
               db  '                     add     rect.bottom, 6',0dh,0ah
               db  '                   MOVmd     rect.right, rectE.right',0dh,0ah
               db  '                     add     rect.right, 6',0dh,0ah
               db  '               .else',0dh,0ah
               db  'sw02:',0dh,0ah
               db  '                     mov     rect.right, 23   ; Width',0dh,0ah
               db  '                     mov     ToolW, 23',0dh,0ah
               db  '                     add     rect.right, 6',0dh,0ah
               db  '                   MOVmd     rect.bottom, rectE.bottom',0dh,0ah
               db  '                     add     rect.bottom, 6',0dh,0ah
               db  '               .endif',0dh,0ah
               db  '            .endif',0dh,0ah,0dh,0ah

               db  'PressOn:',0dh,0ah
               db  '            INVOKE     MoveWindow, hWndFloat, rect.left, rect.top, rect.right, rect.bottom, TRUE',0dh,0ah
               db  '            INVOKE     GetClientRect, hWndFloat, addr rect',0dh,0ah
               db  '               add     rect.right, 2',0dh,0ah
               db  '               add     rect.bottom, 2',0dh,0ah
               db  '            INVOKE     MoveWindow, hWndToolF, -1, -1, rect.right, rect.bottom, TRUE',0dh,0ah
               db  '              call     SetSize',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '            jmp     Ret0',0dh,0ah,0dh,0ah

               db  '      .elseif wmsg == WM_NOTIFY',0dh,0ah
               db  '            mov     ebx, lparam                      ; Get pointer to NMHDR',0dh,0ah
               db  '            mov     eax, (NMHDR ptr [ebx]).code',0dh,0ah
               db  '         .if eax == TTN_NEEDTEXT',0dh,0ah
               db  '               mov     eax, (NMHDR ptr [ebx]).idFrom ; Resource id',0dh,0ah
               db  '               mov     ebx, eax',0dh,0ah
               db  '            INVOKE     LoadString, hInst, ebx, addr szBuff, lengthof szBuff',0dh,0ah
               db  '               mov     ebx, lparam                   ; Get the buffer addr',0dh,0ah
               db  '               lea     eax, szBuff',0dh,0ah
               db  '               mov     (TOOLTIPTEXT ptr [ebx]).lpszText, eax',0dh,0ah
               db  '               jmp     Ret0',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '            jmp     DefWin',0dh,0ah,0dh,0ah

               db  '      .elseif wmsg == WM_COMMAND',0dh,0ah
               db  '         INVOKE     SendMessage, hWnd, WM_COMMAND, wparam, lparam',0dh,0ah
               db  '         INVOKE     SetFocus, hREdit',0dh,0ah
               db  '            xor     eax, eax',0dh,0ah
               db  '            jmp     Ret0',0dh,0ah
               db  '      .endif',0dh,0ah,0dh,0ah,0

szDefWin       db  'DefWin:',0dh,0ah
               db  '      INVOKE     DefWindowProc, hwnd, wmsg, wparam, lparam',0dh,0ah
               db  '         ret',0dh,0ah,0dh,0ah

               db  'Ret0:',0dh,0ah
               db  '         xor     eax, eax',0dh,0ah
               db  '         ret',0dh,0ah
               db  'FloatWndProc ENDP',0dh,0ah,0dh,0ah,0

szSetSize      db  ';======================================================',0dh,0ah
               db  '; Call WM_SIZE PROCEDURE',0dh,0ah
               db  ';======================================================',0dh,0ah
               db  'SetSize PROC',0dh,0ah
               db  'LOCAL    rect:RECT',0dh,0ah,0dh,0ah

               db  '      INVOKE     GetClientRect, hWnd, addr rect',0dh,0ah
               db  '         mov     edx, rect.bottom',0dh,0ah
               db  '         shl     edx, 16',0dh,0ah
               db  '         mov     ecx, rect.right',0dh,0ah
               db  '         mov     dx, cx',0dh,0ah
               db  '      INVOKE     SendMessage, hWnd, WM_SIZE, 0, edx',0dh,0ah
               db  '         ret',0dh,0ah,0dh,0ah

               db  'SetSize ENDP',0dh,0ah,0dh,0ah,0

szError1       db  'The RICHED20.DLL was not found!',0
szError2       db  'The file has been modified.',0Dh,0Ah
               db  'Do you wish to save it?',0
szError3       db  'You need to press the Update button first!',0

szOpenTitle    db  'Open File',0
szSaveTitle    db  'Save File As',0
szFilter       db  'All Files',0,'*.*',0,0
OA             dd  0
w5             dd  0

szNewButt      db  'New Button',0
szFR           db  'Find And Replace',0
FindEnd        db  'There Are No More Matches.'
               db  0Dh,0Ah
               db  'Would You Like To Restart From The'
TopBot         db  ' Top? '
               db  0
Top            db  ' Top? '
Bot            db  ' Bot? '
ToolSet        dd  1,2,3,5,6,7,8,11,12,13,14,16

Text01         db  'New', 0
Text02         db  'Open', 0
Text03         db  'Save', 0
Text04         db  'Cut', 0
Text05         db  'Copy', 0
Text06         db  'Paste', 0
Text07         db  'Delete', 0
Text08         db  'Find', 0
Text09         db  'FindN', 0
Text10         db  'FindP', 0
Text11         db  'Rep', 0
Text12         db  'Exit', 0
szText         dd  Text01,Text02,Text03,Text04,Text05,Text06,
                   Text07,Text08,Text09,Text10,Text11,Text12

Tip01          db  'New', 0
Tip02          db  'Open', 0
Tip03          db  'Save', 0
Tip04          db  'Cut', 0
Tip05          db  'Copy', 0
Tip06          db  'Paste', 0
Tip07          db  'Delete', 0
Tip08          db  'Find', 0
Tip09          db  'Find next match', 0
Tip10          db  'Find previous match', 0
Tip11          db  'Replace', 0
Tip12          db  'Exit this edit program', 0
szTip          dd  Tip01,Tip02,Tip03,Tip04,Tip05,Tip06,
                   Tip07,Tip08,Tip09,Tip10,Tip11,Tip12

TextC01        db  'New', 0
TextC02        db  'Open', 0
TextC03        db  'Save', 0
TextC04        db  'Save All', 0
TextC05        db  'Cut', 0
TextC06        db  'Copy', 0
TextC07        db  'Paste', 0
TextC08        db  'Delete', 0
TextC09        db  'Undo', 0
TextC10        db  'Redo', 0
TextC11        db  'Find', 0
TextC12        db  'FindN', 0
TextC13        db  'FindP', 0
TextC14        db  'Rep', 0
TextC15        db  'MultiI', 0
TextC16        db  'Exit', 0
szTextC        dd  TextC01,TextC02,TextC03,TextC04,TextC05,TextC06,
                   TextC07,TextC08,TextC09,TextC10,TextC11,TextC12,
                   TextC13,TextC14,TextC15,TextC16

;TBSTATE_
State01        db  'CHECKED         equ 00000001h',0
State02        db  'PRESSED         equ 00000002h',0
State03        db  'ENABLED         equ 00000004h',0
State04        db  'HIDDEN          equ 00000008h',0
State05        db  'INDETERMINATE   equ 00000010h',0
State06        db  'WRAP            equ 00000020h',0
StateArray     dd  State01,State02,State03,State04,State05,State06

;TBSTYLE_
Style01        db  'BUTTON          equ 00000000h',0
Style02        db  'SEP             equ 00000001h',0
Style03        db  'CHECK           equ 00000002h',0
Style04        db  'GROUP           equ 00000004h',0
Style05        db  'CHECKGROUP      equ 00000006h',0
Style06        db  'DROPDOWN        equ 00000008h',0
Style07        db  'AUTOSIZE        equ 00000010h',0
Style08        db  'NOPREFIX        equ 00000020h',0
StyleArray     dd  Style01,Style02,Style03,Style04,Style05,Style06,Style07,Style08

fmat1          db  '%01d',0

.data?
hInst          dd  ?
CommandLine    dd  ?
MainExit       dd  ?
hWnd           dd  ?
hREdDll        dd  ?
hREdit         dd  ?
hMenu          dd  ?
hSMenu         dd  ?
hSMenu3        dd  ?
lpRichEdit     dd  ?
hFont          dd  ?
hFontL         dd  ?
hFontD         dd  ?
EXStyles       dd  ?
Styles         dd  ?
FontName       db  64  dup(?)
hWndStat       dd  ?
sbParts        dd  4   dup(?)
hWndTool       dd  ?
hWndFloat      dd  ?
hWndToolF      dd  ?
hWndDock       dd  ?
hToolStyle     dd  ?
hImageList     dd  ?
hImageListM    dd  ?
hImageListG    dd  ?
hToolbarDlg    dd  ?

hDefHeap       dd  ?
ToolArray      dd  ?
ToolArrayM     dd  ?
TextArray      dd  ?
TipArray       dd  ?
hResr          dd  ?
hResrG         dd  ?
hToolTip       dd  ?
hDefines       dd  ?
hText          dd  ?
hEquate        dd  ?
hToolStr       dd  ?
hToolStrF      dd  ?
hOutput        dd  ?

ArrayCnt       dd  ?
StrAddr        dd  ?
StrSize        dd  ?

hListboxG      dd  ?

hListbox1      dd  ?
hListbox2      dd  ?
hListbox3      dd  ?
hRad01         dd  ?
hRad02         dd  ?
hButt01        dd  ?
hButt02        dd  ?
hButt03        dd  ?
hButt04        dd  ?
hButt05        dd  ?
hButt06        dd  ?
hButt07        dd  ?
hButt08        dd  ?
hButt09        dd  ?
hButt10        dd  ?
hButt11        dd  ?
hChk01         dd  ?
hChk02         dd  ?
hChk03         dd  ?
hChk04         dd  ?
hChk05         dd  ?
hChk06         dd  ?
hChk09         dd  ?
hChk10         dd  ?
hEdit01        dd  ?
hEdit02        dd  ?
hEdit03        dd  ?
hEdit04        dd  ?
hEdit05        dd  ?
hEdit06        dd  ?
hComb01        dd  ?
hComb02        dd  ?

hStat01        dd  ?

hBmp           dd  ?
bSize          dd  ?
hData          dd  ?
BmpID          dd  ?
CmdID          dd  ?
ButtID         dd  ?
ImageID        dd  ?
StartID        dd  ?

BmpCnt         dd  ?
BmpArray       dd  64  dup(?)
BmpCntM        dd  ?
BmpArrayM      dd  64  dup(?)

TBmpCnt         dd  ?
TBmpArray       dd  64  dup(?)
TBmpCntG        dd  ?
TBmpArrayG      dd  64  dup(?)

PathName       db  256 dup(?)
WorkBuff       db  256 dup(?)
szRoot         db  256 dup(?)
FileName       db  64  dup(?)
szNameA        db  32  dup(?)
szTextA        db  32  dup(?)
szTipA         db  64  dup(?)

CustClrs       dd  16  dup(?)

szFind         db  100 dup(?)
szRep          db  100 dup(?)
FRFlags        dd  ?
Prev           dd  ?
hFRDlg         dd  ?

SelList1       dd  ?
SelList2       dd  ?
TBLeft         dd  ?
TBTop          dd  ?
TBHgt          dd  ?
TBWth          dd  ?
WWth           dd  ?
WHgt           dd  ?
Redo           dd  ?
NoImage        dd  ?
UpdateOn       dd  ?
Chk10On        dd  ?
AddOn          dd  ?
EditOn         dd  ?
LeftOn         dd  ?
TopOn          dd  ?
RightOn        dd  ?
BottomOn       dd  ?
SavSize        dd  ?
hBRD           dd  ?
SavID          dd  ?
ButtW          dd  ?
ButtH          dd  ?
ToolW          dd  ?
ToolH          dd  ?
DockW          dd  ?
DockH          dd  ?
FloatLock      dd  ?
LockOn         dd  ?
SysParm        dd  ?

Test2          dd  ?
Test4          dd  ?

ToolStructure  STRUCT
   ID          dd  ?
   ImageID     dd  ?        ; +4
   hBitmap     dd  ?        ; +8
   lpName      db 32 dup(?) ; +12
   lpText      db 32 dup(?) ; +44
   lpTip       db 64 dup(?) ; +76
   fsState     dd  ?        ; +140
   fsStyle     dd  ?        ; +144
ToolStructure  ENDS
ts             ToolStructure       <>

tsImageID      dd  ?
tshBitmap      dd  ?
tslpName       dd  ?
tslpText       dd  ?
tslpTip        dd  ?
tsfsState      dd  ?
tsfsStyle      dd  ?

;---------- [Structures] ----------
ft             FINDTEXTEX           <>
charF2         CHARFORMAT2          <>
dis            DRAWITEMSTRUCT       <>
tbi            TBBUTTONINFO         <>
mii            MENUITEMINFO         <>
icc            INITCOMMONCONTROLSEX <>

.code

;======================================================
; Program initialization section
;======================================================
start:
      INVOKE     GetModuleHandle, NULL
         mov     hInst, eax
      INVOKE     GetCommandLine
         mov     CommandLine, eax

;        call     InitCommonControls
         mov     icc.dwSize, sizeof INITCOMMONCONTROLSEX
         mov     icc.dwICC, ICC_LISTVIEW_CLASSES or ICC_TREEVIEW_CLASSES or\
                 ICC_TAB_CLASSES or ICC_BAR_CLASSES or ICC_COOL_CLASSES
      INVOKE     InitCommonControlsEx, addr icc

      INVOKE     LoadLibrary, addr RichEdDLL ; Load the Riched20.dll
         mov     hREdDll, eax
      .if !eax
         INVOKE     MessageBox, NULL, addr szError1, addr AppName, MB_OK or MB_ICONERROR
            jmp     NoGo
      .endif

      INVOKE     GetProcessHeap
         mov     hDefHeap, eax

      INVOKE     WinMain, hInst ,NULL, CommandLine, SW_SHOWDEFAULT
         mov     MainExit, eax
      INVOKE     FreeLibrary, hREdDll

NoGo:
      INVOKE     ExitProcess, MainExit

;======================================================
; WinMain procedure
;======================================================
WinMain proc  uses ebx  hinst:DWORD, hPrevInst, CmdLine, CmdShow
LOCAL    wc:WNDCLASSEX
LOCAL    msg:MSG

         mov     wc.cbSize, sizeof WNDCLASSEX
         mov     wc.style, CS_HREDRAW or CS_VREDRAW
         mov     wc.lpfnWndProc, offset WndProc
         mov     wc.cbClsExtra, NULL
         mov     wc.cbWndExtra, NULL
        push     hInst
         pop     wc.hInstance
         mov     wc.hbrBackground, COLOR_BTNFACE+1
         mov     wc.lpszMenuName, offset MenuName
         mov     wc.lpszClassName, offset ClassName
      INVOKE     LoadIcon, NULL, IDI_APPLICATION
         mov     wc.hIcon, eax
         mov     wc.hIconSm, eax
      INVOKE     LoadCursor, NULL, IDC_ARROW
         mov     wc.hCursor, eax
      INVOKE     RegisterClassEx, addr wc

;---------- [Float Toolbar Class] ----------
          or     wc.style, CS_DBLCLKS
         mov     wc.lpfnWndProc, offset FloatWndProc
         mov     wc.lpszClassName, offset FloatTBClass
         mov     wc.lpszMenuName, NULL
      INVOKE     RegisterClassEx, addr wc

;---------- [Center the window] ----------
      INVOKE     GetSystemMetrics, SM_CXSCREEN
         sub     eax, 480
         shr     eax, 1
        push     eax
      INVOKE     GetSystemMetrics, SM_CYSCREEN
         sub     eax, 462 ;402
         shr     eax, 1
         pop     ebx

;---------- [Create the Main Window] ----------
      INVOKE     CreateWindowEx, WS_EX_CLIENTEDGE, addr ClassName,\
                 addr AppName, WS_OVERLAPPEDWINDOW,\
                 ebx, eax, 480, 462, NULL, NULL, hInst, NULL ;450
         mov     hWnd, eax

      INVOKE     ShowWindow, hWnd, SW_SHOWNORMAL
      INVOKE     UpdateWindow, hWnd

      INVOKE     GetMenu, hWnd              ; Get handle to main menu
         mov     hMenu, eax

;---------- [Message loop] ----------
      .while TRUE
         INVOKE     GetMessage, addr msg, NULL, 0, 0
            .break .if (!eax)
         INVOKE     IsDialogMessage, hToolbarDlg, addr msg
            cmp     eax, 0
            jne     Pass
         INVOKE     TranslateMessage, addr msg
         INVOKE     DispatchMessage, addr msg

Pass:
      .endw
         mov     eax, msg.wParam
         ret
WinMain endp

;======================================================
; WinProc procedure
;======================================================
WndProc proc  uses ebx esi edi hwnd:DWORD, wmsg, wparam, lparam
LOCAL    rect:RECT
LOCAL    lf:LOGFONT
LOCAL    charF:CHARFORMAT2
LOCAL    tbb:TBBUTTON
LOCAL    tbab:TBADDBITMAP
LOCAL    nmt:NMTOOLBAR
LOCAL    pt:POINT
LOCAL    hTbBmp:DWORD, ID, Cnt, Len, Incr, xPos
LOCAL    szBuff[64]:BYTE
;---------- [Create the Control(s) and one time stuff] ----------
      .if wmsg == WM_CREATE

;---------- [Create the status bar window] ----------
         INVOKE     CreateWindowEx, 0, addr StatClass, 0,\
                    WS_CHILD or WS_BORDER or WS_VISIBLE or SBS_SIZEGRIP,\
                    0, 0, 0, 0, hwnd, 0, hInst, 0  
         .if !eax
;Do message
               jmp     Ret0
         .endif
            mov     hWndStat, eax

;---------- [Create the Toolbar Window] ----------
         INVOKE     CreateWindowEx, 0, addr ToolClass, 0,
                    WS_CHILD or WS_VISIBLE or WS_BORDER or TBSTYLE_TOOLTIPS or TBSTYLE_FLAT or\
                    CCS_NOPARENTALIGN or CCS_NORESIZE,\
                    0, -2, 1200, 26, hwnd, 3737, hInst, 0
         .if !eax
;Do message
               jmp     Ret0
         .endif
            mov     hWndTool, eax
INVOKE     SendMessage, hWndTool, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS

            mov     TBLeft, -1
            mov     TBTop, -2
            mov     TBWth, 1200
            mov     TBHgt, 26
         INVOKE     GetWindowLong, hWndTool, GWL_STYLE
            mov     hToolStyle, eax

;---------- [Create the ImageList] ----------
         INVOKE     ImageList_Create, 16, 16, ILC_COLOR32, 12, 64
            mov     hImageList, eax

;---------- [Load The Bitmaps] ----------
            mov     ID, 701           ; Bitmap ID start address
            mov     Cnt, 12           ; Number of bitmaps
         .while (Cnt)
            INVOKE     LoadImage, hInst, ID, IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR
               mov     hTbBmp, eax
            INVOKE     ChgBmpColor, hTbBmp, 1
               mov     hTbBmp, eax
            INVOKE     ImageList_Add, hImageList, hTbBmp, NULL
            INVOKE     DeleteObject, hTbBmp
               inc     ID
               dec     Cnt
         .endw

         INVOKE     SendMessage, hWndTool, TB_BUTTONSTRUCTSIZE, sizeof TBBUTTON, 0
         INVOKE     SendMessage, hWndTool, TB_SETIMAGELIST, 0, hImageList

;---------- [Size the Bitmap and Button] ----------
            mov     ecx, 16  ; loword = bitmap Width
            mov     eax, 16  ; hiword = bitmap Height
            shl     eax, 16
            mov     ax, cx
            mov     bSize, eax
         INVOKE     SendMessage, hWndTool, TB_SETBITMAPSIZE, 0, bSize
;            mov     ecx, 23  ; loword = button Width
;            mov     word ptr bSize, cx
         INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, bSize

;---------- [Create the Toolbar structures] ----------
         TBButt     hWndTool, 0, 1001, 4, 0
         TBButt     hWndTool, 1, 1002, 4, 0
         TBButt     hWndTool, 2, 1003, 4, 0
          TBSep     hWndTool
         TBButt     hWndTool, 3, 1004, 4, 0
         TBButt     hWndTool, 4, 1005, 4, 0
         TBButt     hWndTool, 5, 1006, 4, 0
         TBButt     hWndTool, 6, 1007, 4, 0
          TBSep     hWndTool
         TBButt     hWndTool, 7, 1008, 4, 0
         TBButt     hWndTool, 8, 1009, 4, 0
         TBButt     hWndTool, 9, 1010, 4, 0
         TBButt     hWndTool, 10,1011, 4, 0
          TBSep     hWndTool
         TBButt     hWndTool, 11,1012, 4, 0

;---------- [Create the Edit Window] ----------
         INVOKE     CreateWindowEx, NULL, addr RichEdit, NULL,\
                    WS_CHILD or WS_VISIBLE or WS_BORDER or ES_MULTILINE or\
                    ES_NOHIDESEL or ES_SAVESEL or ES_SELECTIONBAR or\
                    WS_HSCROLL or ES_AUTOHSCROLL or\
                    WS_VSCROLL or ES_AUTOVSCROLL,\
                    0, 0, 0, 0, hwnd, 4444, hInst, NULL
         .if !eax
;Do message
               jmp     Ret0
         .endif
            mov     hREdit, eax

         INVOKE     SendMessage, hREdit, EM_EXLIMITTEXT, 0, 4000000
         INVOKE     SetFocus, hREdit

;---------- [Control window subclassed] ----------
         INVOKE     SetWindowLong, hREdit, GWL_WNDPROC, RichEditProc
            mov     lpRichEdit, eax

         INVOKE     LoadMenu, hInst, addr PopupMenu   
         INVOKE     GetSubMenu, eax, 0
            mov     hSMenu, eax

;---------- [Get the character format] ----------
            mov     charF2.cbSize, sizeof charF2
         INVOKE     SendMessage, hREdit, EM_GETCHARFORMAT, TRUE, addr charF2
            mov     eax, FontW
            mov     charF2.wWeight, ax   
         INVOKE     lstrcpy, addr FontName, addr FontNameCN

         INVOKE     RtlZeroMemory, addr lf, sizeof lf
         INVOKE     lstrcpy, addr lf.lfFaceName, addr FontName
           push     FontHeight
            pop     lf.lfHeight
            xor     eax, eax
            mov     ax, charF2.wWeight
            mov     lf.lfWeight, eax
            mov     al, charF2.bCharSet
            mov     lf.lfCharSet, al
            mov     al, charF2.bPitchAndFamily
            mov     lf.lfPitchAndFamily, al
         INVOKE     CreateFontIndirect, addr lf
            mov     hFont, eax

            mov     lf.lfHeight, -10
            mov     lf.lfWeight, 400
         INVOKE     lstrcpy, addr lf.lfFaceName, addr FontNameAR
         INVOKE     CreateFontIndirect, addr lf
            mov     hFontL, eax

            mov     lf.lfHeight, -9 ;-8
            mov     lf.lfWeight, 400
         INVOKE     lstrcpy, addr lf.lfFaceName, addr FontNameQT ;FontNameMS
         INVOKE     CreateFontIndirect, addr lf
            mov     hFontD, eax   ; Dialog font

         INVOKE     SendMessage, hREdit, WM_SETFONT, hFont, TRUE

;---------- [Allocate memory from the default heap] ----------
         INVOKE     HeapAlloc, hDefHeap, 0, 15000
            mov     ToolArray, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 15000
            mov     ToolArrayM, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 4096
            mov     TextArray, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 6400
            mov     TipArray, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 2024
            mov     hResr, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 2024
            mov     hResrG, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 2024
            mov     hToolStr, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 2024
            mov     hToolStrF, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 2024
            mov     hToolTip, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 2024
            mov     hDefines, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 2024
            mov     hText, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 2024
            mov     hEquate, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 50000
            mov     hOutput, eax

            mov     mii.cbSize, sizeof mii
            mov     mii.fMask, MIIM_DATA or MIIM_ID or MIIM_STATE or\
                               MIIM_SUBMENU or MIIM_TYPE or MIIM_CHECKMARKS

            mov     tbi.cbSize, sizeof tbi
            lea     eax, ts.ID
            lea     ecx, ts.ImageID
            sub     ecx, eax
            mov     tsImageID, ecx
            lea     ecx, ts.hBitmap
            sub     ecx, eax
            mov     tshBitmap, ecx
            lea     ecx, ts.lpName
            sub     ecx, eax
            mov     tslpName, ecx
            lea     ecx, ts.lpText
            sub     ecx, eax
            mov     tslpText, ecx
            lea     ecx, ts.lpTip
            sub     ecx, eax
            mov     tslpTip, ecx
            lea     ecx, ts.fsState
            sub     ecx, eax
            mov     tsfsState, ecx
            lea     ecx, ts.fsStyle
            sub     ecx, eax
            mov     tsfsStyle, ecx

            mov     TopOn, 1

         INVOKE     SystemParametersInfo, SPI_GETDRAGFULLWINDOWS, 0, addr SysParm, 0
         .if SysParm
            INVOKE     SystemParametersInfo, SPI_SETDRAGFULLWINDOWS, 0, 0, SPIF_UPDATEINIFILE
         .endif

;---------- [Move and Size the Control(s)] ----------
      .elseif wmsg == WM_SIZE

;---------- [Size the Statusbar Control] ----------
            mov     eax, lparam       ; Get width
            and     eax, 0ffffh       ; Lowword
            shr     eax, 2            ; /4
            mov     ecx, eax          ; Save factor
            mov     sbParts, eax      ; Make part 1 1/4 the width
            add     eax, ecx
            mov     [sbParts+4], eax  ; and also part2, .. etc
            add     eax, ecx
            mov     [sbParts+8], eax
            mov     [sbParts+12], -1  ; The last part extends to the end
         INVOKE     SendMessage, hWndStat, SB_SETPARTS, 4, addr sbParts
         INVOKE     MoveWindow, hWndStat, 0, 0, 0, 0, TRUE
;         INVOKE     SendMessage, hWndStat, SB_SETTEXT, 0, addr szPart1
         INVOKE     SendMessage, hWndStat, SB_SETTEXT, 2, addr szPart3

;---------- [Size the Toolbar Control] ----------
         INVOKE     SendMessage, hWndTool, TB_AUTOSIZE, 0, 0

;---------- [Size the Edit Control] ----------
            xor     eax, eax             ; Zero out toolbar height
            xor     eax, eax             ; Zero out toolbar height
         .if hWndTool
            INVOKE     GetClientRect, hWnd, addr rect ; Rectangle of main window
               mov     eax, rect.right
               mov     WWth, eax
            .if TopOn || BottomOn
                  inc     eax
                  mov     TBWth, eax
            .endif
               mov     eax, rect.bottom
               mov     WHgt, eax
            INVOKE     GetWindowRect, hWndTool, addr rect ; Rectangle of toolbar
               mov     eax, rect.bottom
               sub     eax, rect.top

            .if TopOn || BottomOn
;                  mov     eax, 26
            .endif
mov     eax, TBHgt
               mov     TBHgt, eax
            .if LeftOn || RightOn
                  mov     eax, WHgt
                  mov     TBHgt, eax
                  xor     eax, eax
            .endif
         .endif

           push     eax                  ; Save height of toolbar
            xor     eax, eax             ; Zero out statusbar height
         .if hWndStat
            INVOKE     GetWindowRect, hWndStat, addr rect ; Rectangle of statusbar
               mov     eax, rect.bottom
               sub     eax, rect.top     ; eax = height of statusbar
         .endif
            pop     edx                  ; edx = height of toolbar
         .if BottomOn
               and     edx, 0
         .endif
            mov     ebx, lparam          ; Width of new client area
            and     ebx, 0ffffh          ; ebx = width
            mov     ecx, lparam
            shr     ecx, 16              ; Height of new client area
            sub     ecx, eax             ; Edit window - height of statusbar
            sub     ecx, edx             ; Edit window - height of toolbar
         .if edx                         ; If toolbar
               sub     edx, 2            ; For border
               add     ecx, 2            ; For border
         .endif
         .if eax                         ; If statusbar
               add     ecx, 2            ; For border
         .endif

            and     xPos, 0
         .if TopOn && TBTop == -4
               sub     edx, 2
               add     ecx, 2
         .endif
         .if LeftOn && !hWndDock
               mov     eax, TBWth
               mov     xPos, eax
               sub     ebx, TBWth
               mov     TBHgt, ecx
         .endif
         .if RightOn && !hWndDock
               mov     xPos, 0
               sub     ebx, TBWth
               mov     TBHgt, ecx
               mov     TBLeft, ebx
         .endif
         .if BottomOn
               sub     ecx, TBHgt
               add     ecx, 20      ; Statusbar height
               mov     TBTop, ecx
         .endif
         .if hWndDock
               mov     edx, 0
               add     ecx, TBHgt
               sub     ecx, 2
         .endif
         .if FloatLock
               mov     eax, ToolW
            .if ToolH > eax
                  add     eax, 6
                  mov     xPos, eax
                  sub     ebx, ToolW
                  sub     ebx, 6
            .else
                  mov     xPos, 0
                  add     edx, ToolH
                  add     edx, 6
                  sub     ecx, ToolH
                  sub     ecx, 6
            .endif
         .endif
         INVOKE     MoveWindow, hREdit, xPos, edx, ebx, ecx, TRUE
         INVOKE     MoveWindow, hWndTool, TBLeft, TBTop, TBWth, TBHgt, TRUE

         .if hToolbarDlg && !hWndFloat && !hWndDock
            INVOKE     GetWindowRect, hREdit, addr rect
              push     rect.top
              push     rect.left
            INVOKE     GetWindowRect, hToolbarDlg, addr rect
               mov     eax, rect.left
               sub     rect.right, eax
               mov     eax, rect.top
               sub     rect.bottom, eax
               pop     rect.left
               pop     rect.top
            .if RightOn
                  mov     eax, TBWth
                  sub     rect.left, eax
            .endif
            .if hWndDock && TBHgt < 50
                  mov     eax, TBHgt
                  sub     eax, 2
                  add     rect.top, eax
            .endif
            INVOKE     MoveWindow, hToolbarDlg, rect.left, rect.top, rect.right, rect.bottom, TRUE
         .endif
         INVOKE     GetWindowRect, hWnd, addr rect
            mov     eax, rect.left
            sub     rect.right, eax
            mov     eax, rect.top
            sub     rect.bottom, eax
            mov     ecx, rect.right
         .if rect.right < 480 || rect.bottom != 462
            .if rect.right < 480
                  mov     ecx, 480
            .endif
            INVOKE     MoveWindow, hWnd, rect.left, rect.top, ecx, 462, TRUE
         .endif

;---------- [Size the Floating Toolbar] ----------
         .if hWndFloat && !ToolH
            INVOKE     GetWindowRect, hWnd, addr rect
               add     rect.left, 325
               add     rect.top, 0
               mov     rect.right, 94
               mov     rect.bottom, 0
               mov     ToolH, 1
            INVOKE     MoveWindow, hWndFloat, rect.left, rect.top, rect.right, rect.bottom, TRUE

         .elseif hWndFloat && FloatLock
            INVOKE     GetWindowRect, hREdit, addr rect
               mov     eax, rect.left
               sub     rect.right, eax
               mov     eax, rect.top
               sub     rect.bottom, eax
               mov     ecx, ToolW
            .if ecx < ToolH
                  add     ecx, 6
                  sub     rect.left, ecx
                  mov     edx, rect.bottom

            .else
                  mov     edx, ToolH
                  add     edx, 6
                  sub     rect.top, edx
                  mov     ecx, rect.right
            .endif
            INVOKE     MoveWindow, hWndFloat, rect.left, rect.top, ecx, edx, TRUE
         .endif

;---------- [Size the Docking Toolbar] ----------
         .if hWndDock ;&& !DockH
            INVOKE     SendMessage, hWndTool, TB_BUTTONCOUNT, 0, 0
               mov     Cnt, eax
               mov     ecx, Cnt
               dec     ecx
            INVOKE     SendMessage, hWndTool, TB_GETITEMRECT, ecx, addr rect
             MOVmd     DockW, rect.right
               add     DockW, 8
             MOVmd     DockH, rect.bottom
               add     DockH, 24 ;25
               inc     rect.right
               add     rect.bottom, 3
            INVOKE     MoveWindow, hWndTool, 0, -2, rect.right, rect.bottom, TRUE
            INVOKE     GetWindowRect, hWndDock, addr rect
              push     rect.left
              push     rect.top
            INVOKE     GetWindowRect, hWnd, addr rect
               pop     edx
               pop     ecx
            .if ecx == 0 || edx == 0
                  add     rect.left, 6
                  add     rect.top, 44
            .else
                  mov     rect.left, ecx
                  mov     rect.top, edx
            .endif
            INVOKE     MoveWindow, hWndDock, rect.left, rect.top, DockW, DockH, TRUE
         .endif

      .elseif wmsg == WM_MOVE
         .if FloatLock || LockOn
               mov     FloatLock, 1
               mov     LockOn, 1
         .endif
          call     SetSize

      .elseif wmsg == WM_ACTIVATEAPP
         INVOKE     DefWindowProc, hWnd, WM_NCACTIVATE, wparam, 0 
            ret

      .elseif wmsg == WM_NCACTIVATE 
            mov     eax, TRUE 
            ret

      .elseif wmsg == WM_NOTIFY
            mov     ebx, lparam                      ; Get pointer to NMHDR
            mov     eax, (NMHDR ptr [ebx]).code
            mov     ecx, (NMHDR ptr [ebx]).hwndFrom
         .if eax == TTN_NEEDTEXT
               mov     eax, (NMHDR ptr [ebx]).idFrom ; Resource id
            .if hToolbarDlg
               INVOKE     GetData, hData, eax, 0
                  lea     eax, szTipA
            .else
                  mov     ebx, eax
               INVOKE     LoadString, hInst, ebx, addr szBuff, lengthof szBuff
                  mov     ebx, lparam                   ; Get the buffer addr
                  lea     eax, szBuff
            .endif
               mov     (TOOLTIPTEXT ptr [ebx]).lpszText, eax
               jmp     Ret0

         .elseif eax == NM_RDBLCLK && ecx == hWndTool && !hWndDock
              call     GetStyles
            .if (Styles & WS_BORDER)
                  xor     Styles, WS_BORDER
               INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 8
            .endif
            INVOKE     SetWindowLong, hWndTool, GWL_STYLE, Styles
            INVOKE     SendMessage, hChk04, BM_SETCHECK, BST_CHECKED, 0
            .if FloatLock
                  mov     LockOn, 1
            .endif
              call     DockToolbar
            INVOKE     SetFocus, hWndDock
               jmp     Ret0

         .elseif eax == TBN_BEGINADJUST
               jmp     Ret1

; Add to Windows.inc Comctl32.dll version 5.80 or later- Removes the help button
         .elseif eax == TBN_FIRST-23 ;TBN_INITCUSTOMIZE
               mov     eax, 1        ;TBNRF_HIDEHELP
               ret

         .elseif eax == TBN_QUERYINSERT
               jmp     Ret1

         .elseif eax == TBN_QUERYDELETE
               jmp     Ret1

         .elseif eax == TBN_GETBUTTONINFO
               mov     eax, [ebx.TBNOTIFY].iItem ; Item num
            .if eax < 33
                 push     ebx
                 push     eax
                  mov     Incr, eax
               INVOKE     SendMessage, hWndTool, TB_BUTTONCOUNT, 0, 0

;---------- [Find matching bitmap ID] ----------
                  and     ID, 0
                  and     Len, 0
                  mov     Cnt, eax
               .while (Cnt)
                  INVOKE     SendMessage, hWndTool, TB_GETBUTTON, ID, addr tbb
                     mov     eax, Incr
                  .if eax == tbb.iBitmap && tbb.fsStyle != TBSTYLE_SEP
                        mov     edx, tbb.idCommand
                     .break
                  .endif
                  .if tbb.fsStyle != TBSTYLE_SEP
                        inc     Len
                  .endif
                     inc     ID
                     dec     Cnt
               .endw
               .if !Cnt
                     xor     edx, edx
                     xor     esi, esi
               .endif
                  pop     eax
                  pop     ebx
               .if !edx                    ; No matching ID
                     mov     edx, eax
                     inc     edx
                     add     edx, 6900
               .endif

                  mov     [ebx.TBNOTIFY.tbButton].iBitmap, eax
                  mov     [ebx.TBNOTIFY.tbButton].idCommand, edx
                  mov     [ebx.TBNOTIFY.tbButton].fsState, TBSTATE_ENABLED
                  mov     [ebx.TBNOTIFY.tbButton].fsStyle, TBSTYLE_BUTTON
                  mov     [ebx.TBNOTIFY.tbButton].dwData, 0

                  lea     ecx, szSpace
                  xor     esi, esi
               .if eax < 16                ; Number of predefined names
                  pushad
                  INVOKE     lstrcpy, addr szTextA, szTextC[eax*4]
                   popad
                     lea     esi, szTextA
               .endif

               .if esi
;                     mov     [ebx.TBNOTIFY.tbButton].iString, esi
                     mov     ecx, esi

                  pushad
                     mov     tbi.dwMask, TBIF_TEXT
                     mov     tbi.pszText, ecx
                     mov     SavID, edx    ; Save the command ID for TBN_TOOLBARCHANGE
                  INVOKE     SendMessage, hWndTool, TB_SETBUTTONINFO, edx, addr tbi
                   popad
               .endif

                  mov     [ebx.TBNOTIFY].cchText, 32
                  mov     [ebx.TBNOTIFY].pszText, ecx
                  jmp     Ret1

            .else
               jmp     Ret0
            .endif

         .elseif eax == TBN_TOOLBARCHANGE
               lea     ecx, szTextA
               mov     tbi.dwMask, TBIF_TEXT
               mov     tbi.pszText, ecx
            INVOKE     SendMessage, hWndTool, TB_SETBUTTONINFO, SavID, addr tbi
               jmp     Ret0

         .elseif eax == TBN_DROPDOWN
               mov     eax, [ebx.NMTOOLBAR].iItem ; Item num
            INVOKE     SendMessage, hWndTool, TB_COMMANDTOINDEX, eax, 0
               mov     ecx, eax
            INVOKE     SendMessage, hWndTool, TB_GETITEMRECT, ecx, addr rect
              push     rect.top
              push     rect.left
            INVOKE     GetWindowRect, hWndTool, addr rect
               pop     eax
               add     rect.left, eax
               pop     eax
               add     eax, 28
               add     rect.top, eax
            INVOKE     TrackPopupMenu, hSMenu, TPM_LEFTALIGN or TPM_LEFTBUTTON,\
                       rect.left, rect.top, 0, hWnd, 0 ;addr rect

         .endif
         jmp     DefWin

;---------- [System and user commands] ----------
      .elseif wmsg == WM_COMMAND

         INVOKE     IsWindowVisible, hToolbarDlg
         .if eax
               mov     ecx, StartID
               mov     edx, ecx
               add     edx, 32
               mov     eax, wparam
              cwde                          ; Only low word contains command
            .if eax >= ecx && eax <= edx
               INVOKE     SendMessage, hWndTool, TB_COMMANDTOINDEX, eax, 0
               INVOKE     SendMessage, hListbox2, LB_SETCURSEL, eax, 0
                  mov     ecx, LBN_SELCHANGE
                  shl     ecx, 16
               INVOKE     SendMessage, hToolbarDlg, WM_COMMAND, ecx, hListbox2
               jmp     Ret0
            .endif
         .endif

            mov     eax, wparam
           cwde                          ; Only low word contains command
         .if eax == IDM_EXIT
            INVOKE     SendMessage, hwnd, WM_CLOSE, 0 ,0

         .elseif eax == IDM_CUT
            INVOKE     SendMessage, hREdit, WM_CUT, 0 ,0

         .elseif eax == IDM_COPY
            INVOKE     SendMessage, hREdit, WM_COPY, 0 ,0

         .elseif eax == IDM_PASTE
            INVOKE     SendMessage, hREdit, WM_PASTE, 0 ,0

         .elseif eax == IDM_DELETE
            INVOKE     SendMessage, hREdit, WM_CLEAR, 0 ,0

         .elseif eax == IDM_SELALL
            INVOKE     SendMessage, hREdit, EM_SETSEL, 0, -1

         .elseif eax == IDM_TOOLBAR && !hToolbarDlg
            INVOKE     CreateDialogParam, hInst, IDD_DLG01, hwnd, addr ToolBarDlg, 0
               mov     hToolbarDlg, eax
              call     SetSize

         .elseif eax == IDM_DIALOG
            INVOKE     IsWindowVisible, hToolbarDlg
            .if !eax
               INVOKE     ShowWindow, hToolbarDlg, SW_SHOWDEFAULT
                  mov     eax, offset szMenu1
                  mov     mii.dwTypeData, eax
            .else
               INVOKE     ShowWindow, hToolbarDlg, SW_HIDE
                  mov     eax, offset szMenu2
                  mov     mii.dwTypeData, eax
            .endif
            INVOKE     SetMenuItemInfo, hMenu, 2, TRUE, addr mii
            INVOKE     DrawMenuBar, hWnd

         .elseif eax > 6900 && eax < 7000
            INVOKE     MessageBox, NULL, addr szNewButt, addr AppName, MB_OK

         .endif

      .elseif wmsg == WM_CLOSE
         INVOKE     SendMessage, hREdit, EM_GETMODIFY, 0, 0
         .if eax != 0
            INVOKE     MessageBox, NULL, addr szError2, addr AppName,
                       MB_YESNOCANCEL or MB_ICONEXCLAMATION or MB_SYSTEMMODAL
            .if eax == IDYES
                 call     SaveFile
               .if eax == IDCANCEL
                     jmp     Ret0
               .endif
            .elseif eax == IDCANCEL
                  jmp     Ret0
            .endif
         .endif
         INVOKE     DestroyWindow, hwnd

      .elseif wmsg == WM_DESTROY
         .if SysParm
            INVOKE     SystemParametersInfo, SPI_SETDRAGFULLWINDOWS, 1, 0, SPIF_UPDATEINIFILE
         .endif

            and     Incr, 0
         .while (BmpCnt)
               mov     eax, Incr
               mov     ecx, BmpArray[eax*4]
            INVOKE     DeleteObject, ecx
               inc     Incr
               dec     BmpCnt
         .endw

            and     Incr, 0
         .while (BmpCntM)
               mov     eax, Incr
               mov     ecx, BmpArrayM[eax*4]
            INVOKE     DeleteObject, ecx
               inc     Incr
               dec     BmpCntM
         .endw

            and     Incr, 0
         .while (TBmpCnt)
               mov     eax, Incr
               mov     ecx, TBmpArray[eax*4]
            INVOKE     DeleteObject, ecx
               inc     Incr
               dec     TBmpCnt
         .endw

            and     Incr, 0
         .while (TBmpCntG)
               mov     eax, Incr
               mov     ecx, TBmpArrayG[eax*4]
            INVOKE     DeleteObject, ecx
               inc     Incr
               dec     TBmpCntG
         .endw

            and     Incr, 0
            mov     Cnt, 13
         .while (Cnt)
               mov     eax, Incr
               mov     ecx, ToolArray[eax*4]
            INVOKE     HeapFree, hDefHeap, 0, ecx
.if eax == 0
;call     GetLastError
;DSPValue hWnd, eax, 1, 'm'
.endif
               inc     Incr
               dec     Cnt
         .endw

         INVOKE     ImageList_Destroy, hImageList
         INVOKE     ImageList_Destroy, hImageListM
         INVOKE     PostQuitMessage, NULL

      .else

DefWin:
         INVOKE     DefWindowProc, hwnd, wmsg, wparam, lparam
            ret
      .endif

Ret1:
         mov     eax, 1
         jmp     Finish

Ret0:
         xor     eax, eax

Finish:
         ret
WndProc endp

;======================================================
; SubClass the Edit control procedure
;======================================================
RichEditProc PROC hwnd:DWORD, wmsg, wparam, lparam
LOCAL    rect:RECT

      .if wmsg == WM_RBUTTONDOWN
            jmp     PopUp
      .endif
         jmp     ThatsAll

PopUp:
      INVOKE     GetWindowRect, hWnd, addr rect
         mov     ecx, lparam        ; x/y pos of window
         mov     ebx, ecx
         and     ebx, 0000ffffh     ; ebx = LOWORD(lparam) = x pos
         shr     ecx, 16            ; ecx = HIWORD(lparam) = y pos
         add     ebx, rect.left
         add     ecx, rect.top
         add     ebx, 10 
         add     ecx, 70
      INVOKE     TrackPopupMenu, hSMenu, TPM_LEFTALIGN or TPM_LEFTBUTTON,\
                 ebx, ecx, 0, hWnd, addr rect
        jmp      ThatsAll

ThatsAll:
      INVOKE     CallWindowProc, lpRichEdit, hwnd, wmsg, wparam, lparam

         ret
RichEditProc ENDP

;======================================================
; ChgBmpColor procedure
;======================================================
ChgBmpColor PROC hBitmap:DWORD, Code
LOCAL    mDC:DWORD, hBrush, hOldBmp, Fill, hOldBrush

      INVOKE     CreateCompatibleDC, NULL
         mov     mDC, eax
      INVOKE     SelectObject, mDC, hBitmap
         mov     hOldBmp, eax
      INVOKE     GetSysColor, COLOR_BTNFACE
      .if !Code
         INVOKE     CreateSolidBrush, 00ffffffh ;eax
      .else
         INVOKE     CreateSolidBrush, eax
      .endif
         mov     hBrush, eax
      INVOKE     SelectObject, mDC, hBrush
         mov     hOldBrush, eax
      .if !Code
;            mov     Fill, 00ffffffh
            mov     Fill, 00c0c0c0h
;      .elseif Code == 4
;            mov     Fill, 00ffffffh
      .else
            mov     Fill, 00c0c0c0h
;            mov     Fill, 00ffffffh
      .endif
      INVOKE     ExtFloodFill, mDC, 0, 0, Fill, FLOODFILLSURFACE
      INVOKE     ExtFloodFill, mDC, 0, 15, Fill, FLOODFILLSURFACE
      INVOKE     ExtFloodFill, mDC, 15, 0, Fill, FLOODFILLSURFACE
      INVOKE     ExtFloodFill, mDC, 15, 15, Fill, FLOODFILLSURFACE
      INVOKE     SelectObject, mDC, hOldBrush
      INVOKE     DeleteObject, hBrush
      INVOKE     SelectObject, mDC, hBitmap
        push     eax
      INVOKE     DeleteDC, mDC
         pop     eax
         ret

ChgBmpColor ENDP

;======================================================
; Load Bitmaps procedure
;======================================================
LoadBitmaps PROC uses esi edi szBitMap:DWORD, Code
LOCAL    hFile:DWORD, bytesread, MemPtr, hDC, hBitmap
LOCAL    szBuff[256]:BYTE, BmpHeader[27]:BYTE

         and     hBitmap, 0
      INVOKE     lstrcpy, addr szBuff, addr szRoot
      INVOKE     lstrcat, addr szBuff, addr szSlashB
      INVOKE     lstrcat, addr szBuff, addr szResr2
      INVOKE     lstrcat, addr szBuff, addr szSlashB
      INVOKE     lstrcat, addr szBuff, szBitMap

      INVOKE     CreateFile, addr szBuff, GENERIC_READ, FILE_SHARE_READ,\
                 0, OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, 0
         cmp     eax, -1
          jz     NoFile      ; No File
         mov     hFile, eax

      INVOKE     ReadFile, hFile, addr BmpHeader, 26, addr bytesread, 0
         cmp     bytesread, 26
         jnz     NotBitmap   ; No read
         cmp     word ptr BmpHeader, 'MB'
         jnz     NotBitmap   ; Not Bitmap

      INVOKE     GlobalAlloc, 0, dword ptr BmpHeader+2 ; BmpHeader+2 = file size
          or     eax, eax
          jz     NotBitmap   ; No allocate
         mov     MemPtr, eax

      INVOKE     SetFilePointer, hFile, 0, 0, 0
      INVOKE     ReadFile, hFile, MemPtr, dword ptr BmpHeader+2, addr bytesread, 0

      INVOKE     GetDC, hWnd                           ; Get the dc of the window
         mov     hDC, eax
         mov     esi, MemPtr
         add     esi, dword ptr BmpHeader+10           ; Pointer to initialization data
         mov     edi, MemPtr
         add     edi, 14                               ; Pointer to bitmap size and format data
      INVOKE     CreateDIBitmap, hDC, edi, CBM_INIT, esi, edi, 0 ; Creates a device-dependent bitmap from a device-independent bitmap
      INVOKE     ChgBmpColor, eax, Code
         mov     hBitmap, eax

      INVOKE     GlobalFree, MemPtr

NotBitmap:
      INVOKE     CloseHandle, hFile

NoFile:
         mov     eax, hBitmap
         ret

LoadBitmaps ENDP

;======================================================
; Fill the DRAWITEM structure
;======================================================
SetDrawList PROC hwnd, hList, ID, Ctrl, Focus
LOCAL    rect:RECT

         mov     dis.CtlType, ODT_LISTBOX
         mov     eax, Ctrl
         mov     dis.CtlID, eax
       MOVmd     dis.itemID, ID
         mov     dis.itemAction, ODA_DRAWENTIRE
      .if Focus
            mov     dis.itemState, ODS_FOCUS
      .else
            mov     dis.itemState, ODS_DEFAULT ;ODS_DEFAULT ODS_FOCUS ODS_DISABLED
      .endif
         mov     eax, hList
         mov     dis.hwndItem, eax
      INVOKE     GetDC, hList
         mov     dis.hdc, eax
      INVOKE     SelectObject, dis.hdc, hFontL
      INVOKE     SendMessage, hList, LB_GETITEMRECT, ID, addr rect
       MOVmd     dis.rcItem.left, rect.left
       MOVmd     dis.rcItem.top, rect.top
       MOVmd     dis.rcItem.right, rect.right
       MOVmd     dis.rcItem.bottom, rect.bottom
         mov     dis.itemData, 0
      .if rect.top > 144 || rect.top > 7fffh
      .else
         INVOKE     SendMessage, hwnd, WM_DRAWITEM, Ctrl, addr dis
      .endif
      INVOKE     ReleaseDC, hList, dis.hdc
         ret
SetDrawList ENDP

;======================================================
; Load Listbox2 structure
;======================================================
LoadListbox2 PROC
LOCAL    Incr:DWORD, ID, bID, IDOn
LOCAL    szBuff1[32]:BYTE, szBuff2[32]:BYTE

         and     ID, 0
         and     bID, 0
         and     IDOn, 0
      INVOKE     IsDlgButtonChecked, hToolbarDlg, IDC_RITIMID
      .if eax
         INVOKE     GetDlgItemInt, hToolbarDlg, IDC_ESTARTID, 0, 0
         .if !eax
               mov     eax, 1001
         .endif
            mov     bID, eax
            mov     IDOn, 1
      .endif

         mov     eax, BmpCntM
         and     Incr, 0
      .while (Incr < eax)
         .if Incr != 3 && Incr != 8 && Incr != 13
            .if !IDOn
                  mov     ecx, ID
                  mov     edx, dword ptr ToolSet[ecx*4]
               INVOKE     SendMessage, hListbox1, LB_GETTEXT, edx, addr szBuff2
               INVOKE     lstrcpy, addr szBuff1, addr szIDM
               INVOKE     lstrcat, addr szBuff1, addr szBuff2+4

            .else
               INVOKE     wsprintf, addr szBuff1, addr fmat1, bID
            .endif
               inc     ID
               inc     bID
         .else
            INVOKE     lstrcpy, addr szBuff1, addr szSpace
         .endif
         INVOKE     SendMessage, hListbox2, LB_ADDSTRING, 0, addr szBuff1

            mov     ecx, eax
            mov     edx, Incr
            mov     eax, BmpArrayM[edx*4]
         INVOKE     SendMessage, hListbox2, LB_SETITEMDATA, ecx, eax
            inc     Incr
            mov     eax, BmpCntM
      .endw

      INVOKE     SendMessage, hListbox2, LB_SETCURSEL, 10, 0
      INVOKE     SendMessage, hListbox2, LB_SETTOPINDEX, 0, 0
      INVOKE     SendMessage, hListbox2, LB_SETCURSEL, -1, 0

         ret
LoadListbox2 ENDP

;======================================================
; Get structure data
;======================================================
GetData PROC hBitmap:DWORD, ItemID, DelOn
LOCAL    Incr:DWORD, Cnt, IDOn, bID

         and     IDOn, 0
      INVOKE     IsDlgButtonChecked, hToolbarDlg,  IDC_RITIMID
      .if eax
            mov     IDOn, 1
      .endif

       MOVmd     Cnt, ArrayCnt
         and     Incr, 0

      .while (Cnt)
            mov     eax, ToolArray
            add     eax, Incr
         .if !ItemID
               add     eax, tshBitmap
               mov     edx, dword ptr[eax]
               mov     ecx, hBitmap
         .else
               mov     edx, dword ptr[eax]
               mov     ecx, ItemID
         .endif
         .if edx == ecx && edx != 1234
            .if !IDOn
                  mov     eax, ToolArray
                  add     eax, Incr
                  add     eax, tslpName
                  mov     ecx, eax
               INVOKE     lstrcpy, addr szNameA, ecx
            .else
                  mov     eax, ToolArray
                  add     eax, Incr
               INVOKE     wsprintf, addr szNameA, addr fmat1, dword ptr [eax]
            .endif
               mov     eax, ToolArray
               add     eax, Incr
               add     eax, tslpText
               mov     ecx, eax
            INVOKE     lstrcpy, addr szTextA, ecx

               mov     eax, ToolArray
               add     eax, Incr
               add     eax, tslpTip
               mov     ecx, eax
            INVOKE     lstrcpy, addr szTipA, ecx
            .if DelOn
                  mov     eax, ToolArray
                  add     eax, Incr
                  add     eax, tshBitmap
                  mov     dword ptr[eax], 9999
            .endif
            .break
         .endif
            mov     eax, StrSize
            add     Incr, eax
            dec     Cnt
      .endw

         ret
GetData ENDP

;======================================================
; Reset Listbox2
;======================================================
ResetListbox2 PROC
LOCAL    Incr:DWORD, Cnt, hBitmap

      INVOKE     SendMessage, hListbox2, LB_GETCOUNT, 0, 0
         mov     Cnt, eax
         and     Incr, 0
      .while (Cnt)
         INVOKE     SendMessage, hListbox2, LB_GETITEMDATA, Incr, 0
            mov     hBitmap, eax
         INVOKE     GetData, hBitmap, 0, 0
         INVOKE     SendMessage, hListbox2, LB_DELETESTRING, Incr, 0
         INVOKE     SendMessage, hListbox2, LB_INSERTSTRING, Incr, addr szNameA
         INVOKE     SendMessage, hListbox2, LB_SETITEMDATA, Incr, hBitmap
            inc     Incr
            dec     Cnt
      .endw

         ret
ResetListbox2 ENDP

;======================================================
; Load Imagelist
;======================================================
LoadImageList PROC hList:DWORD, Code
LOCAL    Incr:DWORD, Cnt

      INVOKE     SendMessage, hList, LB_GETCOUNT, 0, 0
         mov     Cnt, eax
         and     Incr, 0
      .while (Cnt)
         INVOKE     SendMessage, hList, LB_GETITEMDATA, Incr, 0
mov     ecx, hList
.if ecx != hListboxG
mov     ecx, Incr
mov     eax, TBmpArray[ecx*4]
.else
mov     ecx, Incr
mov     eax, TBmpArrayG[ecx*4]
.endif
         INVOKE     ChgBmpColor, eax, 1
            mov     hBmp, eax
            mov     eax, hList
         .if !Code && eax != hListboxG
            INVOKE     ImageList_Add, hImageList, hBmp, 0
            INVOKE     ImageList_Add, hImageListM, hBmp, 0
         .elseif !Code
            INVOKE     ImageList_Add, hImageListG, hBmp, 0
         .endif
;         INVOKE     ChgBmpColor, hBmp, 0
;mov     hBmp, eax
            inc     Incr
            dec     Cnt
      .endw

         ret
LoadImageList ENDP

;======================================================
; Set default listbox selections PROCEDURE
;======================================================
SetCheck PROC
LOCAL    Incr:DWORD, Cnt

      INVOKE     SendMessage, hChk09, BM_SETCHECK, BST_CHECKED, 0
      INVOKE     SendMessage, hChk10, BM_SETCHECK, BST_UNCHECKED, 0

      INVOKE     SendMessage, hListbox3, LB_GETCOUNT, 0, 0
         mov     Cnt, eax
         and     Incr, 0
      .while (Cnt)
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, Incr
            inc     Incr
            dec     Cnt
      .endw

      INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 6
      INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 7
      INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 8
      INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 12
      INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 15
      INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 24
      INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 29
      INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 32

         ret
SetCheck ENDP

;======================================================
; Set Toolbutton information PROCEDURE
;======================================================
SetInfo PROC
LOCAL    Incr:DWORD, Cnt

         and     Incr, 0
       MOVmd     Cnt, ArrayCnt
      .while (Cnt)
            mov     eax, ToolArray
            add     eax, Incr
            mov     edx, dword ptr[eax]
         .if edx
               add     eax, tsImageID
               mov     ecx, dword ptr[eax]
               mov     tbi.iImage, ecx
            .if NoImage
                  mov     tbi.iImage, 9999
            .endif
               mov     eax, ToolArray
               add     eax, Incr
               add     eax, tslpText
               mov     tbi.pszText, eax
            INVOKE     SendMessage, hWndTool, TB_SETBUTTONINFO, edx, addr tbi  ;edx = BtnID
         .endif
            mov     eax, StrSize
            add     Incr, eax
            dec     Cnt
      .endw

         ret
SetInfo ENDP

;======================================================
; Reset Toolbar PROCEDURE
;======================================================
ResetToolbar PROC

      INVOKE     SendMessage, hWndTool, TB_SETBITMAPSIZE, 0, bSize
      INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, bSize
        call     SetInfo
      INVOKE     SetWindowLong, hWndTool, GWL_EXSTYLE, 0
      INVOKE     SetWindowLong, hWndTool, GWL_STYLE, hToolStyle
        call     SetCheck

         ret
ResetToolbar ENDP

;======================================================
; Get Toolbar Text PROCEDURE
;======================================================
GetText PROC uses ebx esi edi
LOCAL    tbb:TBBUTTON
LOCAL    Incr:DWORD, Cnt, hBitmap

      INVOKE     SendMessage, hWndTool, TB_GETBUTTON, SelList2, addr tbb
;         mov     hBitmap, eax
      .if tbb.idCommand
;            mov     esi, ToolArray                ; Structure memory address
            mov     ecx, StrSize                  ; Size of the structure
            and     Incr, 0
          MOVmd     Cnt, ArrayCnt
         .while (Cnt)
               mov     eax, ToolArray
               add     eax, Incr
               mov     edx, dword ptr[eax]
            .if edx == tbb.idCommand
                  mov     eax, ToolArray
                  add     eax, Incr
                  add     eax, tslpTip
                  mov     edx, eax
                  and     EditOn, 0
               INVOKE     SendMessage, hEdit02, WM_SETTEXT, 0, edx
                  mov     eax, ToolArray
                  add     eax, Incr
                  add     eax, tslpText
                  mov     edx, eax
               INVOKE     SendMessage, hEdit01, WM_SETTEXT, 0, edx
                  mov     EditOn, 1
               .break
            .endif
               add     Incr, ecx
               dec     Cnt
         .endw
      .else
         INVOKE     SendMessage, hEdit01, WM_SETTEXT, 0, addr szNull
         INVOKE     SendMessage, hEdit02, WM_SETTEXT, 0, addr szNull
      .endif

         ret
GetText ENDP

;======================================================
; Edit or Add Toolbar Text PROCEDURE
;======================================================
EditAText PROC uses ebx esi edi
LOCAL    tbb:TBBUTTON
LOCAL    Incr:DWORD, Cnt
LOCAL    szBuff1[256]:BYTE, szBuff2[256]:BYTE

      INVOKE     SendMessage, hWndTool, TB_GETBUTTON, SelList2, addr tbb
      .if tbb.idCommand
            mov     esi, ToolArray                ; Structure memory address
            mov     ecx, StrSize                  ; Size of the structure
            and     Incr, 0
          MOVmd     Cnt, ArrayCnt
         .while (Cnt)
               mov     eax, ToolArray
               add     eax, Incr
               mov     edx, dword ptr[eax]
            .if edx == tbb.idCommand
               INVOKE     SendMessage, hEdit01, WM_GETTEXT, sizeof szBuff1, addr szBuff1
               INVOKE     SendMessage, hEdit02, WM_GETTEXT, sizeof szBuff2, addr szBuff2
                  mov     eax, ToolArray
                  add     eax, Incr
                  add     eax, tslpText
                  mov     edx, eax
               INVOKE     lstrcpy, edx, addr szBuff1
                  mov     eax, ToolArray
                  add     eax, Incr
                  add     eax, tslpTip
                  mov     edx, eax
               INVOKE     lstrcpy, edx, addr szBuff2

                  lea     eax, szBuff1
                  mov     tbi.pszText, eax
                  mov     eax, ToolArray
                  add     eax, Incr
                  mov     edx, dword ptr[eax]
                  add     eax, tsImageID
                  mov     ecx, dword ptr[eax]
                  mov     tbi.iImage, ecx
               INVOKE     SendMessage, hWndTool, TB_SETBUTTONINFO, edx, addr tbi
               .break
            .endif
               add     Incr, ecx
               dec     Cnt
         .endw
      .endif

         ret
EditAText ENDP

;======================================================
; esi = input string pointer ecx = len get before call
; returns string converted to lower case
;======================================================
LowerCase PROC

         xor     eax, eax
      .while ecx
         .if byte ptr[esi+eax] >= 'A' && byte ptr[esi+eax] <= 'Z'
;               and     byte ptr[esi+eax], 0dfh  ; and off lower case bit
               add     byte ptr[esi+eax], 20h   ; add 20h to upper case bit
         .endif
            inc     eax
            dec     ecx
      .endw
         ret

LowerCase ENDP

;======================================================
; Create Floating Toolbar PROCEDURE
;======================================================
FloatToolbar PROC
LOCAL    rect:RECT
LOCAL    tbb:TBBUTTON

      .if hWndFloat
         INVOKE     DestroyWindow, hWndToolF
         INVOKE     DestroyWindow, hWndFloat
            and     ToolH, 0
      .endif

      INVOKE     CreateWindowEx, WS_EX_TOOLWINDOW or WS_EX_WINDOWEDGE, addr FloatTBClass,
                 0, WS_POPUP or\
                 WS_VISIBLE or WS_THICKFRAME, 0, 0, 0, 0,\
                 hWnd, NULL, hInst, NULL
         mov     hWndFloat, eax

; or TBSTYLE_FLAT or CCS_ADJUSTABLE
      INVOKE     CreateWindowEx, 0, addr ToolClass, 0,
                 WS_CHILD or WS_VISIBLE or TBSTYLE_TOOLTIPS or CCS_NOPARENTALIGN or\
                 CCS_NORESIZE or TBSTYLE_FLAT or TBSTYLE_WRAPABLE or CCS_NODIVIDER,\
                 0, 0, 0, 0, hWndFloat, 0, hInst, 0
         mov     hWndToolF, eax

      INVOKE     SendMessage, hWndToolF, TB_BUTTONSTRUCTSIZE, sizeof TBBUTTON, 0
      INVOKE     SendMessage, hWndToolF, TB_SETIMAGELIST, 0, hImageListM

;---------- [Size the Bitmap and Button] ----------
; loword = Width
; hiword = Height
         mov     eax, 00100010h
      INVOKE     SendMessage, hWndToolF, TB_SETBITMAPSIZE, 0, eax
         mov     eax, 00160017h
      INVOKE     SendMessage, hWndToolF, TB_SETBUTTONSIZE, 0, eax

;---------- [Create the Toolbar structures] ----------
      TBButt     hWndToolF, 0, 1001, 4, 0
      TBButt     hWndToolF, 1, 1002, 4, 0
      TBButt     hWndToolF, 2, 1003, 4, 0
      TBButt     hWndToolF, 4, 1004, 4, 0
      TBButt     hWndToolF, 5, 1005, 4, 0
      TBButt     hWndToolF, 6, 1006, 4, 0
      TBButt     hWndToolF, 7, 1007, 4, 0
      TBButt     hWndToolF, 10,1008, 4, 0
      TBButt     hWndToolF, 11,1009, 4, 0
      TBButt     hWndToolF, 12,1010, 4, 0
      TBButt     hWndToolF, 13,1011, 4, 0
      TBButt     hWndToolF, 15,1012, 4, 0

        call     SetSize

         ret
FloatToolbar ENDP

;======================================================
; Create Floating Toolbar PROCEDURE
;======================================================
DockToolbar PROC
LOCAL    rect:RECT
LOCAL    tbb:TBBUTTON

      .if hWndDock
         INVOKE     DestroyWindow, hWndDock
            and     DockH, 0
      .endif

      INVOKE     CreateWindowEx, WS_EX_TOOLWINDOW, addr FloatTBClass,
                 0, WS_POPUPWINDOW or WS_CAPTION or\
                 WS_VISIBLE or WS_THICKFRAME, 0, 0, 0, 0,\
                 hWnd, NULL, hInst, NULL
         mov     hWndDock, eax
        call     SetSize
      INVOKE     SetParent, hWndTool, hWndDock

         ret
DockToolbar ENDP

;======================================================
; Create Toolbar PROCEDURE
;======================================================
ToolBarDlg PROC uses ebx esi edi hdlg:DWORD, wmsg, wparam, lparam
LOCAL    pt:POINT
LOCAL    rect:RECT
LOCAL    tbb:TBBUTTON
LOCAL    tbab:TBADDBITMAP
LOCAL    cm:COLORMAP
LOCAL    FindData:WIN32_FIND_DATA
LOCAL    tm:TEXTMETRIC
LOCAL    hBrush:DWORD, ID, Cnt, Len, Index, Ypos, hFind, hMemDC
LOCAL    Incr:DWORD, hList, hStyle, hBitmap, SavSel, SavState
LOCAL    szBuff[256]:BYTE, szBuff1[64]:BYTE, szBuff2[32]:BYTE

      .if wmsg == WM_INITDIALOG

         INVOKE     CreatePopupMenu
            mov     hSMenu3, eax
            mov     mii.fType, MFT_STRING
            mov     mii.wID, IDM_DIALOG
;           push     hSMenu3
;            pop     mii.hSubMenu
            mov     mii.hSubMenu, 0
            mov     mii.dwItemData, 8040
            mov     eax, offset szMenu1
            mov     mii.dwTypeData, eax
         INVOKE     InsertMenuItem, hMenu, 2, TRUE, addr mii   ; Adds new menu
         INVOKE     DrawMenuBar, hWnd

            mov     ButtW, 23
            mov     ButtH, 24 ;22
            and     hData, 0
            and     EditOn, 0
            mov     UpdateOn, 1
            mov     StartID, 1001
         INVOKE     GetDlgItem, hdlg, IDC_STATIC01
            mov     hStat01, eax
         INVOKE     GetDlgItem, hdlg, IDC_STATIC03
            mov     ecx, eax
         INVOKE     SendMessage, ecx, WM_SETFONT, hFontD, TRUE

      INVOKE     CreateWindowEx, 0, addr ListboxClass, 0,\
                 WS_CHILD or WS_BORDER or WS_VSCROLL or\
                 LBS_HASSTRINGS or LBS_NOINTEGRALHEIGHT or LBS_NOTIFY or LBS_SORT,\
                 100, 100, 100, 100, hdlg, 89, hInst, 0
         mov     hListboxG, eax

            and     Len, 0
            mov     Incr, 2001
            mov     Cnt, 32
         .while (Cnt)
            INVOKE     GetDlgItem, hdlg, Incr
               mov     ecx, Len
               mov     hListbox1[ecx*4], eax
               mov     ecx, eax
            .if Incr != 2028 && Incr != 2029 && Incr != 2030
               INVOKE     SendMessage, ecx, WM_SETFONT, hFontD, TRUE
            .endif
               inc     Len
               inc     Incr
               dec     Cnt
         .endw

         INVOKE     SendMessage, hComb01, CB_SETITEMHEIGHT, -1, 13       ; Selection field
         INVOKE     SendMessage, hComb01, CB_SETITEMHEIGHT, 0, 11        ; List items
         INVOKE     SendMessage, hComb01, CB_RESETCONTENT, 0, 0
         INVOKE     SendMessage, hComb02, CB_SETITEMHEIGHT, -1, 13       ; Selection field
         INVOKE     SendMessage, hComb02, CB_SETITEMHEIGHT, 0, 11        ; List items
         INVOKE     SendMessage, hComb02, CB_RESETCONTENT, 0, 0
         INVOKE     SendMessage, hListbox3, LB_SETITEMHEIGHT, 0, 11        ; List items

;---------- [Fill the State Combobox] ----------
            mov     Incr, 0
            mov     Cnt, 6
         .while (Cnt)
               mov     eax, Incr
               mov     ecx, StateArray[eax*4]
            INVOKE     lstrcpy, addr szBuff1, ecx
            INVOKE     lstrcpyn, addr szBuff2, addr szBuff1+20, 9
            INVOKE     AsciiBase, addr szBuff2, 16
               mov     Styles, eax
            INVOKE     lstrcpyn, addr szBuff1, addr szBuff1, 14
            INVOKE     SendMessage, hComb01, CB_ADDSTRING, 0, addr szBuff1
               mov     ecx, eax
            INVOKE     SendMessage, hComb01, CB_SETITEMDATA, ecx, Styles
               inc     Incr
               dec     Cnt
         .endw
         INVOKE     SendMessage, hComb01, CB_SETCURSEL, 2, 0

;---------- [Fill the Style Combobox] ----------
            mov     Incr, 0
            mov     Cnt, 8
         .while (Cnt)
               mov     eax, Incr
               mov     ecx, StyleArray[eax*4]
            INVOKE     lstrcpy, addr szBuff1, ecx
            INVOKE     lstrcpyn, addr szBuff2, addr szBuff1+20, 9
            INVOKE     AsciiBase, addr szBuff2, 16
               mov     Styles, eax
            INVOKE     lstrcpyn, addr szBuff1, addr szBuff1, 14
            INVOKE     SendMessage, hComb02, CB_ADDSTRING, 0, addr szBuff1
               mov     ecx, eax
            INVOKE     SendMessage, hComb02, CB_SETITEMDATA, ecx, Styles
               inc     Incr
               dec     Cnt
         .endw
         INVOKE     SendMessage, hComb02, CB_SETCURSEL, 0, 0

            and     Len, 0
            mov     Incr, 7001
            mov     Cnt, 11
         .while (Cnt)
            INVOKE     GetDlgItem, hdlg, Incr
               mov     ecx, eax
            .if Incr != 7001 && Incr != 7002 && Incr != 7004 && Incr != 7007
               INVOKE     SendMessage, ecx, WM_SETFONT, hFontD, TRUE
            .endif
               inc     Incr
               dec     Cnt
         .endw

            lea     eax, offset szDividerE
            mov     Index, eax
            mov     Cnt, 37
         .while (Cnt)
               mov     ecx, Index
            INVOKE     lstrcpy, addr szBuff1, ecx
            .if byte ptr szBuff1+2 != '*'
               INVOKE     lstrcpyn, addr szBuff2, addr szBuff1+26, 9
               INVOKE     AsciiBase, addr szBuff2, 16
                  mov     Styles, eax
                  xor     eax, eax
                  mov     ecx, 26
               .while (ecx)
                  .if byte ptr szBuff1[eax] == ' '
                        mov     byte ptr szBuff1[eax], 0
                     .break
                  .endif
                     inc     eax
                     dec     ecx
               .endw

            .else
               INVOKE     lstrcpyn, addr szBuff2, addr szBuff2, 26
                  mov     Styles, 1234
            .endif
            INVOKE     SendMessage, hListbox3, LB_ADDSTRING, 0, addr szBuff1
               mov     ecx, eax
            INVOKE     SendMessage, hListbox3, LB_SETITEMDATA, ecx, Styles
               add     Index, 36
               dec     Cnt
         .endw

         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 6
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 7
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 8
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 12
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 15
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 24
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 29
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 32


         INVOKE     SendMessage, hEdit01, EM_LIMITTEXT, 31, 0 ; Limit text size
         INVOKE     SendMessage, hEdit02, EM_LIMITTEXT, 63, 0
         INVOKE     SendMessage, hEdit03, EM_LIMITTEXT, 31, 0
         INVOKE     SendMessage, hRad02, BM_SETCHECK, BST_CHECKED, 0
           call     SetCheck

         INVOKE     EnableWindow, hButt01, 0
         INVOKE     EnableWindow, hButt02, 0
         INVOKE     EnableWindow, hButt03, 0
         INVOKE     EnableWindow, hButt04, 0
         INVOKE     EnableWindow, hButt05, 0
         INVOKE     EnableWindow, hEdit01, 0
         INVOKE     EnableWindow, hEdit02, 0
         INVOKE     EnableWindow, hEdit03, 0
         INVOKE     EnableWindow, hComb01, 0
         INVOKE     EnableWindow, hComb02, 0
         INVOKE     SetDlgItemInt, hdlg, IDC_ESTARTID, StartID, 0
         INVOKE     SetDlgItemInt, hdlg, IDC_ECHANGEW, 23, 0
         INVOKE     SetDlgItemInt, hdlg, IDC_ECHANGEH, 24, 0
         INVOKE     SendMessage, hComb01, CB_SETCURSEL, -1, 0
         INVOKE     SendMessage, hComb02, CB_SETCURSEL, -1, 0

         .if !BmpCnt
            INVOKE     SendMessage, hListbox1, LB_ADDSTRING, 0, addr szSpace
            INVOKE     SendMessage, hListbox1, LB_SETITEMDATA, 0, 1234
            INVOKE     SendMessage, hListboxG, LB_ADDSTRING, 0, addr szSpace
            INVOKE     SendMessage, hListboxG, LB_SETITEMDATA, 0, 1234
         .endif

         INVOKE     ImageList_Create, 16, 16, ILC_COLOR32, 36, 32
            mov     hImageListM, eax
         INVOKE     ImageList_Create, 16, 16, ILC_COLOR32, 36, 32
            mov     hImageListG, eax
and     TBmpCnt, 0
and     TBmpCntG, 0

;---------- [Set the Font and the line height of the Listbox] ----------
         INVOKE     SendMessage, hListbox1, WM_SETFONT, hFontL, 1
         INVOKE     SendMessage, hListbox2, WM_SETFONT, hFontL, 1

;---------- [Get the current dir and load the Listbox with its files] ----------
         INVOKE     GetCurrentDirectory, lengthof szRoot, addr szRoot
         INVOKE     lstrcat, addr szRoot, addr szSlashB
         INVOKE     lstrcpy, addr szBuff, addr szRoot

         INVOKE     lstrcat, addr szBuff, addr szResr2
         INVOKE     lstrcat, addr szBuff, addr szSlashB
         INVOKE     lstrcat, addr szBuff, addr szAll
         INVOKE     FindFirstFile, addr szBuff, addr FindData
           test     eax, eax
             js     NoFile
            mov     hFind, eax
            jmp     Addem

Getem:
         INVOKE     FindNextFile, hFind, addr FindData
           test     eax, eax
             jz     AllDone

Addem:
         .if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||\
             (FindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ||\
             (FindData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ||\
             byte ptr FindData.cFileName != 'B' && byte ptr FindData.cFileName != 'S' &&\
             byte ptr FindData.cFileName != 'G'
               jmp     Getem
         .endif
         INVOKE     lstrlen, addr FindData.cFileName
            sub     eax, 3
         INVOKE     lstrcpyn, addr szBuff, addr FindData.cFileName, eax
         .if byte ptr FindData.cFileName != 'G'
            INVOKE     SendMessage, hListbox1, LB_ADDSTRING, 0, addr szBuff ;FindData.cFileName
         .else
            INVOKE     SendMessage, hListboxG, LB_ADDSTRING, 0, addr szBuff ;FindData.cFileName
         .endif
           push     eax
         INVOKE     LoadBitmaps, addr FindData.cFileName, 0
            pop     ecx
         .if byte ptr FindData.cFileName != 'G'
            INVOKE     SendMessage, hListbox1, LB_SETITEMDATA, ecx, eax

         INVOKE     LoadBitmaps, addr FindData.cFileName, 1
mov     ecx, TBmpCnt
mov     TBmpArray[ecx*4], eax
inc     TBmpCnt

         .else
            INVOKE     SendMessage, hListboxG, LB_SETITEMDATA, ecx, eax

         INVOKE     LoadBitmaps, addr FindData.cFileName, 1
mov     ecx, TBmpCntG
mov     TBmpArrayG[ecx*4], eax
inc     TBmpCntG

         .endif
            jmp     Getem

AllDone:
         INVOKE     FindClose, hFind
         INVOKE     SendMessage, hListbox1, LB_SETCURSEL, 10, 0
         INVOKE     SendMessage, hListbox1, LB_SETTOPINDEX, 0, 0
         INVOKE     SendMessage, hListbox1, LB_SETCURSEL, -1, 0

         INVOKE     LoadImageList, hListbox1, 0
         INVOKE     LoadImageList, hListboxG, 0

         INVOKE     SendMessage, hWndTool, TB_SETIMAGELIST, 0, hImageListM
         INVOKE     SendMessage, hWndTool, TB_BUTTONCOUNT, 0, 0
            mov     Cnt, eax
            mov     Incr, eax
            dec     Incr
         .while (Cnt)
            INVOKE     SendMessage, hWndTool, TB_DELETEBUTTON, Incr, 0
               dec     Incr
               dec     Cnt
         .endw

         TBButt     hWndTool, 0, 1001, 4, 0 ;1001
         TBButt     hWndTool, 1, 1002, 4, 0 ;1002
         TBButt     hWndTool, 2, 1003, 4, 0 ;1003
          TBSep     hWndTool
         TBButt     hWndTool, 4, 1004, 4, 0 ;1005
         TBButt     hWndTool, 5, 1005, 4, 0 ;1006
         TBButt     hWndTool, 6, 1006, 4, 0 ;1007
         TBButt     hWndTool, 7, 1007, 4, 0 ;1008
          TBSep     hWndTool
         TBButt     hWndTool, 10,1008, 4, 0 ;1011
         TBButt     hWndTool, 11,1009, 4, 0 ;1012
         TBButt     hWndTool, 12,1010, 4, 0 ;1013
         TBButt     hWndTool, 13,1011, 4, 0 ;1014
          TBSep     hWndTool
         TBButt     hWndTool, 15,1012, 4, 0 ;1016
            mov     ImageID, 1

NoFile:
;---------- [Reload the master Bitmap array in sequence] ---------
         INVOKE     SendMessage, hListbox1, LB_GETCOUNT, 0, 0
            mov     Cnt, eax
            and     BmpCnt, 0
         .while (Cnt)
               mov     eax, BmpCnt
            INVOKE     SendMessage, hListbox1, LB_GETITEMDATA, eax, 0
               mov     ecx, BmpCnt
               mov     BmpArray[ecx*4], eax
               inc     BmpCnt
               dec     Cnt
         .endw

;---------- [Load the Toolbar Bitmap array] ---------
            and     BmpCntM, 0
            and     ID, 0
            mov     Cnt, 12           ; Number of bitmaps
         .while (Cnt)
               mov     ecx, ID
              imul     ecx, 4
               mov     eax, dword ptr ToolSet[ecx]
            INVOKE     SendMessage, hListbox1, LB_GETITEMDATA, eax, 0
               mov     ecx, BmpCntM
               mov     BmpArrayM[ecx*4], eax
               inc     BmpCntM
            .if BmpCntM == 3 || BmpCntM == 8 || BmpCntM == 13
                  mov     ecx, BmpCntM
                  mov     BmpArrayM[ecx*4], 1234  ; Seperator code
                  inc     BmpCntM
            .endif
               dec     Cnt
               inc     ID
         .endw

           call     LoadListbox2

;---------- [Load the ToolStructure into memory] ----------
            and     ArrayCnt, 0
            mov     ButtID, 1001
            and     Incr, 0
            lea     ecx, offset ts
            mov     eax, sizeof ts
            mov     StrSize, eax
            mov     StrAddr, ecx

         .while (ArrayCnt < 12)
             MOVmd     ts.ID, ButtID
               mov     eax, Incr
               mov     ecx, dword ptr ToolSet[eax*4]
               dec     ecx
               mov     ts.ImageID, ecx
inc     ecx
            INVOKE     SendMessage, hListbox1, LB_GETITEMDATA, ecx, 0
               mov     ts.hBitmap, eax

               mov     ecx, ts.ImageID
inc     ecx
            INVOKE     SendMessage, hListbox1, LB_GETTEXT, ecx, addr szBuff2
            INVOKE     lstrcpy, addr szBuff1, addr szIDM
               mov     ecx, 4
            .if byte ptr szBuff2 == 'S'
                  mov     ecx, 7
            .endif
            INVOKE     lstrcat, addr szBuff1, addr szBuff2[ecx]
            INVOKE     lstrcpy, addr ts.lpName, addr szBuff1
               mov     eax, Incr
            INVOKE     lstrcpy, addr ts.lpText, szText[eax*4]
               mov     eax, Incr
            INVOKE     lstrcpy, addr ts.lpTip, szTip[eax*4]
               mov     ts.fsState, 4                 ; Set state to normal
               mov     esi, StrAddr                  ; Address of the structure
               mov     ecx, StrSize                  ; Size of the structure
               mov     edi, ToolArray                ; Structure memory address
               mov     eax, ArrayCnt
              imul     eax, ecx
               add     edi, eax                      ; Offset the number of structures
               rep     movsb                         ; Load the structure
               inc     ArrayCnt
               inc     ButtID
               inc     Incr
         .endw

;---------- [Backup the array] ----------
            mov     ecx, StrSize
           imul     ecx, ArrayCnt
            mov     esi, ToolArray
            mov     edi, ToolArrayM
            rep     movsb

            inc     ArrayCnt

         INVOKE     SetFocus, hStat01

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

      .elseif wmsg == WM_CTLCOLORLISTBOX || wmsg == WM_CTLCOLOREDIT
         INVOKE     SetBkColor, wparam, 00000000h
         INVOKE     SetTextColor, wparam, 00ffff00h
         INVOKE     GetStockObject, BLACK_BRUSH
            ret

      .elseif wmsg == WM_DRAWITEM
         .if wparam == 2001 || wparam == 2002
               mov     esi, lparam
               lea     edi, dis
               mov     ecx, sizeof dis
               rep     movsb
            .if dis.itemID != -1
               .if wparam == 2001
                    push     hListbox1
               .else
                    push     hListbox2
               .endif
                  pop     hList
               INVOKE     SendMessage, hList, LB_GETTEXT, dis.itemID, addr szBuff
                  mov     Len, eax
               INVOKE     SendMessage, hList, LB_GETITEMDATA, dis.itemID, 0
                  mov     hBmp, eax
               .if eax == 1234
                  INVOKE     lstrcpy, addr szBuff, addr szSep
                  INVOKE     lstrlen, addr szBuff
                     mov     Len, eax
               .endif
               INVOKE     GetTextMetrics, dis.hdc, addr tm
                  mov     eax, dis.rcItem.bottom
                  add     eax, dis.rcItem.top
                  sub     eax, tm.tmHeight
                  shr     eax, 1
                  mov     Ypos, eax

               .if (dis.itemState & ODS_SELECTED)
                  INVOKE     CreateSolidBrush, 00800000h      ; Highlight background color
                     mov     hBrush, eax
                  INVOKE     FillRect, dis.hdc, addr dis.rcItem, eax
                  INVOKE     SetTextColor, dis.hdc, 00ffffffh ; Highlight text color
                  INVOKE     SetBkColor, dis.hdc, 00800000h   ; Highlight text background color
               .else
                  INVOKE     CreateSolidBrush, 00ffffffh      ; Background color
                     mov     hBrush, eax
                  INVOKE     FillRect, dis.hdc, addr dis.rcItem, eax
                  INVOKE     SetTextColor, dis.hdc, 00ff0000h ; Text color - dis.itemData
                  INVOKE     SetBkColor, dis.hdc, 00ffffffh   ; Text background color
               .endif
                  add     dis.rcItem.left, 20
               INVOKE     TextOut, dis.hdc, dis.rcItem.left, Ypos, addr szBuff, Len
                  sub     dis.rcItem.left, 19
                  mov     dis.rcItem.right, 17
               INVOKE     DeleteObject, hBrush

               .if hBmp != 1234
                  INVOKE     CreateCompatibleDC, dis.hdc      ; Create a compatible dc in memory
                     mov     hMemDC, eax
                  INVOKE     SelectObject, hMemDC, hBmp       ; Select the opened bitmap into the dc
                  INVOKE     BitBlt, dis.hdc, 0, dis.rcItem.top, 16, 16, hMemDC, 0, 0, SRCCOPY ;Copy the bitmap
                  INVOKE     DeleteDC, hMemDC                 ; Delete the memory dc
;                  INVOKE     ReleaseDC, hButt, dis.hdc        ; Release the control dc
               .endif

            .endif
               mov     dis.itemState, ODS_DEFAULT
               mov     dis.hdc, 0
         .endif

      .elseif wmsg == WM_COMMAND
         .if wparam == IDCANCEL
               jmp     CloseIt
         .endif
            mov     eax, wparam
            shr     eax, 16
            mov     ebx, wparam
            and     ebx, 0ffffh
            mov     wparam, ebx

;---------- [Extract the selected item] ----------
         .if eax == LBN_SELCHANGE
            INVOKE     SendMessage, lparam, LB_GETCURSEL, 0, 0
            .if eax == LB_ERR
                  jmp     DlgDone
            .endif
               mov     ecx, eax
               mov     eax, lparam

;---------- [Available buttons change] ----------
            .if eax == hListbox1
                  mov     SelList1, ecx
                  and     EditOn, 0
                  and     hData, 0
                  and     CmdID, 0
               INVOKE     SendMessage, hWndTool, TB_BUTTONCOUNT, 0, 0
               .if eax
                  INVOKE     EnableWindow, hButt01, 1
               .endif
               INVOKE     EnableWindow, hButt02, 1
               INVOKE     EnableWindow, hButt03, 0
               INVOKE     EnableWindow, hButt04, 0
               INVOKE     EnableWindow, hButt05, 0
               INVOKE     EnableWindow, hEdit01, 0
               INVOKE     EnableWindow, hEdit02, 0
               INVOKE     EnableWindow, hEdit03, 0
               INVOKE     EnableWindow, hComb01, 0
               INVOKE     EnableWindow, hComb02, 0
               INVOKE     SendMessage, hEdit01, WM_SETTEXT, 0, addr szNull
               INVOKE     SendMessage, hEdit02, WM_SETTEXT, 0, addr szNull
               INVOKE     SendMessage, hEdit03, WM_SETTEXT, 0, addr szNull
               INVOKE     SendMessage, hComb01, CB_SETCURSEL, -1, 0
               INVOKE     SendMessage, hComb02, CB_SETCURSEL, -1, 0

               INVOKE     SendMessage, hListbox2, LB_GETCURSEL, 0, 0
               .if eax != LB_ERR
                  INVOKE     SetDrawList, hdlg, hListbox2, eax, 2002, 1
                  INVOKE     RedrawWindow, hListbox1, 0, 0,\
                             RDW_ERASE or RDW_INVALIDATE or RDW_UPDATENOW
               .endif

;---------- [Current buttons change] ----------
            .elseif eax == hListbox2
                  mov     SelList2, ecx
                  and     CmdID, 0
               INVOKE     EnableWindow, hButt01, 0
               INVOKE     EnableWindow, hButt02, 0
               INVOKE     EnableWindow, hButt03, 1
               INVOKE     EnableWindow, hButt04, 1
               INVOKE     EnableWindow, hButt05, 1
               INVOKE     SendMessage, hListbox2, LB_GETTEXT, SelList2, addr szBuff
               INVOKE     SendMessage, hListbox2, LB_GETITEMDATA, SelList2, 0
               .if eax != 1234
                  INVOKE     EnableWindow, hEdit01, 1
                  INVOKE     EnableWindow, hEdit02, 1
                  INVOKE     EnableWindow, hEdit03, 1
                  INVOKE     EnableWindow, hComb01, 1
                  INVOKE     EnableWindow, hComb02, 1
                  INVOKE     SendMessage, hEdit03, WM_SETTEXT, 0, addr szBuff
                  INVOKE     SendMessage, hWndTool, TB_GETBUTTON, SelList2, addr tbb
                     mov     ecx, 2
                     mov     al, tbb.fsState
                  .if al == TBSTATE_CHECKED || al == TBSTATE_CHECKED or TBSTATE_ENABLED
                        mov     ecx, 0
                  .elseif al == TBSTATE_PRESSED || al == TBSTATE_PRESSED or TBSTATE_ENABLED
                        mov     ecx, 1
                  .elseif al == TBSTATE_ENABLED
                        mov     ecx, 2
                  .elseif al == TBSTATE_HIDDEN
                        mov     ecx, 3
                  .elseif al == TBSTATE_INDETERMINATE
                        mov     ecx, 4
                  .elseif al == TBSTATE_WRAP || al == TBSTATE_WRAP or TBSTATE_ENABLED
                        mov     ecx, 5
                  .endif
                  INVOKE     SendMessage, hComb01, CB_SETCURSEL, ecx, 0

                     mov     ecx, 0
                     mov     al, tbb.fsStyle
                  .if al == TBSTYLE_BUTTON
                        mov     ecx, 0
                  .elseif al == TBSTYLE_SEP
                        mov     ecx, 1
                  .elseif al == TBSTYLE_CHECK
                        mov     ecx, 2
                  .elseif al == TBSTYLE_GROUP
                        mov     ecx, 3
                  .elseif al == TBSTYLE_CHECKGROUP
                        mov     ecx, 4
                  .elseif al == TBSTYLE_DROPDOWN
                        mov     ecx, 5
                  .elseif al == TBSTYLE_AUTOSIZE
                        mov     ecx, 6
                  .elseif al == TBSTYLE_NOPREFIX
                        mov     ecx, 7
                  .endif
                  INVOKE     SendMessage, hComb02, CB_SETCURSEL, ecx, 0
                     mov     EditOn, 1

               .else
                  INVOKE     EnableWindow, hEdit01, 0
                  INVOKE     EnableWindow, hEdit02, 0
                  INVOKE     EnableWindow, hEdit03, 0
                  INVOKE     EnableWindow, hComb01, 0
                  INVOKE     EnableWindow, hComb02, 0
                  INVOKE     SendMessage, hEdit03, WM_SETTEXT, 0, addr szNull
                  INVOKE     SendMessage, hComb01, CB_SETCURSEL, -1, 0
                  INVOKE     SendMessage, hComb02, CB_SETCURSEL, -1, 0
                     and     EditOn, 0
               .endif
                  and     hData, 0
               INVOKE     SendMessage, hListbox1, LB_GETCURSEL, 0, 0
               .if eax != LB_ERR
                  INVOKE     SetDrawList, hdlg, hListbox1, eax, 2001, 0
                  INVOKE     RedrawWindow, hListbox2, 0, 0,\
                             RDW_ERASE or RDW_INVALIDATE or RDW_UPDATENOW
               .endif
                 call     GetText

;---------- [Button state change] ----------
            .elseif eax == hComb01
               INVOKE     SendMessage, hListbox2, LB_GETITEMDATA, SelList2, 0
                  mov     hBitmap, eax
               INVOKE     SendMessage, hComb01, CB_GETCURSEL, 0, 0
               INVOKE     SendMessage, hComb01, CB_GETITEMDATA, eax, 0
                 push     eax
               INVOKE     SendMessage, hWndTool, TB_GETBUTTON, SelList2, addr tbb
                  pop     eax
               .if eax == TBSTATE_CHECKED || eax == TBSTATE_PRESSED || eax == TBSTATE_WRAP
                      or     eax, TBSTATE_ENABLED
               .endif
                  mov     SavState, eax
               INVOKE     SendMessage, hWndTool, TB_SETSTATE, tbb.idCommand, eax

                MOVmd     Cnt, ArrayCnt
                  and     Incr, 0

               .while (Cnt)
                     mov     eax, ToolArray
                     add     eax, Incr
                     add     eax, tshBitmap
                     mov     edx, dword ptr[eax]
                  .if edx == hBitmap && edx != 1234
                        mov     ecx, ToolArray
                        add     ecx, Incr
                        add     ecx, tsfsState
                        mov     eax, SavState
                        mov     dword ptr[ecx], eax
                     .break
                  .endif
                     mov     eax, StrSize
                     add     Incr, eax
                     dec     Cnt
               .endw

;---------- [Button style change] ----------
            .elseif eax == hComb02
               INVOKE     SendMessage, hListbox2, LB_GETITEMDATA, SelList2, 0
                  mov     hBitmap, eax
               INVOKE     SendMessage, hComb02, CB_GETCURSEL, 0, 0
               INVOKE     SendMessage, hComb02, CB_GETITEMDATA, eax, 0
                 push     eax
               INVOKE     SendMessage, hWndTool, TB_GETBUTTON, SelList2, addr tbb
                  pop     eax
                  mov     SavState, eax

;---------- [Update the Command ID for the toolbar button] ----------
                 push     tbi.dwMask
                  mov     tbi.dwMask, TBIF_STYLE
                  mov     tbi.fsStyle, al
               INVOKE     SendMessage, hWndTool, TB_SETBUTTONINFO, tbb.idCommand, addr tbi  ;edx = BtnID
                  pop     tbi.dwMask

                MOVmd     Cnt, ArrayCnt
                  and     Incr, 0

               .while (Cnt)
                     mov     eax, ToolArray
                     add     eax, Incr
                     add     eax, tshBitmap
                     mov     edx, dword ptr[eax]
                  .if edx == hBitmap && edx != 1234
                        mov     ecx, ToolArray
                        add     ecx, Incr
                        add     ecx, tsfsStyle
                        mov     eax, SavState
                        mov     dword ptr[ecx], eax
                     .break
                  .endif
                     mov     eax, StrSize
                     add     Incr, eax
                     dec     Cnt
               .endw

;---------- [Style change] ----------
            .elseif eax == hListbox3
                  and     UpdateOn, 0
               INVOKE     LockWindowUpdate, hListbox3
               INVOKE     SendMessage, hListbox3, LB_GETTOPINDEX, 0, 0
                  mov     ID, eax
               INVOKE     SendMessage, hListbox3, LB_GETCARETINDEX, 0, 0
                  mov     SavSel, eax
               INVOKE     SendMessage, hListbox3, LB_GETSEL, SavSel, 0
                 push     eax
               .if eax && SavSel == 12
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 14
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 15
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 19
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 20
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 21
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 30
               .elseif eax && SavSel == 13
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 15
               .elseif eax && SavSel == 14
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 12
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 15
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 19
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 20
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 21
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 30
               .elseif eax && SavSel == 15
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 13
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 22
               .elseif eax && SavSel == 19
                  INVOKE     SendMessage, hListbox3, LB_GETSEL, 21, 0
                  .if !eax || eax == LB_ERR
                     INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 20
                  .endif
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 12
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 14
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 15
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 30
               .elseif eax && SavSel == 20
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 12
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 14
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 15
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 19
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 21
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 30
               .elseif eax && SavSel == 21
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 12
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 14
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 15
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 19
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 20
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 30
               .elseif eax && SavSel == 22
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 15
               .endif

               INVOKE     SendMessage, hListbox3, LB_GETSEL, 19, 0
               .if !eax
                  INVOKE     SendMessage, hListbox3, LB_GETSEL, 14, 0
                  .if !eax
                     INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 12
                     INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 14
                     INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 15
                     INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 19
                     INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 20
                     INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 21
                     INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 30
                  .endif
               .else
                  INVOKE     SendMessage, hListbox3, LB_GETSEL, 20, 0
                  .if !eax
                     INVOKE     SendMessage, hListbox3, LB_GETSEL, 21, 0
                     .if !eax
                        INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 12
                        INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 14
                        INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 15
                        INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 19
                        INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 30
                     .endif
                  .endif
               .endif
               INVOKE     SendMessage, hListbox3, LB_GETSEL, 25, 0
               .if eax
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 25
               .endif
               INVOKE     SendMessage, hListbox3, LB_GETSEL, 26, 0
               .if eax
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 26
               .endif
               INVOKE     LockWindowUpdate, 0
               INVOKE     SendMessage, hListbox3, LB_SETTOPINDEX, ID, 0
            INVOKE     RedrawWindow, hListbox3, 0, 0,\
                       RDW_ERASE or RDW_INVALIDATE or RDW_UPDATENOW
                  pop     eax
            .endif

         .elseif eax == EN_CHANGE
            .if wparam == IDC_ETOOLTEXT && EditOn || wparam == IDC_ETOOLTIP && EditOn
                  mov     tbi.dwMask, TBIF_IMAGE or TBIF_TEXT
                 call     EditAText

            .elseif wparam == IDC_EIDNAME && EditOn
               INVOKE     SendMessage, hEdit03, WM_GETTEXT, 256, addr szBuff
               INVOKE     SendMessage, hListbox2, LB_GETITEMDATA, SelList2, 0
                  mov     hBitmap, eax
               INVOKE     SendMessage, hListbox2, LB_DELETESTRING, SelList2, 0
               INVOKE     SendMessage, hListbox2, LB_INSERTSTRING, SelList2, addr szBuff
               INVOKE     SendMessage, hListbox2, LB_SETCURSEL, SelList2, 0
               INVOKE     SendMessage, hListbox2, LB_SETITEMDATA, SelList2, hBitmap

                MOVmd     Cnt, ArrayCnt
                  and     Incr, 0

               .while (Cnt)
                     mov     eax, ToolArray
                     add     eax, Incr
                     add     eax, tshBitmap
                     mov     edx, dword ptr[eax]
                  .if edx == hBitmap && edx != 1234
                     INVOKE     IsDlgButtonChecked, hToolbarDlg,  IDC_RITIMID
                     .if eax
                        INVOKE     GetDlgItemInt, hToolbarDlg, IDC_EIDNAME, 0, 0
                           mov     ecx, ToolArray
                           add     ecx, Incr
                        .if !CmdID
                            MOVmd     CmdID, dword ptr[ecx]
                        .endif
                           mov     dword ptr[ecx], eax

;---------- [Update the Command ID for the toolbar button] ----------
                           mov     ecx, eax
                          push     tbi.dwMask
                           mov     tbi.dwMask, TBIF_COMMAND
                           mov     tbi.idCommand, ecx
                        INVOKE     SendMessage, hWndTool, TB_SETBUTTONINFO, CmdID, addr tbi  ;edx = BtnID
                         MOVmd     CmdID, tbi.idCommand
                           pop     tbi.dwMask

                     .else
                           mov     eax, ToolArray
                           add     eax, Incr
                           add     eax, tslpName
                           mov     ecx, eax
                        INVOKE     lstrcpy, ecx, addr szBuff
                     .endif
                     .break
                  .endif
                     mov     eax, StrSize
                     add     Incr, eax
                     dec     Cnt
               .endw

            .elseif wparam == IDC_EIDNAME
               INVOKE     GetDlgItemInt, hToolbarDlg, IDC_ESTARTID, 0, 0
               .if !eax
                     mov     eax, 1001
               .endif
                  mov     StartID, eax
            .endif

;---------- [IDC_RITIMID and IDC_RNAME = ID or name for listbox] ----------
         .elseif wparam ==  IDC_RITIMID || wparam == IDC_RNAME
               and     hData, 0
            INVOKE     SendMessage, hListbox2, LB_GETCURSEL, 0, 0
               mov     SelList2, eax
              call     ResetListbox2
            .if SelList2 != LB_ERR
               INVOKE     SendMessage, hListbox2, LB_SETCURSEL, SelList2, 0
               INVOKE     SendMessage, hListbox2, LB_GETTEXT, SelList2, addr szBuff
               INVOKE     SendMessage, hEdit03, WM_SETTEXT, 0, addr szBuff
            .endif

;---------- [IDC_CHK01 = text only] ----------
         .elseif wparam == IDC_CHK01
            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK01
            .if eax
               INVOKE     IsWindowEnabled, hButt03
               .if eax
                    call     GetText
               .endif
            .endif
            INVOKE     SetFocus, hStat01
            INVOKE     SendMessage, hdlg, WM_COMMAND, IDC_BSTYLESU, 0

;---------- [IDC_CHK02 = Customizable Toolbar] ----------
         .elseif wparam == IDC_CHK02
            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK02
            .if eax
               INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 17
            .else
               INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 17
            .endif
            INVOKE     SetFocus, hStat01
            INVOKE     SendMessage, hdlg, WM_COMMAND, IDC_BSTYLESU, 0

;---------- [IDC_CHK03 = Explorer Type Toolbar] ----------
         .elseif wparam == IDC_CHK03
            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK03
            .if eax
               INVOKE     SendMessage, hWndTool, TB_SETIMAGELIST, 0, hImageListG
               INVOKE     SendMessage, hWndTool, TB_SETHOTIMAGELIST, 0, hImageListM
            .else
               INVOKE     SendMessage, hWndTool, TB_SETIMAGELIST, 0, hImageListM
               INVOKE     SendMessage, hWndTool, TB_SETHOTIMAGELIST, 0, hImageListM
            .endif
            INVOKE     RedrawWindow, hWndTool, 0, 0,\
                       RDW_ERASE or RDW_INVALIDATE or RDW_UPDATENOW
            INVOKE     SetFocus, hStat01

;---------- [IDC_CHK04 = Floating Toolbar] ----------
         .elseif wparam == IDC_CHK04
            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK04
            .if eax
                 call     FloatToolbar
            .else
               INVOKE     DestroyWindow, hWndToolF
               INVOKE     DestroyWindow, hWndFloat
                  and     ToolW, 0
                  and     ToolH, 0
                  and     hWndToolF, 0
                  and     hWndFloat, 0
            .endif

;---------- [IDC_CHK05 = Dockinging Toolbar] ----------
         .elseif wparam == IDC_CHK05
              call     GetStyles
            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK05
            .if eax
               .if (Styles & WS_BORDER)
                     xor     Styles, WS_BORDER
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 0, 8
               .endif
               INVOKE     SetWindowLong, hWndTool, GWL_STYLE, Styles
                 call     DockToolbar

            .else
               .if !(Styles & WS_BORDER)
                     xor     Styles, WS_BORDER
                  INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 8
               .endif
               INVOKE     SetWindowLong, hWndTool, GWL_STYLE, Styles
               INVOKE     SetParent, hWndTool, hWnd
               INVOKE     DestroyWindow, hWndDock
                  and     hWndDock, 0
                  and     DockH, 0
                 call     SetSize
            .endif

;---------- [IDC_CHK09 = Sample buttons] ----------
         .elseif wparam == IDC_CHK09
            INVOKE     SetFocus, hStat01
            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK09
            .if eax
                  and     Chk10On, 0
                  and     AddOn, 0
               INVOKE     SendMessage, hChk10, BM_SETCHECK, BST_UNCHECKED, 0
               INVOKE     SendMessage, hdlg, WM_COMMAND, IDC_BRESTORE, 0

            .else
               INVOKE     SendMessage, hChk10, BM_SETCHECK, BST_CHECKED, 0
            .endif

;---------- [IDC_CHK10 = Remove buttons] ----------
         .elseif wparam == IDC_CHK10
            INVOKE     SetFocus, hStat01
            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK10
            .if eax
               INVOKE     SendMessage, hChk09, BM_SETCHECK, BST_UNCHECKED, 0
               INVOKE     SendMessage, hListbox2, LB_RESETCONTENT, 0, 0
                  and     ArrayCnt, 0
                  mov     SelList2, 0
                  mov     Chk10On, 1
                  mov     AddOn, 1
               INVOKE     GetDlgItemInt, hToolbarDlg, IDC_ESTARTID, 0, 0
               .if !eax
                     mov     eax, 1001
               .endif
                  mov     ButtID, eax

               INVOKE     SendMessage, hWndTool, TB_BUTTONCOUNT, 0, 0
                  mov     Cnt, eax
                  mov     Incr, eax
                  dec     Incr
               .while (Cnt)
                  INVOKE     SendMessage, hWndTool, TB_DELETEBUTTON, Incr, 0
                     dec     Incr
                     dec     Cnt
               .endw

            .else
               INVOKE     SendMessage, hChk09, BM_SETCHECK, BST_CHECKED, 0
            .endif

;---------- [IDC_BINSERT = insert new button  IDC_BADD = add new button to end] ----------
         .elseif wparam == IDC_BINSERT || wparam == IDC_BADD
               and     AddOn, 0
            .if wparam == IDC_BADD
                  mov     AddOn, 1
            .endif
            INVOKE     SetFocus, hStat01
            INVOKE     SendMessage, hListbox1, LB_GETCURSEL, 0, 0
               mov     SelList1, eax
            INVOKE     SendMessage, hListbox1, LB_GETITEMDATA, eax, 0
              push     eax

            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK10
            .if !eax
               INVOKE     SendMessage, hListbox2, LB_GETCURSEL, 0, 0
               .if eax == LB_ERR
                     pop     eax
                     jmp     DlgDone
               .else
                     mov     SelList2, eax
               .endif
            .else
               INVOKE     SendMessage, hListbox2, LB_GETCURSEL, 0, 0
               .if eax != LB_ERR
                     mov     SelList2, eax
               .endif
            .endif

            INVOKE     IsDlgButtonChecked, hToolbarDlg,  IDC_RITIMID
            .if eax
               INVOKE     SendMessage, hListbox1, LB_GETTEXT, SelList1, addr szBuff2
                  mov     ecx, 4
               .if byte ptr szBuff2 == 'S'
                     mov     ecx, 7
               .endif
               INVOKE     lstrcpyn, addr szTextA, addr szBuff2[ecx], 6
                  mov     ecx, 4
                  lea     esi, szTextA
                 call     LowerCase               ; Convert to lowercase
                  and     byte ptr szTextA, 0dfh  ; and off lower case bit
               INVOKE     wsprintf, addr szBuff1, addr fmat1, ButtID
            .else
               INVOKE     SendMessage, hListbox1, LB_GETTEXT, SelList1, addr szBuff2
               INVOKE     lstrcpy, addr szBuff1, addr szIDM
                  mov     ecx, 4
               .if byte ptr szBuff2 == 'S'
                     mov     ecx, 7
               .endif
                 push     ecx
               INVOKE     lstrcat, addr szBuff1, addr szBuff2[ecx]
                  pop     ecx
               INVOKE     lstrcpyn, addr szTextA, addr szBuff2[ecx], 6
                  mov     ecx, 4
                  lea     esi, szTextA
                 call     LowerCase               ; Convert to lowercase
                  and     byte ptr szTextA, 0dfh  ; and off lower case bit
            .endif

            INVOKE     SendMessage, hWndTool, TB_BUTTONCOUNT, 0, 0
            .if !AddOn
               INVOKE     SendMessage, hListbox2, LB_INSERTSTRING, SelList2, addr szBuff1
            .else
               INVOKE     SendMessage, hListbox2, LB_ADDSTRING, 0, addr szBuff1
                  mov     SelList2, eax
                  mov     eax, 00100010h
               INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, eax
            .endif

               pop     edx
            INVOKE     SendMessage, hListbox2, LB_SETITEMDATA, SelList2, edx
               mov     ecx, SelList2
            .if !AddOn
                  inc     ecx
            .endif
            INVOKE     SendMessage, hListbox2, LB_SETCURSEL, ecx, 0
            INVOKE     SetFocus, hListbox1
               mov     eax, SelList1
               dec     eax

AddTool:
            .if Chk10On
                  lea     ebx, szTextA
            .else
                  xor     ebx, ebx
            .endif
               mov     edx, TBSTYLE_BUTTON
            .if SelList1 == 9999
                  lea     ebx, szTextA
                  mov     ecx, tbb.idCommand
            .elseif SelList1
                  mov     ecx, ButtID
                  inc     ButtID
            .endif

            .if !(Styles & TBSTYLE_LIST)
                  xor     ebx, ebx
            .endif

            .if !SelList1
                  xor     eax, eax
                  xor     ecx, ecx
                  mov     edx, TBSTYLE_SEP
            .endif
               mov     tbb.iBitmap, eax           ; Button image number
               mov     tbb.idCommand, ecx         ; Command ID number
.if SelList1 != 9999
               mov     tbb.fsState, TBSTATE_ENABLED
.endif
               mov     tbb.fsStyle, dl
               mov     tbb.dwData, 0
               mov     tbb.iString, ebx           ; Text string
              push     eax
              push     ecx
            INVOKE     SendMessage, hWndTool, TB_GETITEMRECT, 0, addr rect
            INVOKE     SendMessage, hWndTool, TB_INSERTBUTTON, SelList2, addr tbb

;            .if !(Styles & TBSTYLE_LIST)
;                  mov     ecx, ButtH ;rect.bottom
;               .if !(Styles & TBSTYLE_FLAT)
;                     sub     ecx, 2
;               .endif
;                  shl     ecx, 16
;                  mov     eax, ButtW ;rect.right
;               .if eax > 100
;                     mov     eax, 23
;               .endif
;                  mov     cx, ax
;               INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, ecx
;            .endif

               mov     ecx, ButtH
;            .if !(Styles & TBSTYLE_FLAT)
                  sub     ecx, 2
;            .endif
               shl     ecx, 16
               mov     cx, word ptr ButtW
            INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, ecx

;---------- [Text only] ----------
            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK01 ; Text only
            .if eax
                  lea     ebx, szTextA
                  pop     ecx
                 push     ecx
                  mov     tbi.dwMask, TBIF_IMAGE or TBIF_TEXT
                  mov     tbi.iImage, 9999
                  mov     tbi.pszText, ebx
               INVOKE     SendMessage, hWndTool, TB_SETBUTTONINFO, ecx, addr tbi
               INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, SavSize
            .endif

               pop     ecx
               pop     eax

;---------- [Add new tool button to the array] ----------
            .if SelList1 && SelList1 != 9999
                  mov     ts.ID, ecx
                  mov     ts.ImageID, eax
               INVOKE     SendMessage, hListbox2, LB_GETITEMDATA, SelList2, 0
                  mov     ts.hBitmap, eax
               INVOKE     SendMessage, hListbox1, LB_GETTEXT, SelList1, addr szBuff2
               INVOKE     lstrcpy, addr szBuff1, addr szIDM
                  mov     ecx, 4
               .if byte ptr szBuff2 == 'S'
                     mov     ecx, 7
               .endif
                 push     ecx
               INVOKE     lstrcat, addr szBuff1, addr szBuff2[ecx]
                  pop     ecx
               INVOKE     lstrcpyn, addr szTextA, addr szBuff2[ecx],6
                  mov     ecx, 4
                  lea     esi, szTextA
                 call     LowerCase               ; Convert to lowercase
                  and     byte ptr szTextA, 0dfh  ; and off lower case bit
               INVOKE     lstrcpy, addr ts.lpName, addr szBuff1
               INVOKE     lstrcpy, addr ts.lpText, addr szTextA
                  mov     byte ptr ts.lpTip, 0
                  mov     ts.fsState, 4                 ; Set state to normal
                  mov     esi, StrAddr                  ; Address of the structure
                  mov     ecx, StrSize                  ; Size of the structure
                  mov     edi, ToolArray                ; Structure memory address
                  mov     eax, ArrayCnt
                 imul     eax, ecx
                  add     edi, eax                      ; Offset the number of structures
                  rep     movsb                         ; Load the structure
                  inc     ArrayCnt
               .if hWndDock
                       call     SetSize
               .endif
            .endif

;---------- [IDC_BREMOVE = remove button] ----------
         .elseif wparam == IDC_BREMOVE
            INVOKE     SetFocus, hStat01
            INVOKE     SendMessage, hListbox2, LB_GETCURSEL, 0, 0
            .if eax == LB_ERR
                  jmp     DlgDone
            .endif
               mov     SelList2, eax
            INVOKE     SendMessage, hListbox2, LB_GETITEMDATA, SelList2, 0
               mov     hData, eax
            INVOKE     GetData, hData, 0, 1
            INVOKE     SendMessage, hListbox2, LB_DELETESTRING, SelList2, 0
            INVOKE     SendMessage, hWndTool, TB_DELETEBUTTON, SelList2, 0
               and     hData, 0
               dec     SelList2
            INVOKE     SendMessage, hListbox2, LB_SETCURSEL, SelList2, 0
              call     SetSize

;---------- [IDC_BMOVEU and IDC_BMOVED = shift up & shift down] ----------
         .elseif wparam == IDC_BMOVEU || wparam == IDC_BMOVED
            INVOKE     SetFocus, hStat01
            INVOKE     SendMessage, hListbox2, LB_GETCURSEL, 0, 0
            .if eax == LB_ERR
                  jmp     DlgDone
            .endif
               mov     SelList2, eax
            INVOKE     SendMessage, hWndTool, TB_GETBUTTON, SelList2, addr tbb
            INVOKE     SendMessage, hWndTool, TB_BUTTONCOUNT, 0, 0
               dec     eax
               mov     Cnt, eax
               mov     eax, SelList2
            .if wparam == IDC_BMOVEU && eax == 0 || wparam == IDC_BMOVED && eax >= Cnt
                  jmp     DlgDone
            .endif
            .if !hData
               INVOKE     SendMessage, hListbox2, LB_GETITEMDATA, SelList2, 0
                  mov     hData, eax
               INVOKE     GetData, hData, 0, 0
            .endif
            INVOKE     SendMessage, hListbox2, LB_DELETESTRING, SelList2, 0
            INVOKE     SendMessage, hWndTool, TB_DELETEBUTTON, SelList2, 0
            .if wparam == IDC_BMOVEU
                  dec     SelList2
            .else
                  inc     SelList2
            .endif
            INVOKE     SendMessage, hListbox2, LB_INSERTSTRING, SelList2, addr szNameA
            INVOKE     SendMessage, hListbox2, LB_SETITEMDATA, SelList2, hData
            INVOKE     SendMessage, hListbox2, LB_SETCURSEL, SelList2, 0

               mov     eax, tbb.iBitmap
               mov     SelList1, 9999
            .if hData == 1234
                  and     SelList1, 0
            .endif
               jmp     AddTool


;---------- [IDC_BSTYLESU = update and IDC_BSTYLESR = reset] ----------
         .elseif wparam == IDC_BSTYLESU || wparam == IDC_BSTYLESR
               mov     UpdateOn, 1

DoAgain:
            .if wparam == IDC_BSTYLESR
                  and     DockH, 0
                  jmp     Pass
            .endif
               mov     TBTop, -4
               mov     TBHgt, 28
               mov     eax, 00100010h
            INVOKE     SendMessage, hWndTool, TB_SETBITMAPSIZE, 0, eax

;               mov     eax, 00120010h
;            INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, eax

            .if ButtH < 29
                  mov     ButtW, 23
            .endif
               mov     ecx, ButtH
               sub     ecx, 2
               shl     ecx, 16
               mov     cx, word ptr ButtW
            INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, ecx

               mov     tbi.dwMask, TBIF_IMAGE
               and     NoImage, 0
              call     SetInfo

              call     GetStyles
               mov     ecx, Styles
               mov     hStyle, ecx

            .if (Styles & TBSTYLE_FLAT)
                  mov     TBTop, -2
                  mov     TBHgt, 26

;                  mov     eax, 00100010h
;               INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, eax

                  mov     ecx, ButtH
                  sub     ecx, 2
                  shl     ecx, 16
                  mov     cx, word ptr ButtW
               INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, ecx

            .endif

            .if (Styles & TBSTYLE_LIST)
                  and     NoImage, 0
               .if ButtW < 58
                     mov     ButtW, 58
               .endif
                  mov     ecx, ButtH
;               .if !(Styles & TBSTYLE_FLAT)
                     sub     ecx, 2
;               .endif
                  shl     ecx, 16
                  mov     cx, word ptr ButtW
               INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, ecx

                  mov     tbi.dwMask, TBIF_IMAGE or TBIF_TEXT
               INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK01 ; Text only
               .if eax
                     mov     NoImage, 1
                     mov     eax, 00100000h
                  INVOKE     SendMessage, hWndTool, TB_SETBITMAPSIZE, 0, eax
                  .if ButtW < 48 || ButtW > 57
                        mov     ButtW, 48
                  .endif
                     mov     ecx, ButtH
;                  .if !(Styles & TBSTYLE_FLAT)
                        sub     ecx, 2
;                  .endif
                     shl     ecx, 16
                     mov     cx, word ptr ButtW
                     mov     SavSize, ecx
                  INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, ecx
               .endif
                 call     SetInfo
            .endif

            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK01    ; Text only
            .if eax
               INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 33
            .endif
               INVOKE     SetWindowLong, hWndTool, GWL_EXSTYLE, EXStyles
               INVOKE     SetWindowLong, hWndTool, GWL_STYLE, Styles

               INVOKE     RedrawWindow, hWndTool, 0, 0,\
                          RDW_ERASE or RDW_INVALIDATE or RDW_UPDATENOW

            .if LeftOn || RightOn
               .if LeftOn
                     mov     TBLeft, -1
                     and     DockH, 0
               .endif
               INVOKE     SendMessage, hWndTool, TB_GETITEMRECT, 0, addr rect
                MOVmd     TBWth, rect.right
                  add     TBWth, 2
            .endif

            .if TopOn || BottomOn
               INVOKE     GetClientRect, hWnd, addr rect
                MOVmd     TBWth, rect.right
                  mov     TBLeft, -1
               INVOKE     SendMessage, hWndTool, TB_GETITEMRECT, 0, addr rect
                MOVmd     TBHgt, rect.bottom
                  add     TBHgt, 4
            .endif

Pass:
            .if wparam == IDC_BSTYLESU

            .else
                  mov     TopOn, 1
                  and     LeftOn, 0
                  and     RightOn, 0
                  and     BottomOn, 0
                  mov     TBLeft, -1
                  mov     TBTop, -2
                  mov     TBHgt, 26
               INVOKE     GetClientRect, hWnd, addr rect
                MOVmd     TBWth, rect.right
                  mov     tbi.dwMask, TBIF_IMAGE
                  and     NoImage, 0
                 call     ResetToolbar
            .endif

;            INVOKE     SetFocus, hStat01
            .if !Redo
                  mov     Redo, 1
;               INVOKE     SetFocus, hWnd
;;               INVOKE     SendMessage, hdlg, WM_COMMAND, wparam, 0
jmp     DoAgain
            .endif
               and     Redo, 0

            .if !BottomOn
               INVOKE     ShowWindow, hWndStat, SW_SHOWDEFAULT
            .else
               INVOKE     ShowWindow, hWndStat, SW_HIDE
            .endif

;---------- [Need to move the Toolbar so some of the styles will show properly] ---------- 
               inc     TBTop
              call     SetSize
               dec     TBTop

              call     SetSize
            INVOKE     RedrawWindow, hWndTool, 0, 0,\
                       RDW_ERASE or RDW_INVALIDATE or RDW_UPDATENOW

            INVOKE     SendMessage, hWndTool, TB_GETITEMRECT, 0, addr rect
;DSPValue hWnd, rect.right, 1, 'm'
            .if rect.right < 23 || rect.right > 100
                  mov     rect.right, 23
            .endif
            .if rect.bottom < 22 || rect.bottom > 60
                  mov     rect.bottom, 22
            .endif
            .if (Styles & TBSTYLE_FLAT)
                  add     rect.bottom, 2
            .endif
            INVOKE     SetDlgItemInt, hdlg, IDC_ECHANGEW, rect.right, 0
            INVOKE     SetDlgItemInt, hdlg, IDC_ECHANGEH, rect.bottom, 0
             MOVmd     ButtW, rect.right
             MOVmd     ButtH, rect.bottom
            .if hWndDock
               INVOKE     SetFocus, hWndDock
            .endif

;---------- [IDC_BRESTORE = restore] ----------
         .elseif wparam == IDC_BRESTORE
            INVOKE     SetFocus, hStat01
            .if hWndFloat
               INVOKE     DestroyWindow, hWndToolF
               INVOKE     DestroyWindow, hWndFloat
                  and     ToolW, 0
                  and     ToolH, 0
                  and     hWndToolF, 0
                  and     hWndFloat, 0
                  and     FloatLock, 0
                  and     LockOn, 0
            .endif

            .if hWndDock
               INVOKE     SetParent, hWndTool, hWnd
               INVOKE     DestroyWindow, hWndDock
                  and     DockH, 0
                  and     hWndDock, 0
            .endif

               and     hData, 0
               and     Chk10On, 0
               and     AddOn, 0
               and     EditOn, 0

               mov     ecx, StrSize
              imul     ecx, 12
               mov     esi, ToolArrayM
               mov     edi, ToolArray
               rep     movsb
               mov     ArrayCnt, 13

            INVOKE     EnableWindow, hButt01, 0
            INVOKE     EnableWindow, hButt02, 0
            INVOKE     EnableWindow, hButt03, 0
            INVOKE     EnableWindow, hButt04, 0
            INVOKE     EnableWindow, hButt05, 0
            INVOKE     EnableWindow, hEdit01, 0
            INVOKE     EnableWindow, hEdit02, 0
            INVOKE     EnableWindow, hEdit03, 0
            INVOKE     SendMessage, hEdit01, WM_SETTEXT, 0, addr szNull
            INVOKE     SendMessage, hEdit02, WM_SETTEXT, 0, addr szNull
            INVOKE     SendMessage, hEdit03, WM_SETTEXT, 0, addr szNull
            INVOKE     SendMessage, hChk01, BM_SETCHECK, BST_UNCHECKED, 0
            INVOKE     SendMessage, hChk02, BM_SETCHECK, BST_UNCHECKED, 0
            INVOKE     SendMessage, hChk03, BM_SETCHECK, BST_UNCHECKED, 0
            INVOKE     SendMessage, hChk04, BM_SETCHECK, BST_UNCHECKED, 0
            INVOKE     SendMessage, hListbox2, LB_RESETCONTENT, 0, 0
              call     LoadListbox2

            INVOKE     SendMessage, hWndTool, TB_BUTTONCOUNT, 0, 0
               mov     Cnt, eax
               mov     Incr, eax
               dec     Incr
            .while (Cnt)
               INVOKE     SendMessage, hWndTool, TB_DELETEBUTTON, Incr, 0
                  dec     Incr
                  dec     Cnt
            .endw

            TBButt     hWndTool, 0, 1001, 4, 0 ;1001
            TBButt     hWndTool, 1, 1002, 4, 0 ;1002
            TBButt     hWndTool, 2, 1003, 4, 0 ;1003
             TBSep     hWndTool
            TBButt     hWndTool, 4, 1004, 4, 0 ;1005
            TBButt     hWndTool, 5, 1005, 4, 0 ;1006
            TBButt     hWndTool, 6, 1006, 4, 0 ;1007
            TBButt     hWndTool, 7, 1007, 4, 0 ;1008
             TBSep     hWndTool
            TBButt     hWndTool, 10,1008, 4, 0 ;1011
            TBButt     hWndTool, 11,1009, 4, 0 ;1012
            TBButt     hWndTool, 12,1010, 4, 0 ;1013
            TBButt     hWndTool, 13,1011, 4, 0 ;1014
             TBSep     hWndTool
            TBButt     hWndTool, 15,1012, 4, 0 ;1016
               and     Redo, 0
            INVOKE     SendMessage, hdlg, WM_COMMAND, IDC_BSTYLESR, 0

;---------- [IDC_BCHANGEW = change width of toolbar buttons] ----------
         .elseif wparam == IDC_BCHANGEW || wparam == IDC_BCHANGEH
              call     GetStyles
            INVOKE     SendMessage, hWndTool, TB_GETITEMRECT, 0, addr rect
            INVOKE     GetDlgItemInt, hToolbarDlg, IDC_ECHANGEW, 0, 0
               mov     rect.right, eax
            .if eax < 23 || eax > 100
               INVOKE     SetDlgItemInt, hdlg, IDC_ECHANGEW, 23, 0
                  mov     rect.right, 23
            .endif
             MOVmd     ButtW, rect.right
            INVOKE     GetDlgItemInt, hToolbarDlg, IDC_ECHANGEH, 0, 0
               mov     rect.bottom, eax
            .if eax < 24 || eax > 60
               INVOKE     SetDlgItemInt, hdlg, IDC_ECHANGEH, 24, 0
                  mov     rect.bottom, 24 ;22
            .endif
             MOVmd     ButtH, rect.bottom
.if (Styles & TBSTYLE_FLAT)
sub     rect.bottom, 2
.endif
               mov     ecx, rect.bottom
;            .if !(Styles & TBSTYLE_FLAT)
                  sub     ecx, 2
;            .endif
               shl     ecx, 16
               mov     cx, word ptr rect.right

            INVOKE     SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, ecx
            .if LeftOn || RightOn
                MOVmd     TBWth, rect.right
                  add     TBWth, 3
            .elseif TopOn || BottomOn
                MOVmd     TBHgt, rect.bottom
                  add     TBHgt, 4
            .endif
            .if !BottomOn
               INVOKE     ShowWindow, hWndStat, SW_SHOWDEFAULT
            .else
               INVOKE     ShowWindow, hWndStat, SW_HIDE
            .endif

              call     SetSize
            INVOKE     RedrawWindow, hWndTool, 0, 0,\
                       RDW_ERASE or RDW_INVALIDATE or RDW_UPDATENOW
            INVOKE     SetFocus, hStat01

;---------- [IDC_BBUILD = Extract the Toolbar information] ----------
         .elseif wparam == IDC_BBUILD
            INVOKE     SetFocus, hStat01
            .if !UpdateOn
               INVOKE     MessageBox, NULL, addr szError3, addr AppName,
                          MB_OK or MB_ICONEXCLAMATION or MB_SYSTEMMODAL
                  jmp     DlgDone
            .endif
               mov     eax, offset szMenu2
               mov     mii.dwTypeData, eax
            INVOKE     SetMenuItemInfo, hMenu, 2, TRUE, addr mii
            INVOKE     DrawMenuBar, hWnd
            INVOKE     ShowWindow, hToolbarDlg, SW_HIDE
              call     Extract
         .endif
      .endif
         jmp     DlgDone

CloseIt:
      INVOKE     DeleteMenu, hMenu, 2, MF_BYPOSITION
      INVOKE     DrawMenuBar, hWnd

      INVOKE     SendMessage, hdlg, WM_COMMAND, IDC_BRESTORE, 0

         and     hData, 0
         and     hToolbarDlg, 0
         and     Incr, 0
      .while (BmpCnt)
            mov     eax, Incr
            mov     ecx, BmpArray[eax*4]
         INVOKE     DeleteObject, ecx
            inc     Incr
            dec     BmpCnt
      .endw

         and     Incr, 0
      .while (BmpCntM)
            mov     eax, Incr
            mov     ecx, BmpArrayM[eax*4]
         INVOKE     DeleteObject, ecx
            inc     Incr
            dec     BmpCntM
      .endw

      .if hBRD
         INVOKE     DeleteObject, hBRD
            and     hBRD, 0
      .endif
         mov     StartID, 1001

      INVOKE     EndDialog, hdlg, wparam ; End the dialog with wparam as return
         mov     eax, TRUE               ; Return
         jmp     DlgRet                  ; with TRUE

DlgDone:
         mov     eax, FALSE              ; Return with FALSE

DlgRet:
         ret
ToolBarDlg ENDP

;=====================================================
; Get styles PROCEDURE
;=====================================================
GetStyles PROC
LOCAL    Cnt:DWORD, Index
LOCAL    szBuff1[64]:BYTE, szArray[256]:BYTE

      INVOKE     SendMessage, hListbox3, LB_GETSELCOUNT, 0, 0
      .if !eax
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 0
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 1
            mov     eax, 2
      .endif
         mov     ecx, eax
      INVOKE     SendMessage, hListbox3, LB_GETSELITEMS, ecx, addr szArray
         and     LeftOn, 0
         and     TopOn, 0
         and     RightOn, 0
         and     BottomOn, 0
         and     EXStyles, 0
         and     Styles, 0
         and     Index, 0
         mov     Cnt, eax
      .while (Cnt)
            mov     ecx, Index
         INVOKE     SendMessage, hListbox3, LB_GETTEXT, dword ptr szArray[ecx*4], addr szBuff1
         .if byte ptr szBuff1 != ' '
               mov     ecx, Index
            .if dword ptr szBuff1+2 == '_XE_' || dword ptr szBuff1+3 == '_XE_'
               INVOKE     SendMessage, hListbox3, LB_GETITEMDATA, dword ptr szArray[ecx*4], 0
                   or     EXStyles, eax

            .else
               INVOKE     SendMessage, hListbox3, LB_GETITEMDATA, dword ptr szArray[ecx*4], 0
                   or     Styles, eax
               .if eax == CCS_LEFT
                     mov     LeftOn, 1
               .elseif eax == CCS_TOP
                     mov     TopOn, 1
               .elseif eax == CCS_RIGHT
                     mov     RightOn, 1
               .elseif eax == CCS_BOTTOM
                     mov     BottomOn, 1
               .endif
            .endif
         .endif
            inc     Index
            dec     Cnt
      .endw

      .if !(Styles & WS_CHILD)
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 0
             or     Styles, WS_CHILD
      .endif
      .if !(Styles & WS_VISIBLE)
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 1
             or     Styles, WS_VISIBLE
      .endif

         ret
GetStyles ENDP

;======================================================
; Find Replace Procedure
;======================================================
FindRep PROC lpInput:DWORD, lpReplace
;LOCAL    ft:FINDTEXT
LOCAL    cr:CHARRANGE

         mov     ft.chrg.cpMin, 0
         mov     ft.chrg.cpMax, -1
         mov     eax, lpInput
         mov     ft.lpstrText, eax

FindNext:
      INVOKE     SendMessage, hREdit, EM_FINDTEXT, FR_DOWN or FR_WHOLEWORD, addr ft
      .if eax != -1
            mov     ft.chrg.cpMin, eax
            inc     ft.chrg.cpMin
            mov     cr.cpMin, eax
            mov     cr.cpMax, eax
            add     cr.cpMax, 4
         INVOKE     SendMessage, hREdit, EM_EXSETSEL, 0, addr cr
         INVOKE     SendMessage, hREdit, EM_REPLACESEL, TRUE, lpReplace
            jmp     FindNext
      .endif

         ret
FindRep ENDP

;======================================================
; Extract Toolbar information PROCEDURE
;======================================================
Extract PROC uses ebx esi edi
LOCAL    Cnt:DWORD, Index, Incr1, Cnt1, Incr2, Cnt2, Incr3, Cnt3
LOCAL    hBitmap:DWORD, BitmapOn, StyleCnt, ID, IDOn, TextOn 
LOCAL    CustomOn:DWORD, DropOn, SavState, SavStyle
LOCAL    szResc[32]:BYTE, szName[32]:BYTE, szTextTB[32]:BYTE, szTipTB[64]:BYTE
LOCAL    szWork[64]:BYTE, szBuff0[256]:BYTE, szEXStyles[256]:BYTE, szStyles[512]:BYTE
LOCAL    szArray[256]:BYTE

      INVOKE     SendMessage, hListbox1, LB_GETCOUNT, 0, 0
      .if eax == LB_ERR || !eax
            ret
      .endif
         and     Incr1, 0
         mov     Cnt, eax

      INVOKE     SendMessage, hListbox2, LB_GETCOUNT, 0, 0
      .if eax == LB_ERR || !eax
            ret
      .endif
         and     Incr2, 0
         mov     Cnt2, eax

         and     ID, 0
         and     IDOn, 0
         and     TextOn, 0
         and     DropOn, 0
         and     CustomOn, 0
         and     StyleCnt, 0
         mov     BmpID, 701
         mov     BitmapOn, 1
         mov     eax, hResr
         mov     byte ptr[eax], 0
         mov     eax, hResrG
         mov     byte ptr[eax], 0
         mov     eax, hToolStr
         mov     byte ptr[eax], 0
         mov     eax, hToolStrF
         mov     byte ptr[eax], 0
         mov     eax, hEquate
         mov     byte ptr[eax], 0
         mov     eax, hDefines
         mov     byte ptr[eax], 0
         mov     eax, hText
         mov     byte ptr[eax], 0
         mov     eax, hOutput
         mov     byte ptr[eax], 0
         mov     byte ptr szEXStyles, 0
         mov     byte ptr szStyles, 0

      INVOKE     IsDlgButtonChecked, hToolbarDlg, IDC_RITIMID
      .if eax
            mov     IDOn, 1
      .endif
      INVOKE     IsDlgButtonChecked, hToolbarDlg, IDC_CHK02
      .if eax
            mov     CustomOn, 1
      .endif

      INVOKE     lstrcpy, hOutput, addr szToolbarRes
      INVOKE     lstrcpy, hToolTip, addr szToolbarTip

;---------- [Extract the Extended, Window, and Control styles] ----------
      INVOKE     lstrcpy, addr szStyles, addr szClear
      .if hWndDock || hWndToolF
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 8
      .endif
      INVOKE     SendMessage, hListbox3, LB_GETSELCOUNT, 0, 0
      .if !eax
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 6
         INVOKE     SendMessage, hListbox3, LB_SETSEL, 1, 7
            mov     eax, 2
      .endif
         mov     ecx, eax
      INVOKE     SendMessage, hListbox3, LB_GETSELITEMS, ecx, addr szArray
         and     Index, 0
         and     Cnt3, 0
         mov     Cnt1, eax
      .while (Cnt1)
            mov     ecx, Index
         INVOKE     SendMessage, hListbox3, LB_GETTEXT, dword ptr szArray[ecx*4], addr szBuff0
         .if byte ptr szBuff0 != ' '
               mov     ecx, Index
            .if dword ptr szBuff0+2 == '_XE_' || dword ptr szBuff0+3 == '_XE_'
               .if byte ptr szEXStyles != 0
                  INVOKE     lstrcat, addr szEXStyles, addr szOR
               .endif
               INVOKE     lstrcat, addr szEXStyles, addr szBuff0

            .else
               .if Cnt3 != 0
                  INVOKE     lstrcat, addr szStyles, addr szOR
                  .if Cnt3 == 4 || Cnt3 == 8 || Cnt3 == 12
                     INVOKE     lstrcat, addr szStyles, addr szSlashB
                     INVOKE     lstrcat, addr szStyles, addr szCRLF
                     INVOKE     lstrcat, addr szStyles, addr szClear
                  .endif
               .endif
               INVOKE     lstrcat, addr szStyles, addr szBuff0
                  inc     Cnt3
                  mov     ecx, Index
               INVOKE     SendMessage, hListbox3, LB_GETITEMDATA, dword ptr szArray[ecx*4], 0
               .if eax == TBSTYLE_LIST
                     mov     TextOn, 1
               .elseif eax == CCS_LEFT
                     mov     LeftOn, 1
               .elseif eax == CCS_TOP
                     mov     TopOn, 1
               .elseif eax == CCS_RIGHT
                     mov     RightOn, 1
               .elseif eax == CCS_BOTTOM
                     mov     BottomOn, 1
               .endif
            .endif
         .endif
            inc     Index
            dec     Cnt1
      .endw

      .if byte ptr szEXStyles == 0
         INVOKE     lstrcpy, addr szEXStyles, addr szZero
      .endif
      INVOKE     lstrcat, addr szStyles, addr szComma
      INVOKE     lstrcat, addr szStyles, addr szSlashB
      INVOKE     lstrcat, addr szStyles, addr szCRLF

      INVOKE     IsDlgButtonChecked, hToolbarDlg, IDC_CHK01
      .if eax
            and     BitmapOn, 0
            inc     TextOn
      .endif

      .if CustomOn
            mov     Incr1, 1
            mov     Cnt1, 16
         .while (Cnt1)
            INVOKE     SendMessage, hListbox1, LB_GETITEMDATA, Incr1, 0
            INVOKE     SendMessage, hListbox1, LB_GETTEXT, Incr1, addr szResc
            INVOKE     BuildR, addr szResc
               inc     BmpID
               inc     Incr1
               dec     Cnt1
         .endw
      .endif
         mov     BmpID, 701

      .while (Cnt2)
         INVOKE     SendMessage, hListbox2, LB_GETITEMDATA, Incr2, 0
            mov     hBitmap, eax
         .if eax == 1234   ; Seperator
            INVOKE     lstrcat, hToolStr, addr szTBSep
            INVOKE     lstrcat, hToolStr, addr szCRLF
               jmp     Bypass
         .endif

            and     Incr1, 0
          MOVmd     Cnt1, Cnt
         .while (Cnt1)
            INVOKE     SendMessage, hListbox1, LB_GETITEMDATA, Incr1, 0
            .if eax == hBitmap
               INVOKE     SendMessage, hListbox1, LB_GETTEXT, Incr1, addr szResc
               .if !CustomOn
                  INVOKE     BuildR, addr szResc
               .endif
                  inc     BmpID

                  mov     ecx, StrSize        ; Size of the structure
                  and     Incr3, 0
                MOVmd     Cnt3, ArrayCnt
               .while (Cnt3)
                     mov     eax, ToolArray
                     add     eax, Incr3
                     add     eax, tshBitmap
                     mov     edx, dword ptr[eax]
                  .if edx == hBitmap
                        mov     eax, ToolArray
                        add     eax, Incr3
                        mov     edx, dword ptr[eax]
                        mov     CmdID, edx
                        mov     eax, ToolArray
                        add     eax, Incr3
                        add     eax, tslpName
                        mov     edx, eax
                     INVOKE     lstrcpy, addr szName, edx
                        mov     eax, ToolArray
                        add     eax, Incr3
                        add     eax, tslpText
                        mov     edx, eax
                     INVOKE     lstrcpy, addr szTextTB, edx
                        mov     eax, ToolArray
                        add     eax, Incr3
                        add     eax, tslpTip
                        mov     edx, eax
                     INVOKE     lstrcpy, addr szTipTB, edx

                        mov     eax, ToolArray
                        add     eax, Incr3
                        add     eax, tsfsState
                        mov     edx, dword ptr[eax]
                        mov     SavState, edx

                        mov     eax, ToolArray
                        add     eax, Incr3
                        add     eax, tsfsStyle
                        mov     edx, dword ptr[eax]
                        mov     SavStyle, edx
                     .if edx == TBSTYLE_DROPDOWN
                           mov     DropOn, 1
                     .endif

                     INVOKE     lstrcat, hToolStr, addr szTBButt
                     INVOKE     lstrcat, hToolStrF, addr szTBButtF
                     INVOKE     lstrcat, hDefines, addr szDefine
                     .if TextOn == 2
                           mov     ID, 9999
                     .endif
                     .if CustomOn
                           mov     ecx, Incr1
                           dec     ecx
                        INVOKE     wsprintf, addr szWork, addr fmat1, ecx
                     .else
                        INVOKE     wsprintf, addr szWork, addr fmat1, ID
                     .endif
                     INVOKE     lstrcat, hToolStr, addr szWork
                     INVOKE     lstrcat, hToolStr, addr szComma
                     INVOKE     lstrcat, hToolStrF, addr szWork
                     INVOKE     lstrcat, hToolStrF, addr szComma
                     INVOKE     lstrcat, hToolTip, addr szFill+15
                     .if !IDOn
                        INVOKE     lstrcat, hToolStr, addr szName
                        INVOKE     lstrcat, hToolStrF, addr szName
                        INVOKE     lstrcat, hToolTip, addr szName
                        INVOKE     lstrcat, hEquate, addr szName
                        INVOKE     lstrcat, hDefines, addr szName
                        INVOKE     lstrlen, addr szName
                     .else
                        INVOKE     wsprintf, addr szWork, addr fmat1, CmdID
                        INVOKE     lstrcat, hToolStr, addr szWork
                        INVOKE     lstrcat, hToolStrF, addr szWork
                        INVOKE     lstrcat, hToolTip, addr szWork
                        INVOKE     lstrcat, hDefines, addr szWork
                        INVOKE     lstrlen, addr szName
                     .endif
                        mov     ecx, 20
                        sub     ecx, eax
                     INVOKE     lstrcpyn, addr szWork, addr szFill, ecx
                     INVOKE     lstrcat, hToolTip, addr szWork
                     INVOKE     lstrcat, hToolTip, addr szQuote
                     INVOKE     lstrcat, hToolTip, addr szTipTB
                     INVOKE     lstrcat, hToolTip, addr szQuote
                     INVOKE     lstrcat, hToolStr, addr szComma
                     INVOKE     lstrcat, hToolStrF, addr szComma
                     INVOKE     lstrcat, hDefines, addr szWork
                     INVOKE     lstrcat, hEquate, addr szWork
                     INVOKE     lstrcat, hEquate, addr szEqu
                     INVOKE     wsprintf, addr szWork, addr fmat1, CmdID
                     INVOKE     lstrcat, hEquate, addr szWork
                     INVOKE     lstrcat, hDefines, addr szWork

                     INVOKE     wsprintf, addr szWork, addr fmat1, SavState
                     INVOKE     lstrcat, hToolStr, addr szWork
                     INVOKE     lstrcat, hToolStr, addr szComma
                     INVOKE     lstrcat, hToolStrF, addr szWork
                     INVOKE     lstrcat, hToolStrF, addr szComma

                     INVOKE     wsprintf, addr szWork, addr fmat1, SavStyle
                     INVOKE     lstrcat, hToolStr, addr szWork
                     INVOKE     lstrcat, hToolStr, addr szComma
                     INVOKE     lstrcat, hToolStrF, addr szZero
                     INVOKE     lstrcat, hToolStrF, addr szComma

                     .if !TextOn
                        INVOKE     lstrcat, hToolStr, addr szZero
                        INVOKE     lstrcat, hToolStrF, addr szZero
                     .else
                        INVOKE     lstrcpy, addr szWork, addr szOffset
                        INVOKE     lstrcat, addr szWork, addr szSZ
                        INVOKE     lstrcat, addr szWork, addr szTextTB
                        INVOKE     lstrcat, hToolStr, addr szWork
                        INVOKE     lstrcat, hToolStrF, addr szZero
                        INVOKE     lstrcpy, addr szWork, addr szSZ
                        INVOKE     lstrcat, addr szWork, addr szTextTB
                        INVOKE     lstrcat, hText, addr szWork
                        INVOKE     lstrlen, addr szWork
                           mov     ecx, 16
                           sub     ecx, eax
                        INVOKE     lstrcpyn, addr szWork, addr szFill, ecx
                        INVOKE     lstrcat, hText, addr szWork
                        INVOKE     lstrcat, hText, addr szDB
                        INVOKE     lstrcat, hText, addr szQuoteS
                        INVOKE     lstrcat, hText, addr szTextTB
                        INVOKE     lstrcat, hText, addr szQuoteS
                        INVOKE     lstrcat, hText, addr szComma
                        INVOKE     lstrcat, hText, addr szZero
                     .endif
                     INVOKE     lstrcat, hToolStr, addr szCRLF
                     INVOKE     lstrcat, hToolStrF, addr szCRLF
                     INVOKE     lstrcat, hToolTip, addr szCRLF
                     INVOKE     lstrcat, hEquate, addr szCRLF
                     INVOKE     lstrcat, hDefines, addr szCRLF
                     INVOKE     lstrcat, hText, addr szCRLF
                        inc     ID
                     .break
                  .endif
                     add     Incr3, ecx
                     dec     Cnt3
               .endw

               .break
            .endif
               inc     Incr1
               dec     Cnt1
         .endw

         .if !Cnt1
;DSPValue hWnd, 1111, 1, 'm'
         .endif

Bypass:
            inc     Incr2
            dec     Cnt2
      .endw

      INVOKE     lstrcat, hToolTip, addr szEnd
      INVOKE     lstrcat, hToolTip, addr szCRLF
      INVOKE     lstrcat, hToolStr, addr szCRLF
      INVOKE     lstrcat, hToolStrF, addr szCRLF
      INVOKE     lstrcat, hText, addr szCRLF
      .if !IDOn
         INVOKE     lstrcat, hOutput, hDefines
         INVOKE     lstrcat, hOutput, addr szCRLF
      .endif
      INVOKE     lstrcat, hOutput, hResr
      INVOKE     lstrcat, hOutput, addr szCRLF

;---------- Gray Bitmaps] ----------
      INVOKE     IsDlgButtonChecked, hToolbarDlg, IDC_CHK03
      .if eax
         INVOKE     lstrcat, hOutput, hResrG
         INVOKE     lstrcat, hOutput, addr szCRLF
      .endif

      INVOKE     lstrcat, hOutput, hToolTip
      INVOKE     lstrcat, hOutput, addr szCRLF
      INVOKE     lstrcat, hOutput, addr szToolbarMac
      INVOKE     lstrcat, hOutput, hEquate
      INVOKE     lstrcat, hOutput, addr szCRLF
;      INVOKE     lstrcat, hOutput, addr szCRLF
;      INVOKE     lstrcat, hOutput, addr szCRLF
      INVOKE     lstrcat, hOutput, addr szToolbarDat1
      .if hWndDock || hWndToolF
         INVOKE     lstrcat, hOutput, addr szFloatClass
      .endif
      INVOKE     lstrcat, hOutput, addr szCRLF
      .if TextOn
         INVOKE     lstrcat, hOutput, hText
      .endif
      .if CustomOn
         INVOKE     lstrcat, hOutput, addr szToolCustom1
      .endif
      INVOKE     lstrcat, hOutput, addr szToolbarDat2
;---------- Gray Bitmaps] ----------
      INVOKE     IsDlgButtonChecked, hToolbarDlg, IDC_CHK03
      .if eax
         INVOKE     lstrcat, hOutput, addr szToolbarDatG
      .endif
      INVOKE     lstrcat, hOutput, addr szCRLF
      INVOKE     lstrcat, hOutput, addr szToolbarDat3
      .if hWndDock || hWndToolF
         INVOKE     lstrcat, hOutput, addr szToolbarDat4
      .endif
      .if CustomOn
         INVOKE     lstrcat, hOutput, addr szToolCustom2
      .endif
      .if hWndDock || hWndToolF
         INVOKE     lstrcat, hOutput, addr szWinMain
      .endif
      INVOKE     lstrcat, hOutput, addr szWinProc
      INVOKE     lstrcat, hOutput, addr szToolbarLoc
      .if CustomOn
         INVOKE     lstrcat, hOutput, addr szToolCusLoc
      .endif
      INVOKE     lstrcat, hOutput, addr szCRLF
      INVOKE     lstrcat, hOutput, addr szToolbarWnd1
      INVOKE     lstrcat, hOutput, addr szStyles
      INVOKE     lstrcat, hOutput, addr szToolbarWnd2
      INVOKE     lstrcat, hOutput, addr szToolbarCre1
;---------- Gray Bitmaps] ----------
      INVOKE     IsDlgButtonChecked, hToolbarDlg, IDC_CHK03
      .if eax
         INVOKE     lstrcat, hOutput, addr szToolbarCreG
      .endif
      INVOKE     lstrcat, hOutput, addr szToolbarCre2
      INVOKE     lstrcat, hOutput, hToolStr
      .if hWndToolF
         INVOKE     lstrcat, hOutput, addr szToolbarFloat
         INVOKE     lstrcat, hOutput, hToolStrF
      .endif
      .if DropOn
         INVOKE     lstrcat, hOutput, addr szSetDropdown
      .endif
      INVOKE     lstrcat, hOutput, addr szSetValues
      .if CustomOn
         INVOKE     lstrcat, hOutput, addr szToolCustom3
      .endif
      .if hWndToolF
         INVOKE     lstrcat, hOutput, addr szRemoveParm
      .endif
      INVOKE     lstrcat, hOutput, addr szToolSiz1
      .if hWndDock
         INVOKE     lstrcat, hOutput, addr szToolDock
      .endif
      .if hWndToolF
         INVOKE     lstrcat, hOutput, addr szToolFloat1
      .endif
      INVOKE     lstrcat, hOutput, addr szToolSiz2
      .if hWndToolF
         INVOKE     lstrcat, hOutput, addr szSizeFloat
      .endif
      .if hWndDock
         INVOKE     lstrcat, hOutput, addr szSizeDock
      .endif
      .if hWndDock || hWndToolF
         INVOKE     lstrcat, hOutput, addr szMovAct
      .endif
      INVOKE     lstrcat, hOutput, addr szNotify
      .if hWndDock
         INVOKE     lstrcat, hOutput, addr szOpenDock
      .endif
      .if CustomOn
         INVOKE     lstrcat, hOutput, addr szToolCustom4
      .endif
      .if DropOn
         INVOKE     lstrcat, hOutput, addr szToolDrop
      .endif
      INVOKE     lstrcat, hOutput, addr szToolbarDes

;---------- Gray Bitmaps] ----------
      INVOKE     IsDlgButtonChecked, hToolbarDlg, IDC_CHK03
      .if eax
         INVOKE     lstrcat, hOutput, addr szToolbarDesG
      .endif
      .if hWndToolF
         INVOKE     lstrcat, hOutput, addr szResetParm
      .endif
      INVOKE     lstrcat, hOutput, addr szCRLF
      INVOKE     lstrcat, hOutput, addr szChgBmpColor
      .if hWndDock
         INVOKE     lstrcat, hOutput, addr szDockProc
      .endif
      .if hWndDock || hWndToolF
         INVOKE     lstrcat, hOutput, addr szFloatProc
      .endif
      .if hWndDock
         INVOKE     lstrcat, hOutput, addr szDock
      .endif
      .if hWndToolF
         INVOKE     lstrcat, hOutput, addr szFloat
      .endif
      .if hWndDock || hWndToolF
         INVOKE     lstrcat, hOutput, addr szDefWin
         INVOKE     lstrcat, hOutput, addr szSetSize
      .endif

      INVOKE     SendMessage, hREdit, WM_SETTEXT, 0, hOutput
      .if CustomOn
            mov     ID, 16
      .endif

      INVOKE     wsprintf, addr szWork, addr fmat1, ID
      INVOKE     FindRep, addr szNNNN, addr szWork
      INVOKE     GetDlgItemInt, hToolbarDlg, IDC_ECHANGEW, 0, 0
      INVOKE     wsprintf, addr szWork, addr fmat1, eax
      INVOKE     FindRep, addr szWWWW, addr szWork
      INVOKE     GetDlgItemInt, hToolbarDlg, IDC_ECHANGEH, 0, 0
         sub     eax, 2
      INVOKE     wsprintf, addr szWork, addr fmat1, eax
      INVOKE     FindRep, addr szHHHH, addr szWork
      INVOKE     wsprintf, addr szWork, addr fmat1, LeftOn
      INVOKE     FindRep, addr szLLLL, addr szWork
      INVOKE     wsprintf, addr szWork, addr fmat1, TopOn
      INVOKE     FindRep, addr szTTTT, addr szWork
      INVOKE     wsprintf, addr szWork, addr fmat1, RightOn
      INVOKE     FindRep, addr szRRRR, addr szWork
      INVOKE     wsprintf, addr szWork, addr fmat1, BottomOn
      INVOKE     FindRep, addr szBBBB, addr szWork
      INVOKE     wsprintf, addr szWork, addr fmat1, TBLeft
      INVOKE     FindRep, addr szTBLL, addr szWork
      INVOKE     wsprintf, addr szWork, addr fmat1, TBTop
      INVOKE     FindRep, addr szTBTT, addr szWork
      INVOKE     wsprintf, addr szWork, addr fmat1, TBWth
      INVOKE     FindRep, addr szTBWW, addr szWork
      INVOKE     wsprintf, addr szWork, addr fmat1, TBHgt
      INVOKE     FindRep, addr szTBHH, addr szWork

ExtractDone:
         ret
Extract ENDP

;======================================================
; Build the resource string PROCEDURE
;======================================================
BuildR PROC uses esi edi lpName:DWORD
LOCAL    szBuff0[256]:BYTE, szResStr[256]:BYTE, szWork[10]:BYTE

      INVOKE     lstrcpy, addr szBuff0, addr szResr1
      INVOKE     lstrcat, addr szBuff0, addr szRoot  ;+2
      INVOKE     lstrcat, addr szBuff0, addr szResr2
      INVOKE     lstrcat, addr szBuff0, addr szSlashB
      INVOKE     lstrlen, addr szBuff0
         mov     ecx, eax
         lea     esi, szBuff0
         lea     edi, szResStr
      .while (ecx)
            mov     al, byte ptr[esi]
            mov     byte ptr[edi], al
         .if al == '\'
               inc     edi
               mov     byte ptr[edi], '\'
         .endif
            inc     esi
            inc     edi
            dec     ecx
      .endw
         mov     byte ptr[edi], 0

      INVOKE     wsprintf, addr szWork, addr fmat1, BmpID
      INVOKE     lstrcat, hResr, addr szWork
      INVOKE     lstrcat, hResr, addr szResStr
      INVOKE     lstrcat, hResr, lpName
      INVOKE     lstrcat, hResr, addr szBmp
      INVOKE     lstrcat, hResr, addr szQuote
      INVOKE     lstrcat, hResr, addr szCRLF

;---------- Gray Bitmaps] ----------
      INVOKE     IsDlgButtonChecked, hToolbarDlg, IDC_CHK03
      .if eax
         INVOKE     wsprintf, addr szWork, addr fmat1, BmpID
            mov     byte ptr szWork, '8'
         INVOKE     lstrcat, hResrG, addr szWork
         INVOKE     lstrcat, hResrG, addr szResStr
            mov     eax, lpName
            mov     byte ptr[eax], 'G'
         INVOKE     lstrcat, hResrG, lpName
         INVOKE     lstrcat, hResrG, addr szBmp
         INVOKE     lstrcat, hResrG, addr szQuote
         INVOKE     lstrcat, hResrG, addr szCRLF
      .endif

;INVOKE     MessageBox, NULL, hResrG, addr AppName, MB_OK

         ret
BuildR ENDP

;=====================================================
; Converts a Dec, Hex, Oct or Bin ascii string to a 32 bit num value.
;=====================================================
;INVOKE     AsciiBase, addr szBuff, addr Num, 10
AsciiBase PROC uses ecx edx esi edi Input:DWORD, Base
         mov     esi, Input
         xor     edi, edi
      INVOKE     lstrlen, Input
         xor     ecx, ecx
      .while (eax)
         .if byte ptr[esi+ecx] > 60h
               sub     byte ptr[esi+ecx], 57h
         .elseif byte ptr[esi+ecx] > 40h
               sub     byte ptr[esi+ecx], 37h
         .else
               xor     byte ptr[esi+ecx], 30h
         .endif
            dec     eax
            inc     ecx
      .endw
         mov     ebx, 1
         mov     esi, Input
         add     esi, ecx
         dec     esi
         xor     edx, edx
      .while (ecx)
            mov     al, byte ptr[esi]      ; Extract byte for conversion
            and     eax, 000000ffh
           imul     eax, ebx
            add     edi, eax               ; Accumulate output
           imul     ebx, Base
            dec     esi
            dec     ecx 
      .endw
          mov     eax, edi
          ret
AsciiBase ENDP

;======================================================
; Save file PROCEDURE
;======================================================
SaveFile PROC
LOCAL    ofn:OPENFILENAME
LOCAL    EditS:EDITSTREAM
LOCAL    hFile:DWORD

      INVOKE     SendMessage,  hREdit, WM_GETTEXTLENGTH, 0, 0
      .if !eax
            jmp     EndSave
      .endif

;---------- [Zero out the structures] ----------
      INVOKE     RtlZeroMemory, addr ofn, sizeof ofn
      INVOKE     RtlZeroMemory, addr EditS, sizeof EditS

      INVOKE     lstrcpy, addr PathName, addr szRoot
      INVOKE     lstrcat, addr PathName, addr szTemp

;---------- [Set the OPENFILENAME attributes] ----------
         mov     ofn.lStructSize, sizeof ofn
         mov     eax, hWnd
         mov     ofn.hwndOwner, eax
         mov     eax, hInst
         mov     ofn.hInstance, eax
         mov     ofn.lpstrFilter, offset szFilter
         mov     ofn.lpstrFile, offset PathName
         mov     ofn.nMaxFile, lengthof PathName
         mov     ofn.lpstrFileTitle, offset FileName
         mov     ofn.nMaxFileTitle, lengthof FileName
         mov     ofn.lpstrTitle, offset szSaveTitle
         mov     ofn.Flags, OFN_OVERWRITEPROMPT or OFN_CREATEPROMPT or\
                 OFN_PATHMUSTEXIST or OFN_FILEMUSTEXIST
      INVOKE     GetSaveFileName, addr ofn
      .if !eax                       ; Cancel'ed or error occurred
            mov     eax, IDCANCEL
            jmp     EndSave
      .endif

      INVOKE     CreateFile, addr PathName,\
                 GENERIC_READ or GENERIC_WRITE ,\
                 FILE_SHARE_READ or FILE_SHARE_WRITE,\
                 NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
         cmp     eax, -1             ; Error?
         jne     savcrok

saverr:
         jmp     EndSave

savcrok:
         mov     hFile, eax
         mov     EditS.dwCookie, eax
         mov     EditS.dwError, 0
         mov     EditS.pfnCallback, offset EditStreamWrite

      INVOKE     SendMessage, hREdit, EM_STREAMOUT, SF_TEXT, addr EditS
      INVOKE     CloseHandle, hFile
      INVOKE     SendMessage,  hREdit, EM_SETMODIFY, FALSE, 0

EndSave:
         ret
SaveFile ENDP

;======================================================
; Edit Stream Save Callback PROCEDURE
;======================================================
EditStreamWrite PROC  dwCookie:DWORD, pbBuff, cb, pcb
      INVOKE     WriteFile, dwCookie, pbBuff, cb, pcb, 0
         mov     eax, 0              ; File completely read
         ret
EditStreamWrite ENDP

;===================================================
; FloatWndProc procedure
;===================================================
FloatWndProc PROC  uses ebx esi edi hwnd:DWORD, wmsg, wparam, lparam
LOCAL    rect:RECT
LOCAL    rectE:RECT
LOCAL    rectF:RECT
LOCAL    wp:WINDOWPLACEMENT
LOCAL    Cnt:DWORD, WH, Var, swOn
LOCAL    szBuff[64]:BYTE

      .if wmsg == WM_MOVE || wmsg == WM_SIZE
            mov     wp.iLength, sizeof wp
         INVOKE     GetWindowPlacement, hWnd, addr wp
         .if wp.showCmd == SW_SHOWMINIMIZED || wp.showCmd == SW_MINIMIZE
            INVOKE     SetFocus, hREdit
               mov     eax, 1
               ret
         .endif
      .endif

         mov     eax, hwnd
      .if eax == hWndDock
         .if wmsg == WM_CLOSE || wmsg == WM_RBUTTONDBLCLK
            INVOKE     SetParent, hWndTool, hWnd
            INVOKE     DestroyWindow, hWndDock
               and     hWndDock, 0
            INVOKE     GetWindowLong, hWndTool, GWL_STYLE
               mov     Styles, eax
            .if !(Styles & WS_BORDER)
                  xor     Styles, WS_BORDER
            .endif
            INVOKE     SetWindowLong, hWndTool, GWL_STYLE, Styles
            INVOKE     SendMessage, hChk04, BM_SETCHECK, BST_UNCHECKED, 0
            .if FloatLock
               INVOKE     GetWindowRect, hWndFloat, addr rectF
               INVOKE     GetWindowRect, hREdit, addr rectE
                  mov     eax, rectE.left
                  add     eax, 6
                  sub     rectE.right, eax
                  mov     eax, rectE.top
                  add     eax, 6
                  sub     rectE.bottom, eax

                  mov     eax, rectF.left
                  sub     rectF.right, eax
                  mov     eax, rectF.top
                  sub     rectF.bottom, eax

                  add     rectF.top, 26
                  mov     eax, rectF.right
               .if rectF.bottom > eax
                     sub     rectF.top, 3
                     sub     rectF.bottom, 26
               .endif
                  mov     LockOn, 1
               INVOKE     MoveWindow, hWndFloat, rectF.left, rectF.top, rectF.right, rectF.bottom, TRUE
                  mov     FloatLock, 1
            .endif
              call     SetSize

               mov     eax, 1
               ret
         .endif
            jmp     DefWin
      .endif

      .if wmsg == WM_NCLBUTTONDBLCLK
         INVOKE     PostMessage, hWndFloat, WM_NCLBUTTONDOWN, HTCAPTION, 0
      .endif

         mov     eax, hwnd
      .if eax != hWndFloat
            mov     eax, 1
            ret
      .endif

      .if wmsg == WM_MOVE
         INVOKE     SetFocus, hREdit
         .if !ToolW
               mov     eax, TRUE
               ret     
         .endif
            and     swOn, 0
         INVOKE     GetWindowRect, hWndFloat, addr rectF ; Rectangle of Float
         INVOKE     GetWindowRect, hREdit, addr rectE ; Rectangle of Edit 

            mov     eax, lparam       ; Get xPos
            and     eax, 0ffffh       ; Lowword
            mov     ecx, lparam       ; Get yPos
            shr     ecx, 16           ; Hiword

            add     rectE.left, 6
            add     rectE.top, 6


         .if eax < 5 || eax > 7fffh || ecx > 7fffh
            .if eax > 5
                 push     eax
               INVOKE     GetWindowRect, hWndFloat, addr rectF ; Rectangle of Float
                 push     rectF.left
                 push     rectF.top
               INVOKE     GetClientRect, hWndFloat, addr rectF ; Rectangle of Float
                  pop     ecx
                  pop     edx
                  pop     eax
               .if eax > 7fffh
                     mov     rectF.top, ecx
               .else
                     mov     rectF.left, edx
               .endif
                     add     rectF.right, 6
                     add     rectF.bottom, 6
                  INVOKE     MoveWindow, hWndFloat, rectF.left, rectF.top, rectF.right, rectF.bottom, TRUE
            .endif
            .if FloatLock && LockOn
                 mov     eax, 1
                 ret
            .endif
               and     FloatLock, 0
               xor     eax, eax
               ret
         .endif

            mov     ebx, eax
         .if eax > 9
               sub     eax, 10
         .else
               xor     eax, eax
         .endif
            add     ebx, 10
            mov     edx, ecx
            sub     ecx, 10
            add     edx, 10

         .if eax < rectE.left && ebx > rectE.left &&\
             ecx < rectE.top && edx > rectE.top || LockOn
               and     LockOn, 0
               mov     FloatLock, 1
            INVOKE     GetClientRect, hWndFloat, addr rectF
            INVOKE     GetWindowRect, hREdit, addr rectE
               mov     eax, rectE.left
               add     eax, 6
               sub     rectE.right, eax
               mov     eax, rectE.top
               add     eax, 6
               sub     rectE.bottom, eax

               mov     eax, rectF.right
            .if eax > rectF.bottom
                  mov     WH, 1
                  mov     eax, 22  ; Height
                 push     rectE.right
                 push     eax
            .else
                  mov     WH, 2
                  mov     eax, 23  ; Width
                 push     rectE.bottom
                 push     eax
            .endif
               jmp     NewPos

         .else
            INVOKE     GetClientRect, hWndFloat, addr rectF
               and     FloatLock, 0
              call     SetSize
            INVOKE     GetWindowRect, hWndFloat, addr rect
            INVOKE     SendMessage, hWndToolF, TB_BUTTONCOUNT, 0, 0
               mov     Cnt, eax
            .if rectF.right == 23 || rectF.bottom == 22
               .if rectF.right == 23
                    imul     eax, 22
                     mov     rectF.bottom, eax
               .elseif rectF.bottom == 22
                    imul     eax, 23
                     mov     rectF.right, eax
               .endif

                  mov     WH, 1
                 push     rectF.right
                 push     rectF.bottom
                  jmp     NewPos
            .endif
         .endif
            mov     eax, TRUE
            ret
      .endif

      .if wmsg == WM_SIZE
         INVOKE     SendMessage, hWndToolF, TB_BUTTONCOUNT, 0, 0
            mov     Cnt, eax
         .if !eax
               jmp     DefWin
         .endif
         INVOKE     GetWindowRect, hREdit, addr rectE
            mov     eax, rectE.left
            add     eax, 6
            sub     rectE.right, eax
            mov     eax, rectE.top
            add     eax, 6
            sub     rectE.bottom, eax

         INVOKE     GetWindowRect, hWndFloat, addr rect
            mov     eax, lparam       ; Get width
            and     eax, 0ffffh       ; Lowword
            mov     ebx, lparam       ; Get height
            shr     ebx, 16           ; Hiword

         .if !ToolW
               mov     ToolW, eax
               mov     ToolH, ebx
               dec     ToolW
         .endif

            and     swOn, 0
            xor     edx, edx
         .if FloatLock && ebx == ToolH && eax != ToolW
               mov     WH, 1
               mov     eax, 22  ; Height
              push     rectE.right
              push     eax
               mov     swOn, 1
               jmp     NewPos
         .endif
         .if FloatLock && eax == ToolW && ebx != ToolH
               mov     WH, 2
               mov     eax, 23  ; Width
              push     rectE.bottom
              push     eax
               mov     swOn, 2
               jmp     NewPos
         .endif

         .if eax != ToolW || ebx != ToolH
               mov     WH, 1
               mov     ecx, 22
            .if ebx != ToolH
                  mov     WH, 2
                  mov     ecx, 23
                  mov     eax, ebx
            .endif
               div     ecx
            .if edx
                  inc     eax
            .endif
            .if eax > Cnt
                  mov     eax, Cnt
            .endif

DoAgain:
            .if !eax
                  mov     eax, 1
            .endif
               mov     ebx, eax

               mov     Var, 22
            .if WH == 1
                  mov     Var, 23
            .endif
              imul     eax, Var

              push     eax           ; W if WH == 1
               xor     edx, edx
               mov     eax, Cnt
               div     ebx
            .if !eax
                  inc     eax
            .endif
            .if edx
                  inc     eax
            .endif

            .if WH == 2 && eax == 2 || WH == 2 && eax == 3
                 imul     ebx, eax
               .if ebx > Cnt
                  .if eax == 3
                        pop     eax
                        xor     edx, edx
                        mov     eax, Cnt
                        mov     ebx, 3
                        div     ebx
                        jmp     DoAgain
                  .endif
                     pop     eax
                     mov     eax, Cnt
                     jmp     DoAgain
               .endif
            .endif

               mov     Var, 23
            .if WH == 1
                  mov     Var, 22
            .endif
              imul     eax, Var
              push     eax           ; H if WH == 1

NewPos:
            INVOKE     GetWindowRect, hWndFloat, addr rect
            .if WH == 1
                  pop     eax
                  pop     ebx
            .else
                  pop     ebx
                  pop     eax
            .endif

               mov     ToolW, ebx
               mov     ToolH, eax
               mov     rect.right, ebx
               mov     rect.bottom, eax
               add     rect.right, 6
               add     rect.bottom, 6

            .if FloatLock
                  and     FloatLock, 0
                 call     SetSize
                  mov     FloatLock, 1
               INVOKE     GetWindowRect, hREdit, addr rectE
                MOVmd     rect.left, rectE.left
                MOVmd     rect.top, rectE.top
                  mov     eax, rectE.left
                  add     eax, 6
                  sub     rectE.right, eax
                  mov     eax, rectE.top
                  add     eax, 6
                  sub     rectE.bottom, eax

               .if swOn
                  .if swOn == 1
                        jmp     sw01
                  .else
                        jmp     sw02
                  .endif
                     jmp     PressOn
               .endif
               INVOKE     GetClientRect, hWndFloat, addr rectF
                  mov     eax, rectF.right
               .if eax > rectF.bottom
sw01:
                     mov     rect.bottom, 22  ; Height
                     mov     ToolH, 22
                     add     rect.bottom, 6
                   MOVmd     rect.right, rectE.right
                     add     rect.right, 6
               .else
sw02:
                     mov     rect.right, 23   ; Width
                     mov     ToolW, 23
                     add     rect.right, 6
                   MOVmd     rect.bottom, rectE.bottom
                     add     rect.bottom, 6
               .endif
            .endif

PressOn:
            INVOKE     MoveWindow, hWndFloat, rect.left, rect.top, rect.right, rect.bottom, TRUE
            INVOKE     GetClientRect, hWndFloat, addr rect
               add     rect.right, 2
               add     rect.bottom, 2
            INVOKE     MoveWindow, hWndToolF, -1, -1, rect.right, rect.bottom, TRUE
              call     SetSize
         .endif
            jmp     Ret0

      .elseif wmsg == WM_NOTIFY
            mov     ebx, lparam                      ; Get pointer to NMHDR
            mov     eax, (NMHDR ptr [ebx]).code
         .if eax == TTN_NEEDTEXT
               mov     eax, (NMHDR ptr [ebx]).idFrom ; Resource id
               mov     ebx, eax
            INVOKE     LoadString, hInst, ebx, addr szBuff, lengthof szBuff
               mov     ebx, lparam                   ; Get the buffer addr
               lea     eax, szBuff
               mov     (TOOLTIPTEXT ptr [ebx]).lpszText, eax
               jmp     Ret0
         .endif
            jmp     DefWin

      .elseif wmsg == WM_COMMAND
         INVOKE     SendMessage, hWnd, WM_COMMAND, wparam, lparam
         INVOKE     SetFocus, hREdit
            xor     eax, eax
            jmp     Ret0
      .endif

DefWin:
      INVOKE     DefWindowProc, hwnd, wmsg, wparam, lparam
         ret
;      .endif

Ret0:
         xor     eax, eax
         ret
FloatWndProc ENDP

;======================================================
; Call WM_SIZE PROCEDURE
;======================================================
SetSize PROC
LOCAL    rect:RECT

      INVOKE     GetClientRect, hWnd, addr rect
         mov     edx, rect.bottom
         shl     edx, 16
         mov     ecx, rect.right
         mov     dx, cx
      INVOKE     SendMessage, hWnd, WM_SIZE, 0, edx
         ret

SetSize ENDP

end start
