         title   Tabcontrol 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  G:\WebPage\AsmEdit\include\DSPMACRO.asm

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

;===================================================
; PROTO, MACRO, and Data section
;===================================================
WinMain         PROTO  :DWORD, :DWORD, :DWORD, :DWORD
RichEditProc    PROTO  :DWORD, :DWORD, :DWORD, :DWORD
TabCtrlDlg      PROTO  :DWORD, :DWORD, :DWORD, :DWORD
TabEditProc     PROTO  :DWORD, :DWORD, :DWORD, :DWORD
AsciiBase       PROTO  :DWORD, :DWORD
ChgBmpColor     PROTO  :DWORD

MOVmd    MACRO Var1, Var2
         push     Var2
          pop     Var1
         ENDM

.const
IDM_EXIT       equ 7001
IDM_TABCTRL    equ 8001

IDM_CUT        equ 1004
IDM_COPY       equ 1005
IDM_PASTE      equ 1006
IDM_DELETE     equ 1007
IDM_SELALL     equ 1008
IDM_DIALOG     equ 8040

IDD_DLG01      equ 2000
IDC_GRP01      equ 2001
IDC_STATIC01   equ 2002
IDC_REDIT01    equ 2009
IDC_REDIT02    equ 2010
IDC_REDIT03    equ 2011
IDC_REDIT04    equ 2012
IDC_REDIT05    equ 2013
IDC_CHK01      equ 2014
IDC_CHK02      equ 2015
IDC_GRP02      equ 2016
IDC_LISTBOX01  equ 2017
IDC_BUTT01     equ 2018
IDC_BUTT02     equ 2019
IDC_COMBO01    equ 2020
IDC_COMBO02    equ 2021

.data
ClassName      db  'TabCtrl',0
AppName        db  'Create Tab Control',0
MenuName       db  'MainMenu',0
PopupMenu      db  'PopupMenu',0
RichEdit       db  'RichEdit20A',0
RichEdDLL      db  'RICHED20.DLL',0
StaticClass    db  'static',0
ButtonClass    db  'button',0
TabCtrlClass   db  'SysTabControl32',0

FontNameCN     db  'Courier New',0
FontNameMS     db  'MS Sans Serif',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
szES05         db  'TCS_EX_FLATSEPARATORS equ 00000001h',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  ' **** Control Styles ****          ',0
szTCS01        db  'TCS_TABS              equ 00000000h',0
szTCS02        db  'TCS_RIGHTJUSTIFY      equ 00000000h',0
szTCS03        db  'TCS_SINGLELINE        equ 00000000h',0
szTCS04        db  'TCS_SCROLLOPPOSITE    equ 00000001h',0
szTCS05        db  'TCS_RIGHT             equ 00000002h',0  ; Used with TCS_VERTICAL
szTCS06        db  'TCS_BOTTOM            equ 00000002h',0
szTCS07        db  'TCS_MULTISELECT       equ 00000004h',0
szTCS08        db  'TCS_FLATBUTTONS       equ 00000008h',0
szTCS09        db  'TCS_FORCEICONLEFT     equ 00000010h',0
szTCS10        db  'TCS_FORCELABELLEFT    equ 00000020h',0
szTCS11        db  'TCS_HOTTRACK          equ 00000040h',0
szTCS12        db  'TCS_VERTICAL          equ 00000080h',0
szTCS13        db  'TCS_BUTTONS           equ 00000100h',0
szTCS14        db  'TCS_MULTILINE         equ 00000200h',0
szTCS15        db  'TCS_FIXEDWIDTH        equ 00000400h',0
szTCS16        db  'TCS_RAGGEDRIGHT       equ 00000800h',0
szTCS17        db  'TCS_FOCUSONBUTTONDOWN equ 00001000h',0
szTCS18        db  'TCS_OWNERDRAWFIXED    equ 00002000h',0
szTCS19        db  'TCS_TOOLTIPS          equ 00004000h',0
szTCS20        db  'TCS_FOCUSNEVER        equ 00008000h',0

szMenu1        db  'Hide Dialog',0
szMenu2        db  'Show Dialog',0

TabTitle       db  'Tab Text ',0
.data?
szTab01        db  64  dup(?)
szTab02        db  64  dup(?)
szTab03        db  64  dup(?)
szTab04        db  64  dup(?)
szTab05        db  64  dup(?)
szTab06        db  64  dup(?)
szTab07        db  64  dup(?)
szTab08        db  64  dup(?)
szTab09        db  64  dup(?)
szTab10        db  64  dup(?)
szTab11        db  64  dup(?)
szTab12        db  64  dup(?)
szTab13        db  64  dup(?)
szTab14        db  64  dup(?)
szTab15        db  64  dup(?)
szTab16        db  64  dup(?)
.data
TabArray       dd  szTab01,szTab02,szTab03,szTab04
               dd  szTab05,szTab06,szTab07,szTab08
               dd  szTab09,szTab10,szTab11,szTab12
               dd  szTab13,szTab14,szTab15,szTab16

TabTip         db  'This Is Tab #',0
.data?
szTabT01       db  64  dup(?)
szTabT02       db  64  dup(?)
szTabT03       db  64  dup(?)
szTabT04       db  64  dup(?)
szTabT05       db  64  dup(?)
szTabT06       db  64  dup(?)
szTabT07       db  64  dup(?)
szTabT08       db  64  dup(?)
szTabT09       db  64  dup(?)
szTabT10       db  64  dup(?)
szTabT11       db  64  dup(?)
szTabT12       db  64  dup(?)
szTabT13       db  64  dup(?)
szTabT14       db  64  dup(?)
szTabT15       db  64  dup(?)
szTabT16       db  64  dup(?)
.data
TabTArray      dd  szTabT01,szTabT02,szTabT03,szTabT04
               dd  szTabT05,szTabT06,szTabT07,szTabT08
               dd  szTabT09,szTabT10,szTabT11,szTabT12
               dd  szTabT13,szTabT14,szTabT15,szTabT16

szError1       db  'The RICHED20.DLL was not found!',0

szNull         db  0
szSlashB       db  '\',0
szQuote        db  '"',0
szQuoteS       db  "'",0
szComma        db  ',',0
szClear        db  '                    ',0
szSpace        db  ' ',0
szZero         db  '0',0
szCRLF         db  0dh,0ah,0
szNN           dd  'NNN',0
szTT           dd  'TTT',0
szOO           dd  'OOO',0

fmat1          db  '%01u',0
fmat2          db  '%02u',0

szB01          db  'B01_New.bmp',0
szB02          db  'B02_Open.bmp',0
szB03          db  'B03_Save.bmp',0
szB04          db  'B04_SAVEALL.bmp',0
szB05          db  'B05_Cut.bmp',0
szB06          db  'B06_Copy.bmp',0
szB07          db  'B07_Paste.bmp',0
szB08          db  'B08_Delete.bmp',0
szB09          db  'B09_UNDO.bmp',0
szB10          db  'B10_REDO.bmp',0
szB11          db  'B11_Find.bmp',0
szB12          db  'B12_FindNext.bmp',0
szB13          db  'B13_FindPrev.bmp',0
szB14          db  'B14_Replace.bmp',0
szB15          db  'B15_MULTI.bmp',0
szB16          db  'B16_Exit.bmp',0
BmpArray       dd  szB01,szB02,szB03,szB04
               dd  szB05,szB06,szB07,szB08
               dd  szB09,szB10,szB11,szB12
               dd  szB13,szB14,szB15,szB16

szOR           db  ' or ',0
szResr1        db  '    BITMAP  DISCARDABLE  "',0
szResr2        db  'Res',0
szTabArray     db  'TabArray       dd  ',0
szTabArrayC    db  '               dd  ',0

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

szTabCtrlTip   db  'STRINGTABLE DISCARDABLE',0dh,0ah
               db  'BEGIN',0dh,0ah
               db  '/* Tab control tips */',0dh,0ah,0

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

szTabCtrlMac1  db  ';***** [Place in the Application or Include F:\masm32\include\file] *****',0dh,0ah
               db  'TabChildProc   PROTO  :DWORD, :DWORD, :DWORD, :DWORD',0dh,0ah,0
szTabCtrlPro1  db  'TabCtrlProc    PROTO  :DWORD, :DWORD, :DWORD, :DWORD',0dh,0ah,0
szTabCtrlPro2  db  'ChgBmpColor    PROTO :DWORD',0dh,0ah,0
szTabCtrlMac2  db  0dh,0ah
               db  ';---------- [Move memory dword macro] ----------',0dh,0ah
               db  'MOVmd    MACRO Var1, Var2',0dh,0ah
               db  '          push     Var2',0dh,0ah
               db  '           pop     Var1',0dh,0ah
               db  '          ENDM',0dh,0ah,0dh,0ah,0

szTabCtrlDat1  db  ';***** [Place in the Application file (.asm)] *****',0dh,0ah
               db  '.data',0dh,0ah
               db  "TabCtrlClass   db  'SysTabControl32',0",0dh,0ah
               db  "StaticClass    db  'static',0",0dh,0ah
               db  "ButtonClass    db  'button',0",0dh,0ah,0dh,0ah
               db  "FontNameMS     db  'MS Sans Serif',0",0dh,0ah,0dh,0ah,0

szTabCtrlDat2  db  '.data?',0dh,0ah
               db  'hTabCtrl       dd  ?',0dh,0ah
               db  'lpTabCtrl      dd  ?',0dh,0ah
               db  'lpTabChild     dd  ?',0dh,0ah
               db  'hTabCtrlDlg    dd  ?',0dh,0ah
               db  'TabSelect      dd  ?',0dh,0ah
               db  'hFontT         dd  ?',0dh,0ah
               db  'hTabSeL        dd  16  dup(?)',0dh,0ah
               db  'hTabBmp        dd  16  dup(?)',0dh,0ah,0dh,0ah
               db  'hImageList     dd  ?',0dh,0ah
               db  'Styles         dd  ?',0dh,0ah
               db  'hBRD           dd  ?',0dh,0ah
               db  'Num            dd  ?',0dh,0ah
               db  'NumTabs        dd  ?',0dh,0ah
               db  'DrawOn         dd  ?',0dh,0ah
               db  'BotOn          dd  ?',0dh,0ah
               db  'ButOn          dd  ?',0dh,0ah
               db  'LeftOn         dd  ?',0dh,0ah
               db  'RightOn        dd  ?',0dh,0ah
               db  'ImageOnlyOn    dd  ?',0dh,0ah
               db  'ImageTextOn    dd  ?',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,0
szTabCtrlLoc   db  'LOCAL    lf:LOGFONT',0dh,0ah
               db  'LOCAL    tci:TC_ITEM',0dh,0ah
               db  'LOCAL    dis:DRAWITEMSTRUCT',0dh,0ah
               db  'LOCAL    hBrush:DWORD, hTemp, Cnt, ID, Incr, hMemDC, TextColor, uFormat',0dh,0ah
               db  'LOCAL    szBuff0[64]:BYTE',0dh,0ah,0dh,0ah,0

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

               db  ';---------- [Create the Tab Control Window] ----------',0dh,0ah
               db  '         INVOKE     CreateWindowEx, ',0
szTabCtrlWnd2  db  ', addr TabCtrlClass, 0,\',0dh,0ah,0

szTabCtrlWnd3  db  '                    ',0
szTabCtrlWnd4  db  ', hwnd, 702, hInst, 0',0dh,0ah
               db  '            mov     hTabCtrl, eax',0dh,0ah,0dh,0ah

               db  '         INVOKE     RtlZeroMemory, addr lf, sizeof lf',0dh,0ah
               db  '         INVOKE     lstrcpy, addr lf.lfFaceName, addr FontNameMS',0dh,0ah
               db  '            mov     lf.lfHeight, -8',0dh,0ah
               db  '            mov     lf.lfWeight, 400',0dh,0ah
               db  '         INVOKE     CreateFontIndirect, addr lf',0dh,0ah
               db  '            mov     hFontT, eax   ; Tab font',0dh,0ah,0dh,0ah,0

szTabWndSub    db  ';---------- [Tab Control window subclassed] ----------',0dh,0ah
               db  '         INVOKE     SetWindowLong, hTabCtrl, GWL_WNDPROC, TabCtrlProc',0dh,0ah
               db  '            mov     lpTabCtrl, eax',0dh,0ah,0dh,0ah,0

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

               db  ';---------- [Load The Bitmaps] ----------',0dh,0ah
               db  '            mov     ID, 901           ; Bitmap ID',0dh,0ah
               db  '            mov     Cnt, NNN',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     ecx, ID',0dh,0ah
               db  '               sub     ecx, 901',0dh,0ah
               db  '               mov     hTabBmp[ecx*4], eax',0dh,0ah
               db  '               mov     hTemp, eax',0dh,0ah
               db  '            INVOKE     ImageList_Add, hImageList, hTemp, NULL',0dh,0ah
               db  '               inc     ID',0dh,0ah
               db  '               dec     Cnt',0dh,0ah
               db  '         .endw',0dh,0ah,0dh,0ah

               db  '         INVOKE     SendMessage, hTabCtrl, TCM_SETIMAGELIST, 0, hImageList',0dh,0ah,0dh,0ah,0

szTabCtrlCre2  db  '         INVOKE     SendMessage, hTabCtrl, WM_SETFONT, hFontT, TRUE',0dh,0ah,0dh,0ah

               db  '         INVOKE     GetWindowLong, hTabCtrl, GWL_STYLE',0dh,0ah
               db  '            mov     Styles, eax',0dh,0ah,0dh,0ah

               db  '         .if (Styles & TCS_OWNERDRAWFIXED)',0dh,0ah
               db  '               mov     DrawOn, 1',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '         .if (Styles & TCS_BUTTONS)',0dh,0ah
               db  '               mov     ButOn, 1',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '         .if (Styles & 2h) && !(Styles & 80h)  ; 2 = TCS_BOTTOM,  80h = TCS_VERTICAL',0dh,0ah
               db  '               mov     BotOn, 1',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '         .if (Styles & 80h) && !(Styles & 2h)  ; 80h = TCS_VERTICAL,  2 = TCS_RIGHT',0dh,0ah
               db  '               mov     LeftOn, 1',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '         .if (Styles & 80h) && (Styles & 2h)',0dh,0ah
               db  '               mov     RightOn, 1',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '            mov     NumTabs, NNN',0dh,0ah
               db  '            mov     ImageTextOn, TTT',0dh,0ah
               db  '            mov     ImageOnlyOn, OOO',0dh,0ah
               db  '           call     DoTabs',0dh,0ah,0dh,0ah,0

szTabNoteTip   db  ';---------- [Get Selchange and Tooltips] ----------',0dh,0ah
               db  '      .elseif wMsg == WM_NOTIFY',0dh,0ah
               db  '            mov     ecx, lParam          ; Get pointer to NMHDR',0dh,0ah
               db  '            mov     eax, (NMHDR ptr [ecx]).code',0dh,0ah
               db  '         .if eax == TCN_SELCHANGE',0dh,0ah
               db  '               mov     eax, TabSelect                   ; Previous selected Tab',0dh,0ah
               db  '               mov     ecx, hTabSeL+[eax*4]             ; Extract previous Tabs handle',0dh,0ah
               db  '            INVOKE     ShowWindow, ecx, SW_HIDE         ; Hide its window',0dh,0ah
               db  '            INVOKE     SendMessage, hTabCtrl, TCM_GETCURSEL, 0, 0  ; New selected Tab',0dh,0ah
               db  '               mov     TabSelect, eax                   ; Save the Tab ID',0dh,0ah
               db  '               mov     ecx, hTabSeL+[eax*4]             ; Extract new Tabs handle',0dh,0ah
               db  '            INVOKE     ShowWindow, ecx, SW_SHOWDEFAULT  ; Show its window',0dh,0ah,0dh,0ah

               db  '         .elseif eax == TTN_NEEDTEXT',0dh,0ah
               db  '               mov     eax, (NMHDR ptr [ecx]).idFrom ; Resource id',0dh,0ah
               db  '               mov     ecx, eax',0dh,0ah
               db  '            INVOKE     LoadString, hInst, ecx, addr szBuff0, lengthof szBuff0',0dh,0ah
               db  '               mov     ecx, lParam                   ; Get the buffer addr',0dh,0ah
               db  '               lea     eax, szBuff0',0dh,0ah
               db  '               mov     (TOOLTIPTEXT ptr [ecx]).lpszText, eax',0dh,0ah
               db  '               mov     eax, FALSE',0dh,0ah
               db  '               ret',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah,0

szTabCtrlDraw  db  ';---------- [Draw the Tab control] ----------',0dh,0ah
               db  '      .elseif wMsg == WM_DRAWITEM',0dh,0ah
               db  '         .if wParam == 702',0dh,0ah
               db  '               mov     esi, lParam',0dh,0ah
               db  '               lea     eax, dis',0dh,0ah
               db  '               mov     edi, eax',0dh,0ah
               db  '               mov     ecx, sizeof dis',0dh,0ah
               db  '               rep     movsb',0dh,0ah
               db  '            .if dis.itemID != -1',0dh,0ah,0dh,0ah

               db  '               .if ImageTextOn || ImageOnlyOn',0dh,0ah
               db  '                     mov     eax, dis.itemID',0dh,0ah
               db  '                     mov     edx, hTabBmp[eax*4]',0dh,0ah
               db  '                     mov     hTemp, edx',0dh,0ah
               db  '                  .if !BotOn || BotOn && ButOn',0dh,0ah
               db  '                        add     dis.rcItem.top, 2',0dh,0ah
               db  '                  .endif',0dh,0ah
               db  '                  .if (dis.itemState & ODS_SELECTED)',0dh,0ah
               db  '                     .if !ButOn',0dh,0ah
               db  '                           add     dis.rcItem.left, 1',0dh,0ah
               db  '                           add     dis.rcItem.top, 2',0dh,0ah
               db  '                     .endif',0dh,0ah
               db  '                  .endif',0dh,0ah
               db  '                  INVOKE     CreateCompatibleDC, dis.hdc ; Create a compat dc in mem',0dh,0ah
               db  '                     mov     hMemDC, eax',0dh,0ah
               db  '                  INVOKE     SelectObject, hMemDC, hTemp ; Select the bitmap into the dc',0dh,0ah
               db  '                  INVOKE     BitBlt, dis.hdc, dis.rcItem.left, dis.rcItem.top,\',0dh,0ah
               db  '                             16, 16, hMemDC, 0, 0, SRCCOPY',0dh,0ah
               db  '                  INVOKE     DeleteDC, hMemDC            ; Delete the memory dc',0dh,0ah
               db  '                     mov     TextColor, 00ff0000h',0dh,0ah
               db  '                  .if !BotOn || BotOn && ButOn',0dh,0ah
               db  '                        sub     dis.rcItem.top, 2',0dh,0ah
               db  '                  .endif',0dh,0ah
               db  '                  .if (dis.itemState & ODS_SELECTED)',0dh,0ah
               db  '                        mov     TextColor, 000000ffh',0dh,0ah
               db  '                     .if !ButOn',0dh,0ah
               db  '                           sub     dis.rcItem.left, 1',0dh,0ah
               db  '                           sub     dis.rcItem.top, 2',0dh,0ah
               db  '                     .endif',0dh,0ah
               db  '                  .endif',0dh,0ah,0dh,0ah

               db  '               .else',0dh,0ah
               db  '                     mov     TextColor, 00ff0000h',0dh,0ah
               db  '                  .if (dis.itemState & ODS_SELECTED)',0dh,0ah
               db  '                        mov     TextColor, 000000ffh',0dh,0ah
               db  '                  .endif',0dh,0ah
               db  '               .endif',0dh,0ah,0dh,0ah

               db  '                  mov     tci.imask, TCIF_TEXT or TCIF_IMAGE',0dh,0ah
               db  '                  lea     eax, szBuff0',0dh,0ah
               db  '                  mov     tci.pszText, eax',0dh,0ah
               db  '                  mov     tci.cchTextMax, 63',0dh,0ah
               db  '               INVOKE     SendMessage, hTabCtrl, TCM_GETITEM, dis.itemID, addr tci',0dh,0ah
               db  '               INVOKE     CreateSolidBrush, 00ffffc0h',0dh,0ah
               db  '                  mov     hBrush, eax',0dh,0ah
               db  '                  mov     uFormat, DT_CENTER or DT_VCENTER or DT_SINGLELINE',0dh,0ah
               db  '               .if ImageTextOn || ImageOnlyOn',0dh,0ah
               db  '                     add     dis.rcItem.left, 17',0dh,0ah
               db  '               .endif',0dh,0ah
               db  '               INVOKE     FillRect, dis.hdc, addr dis.rcItem, eax',0dh,0ah
               db  '               INVOKE     SetTextColor, dis.hdc, TextColor',0dh,0ah
               db  '               INVOKE     SetBkColor, dis.hdc, 00ffffc0h',0dh,0ah
               db  '               .if !ImageOnlyOn',0dh,0ah
               db  '                  INVOKE     DrawText, dis.hdc, tci.pszText, -1, addr dis.rcItem, uFormat',0dh,0ah
               db  '               .endif',0dh,0ah
               db  '               INVOKE     DeleteObject, hBrush',0dh,0ah
               db  '            .endif',0dh,0ah
               db  '               mov     dis.itemState, ODS_DEFAULT',0dh,0ah
               db  '               mov     dis.hdc, 0',0dh,0ah
               db  '         .endif',0dh,0ah,0dh,0ah,0

szTabCtrlDes1  db  ';---------- [Destroy the various resources] ----------',0dh,0ah
               db  '      .elseif wMsg == WM_CLOSE (or) .elseif wMsg == WM_DESTROY',0dh,0ah
               db  '         .if hBRD',0dh,0ah
               db  '            INVOKE     DeleteObject, hBRD',0dh,0ah
               db  '         .endif',0dh,0ah,0
szTabCtrlDes2  db  '            and     Incr, 0',0dh,0ah
               db  '            mov     Cnt, NNN',0dh,0ah
               db  '         .while (Cnt)',0dh,0ah
               db  '               mov     eax, Incr',0dh,0ah
               db  '            INVOKE     DeleteObject, hTabBmp[eax*4]',0dh,0ah
               db  '               inc     Incr',0dh,0ah
               db  '               dec     Cnt',0dh,0ah
               db  '         .endw',0dh,0ah
               db  '         INVOKE     ImageList_Destroy, hImageList',0dh,0ah,0dh,0ah,0
               db  '         .if hBRD',0dh,0ah
               db  '            INVOKE     DeleteObject, hBRD',0dh,0ah
               db  '         .endif',0dh,0ah,0

szTabCtrlSub   db  ';======================================================',0dh,0ah
               db  '; SubClass the Tab child control procedure',0dh,0ah
               db  ';======================================================',0dh,0ah
               db  'TabChildProc PROC hwnd:DWORD, wmsg, wparam, lparam',0dh,0ah
               db  'LOCAL    szBuff1[64]:BYTE',0dh,0ah,0dh,0ah

               db  '      .if wmsg == WM_COMMAND',0dh,0ah
               db  '      mov     eax, wparam',0dh,0ah
               db  '      cwde',0dh,0ah,0dh,0ah

               db  '         .if eax == 2222',0dh,0ah
               db  '               mov     eax, TabSelect',0dh,0ah
               db  '               mov     ecx, TabArray[eax*4]',0dh,0ah
               db  '            INVOKE     lstrcpy, addr szBuff1, ecx',0dh,0ah
               db  '            INVOKE     MessageBox, NULL, addr szBuff1, addr AppName, MB_OK',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '      .endif',0dh,0ah,0dh,0ah

               db  'ThatsAll:',0dh,0ah
               db  '      INVOKE     CallWindowProc, lpTabChild, hwnd, wmsg, wparam, lparam',0dh,0ah,0dh,0ah

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

szTabCtrlItem  db  ';=====================================================',0dh,0ah
               db  '; Insert Tab item PROCEDURE',0dh,0ah
               db  ';=====================================================',0dh,0ah
               db  'DoTabs PROC',0dh,0ah
               db  'LOCAL     rect:RECT',0dh,0ah
               db  'LOCAL     rectI:RECT',0dh,0ah
               db  'LOCAL     tci:TC_ITEM',0dh,0ah
               db  'LOCAL     Cnt:DWORD, TabCnt, Index, hTemp, Pad, RowCnt, xPos, yPos, Wth, Hgt',0dh,0ah
               db  'LOCAL     szBuff1[64]:BYTE',0dh,0ah,0dh,0ah

               db  '         and     Index, 0',0dh,0ah,0dh,0ah
               db  ';---------- [Fill the Tab Control Item structure and insert the item] ----------',0dh,0ah
               db  '         mov     tci.imask, TCIF_TEXT or TCIF_IMAGE ; Mask text & image',0dh,0ah
               db  '         mov     tci.lpReserved1, 0                 ; Reserved',0dh,0ah
               db  '         mov     tci.lpReserved2, 0                 ; Reserved',0dh,0ah
               db  '         mov     tci.pszText, 0',0dh,0ah
               db  '         mov     tci.cchTextMax, 0',0dh,0ah
               db  '      .if !ImageOnlyOn',0dh,0ah
               db  '            mov     tci.pszText, offset szTab01     ; pointer to string with tab text',0dh,0ah
               db  '            mov     tci.cchTextMax, sizeof szTab01  ; Size of szTab01',0dh,0ah
               db  '      .endif',0dh,0ah
               db  '         mov     tci.iImage, -1                     ; No image',0dh,0ah
               db  '      .if ImageTextOn || ImageOnlyOn',0dh,0ah
               db  '            MOVmd     tci.iImage, Index             ; Index to tab controls image',0dh,0ah
               db  '      .endif',0dh,0ah
               db  '         mov     tci.lParam, 0                      ; Extra info',0dh,0ah
               db  '      INVOKE     SendMessage, hTabCtrl, TCM_INSERTITEM, 0, addr tci',0dh,0ah,0dh,0ah

               db  ';---------- [Create the child controls for the Tab control] ----------',0dh,0ah
               db  '       MOVmd     Num, NumTabs',0dh,0ah
               db  '         mov     Index, 1',0dh,0ah
               db  '         dec     Num',0dh,0ah
               db  '      .while (Num)',0dh,0ah
               db  '            mov     eax, Index',0dh,0ah
               db  '            mov     ecx, TabArray[eax*4]',0dh,0ah
               db  '            mov     tci.pszText, 0',0dh,0ah
               db  '            mov     tci.cchTextMax, 0',0dh,0ah
               db  '         .if !ImageOnlyOn',0dh,0ah
               db  '               mov     tci.pszText, ecx',0dh,0ah
               db  '               mov     tci.cchTextMax, 64',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '            mov     tci.iImage, -1                    ; No image',0dh,0ah
               db  '         .if ImageTextOn || ImageOnlyOn',0dh,0ah
               db  '             MOVmd     tci.iImage, Index              ; Set image',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '         INVOKE     SendMessage, hTabCtrl, TCM_INSERTITEM, Index, addr tci',0dh,0ah
               db  '            inc     Index',0dh,0ah
               db  '            dec     Num',0dh,0ah
               db  '      .endw',0dh,0ah,0dh,0ah

               db  '       MOVmd     Num, NumTabs',0dh,0ah
               db  '      INVOKE     SendMessage, hTabCtrl, TCM_GETITEMCOUNT, 0, 0',0dh,0ah
               db  '         mov     ecx, 0',0dh,0ah
               db  '      .if ButOn',0dh,0ah
               db  '            dec     eax',0dh,0ah
               db  '            mov     ecx, eax',0dh,0ah
               db  '      .endif',0dh,0ah
               db  '      INVOKE     SendMessage, hTabCtrl, TCM_GETITEMRECT, ecx, addr rectI',0dh,0ah
               db  '      INVOKE     GetClientRect, hTabCtrl, addr rect',0dh,0ah,0dh,0ah

               db  '      .if !BotOn && !LeftOn && !RightOn',0dh,0ah
               db  '            mov     xPos, 2',0dh,0ah
               db  '          MOVmd     yPos, rectI.bottom',0dh,0ah
               db  '          MOVmd     Wth, rect.right',0dh,0ah
               db  '          MOVmd     Hgt, rect.bottom',0dh,0ah
               db  '            mov     eax, rectI.bottom',0dh,0ah
               db  '            sub     Hgt, eax',0dh,0ah
               db  '            add     yPos, 1',0dh,0ah
               db  '            sub     Wth, 4',0dh,0ah
               db  '            sub     Hgt, 3',0dh,0ah,0dh,0ah

               db  '      .elseif BotOn',0dh,0ah
               db  '            mov     xPos, 2',0dh,0ah
               db  '            mov     yPos, 2',0dh,0ah
               db  '          MOVmd     Wth, rect.right',0dh,0ah
               db  '          MOVmd     Hgt, rectI.top',0dh,0ah
               db  '            sub     Wth, 4',0dh,0ah
               db  '            sub     Hgt, 4',0dh,0ah,0dh,0ah

               db  '      .elseif LeftOn',0dh,0ah
               db  '          MOVmd     xPos, rectI.right',0dh,0ah
               db  '            mov     yPos, 2',0dh,0ah
               db  '          MOVmd     Wth, rect.right',0dh,0ah
               db  '          MOVmd     Hgt, rect.bottom',0dh,0ah
               db  '            mov     eax, rectI.right',0dh,0ah
               db  '            sub     Wth, eax',0dh,0ah
               db  '            add     xPos, 2',0dh,0ah
               db  '            sub     Wth, 4',0dh,0ah
               db  '            sub     Hgt, 4',0dh,0ah,0dh,0ah

               db  '      .elseif RightOn',0dh,0ah
               db  '            mov     xPos, 2',0dh,0ah
               db  '            mov     yPos, 2',0dh,0ah
               db  '          MOVmd     Wth, rectI.left',0dh,0ah
               db  '          MOVmd     Hgt, rect.bottom',0dh,0ah
               db  '            sub     Wth, 4',0dh,0ah
               db  '            sub     Hgt, 4',0dh,0ah
               db  '      .endif',0dh,0ah,0dh,0ah

               db  ';----------------- [Load the Controls in the Tab Controls] --------------------',0dh,0ah
               db  '         mov     TabCnt, 801',0dh,0ah
               db  '         and     Index, 0',0dh,0ah
               db  '         and     TabSelect, 0',0dh,0ah
               db  '      .while (Num)',0dh,0ah,0dh,0ah
               db  ';---------- [Create the Tab static Window] ----------',0dh,0ah
               db  '         INVOKE     CreateWindowEx, NULL, addr StaticClass, NULL,\',0dh,0ah
               db  '                    WS_CHILD or WS_VISIBLE,\',0dh,0ah
               db  '                    xPos, yPos, Wth, Hgt, hTabCtrl, TabCnt, hInst, NULL',0dh,0ah
               db  '            mov     edx, TabSelect                   ; New selected Tab',0dh,0ah
               db  '            mov     hTabSeL+[edx*4], eax             ; Store Tabs handle',0dh,0ah
               db  '            mov     hTemp, eax',0dh,0ah,0dh,0ah

               db  ';---------- [Tab Child Control window subclassed] ----------',0dh,0ah
               db  '         INVOKE     SetWindowLong, hTemp, GWL_WNDPROC, TabChildProc',0dh,0ah
               db  '            mov     lpTabChild, eax',0dh,0ah

               db  '            mov     eax, Index',0dh,0ah
               db  '            mov     ecx, TabArray[eax*4]',0dh,0ah
               db  '         INVOKE     lstrcpy, addr szBuff1, ecx',0dh,0ah,0dh,0ah

               db  '            mov     ecx, Wth',0dh,0ah
               db  '            shr     ecx, 1',0dh,0ah
               db  '            sub     ecx, 45',0dh,0ah
               db  '            mov     edx, Hgt',0dh,0ah
               db  '            shr     edx, 1',0dh,0ah
               db  '            sub     edx, 20',0dh,0ah,0dh,0ah

               db  '         INVOKE     CreateWindowEx, NULL, addr ButtonClass, addr szBuff1,\',0dh,0ah
               db  '                    WS_CHILD or WS_VISIBLE,\',0dh,0ah
               db  '                    ecx, edx, 90, 40, hTemp, 2222, hInst, NULL',0dh,0ah,0dh,0ah
               db  '         INVOKE     ShowWindow, hTemp, SW_HIDE       ; Hide its window',0dh,0ah
               db  '            inc     TabSelect',0dh,0ah
               db  '            inc     TabCnt',0dh,0ah
               db  '            inc     Index',0dh,0ah
               db  '            dec     Num',0dh,0ah
               db  '      .endw',0dh,0ah,0dh,0ah

               db  '         mov     TabSelect, 0',0dh,0ah
               db  '      INVOKE     SendMessage, hTabCtrl, TCM_SETCURSEL, TabSelect, 0',0dh,0ah
               db  '      INVOKE     SendMessage, hTabCtrl, TCM_GETCURSEL, 0, 0  ; New selected Tab',0dh,0ah
               db  '         mov     TabSelect, eax                   ; Save the Tab ID',0dh,0ah
               db  '         mov     ecx, hTabSeL+[eax*4]             ; Extract new Tabs handle',0dh,0ah
               db  '      INVOKE     ShowWindow, ecx, SW_SHOWDEFAULT  ; Show its window',0dh,0ah,0dh,0ah

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

szTabCtrlProc  db  ';======================================================',0dh,0ah
               db  '; SubClass the Tab control procedure',0dh,0ah
               db  ';======================================================',0dh,0ah
               db  'TabCtrlProc PROC hwnd:DWORD, wmsg, wparam, lparam',0dh,0ah
               db  'LOCAL    StacicColor:DWORD',0dh,0ah,0dh,0ah

               db  '      .if wmsg == WM_CTLCOLORSTATIC && DrawOn',0dh,0ah
               db  '            mov     eax, 00ffffe0h',0dh,0ah
               db  '            mov     StacicColor, eax',0dh,0ah
               db  '         INVOKE     SetBkColor, wparam, StacicColor',0dh,0ah
               db  '         INVOKE     SetTextColor, wparam, 00000000h',0dh,0ah
               db  '         .if hBRD',0dh,0ah
               db  '            INVOKE     DeleteObject, hBRD',0dh,0ah
               db  '         .endif',0dh,0ah
               db  '         INVOKE     CreateSolidBrush, StacicColor',0dh,0ah
               db  '            mov     hBRD, eax',0dh,0ah
               db  '            ret',0dh,0ah
               db  '      .endif',0dh,0ah,0dh,0ah

               db  'ThatsAll:',0dh,0ah
               db  '      INVOKE     CallWindowProc, lpTabCtrl, hwnd, wmsg, wparam, lparam',0dh,0ah,0dh,0ah

               db  '         ret',0dh,0ah
               db  'TabCtrlProc ENDP',0dh,0ah,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,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,0dh,0ah

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


szTab          db  'szTab',0
szDB           db  '        db  ',0
szDBEND        db  ',0',0

.data?
hInst          dd  ?
CommandLine    dd  ?
MainExit       dd  ?
hWnd           dd  ?
hREdDll        dd  ?
hREdit         dd  ?
lpRichEdit     dd  ?
lpTabEdit      dd  ?
hImageList     dd  ?
hMenu          dd  ?
hSMenu         dd  ?
hSMenu3        dd  ?
MenuCnt        dd  ?
hFont          dd  ?
hFontD         dd  ?
hTabCtrl       dd  ?
lpTabCtrl      dd  ?
lpTabChild     dd  ?
hTabCtrlDlg    dd  ?
hStat01        dd  ?
hListbox       dd  ?
hEditList      dd  ?

hTabSeL        dd  16  dup(?)
TabSelect      dd  ?

hEdit01        dd  ?
hEdit02        dd  ?
hEdit03        dd  ?
hEdit04        dd  ?
hEdit05        dd  ?
hComb01        dd  ?
hComb02        dd  ?

hDefHeap       dd  ?
hTextOut       dd  ?
hTipOut        dd  ?
hResOut        dd  ?
hBmpOut        dd  ?
hCodeOut       dd  ?
hOutput        dd  ?

hBRD           dd  ?
Num            dd  ?
NumTabs        dd  ?
DrawOn         dd  ?
TipOn          dd  ?
BotOn          dd  ?
ButOn          dd  ?
LeftOn         dd  ?
RightOn        dd  ?
ImageOnlyOn    dd  ?
ImageTextOn    dd  ?
SavSel         dd  ?
hCombo         dd  ?
EXStyles       dd  ?
Styles         dd  ?

Test4          dd  ?

hTabBmp        dd  16  dup(?)
szBuffW        db  64  dup(?)

;---------- [Structures] ----------
mii            MENUITEMINFO   <>

.code

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

        call     InitCommonControls
      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

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

;---------- [Create the Main Window] ----------
      INVOKE     CreateWindowEx, WS_EX_CLIENTEDGE, addr ClassName,\
                 addr AppName, WS_OVERLAPPEDWINDOW,\
                 ebx, eax, 480, 410, NULL, NULL, hInst, NULL
         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, hTabCtrlDlg, 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  hwnd:DWORD, wmsg, wparam, lparam
LOCAL    lf:LOGFONT
LOCAL    tci:TC_ITEM
LOCAL    dis:DRAWITEMSTRUCT
LOCAL    hBrush:DWORD, hTemp, Cnt, ID, Incr, hMemDC, TextColor, uFormat
LOCAL    szBuff0[64]:BYTE

;---------- [Create the Control(s) and one time stuff] ----------
      .if wmsg == WM_CREATE

;---------- [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

         INVOKE     RtlZeroMemory, addr lf, sizeof lf
         INVOKE     lstrcpy, addr lf.lfFaceName, addr FontNameCN
            mov     lf.lfHeight, -12
            mov     lf.lfWeight, 500
         INVOKE     CreateFontIndirect, addr lf
            mov     hFont, eax    ; RichEdit font

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

         INVOKE     SendMessage, hREdit, WM_SETFONT, hFont, TRUE

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

;---------- [Load The Bitmaps] ----------
            mov     ID, 901           ; Bitmap ID start address
            mov     Cnt, 16           ; Number of bitmaps
         .while (Cnt)
            INVOKE     LoadImage, hInst, ID, IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR
            INVOKE     ChgBmpColor, eax
               mov     ecx, ID
               sub     ecx, 901
               mov     hTabBmp[ecx*4], eax
               mov     hTemp, eax
            INVOKE     ImageList_Add, hImageList, hTemp, NULL
;            INVOKE     DeleteObject, hTemp
               inc     ID
               dec     Cnt
         .endw

;---------- [Allocate memory from the default heap] ----------
         INVOKE     HeapAlloc, hDefHeap, 0, 4096
            mov     hTextOut, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 4096
            mov     hTipOut, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 4096
            mov     hResOut, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 4096
            mov     hBmpOut, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 4096
            mov     hCodeOut, eax
         INVOKE     HeapAlloc, hDefHeap, 0, 20000
            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

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

;---------- [Size the Edit Control] ----------
            xor     eax, eax             ; Zero out toolbar height
           push     eax                  ; Save height of toolbar

            xor     eax, eax             ; Zero out statusbar height

            pop     edx                  ; edx = height of toolbar
            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
         INVOKE     MoveWindow, hREdit, 0, edx, ebx, ecx, TRUE

      .elseif wmsg == WM_NOTIFY
            mov     ecx, lparam                         ; lparam is a pointer to a NMHDR Struct
            mov     eax, (NMHDR ptr [ecx]).code         ; Check for TCN_SELCHANGE notify message
         .if eax == TCN_SELCHANGE
               mov     eax, TabSelect                   ; Previous selected Tab
               mov     ecx, hTabSeL+[eax*4]             ; Extract previous Tabs handle
            INVOKE     ShowWindow, ecx, SW_HIDE         ; Hide its window
            INVOKE     SendMessage, hTabCtrl, TCM_GETCURSEL, 0, 0  ; New selected Tab
               mov     TabSelect, eax                   ; Save the Tab ID
               mov     ecx, hTabSeL+[eax*4]             ; Extract new Tabs handle
            INVOKE     ShowWindow, ecx, SW_SHOWDEFAULT  ; Show its window

         .elseif eax == TTN_NEEDTEXT
               mov     eax, (NMHDR ptr [ecx]).idFrom    ; Resource id
            .if hTabCtrlDlg
                  mov     eax, TabTArray[eax*4]

            .else
                  mov     ecx, eax
                  add     ecx, 801
               INVOKE     LoadString, hInst, ecx, addr szBuff0, lengthof szBuff0
                  mov     ecx, lparam                   ; Get the buffer addr
                  lea     eax, szBuff0
            .endif
               mov     (TOOLTIPTEXT ptr [ecx]).lpszText, eax
               jmp     Ret0
         .endif
            jmp     DefWin

      .elseif wmsg == WM_DRAWITEM
         .if wparam == 702
               mov     esi, lparam
               lea     eax, dis
               mov     edi, eax
               mov     ecx, sizeof dis
               rep     movsb
            .if dis.itemID != -1


               .if ImageTextOn || ImageOnlyOn
                     mov     eax, dis.itemID
                     mov     edx, hTabBmp[eax*4]
                     mov     hTemp, edx
                  .if !BotOn || BotOn && ButOn
                     add     dis.rcItem.top, 2
                  .endif
                  .if (dis.itemState & ODS_SELECTED)
                     .if !ButOn
                           add     dis.rcItem.left, 1
                           add     dis.rcItem.top, 2
                     .endif
                  .endif
                  INVOKE     CreateCompatibleDC, dis.hdc ; Create a compatible dc in memory
                     mov     hMemDC, eax
                  INVOKE     SelectObject, hMemDC, hTemp ; Select the opened bitmap into the dc
                  INVOKE     BitBlt, dis.hdc, dis.rcItem.left, dis.rcItem.top, 16, 16, hMemDC, 0, 0, SRCCOPY
                  INVOKE     DeleteDC, hMemDC            ; Delete the memory dc
                     mov     TextColor, 00ff0000h
                  .if !BotOn || BotOn && ButOn
                     sub     dis.rcItem.top, 2
                  .endif
                  .if (dis.itemState & ODS_SELECTED)
                        mov     TextColor, 000000ffh
                     .if !ButOn
                           sub     dis.rcItem.left, 1
                           sub     dis.rcItem.top, 2
                     .endif
                  .endif

               .else
                     mov     TextColor, 00ff0000h
                  .if (dis.itemState & ODS_SELECTED)
                        mov     TextColor, 000000ffh
                  .endif
               .endif


                  mov     tci.imask, TCIF_TEXT or TCIF_IMAGE
                  lea     eax, szBuff0
                  mov     tci.pszText, eax
                  mov     tci.cchTextMax, 63
               INVOKE     SendMessage, hTabCtrl, TCM_GETITEM, dis.itemID, addr tci
               INVOKE     CreateSolidBrush, 00ffffc0h ;00ffff00h
                  mov     hBrush, eax
                  mov     uFormat, DT_CENTER or DT_VCENTER or DT_SINGLELINE
               .if ImageTextOn || ImageOnlyOn
                     add     dis.rcItem.left, 17
               .endif
               INVOKE     FillRect, dis.hdc, addr dis.rcItem, eax
               INVOKE     SetTextColor, dis.hdc, TextColor ;00ff0000h
               INVOKE     SetBkColor, dis.hdc, 00ffffc0h ;00ffff00h
               .if !ImageOnlyOn
                  INVOKE     DrawText, dis.hdc, tci.pszText, -1, addr dis.rcItem, uFormat
               .endif
               INVOKE     DeleteObject, hBrush
            .endif
               mov     dis.itemState, ODS_DEFAULT
               mov     dis.hdc, 0
         .endif

;---------- [System and user commands] ----------
      .elseif wmsg == WM_COMMAND
            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_TABCTRL && !hTabCtrlDlg
            INVOKE     CreateDialogParam, hInst, IDD_DLG01, hwnd, addr TabCtrlDlg, 0
               mov     hTabCtrlDlg, eax

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

         .endif

      .elseif wmsg == WM_CLOSE
            and     Incr, 0
            mov     Cnt, 16
         .while (Cnt)
               mov     eax, Incr
            INVOKE     DeleteObject, hTabBmp[eax*4]
               inc     Incr
               dec     Cnt
         .endw

            and     Incr, 0
            mov     Cnt, 6
         .while (Cnt)
               mov     eax, Incr
               mov     ecx, hTextOut[eax*4]
            INVOKE     HeapFree, hDefHeap, 0, ecx
               inc     Incr
               dec     Cnt
         .endw

         INVOKE     ImageList_Destroy, hImageList
         INVOKE     DestroyWindow, hwnd

      .elseif wmsg == WM_DESTROY
         INVOKE     PostQuitMessage, NULL

      .else

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

Ret0:
         xor    eax, eax
         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

;======================================================
; SubClass the Tab Edit control procedure
;======================================================
TabEditProc PROC  uses ebx edx esi edi hwnd:DWORD, wmsg, wparam, lparam
LOCAL    Index:DWORD
LOCAL    szBuff1[64]

      .if hTabCtrlDlg
         .if wmsg == WM_KEYUP ;&& wparam == 0dh  ; Enter key
            INVOKE     GetDlgItemInt, hTabCtrlDlg, IDC_REDIT05, 0, 0
               mov     NumTabs, eax
            .if !eax
                  mov     NumTabs, 4
            .elseif eax > 16
                  mov     NumTabs, 16
            .endif

            INVOKE     SendMessage, hComb01, CB_RESETCONTENT, 0, 0
            INVOKE     SendMessage, hComb02, CB_RESETCONTENT, 0, 0
              push     NumTabs
               pop     Num
               mov     Index, 0
            .while (Num)
                  mov     eax, Index
                  mov     ecx, TabArray[eax*4]
               INVOKE     lstrcpy, addr szBuff1, ecx
               INVOKE     SendMessage, hComb01, CB_ADDSTRING, 0, addr szBuff1
                  mov     eax, Index
                  mov     ecx, TabTArray[eax*4]
               INVOKE     lstrcpy, addr szBuff1, ecx
               INVOKE     SendMessage, hComb02, CB_ADDSTRING, 0, addr szBuff1
                  inc     Index
                  dec     Num
            .endw
            INVOKE     SendMessage, hComb01, CB_SETCURSEL, 0, 0
            INVOKE     SendMessage, hComb02, CB_SETCURSEL, 0, 0
         .endif
      .endif

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

         ret
TabEditProc ENDP

;======================================================
; SubClass the Tab control procedure
;======================================================
TabCtrlProc PROC hwnd:DWORD, wmsg, wparam, lparam
LOCAL    StacicClr:DWORD

      .if wmsg == WM_CTLCOLORSTATIC && DrawOn
            mov     eax, 00ffffe0h
;            mov     ecx, TabSelect
;           imul     ecx, 20
;            sub     eax, ecx
            mov     StacicClr, eax
         INVOKE     SetBkColor, wparam, StacicClr
         INVOKE     SetTextColor, wparam, 00000000h
         .if hBRD
            INVOKE     DeleteObject, hBRD
         .endif
         INVOKE     CreateSolidBrush, StacicClr
            mov     hBRD, eax
            ret
      .endif

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

         ret
TabCtrlProc ENDP

;======================================================
; SubClass the Tab child control procedure
;======================================================
TabChildProc PROC hwnd:DWORD, wmsg, wparam, lparam
LOCAL    szBuff1[64]:BYTE

      .if wmsg == WM_COMMAND
            mov     eax, wparam
           cwde

         .if eax == 2222
               mov     eax, TabSelect
               mov     ecx, TabArray[eax*4]
            INVOKE     lstrcpy, addr szBuff1, ecx
            INVOKE     MessageBox, NULL, addr szBuff1, addr AppName, MB_OK
         .endif
      .endif

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

         ret
TabChildProc ENDP

;======================================================
; Edit List dialog
;======================================================
EditList PROC   hdlg:DWORD, wmsg, wparam, lparam

      .if wmsg == WM_INITDIALOG
         INVOKE     SetDlgItemText, hdlg, 503, addr szBuffW
         INVOKE     GetDlgItem, hdlg, 503
           push     eax
         INVOKE     SendMessage, eax, EM_SETSEL, 0, -1
            pop     eax
         INVOKE     SetFocus, eax

      .elseif wmsg == WM_COMMAND
         .if wparam == 410      ; Update
            INVOKE     GetDlgItemText, hdlg, 503, addr szBuffW, sizeof szBuffW
            .if !eax
                  jmp     Ret0
            .endif
               mov     eax, hCombo
            .if eax == hComb01
               INVOKE     SendMessage, hComb01, CB_DELETESTRING, SavSel, 0
               INVOKE     SendMessage, hComb01, CB_INSERTSTRING, SavSel, addr szBuffW
               INVOKE     SendMessage, hComb01, CB_SETCURSEL, SavSel, 0
                  mov     eax, SavSel
                  mov     ecx, TabArray[eax*4]
               INVOKE     lstrcpy, ecx, addr szBuffW

            .else
               INVOKE     SendMessage, hComb02, CB_DELETESTRING, SavSel, 0
               INVOKE     SendMessage, hComb02, CB_INSERTSTRING, SavSel, addr szBuffW
               INVOKE     SendMessage, hComb02, CB_SETCURSEL, SavSel, 0
                  mov     eax, SavSel
                  mov     ecx, TabTArray[eax*4]
               INVOKE     lstrcpy, ecx, addr szBuffW
            .endif

               and     hEditList, 0
            INVOKE     EndDialog, hdlg, 0 ;wparam
               mov     eax, TRUE
               ret

         .elseif wparam == IDCANCEL
               jmp     CloseIt
         .endif

      .elseif wmsg == WM_CLOSE

CloseIt:
            and     hEditList, 0
         INVOKE     EndDialog, hdlg, 0 ;wparam
            mov     eax, TRUE
            ret
      .endif

Ret0:
         xor     eax, eax
         ret
EditList ENDP

;======================================================
; Create Tab Control PROCEDURE
;======================================================
TabCtrlDlg PROC uses ebx esi edi hdlg:DWORD, wmsg, wparam, lparam
LOCAL    Cnt:DWORD, Incr, Index, xPos, yPos, Wth, Hgt
LOCAL    szBuff1[64]:BYTE, szBuff2[20]:BYTE, szArray[256]:BYTE

      .if wmsg == WM_INITDIALOG
         INVOKE     GetDlgItem, hdlg, IDC_STATIC01
            mov     hStat01, eax
         INVOKE     SetFocus, hStat01
         INVOKE     GetDlgItem, hdlg, IDC_LISTBOX01
            mov     hListbox, eax
         INVOKE     SendMessage, hListbox, WM_SETFONT, hFontD, TRUE

            lea     eax, offset szDividerE ;szWS01
            mov     Index, eax
            mov     Cnt, 33 ;26
         .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, hListbox, LB_ADDSTRING, 0, addr szBuff1
               mov     ecx, eax
            INVOKE     SendMessage, hListbox, LB_SETITEMDATA, ecx, Styles
               add     Index, 36
               dec     Cnt
         .endw

         INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 7
         INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 8
         INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 13
         INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 23
         INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 26
         INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 28

            and     Index, 0
            mov     Incr, 1
            mov     Cnt, 16
         .while (Cnt)
            INVOKE     lstrcpy, addr szBuff1, addr TabTitle
            INVOKE     wsprintf, addr szBuff2, addr fmat2, Incr
            INVOKE     lstrcat, addr szBuff1, addr szBuff2
               mov     eax, Index
               mov     ecx, TabArray[eax*4]
            INVOKE     lstrcpy, ecx, addr szBuff1

            INVOKE     lstrcpy, addr szBuff1, addr TabTip
            INVOKE     wsprintf, addr szBuff2, addr fmat2, Incr
            INVOKE     lstrcat, addr szBuff1, addr szBuff2
               mov     eax, Index
               mov     ecx, TabTArray[eax*4]
            INVOKE     lstrcpy, ecx, addr szBuff1

               inc     Incr
               inc     Index
               dec     Cnt
         .endw

         INVOKE     CreatePopupMenu
            mov     hSMenu3, eax
            mov     mii.fType, MFT_STRING
            mov     mii.wID, IDM_DIALOG
            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

            and     Index, 0
            mov     Incr, 2009
            mov     Cnt, 5
         .while (Cnt)
            INVOKE     GetDlgItem, hdlg, Incr
               mov     ecx, Index
               mov     hEdit01[ecx*4], eax
               mov     ecx, eax
            INVOKE     SendMessage, ecx, WM_SETFONT, hFontD, TRUE
               inc     Index
               inc     Incr
               dec     Cnt
         .endw

         INVOKE     GetDlgItem, hdlg, IDC_COMBO01
            mov     hComb01, eax
         INVOKE     GetDlgItem, hdlg, IDC_COMBO02
            mov     hComb02, eax
         INVOKE     SendMessage, hComb01, WM_SETFONT, hFontD, TRUE
         INVOKE     SendMessage, hComb01, CB_SETITEMHEIGHT, -1, 13       ; Selection field
         INVOKE     SendMessage, hComb01, CB_SETITEMHEIGHT, 0, 10        ; List items
         INVOKE     SendMessage, hComb02, WM_SETFONT, hFontD, TRUE
         INVOKE     SendMessage, hComb02, CB_SETITEMHEIGHT, -1, 13       ; Selection field
         INVOKE     SendMessage, hComb02, CB_SETITEMHEIGHT, 0, 10        ; List items

         INVOKE     SetDlgItemInt, hdlg, IDC_REDIT01, 0, 0
         INVOKE     SetDlgItemInt, hdlg, IDC_REDIT02, 0, 0
         INVOKE     SetDlgItemInt, hdlg, IDC_REDIT03, 400, 0  ;200
         INVOKE     SetDlgItemInt, hdlg, IDC_REDIT04, 300, 0  ;150
         INVOKE     SetDlgItemInt, hdlg, IDC_REDIT05, 4, 0

         INVOKE     SendMessage, hEdit01, EM_LIMITTEXT, 3, 0 ; Limit text size
         INVOKE     SendMessage, hEdit02, EM_LIMITTEXT, 3, 0
         INVOKE     SendMessage, hEdit03, EM_LIMITTEXT, 3, 0
         INVOKE     SendMessage, hEdit04, EM_LIMITTEXT, 3, 0
         INVOKE     SendMessage, hEdit05, EM_LIMITTEXT, 2, 0

;---------- [Control window subclassed] ----------
         INVOKE     SetWindowLong, hEdit05, GWL_WNDPROC, TabEditProc
            mov     lpTabEdit, eax

         INVOKE     GetDlgItemInt, hTabCtrlDlg, IDC_REDIT05, 0, 0
            mov     NumTabs, eax
         .if !eax
               mov     NumTabs, 4
         .elseif eax > 16
               mov     NumTabs, 16
         .endif

        push     NumTabs
         pop     Num
         mov     Index, 0
      .while (Num)
            mov     eax, Index
            mov     ecx, TabArray[eax*4]
         INVOKE     lstrcpy, addr szBuff1, ecx
         INVOKE     SendMessage, hComb01, CB_ADDSTRING, 0, addr szBuff1
            mov     eax, Index
            mov     ecx, TabTArray[eax*4]
         INVOKE     lstrcpy, addr szBuff1, ecx
         INVOKE     SendMessage, hComb02, CB_ADDSTRING, 0, addr szBuff1
            inc     Index
            dec     Num
      .endw
      INVOKE     SendMessage, hComb01, CB_SETCURSEL, 0, 0
      INVOKE     SendMessage, hComb02, CB_SETCURSEL, 0, 0

      .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_COMMAND
            mov     ecx, lparam
            mov     eax, wparam
            shr     eax, 16

;---------- [Check Listbox selection] ----------
         .if eax == LBN_SELCHANGE && ecx == hListbox
            INVOKE     SendMessage, hListbox, LB_GETCARETINDEX, 0, 0
               mov     SavSel, eax
            INVOKE     SendMessage, hListbox, LB_GETSEL, SavSel, 0
;            INVOKE     SendMessage, hListbox, LB_GETTEXT, SavSel, addr szBuff1
            .if eax && SavSel == 13
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 20
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 25
            .elseif eax && SavSel == 15
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 26
            .elseif eax && SavSel == 17
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 18
               INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 24
            .elseif eax && SavSel == 18
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 17
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 24
            .elseif eax && SavSel == 20
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 13
               INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 25
            .elseif eax && SavSel == 24
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 18
            .elseif eax && SavSel == 25
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 13
            .elseif eax && SavSel == 26
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 15
            .elseif !eax && SavSel == 15
               INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 26
            .elseif !eax && SavSel == 24
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 17
            .elseif !eax && SavSel == 25
               INVOKE     SendMessage, hListbox, LB_SETSEL, 0, 20
            .elseif !eax && SavSel == 26
               INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 15
            .endif

         .elseif eax == CBN_SELCHANGE && ecx == hComb01
               and     SavSel, 0
            INVOKE     SendMessage, hComb01, CB_GETCURSEL, 0, 0
            .if eax != CB_ERR
                  mov     SavSel, eax
               INVOKE     SendMessage, hComb01, CB_GETLBTEXT, SavSel, addr szBuffW
               .if !hEditList
                    MOVmd    hCombo, hComb01
                  INVOKE     DialogBoxParam, hInst, 4401, hWnd, addr EditList, 0
                     mov     hEditList, eax
               .endif
            .endif

         .elseif eax == CBN_SELCHANGE && ecx == hComb02
               and     SavSel, 0
            INVOKE     SendMessage, hComb02, CB_GETCURSEL, 0, 0
            .if eax != CB_ERR
                  mov     SavSel, eax
               INVOKE     SendMessage, hComb02, CB_GETLBTEXT, SavSel, addr szBuffW
               .if !hEditList
                    MOVmd    hCombo, hComb02
                  INVOKE     DialogBoxParam, hInst, 4401, hWnd, addr EditList, 0
                     mov     hEditList, eax
               .endif
            .endif

         .endif

         .if wparam == IDCANCEL
               jmp     CloseIt

;---------- [IDC_CHK01 = Use Images and Text] ----------
         .elseif wparam == IDC_CHK01
            INVOKE     SetFocus, hStat01
               and     ImageTextOn, 0
            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK01
            .if eax
                  mov     ImageTextOn, 1
                  and     ImageOnlyOn, 0
               INVOKE     SendDlgItemMessage, hdlg, IDC_CHK02, BM_SETCHECK, BST_UNCHECKED, 0
            .endif

;---------- [IDC_CHK02 = Use Images only] ----------
         .elseif wparam == IDC_CHK02
            INVOKE     SetFocus, hStat01
               and     ImageOnlyOn, 0
            INVOKE     IsDlgButtonChecked, hdlg, IDC_CHK02
            .if eax
                  mov     ImageOnlyOn, 1
                  and     ImageTextOn, 0
               INVOKE     SendDlgItemMessage, hdlg, IDC_CHK01, BM_SETCHECK, BST_UNCHECKED, 0
            .endif

;---------- [IDC_BUTT01 = Preview] ----------
         .elseif wparam == IDC_BUTT01
            INVOKE     SetFocus, hStat01
            .if hTabCtrl
               INVOKE     DestroyWindow, hTabCtrl
            .endif
            INVOKE     ShowWindow, hREdit, SW_HIDE

            INVOKE     GetDlgItemInt, hTabCtrlDlg, IDC_REDIT01, 0, 0
               mov     xPos, eax
            INVOKE     GetDlgItemInt, hTabCtrlDlg, IDC_REDIT02, 0, 0
               mov     yPos, eax
            INVOKE     GetDlgItemInt, hTabCtrlDlg, IDC_REDIT03, 0, 0
               mov     Wth, eax
            .if !eax
                  jmp     DoError
            .endif
            INVOKE     GetDlgItemInt, hTabCtrlDlg, IDC_REDIT04, 0, 0
               mov     Hgt, eax
            .if !eax
                  jmp     DoError
            .endif

              call     GetStyles
              call     SetCode

;---------- [Create the Tab control] ----------
            INVOKE     CreateWindowEx, EXStyles, addr TabCtrlClass, NULL,\
                       Styles,\
                       xPos, yPos, Wth, Hgt, hWnd, 702, hInst, NULL
               mov     hTabCtrl, eax

;---------- [Tab Control window subclassed] ----------
            INVOKE     SetWindowLong, hTabCtrl, GWL_WNDPROC, TabCtrlProc
               mov     lpTabCtrl, eax

            INVOKE     SendMessage, hTabCtrl, TCM_SETIMAGELIST, 0, hImageList

            INVOKE     SendMessage, hTabCtrl, WM_SETFONT, hFontD, TRUE
              call     DoTabs

            INVOKE     ShowWindow, hTabCtrlDlg, SW_HIDE
               mov     eax, offset szMenu2
               mov     mii.dwTypeData, eax
            INVOKE     SetMenuItemInfo, hMenu, 2, TRUE, addr mii
            INVOKE     DrawMenuBar, hWnd

         .elseif wparam == IDC_BUTT02
            INVOKE     SetFocus, hStat01
              call     Extract
         .endif
      .endif
         jmp     DlgDone

DoError:
;Do error message
         jmp     DlgDone

CloseIt:
      INVOKE     DeleteMenu, hMenu, 2, MF_BYPOSITION
      INVOKE     DrawMenuBar, hWnd
      .if hBRD
         INVOKE     DeleteObject, hBRD
            and     hBRD, 0
      .endif
      INVOKE     DestroyWindow, hTabCtrl
      INVOKE     ShowWindow, hREdit, SW_SHOW ;DEFAULT
      INVOKE     EndDialog, hdlg, wparam
         and     hTabCtrlDlg, 0
         mov     eax, TRUE
         jmp     DlgRet

DlgDone:
         mov     eax, FALSE

DlgRet:
         ret
TabCtrlDlg ENDP

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

      INVOKE     SendMessage, hListbox, LB_GETSELCOUNT, 0, 0
      .if !eax
         INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 0
         INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 1
            mov     eax, 2
      .endif
         mov     ecx, eax
      INVOKE     SendMessage, hListbox, LB_GETSELITEMS, ecx, addr szArray
         and     EXStyles, 0
         and     Styles, 0
         and     Index, 0
         mov     Cnt, eax
      .while (Cnt)
            mov     ecx, Index
         INVOKE     SendMessage, hListbox, 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, hListbox, LB_GETITEMDATA, dword ptr szArray[ecx*4], 0
                   or     EXStyles, eax

            .else
               INVOKE     SendMessage, hListbox, LB_GETITEMDATA, dword ptr szArray[ecx*4], 0
                   or     Styles, eax
            .endif
         .endif
            inc     Index
            dec     Cnt
      .endw

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

         ret
GetStyles ENDP

;=====================================================
; Set code PROCEDURE
;=====================================================
SetCode PROC

         and     DrawOn, 0
         and     TipOn, 0
         and     BotOn, 0
         and     ButOn, 0
         and     LeftOn, 0
         and     RightOn, 0

      .if (Styles & TCS_OWNERDRAWFIXED)
            mov     DrawOn, 1
      .endif
      .if (Styles & TCS_BUTTONS)
            mov     ButOn, 1
      .endif
      .if (Styles & TCS_TOOLTIPS)
            mov     TipOn, 1
      .endif
      .if (Styles & 2h) && !(Styles & 80h)  ; 2 = TCS_BOTTOM,  80h = TCS_VERTICAL
            mov     BotOn, 1
      .endif
      .if (Styles & 80h) && !(Styles & 2h)  ; 80h = TCS_VERTICAL,  2 = TCS_RIGHT
            mov     LeftOn, 1
      .endif
      .if (Styles & 80h) && (Styles & 2h)
            mov     RightOn, 1
      .endif

         ret
SetCode ENDP

;=====================================================
; Insert Tab item PROCEDURE
;=====================================================
DoTabs PROC
LOCAL     rect:RECT
LOCAL     rectI:RECT
LOCAL     tci:TC_ITEM
LOCAL     Cnt:DWORD, TabCnt, Index, hTemp, Pad, RowCnt, xPos, yPos, Wth, Hgt
LOCAL     szBuff1[64]:BYTE

         and     Index, 0
;---------- [Fill the Tab Control Item structure and insert the item] ----------
         mov     tci.imask, TCIF_TEXT or TCIF_IMAGE ; Mask text & image 
         mov     tci.lpReserved1, 0                 ; Reserved
         mov     tci.lpReserved2, 0                 ; Reserved
         mov     tci.pszText, 0
         mov     tci.cchTextMax, 0
      .if !ImageOnlyOn
            mov     tci.pszText, offset szTab01     ; pointer to string containing tab text 
            mov     tci.cchTextMax, sizeof szTab01  ; Size of szTab01
      .endif
         mov     tci.iImage, -1                     ; No image
      .if ImageTextOn || ImageOnlyOn
          MOVmd     tci.iImage, Index               ; Index to tab control's image
      .endif
         mov     tci.lParam, 0                      ; Extra info
      INVOKE     SendMessage, hTabCtrl, TCM_INSERTITEM, 0, addr tci

;---------- [Create the child controls for the Tab control] ----------
       MOVmd     Num, NumTabs
         mov     Index, 1
         dec     Num
      .while (Num)
            mov     eax, Index
            mov     ecx, TabArray[eax*4]
            mov     tci.pszText, 0
            mov     tci.cchTextMax, 0
         .if !ImageOnlyOn
               mov     tci.pszText, ecx
               mov     tci.cchTextMax, 64
         .endif
            mov     tci.iImage, -1                    ; No image
         .if ImageTextOn || ImageOnlyOn
             MOVmd     tci.iImage, Index              ; Set image
         .endif
         INVOKE     SendMessage, hTabCtrl, TCM_INSERTITEM, Index, addr tci
            inc     Index
            dec     Num
      .endw
       MOVmd     Num, NumTabs

      INVOKE     SendMessage, hTabCtrl, TCM_GETITEMCOUNT, 0, 0
         mov     ecx, 0
      .if ButOn
            dec     eax
            mov     ecx, eax
      .endif
      INVOKE     SendMessage, hTabCtrl, TCM_GETITEMRECT, ecx, addr rectI
      INVOKE     GetClientRect, hTabCtrl, addr rect

      .if !BotOn && !LeftOn && !RightOn
            mov     xPos, 2
          MOVmd     yPos, rectI.bottom
          MOVmd     Wth, rect.right
          MOVmd     Hgt, rect.bottom
            mov     eax, rectI.bottom
            sub     Hgt, eax
            add     yPos, 1
            sub     Wth, 4
            sub     Hgt, 3

      .elseif BotOn
            mov     xPos, 2
            mov     yPos, 2
          MOVmd     Wth, rect.right
          MOVmd     Hgt, rectI.top
            sub     Wth, 4
            sub     Hgt, 4

      .elseif LeftOn
          MOVmd     xPos, rectI.right
            mov     yPos, 2
          MOVmd     Wth, rect.right
          MOVmd     Hgt, rect.bottom
            mov     eax, rectI.right
            sub     Wth, eax
            add     xPos, 2
            sub     Wth, 4
            sub     Hgt, 4

      .elseif RightOn
            mov     xPos, 2
            mov     yPos, 2
          MOVmd     Wth, rectI.left
          MOVmd     Hgt, rect.bottom
            sub     Wth, 4
            sub     Hgt, 4
      .endif

;----------------- [Load the Controls in the Tab Controls] --------------------
         mov     TabCnt, 801
         and     Index, 0
         and     TabSelect, 0
      .while (Num)
;---------- [Create the Tab static Window] ----------
         INVOKE     CreateWindowEx, NULL, addr StaticClass, NULL,\
                    WS_CHILD or WS_VISIBLE,\
                    xPos, yPos, Wth, Hgt, hTabCtrl, TabCnt, hInst, NULL
            mov     edx, TabSelect                   ; Previous selected Tab
            mov     hTabSeL+[edx*4], eax             ; Extract previous Tabs handle
            mov     hTemp, eax

;---------- [Tab Child Control window subclassed] ----------
         INVOKE     SetWindowLong, hTemp, GWL_WNDPROC, TabChildProc
            mov     lpTabChild, eax

            mov     eax, Index
            mov     ecx, TabArray[eax*4]
         INVOKE     lstrcpy, addr szBuff1, ecx

            mov     ecx, Wth
            shr     ecx, 1
            sub     ecx, 60
            mov     edx, Hgt
            shr     edx, 1
            sub     edx, 20

         INVOKE     CreateWindowEx, NULL, addr ButtonClass, addr szBuff1,\
                    WS_CHILD or WS_VISIBLE,\
                    ecx, edx, 120, 40, hTemp, 2222, hInst, NULL
         INVOKE     ShowWindow, hTemp, SW_HIDE       ; Hide its window
            inc     TabSelect
            inc     TabCnt
            inc     Index
            dec     Num
      .endw

            mov     TabSelect, 0
         INVOKE     SendMessage, hTabCtrl, TCM_SETCURSEL, TabSelect, 0
         INVOKE     SendMessage, hTabCtrl, TCM_GETCURSEL, 0, 0  ; New selected Tab
            mov     TabSelect, eax                   ; Save the Tab ID
            mov     ecx, hTabSeL+[eax*4]             ; Extract new Tabs handle
         INVOKE     ShowWindow, ecx, SW_SHOWDEFAULT  ; Show its window

         ret
DoTabs 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

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

      INVOKE     CreateCompatibleDC, NULL
         mov     mDC, eax
      INVOKE     SelectObject, mDC, hBitmap
         mov     hOldBmp, eax
      INVOKE     GetSysColor, COLOR_BTNFACE
      INVOKE     CreateSolidBrush, eax
         mov     hBrush, eax
      INVOKE     SelectObject, mDC, hBrush
         mov     hOldBrush, eax
         mov     Fill, 00c0c0c0h
      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

;======================================================
; 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, 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, 3
         INVOKE     SendMessage, hREdit, EM_EXSETSEL, 0, addr cr
         INVOKE     SendMessage, hREdit, EM_REPLACESEL, TRUE, lpReplace
            jmp     FindNext
      .endif

         ret
FindRep ENDP

;======================================================
; Extract Tab control information PROCEDURE
;======================================================
Extract PROC uses ebx esi edi
LOCAL    xPos:DWORD, yPos, Wth, Hgt, TabNum
LOCAL    Cnt:DWORD, Cnt1, Index
LOCAL    szWork[64]:BYTE, szEXStyles[256]:BYTE, szStyles[512]:BYTE
LOCAL    szBuff0[256]:BYTE, szBuff1[64]:BYTE, szBuff2[20]:BYTE, szArray[256]:BYTE
LOCAL    szRoot[256]:BYTE, szResStr[256]:BYTE, szTabStr[512]:BYTE

         mov     eax, hTextOut
         mov     byte ptr[eax], 0
         mov     eax, hTipOut
         mov     byte ptr[eax], 0
         mov     eax, hResOut
         mov     byte ptr[eax], 0
         mov     eax, hBmpOut
         mov     byte ptr[eax], 0
         mov     eax, hCodeOut
         mov     byte ptr[eax], 0
         mov     eax, hOutput
         mov     byte ptr[eax], 0
         mov     byte ptr szEXStyles, 0
         mov     byte ptr szStyles, 0
         mov     byte ptr szWork, 0

;---------- [Get the current dir] ----------
      INVOKE     GetCurrentDirectory, lengthof szRoot, addr szRoot
      INVOKE     lstrcat, addr szRoot, addr szSlashB
      INVOKE     lstrcpy, addr szStyles, addr szClear
      INVOKE     GetDlgItemInt, hTabCtrlDlg, IDC_REDIT01, 0, 0
         mov     xPos, eax
      INVOKE     GetDlgItemInt, hTabCtrlDlg, IDC_REDIT02, 0, 0
         mov     yPos, eax
      INVOKE     GetDlgItemInt, hTabCtrlDlg, IDC_REDIT03, 0, 0
         mov     Wth, eax
      .if !eax
            mov     Wth, 350
      .endif
      INVOKE     GetDlgItemInt, hTabCtrlDlg, IDC_REDIT04, 0, 0
         mov     Hgt, eax
      .if !eax
            mov     Hgt, 250
      .endif
      INVOKE     GetDlgItemInt, hTabCtrlDlg, IDC_REDIT05, 0, 0
         mov     TabNum, eax
      .if !eax
            mov     TabNum, 4
      .endif

         and     ImageTextOn, 0
      INVOKE     IsDlgButtonChecked, hTabCtrlDlg, IDC_CHK01
      .if eax
            mov     ImageTextOn, 1
      .endif
         and     ImageOnlyOn, 0
      INVOKE     IsDlgButtonChecked, hTabCtrlDlg, IDC_CHK02
      .if eax
            mov     ImageOnlyOn, 1
      .endif
        call     GetStyles
        call     SetCode

      INVOKE     wsprintf, addr szBuff2, addr fmat1, xPos
      INVOKE     lstrcat, addr szWork, addr szBuff2
      INVOKE     lstrcat, addr szWork, addr szComma
      INVOKE     lstrcat, addr szWork, addr szSpace
      INVOKE     wsprintf, addr szBuff2, addr fmat1, yPos
      INVOKE     lstrcat, addr szWork, addr szBuff2
      INVOKE     lstrcat, addr szWork, addr szComma
      INVOKE     lstrcat, addr szWork, addr szSpace
      INVOKE     wsprintf, addr szBuff2, addr fmat1, Wth
      INVOKE     lstrcat, addr szWork, addr szBuff2
      INVOKE     lstrcat, addr szWork, addr szComma
      INVOKE     lstrcat, addr szWork, addr szSpace
      INVOKE     wsprintf, addr szBuff2, addr fmat1, Hgt
      INVOKE     lstrcat, addr szWork, addr szBuff2
      INVOKE     lstrcpy, addr szTabStr, addr szTabArray

;---------- [Extract the Extended, Window, and Control styles] ----------
      INVOKE     SendMessage, hListbox, LB_GETSELCOUNT, 0, 0
      .if !eax
         INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 0
         INVOKE     SendMessage, hListbox, LB_SETSEL, 1, 1
            mov     eax, 2
      .endif
         mov     ecx, eax
      INVOKE     SendMessage, hListbox, LB_GETSELITEMS, ecx, addr szArray
         and     Index, 0
         and     Cnt1, 0
         mov     Cnt, eax
      .while (Cnt)
            mov     ecx, Index
         INVOKE     SendMessage, hListbox, 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_'
               .if byte ptr szEXStyles != 0
                  INVOKE     lstrcat, addr szEXStyles, addr szOR
               .endif
               INVOKE     lstrcat, addr szEXStyles, addr szBuff1

            .else
               .if Cnt1 != 0
                  INVOKE     lstrcat, addr szStyles, addr szOR
                  .if Cnt1 == 4 || Cnt1 == 8 || Cnt1 == 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 szBuff1
                  inc     Cnt1
            .endif
         .endif
            inc     Index
            dec     Cnt
      .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

;---------- [Extract the Bitmap resources] ----------
         mov     Cnt, 901
         mov     Index, 0
       MOVmd     Num, NumTabs
      .while (Num)
            mov     eax, Index
            mov     ecx, BmpArray[eax*4]
         INVOKE     lstrcpy, addr szBuff1, ecx
         INVOKE     wsprintf, addr szBuff2, addr fmat2, Cnt
         INVOKE     lstrcat, hBmpOut, addr szBuff2
         INVOKE     lstrcat, hBmpOut, addr szResr1

         INVOKE     lstrcpy, addr szBuff0, addr szRoot
         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     lstrcat, hBmpOut, addr szResStr
         INVOKE     lstrcat, hBmpOut, addr szBuff1
         INVOKE     lstrcat, hBmpOut, addr szQuote
         INVOKE     lstrcat, hBmpOut, addr szCRLF
            inc     Cnt
            inc     Index
            dec     Num
      .endw

;---------- [Extract the Tab text and tooltips] ----------
      INVOKE     lstrcat, hTipOut, addr szTabCtrlTip
         mov     Cnt, 1
         mov     Cnt1, 801
         mov     Index, 0
       MOVmd     Num, NumTabs
      .while (Num)
            mov     eax, Index
            mov     ecx, TabArray[eax*4]
         INVOKE     lstrcpy, addr szBuff1, ecx
         INVOKE     lstrcat, hTextOut, addr szTab
         .if Index == 4 || Index == 8 || Index == 12
            INVOKE     lstrcat, addr szTabStr, addr szCRLF
            INVOKE     lstrcat, addr szTabStr, addr szTabArrayC
         .elseif Index
            INVOKE     lstrcat, addr szTabStr, addr szComma
         .endif
         INVOKE     lstrcat, addr szTabStr, addr szTab
         INVOKE     wsprintf, addr szBuff2, addr fmat2, Cnt
         INVOKE     lstrcat, hTextOut, addr szBuff2
         INVOKE     lstrcat, addr szTabStr, addr szBuff2
         INVOKE     lstrcat, hTextOut, addr szDB
         INVOKE     lstrcat, hTextOut, addr szQuoteS
         INVOKE     lstrcat, hTextOut, addr szBuff1
         INVOKE     lstrcat, hTextOut, addr szQuoteS
         INVOKE     lstrcat, hTextOut, addr szDBEND
         INVOKE     lstrcat, hTextOut, addr szCRLF

            mov     eax, Index
            mov     ecx, TabTArray[eax*4]
         INVOKE     lstrcpy, addr szBuff1, ecx
         INVOKE     wsprintf, addr szBuff2, addr fmat2, Cnt1
         INVOKE     lstrcat, hTipOut, addr szClear+16
         INVOKE     lstrcat, hTipOut, addr szBuff2
         INVOKE     lstrcat, hTipOut, addr szClear+15
         INVOKE     lstrcat, hTipOut, addr szQuote
         INVOKE     lstrcat, hTipOut, addr szBuff1
         INVOKE     lstrcat, hTipOut, addr szQuote
         INVOKE     lstrcat, hTipOut, addr szCRLF
            inc     Cnt
            inc     Cnt1
            inc     Index
            dec     Num
      .endw

;---------- [Build the output] ----------
      .if ImageTextOn || ImageOnlyOn || TipOn
         INVOKE     lstrcat, hOutput, addr szTabCtrlRes
         .if ImageTextOn || ImageOnlyOn
            INVOKE     lstrcat, hOutput, hBmpOut
;            INVOKE     lstrcat, hOutput, addr szCRLF
         .endif
         .if TipOn
            INVOKE     lstrcat, hOutput, addr szCRLF
            INVOKE     lstrcat, hOutput, hTipOut
            INVOKE     lstrcat, hOutput, addr szEndTip
         .endif
         INVOKE     lstrcat, hOutput, addr szEnd
      .endif
      INVOKE     lstrcat, hOutput, addr szCRLF
      INVOKE     lstrcat, hOutput, addr szTabCtrlMac1
      .if DrawOn
         INVOKE     lstrcat, hOutput, addr szTabCtrlPro1
      .endif
      .if ImageTextOn || ImageOnlyOn
         INVOKE     lstrcat, hOutput, addr szTabCtrlPro2
      .endif
      INVOKE     lstrcat, hOutput, addr szTabCtrlMac2
      INVOKE     lstrcat, hOutput, addr szTabCtrlDat1
      INVOKE     lstrcat, hOutput, hTextOut
      INVOKE     lstrcat, hOutput, addr szTabStr
      INVOKE     lstrcat, hOutput, addr szCRLF
      INVOKE     lstrcat, hOutput, addr szCRLF
      INVOKE     lstrcat, hOutput, addr szTabCtrlDat2
      INVOKE     lstrcat, hOutput, addr szWinProc
      INVOKE     lstrcat, hOutput, addr szTabCtrlLoc
      INVOKE     lstrcat, hOutput, addr szTabCtrlWnd1
      INVOKE     lstrcat, hOutput, addr szEXStyles
      INVOKE     lstrcat, hOutput, addr szTabCtrlWnd2
      INVOKE     lstrcat, hOutput, addr szStyles
      INVOKE     lstrcat, hOutput, addr szTabCtrlWnd3
      INVOKE     lstrcat, hOutput, addr szWork
      INVOKE     lstrcat, hOutput, addr szTabCtrlWnd4
      .if DrawOn
         INVOKE     lstrcat, hOutput, addr szTabWndSub
      .endif
      .if ImageTextOn || ImageOnlyOn
         INVOKE     lstrcat, hOutput, addr szTabCtrlCre1
      .endif
      INVOKE     lstrcat, hOutput, addr szTabCtrlCre2
      INVOKE     lstrcat, hOutput, addr szTabNoteTip
      .if DrawOn
         INVOKE     lstrcat, hOutput, addr szTabCtrlDraw
      .endif
      INVOKE     lstrcat, hOutput, addr szTabCtrlDes1
      .if ImageTextOn || ImageOnlyOn
         INVOKE     lstrcat, hOutput, addr szTabCtrlDes2
      .endif
      INVOKE     lstrcat, hOutput, addr szTabCtrlSub
      INVOKE     lstrcat, hOutput, addr szTabCtrlItem
      .if DrawOn
         INVOKE     lstrcat, hOutput, addr szTabCtrlProc
      .endif
      .if ImageTextOn || ImageOnlyOn
         INVOKE     lstrcat, hOutput, addr szChgBmpColor
      .endif
      INVOKE     LockWindowUpdate, hREdit
      INVOKE     SendMessage, hREdit, WM_SETTEXT, 0, hOutput
      INVOKE     wsprintf, addr szWork, addr fmat1, TabNum
      INVOKE     FindRep, addr szNN, addr szWork
      INVOKE     wsprintf, addr szWork, addr fmat1, ImageTextOn
      INVOKE     FindRep, addr szTT, addr szWork
      INVOKE     wsprintf, addr szWork, addr fmat1, ImageOnlyOn
      INVOKE     FindRep, addr szOO, addr szWork
      INVOKE     ShowWindow, hTabCtrlDlg, SW_HIDE
         mov     eax, offset szMenu2
         mov     mii.dwTypeData, eax
      INVOKE     SetMenuItemInfo, hMenu, 2, TRUE, addr mii
      INVOKE     DrawMenuBar, hWnd
      INVOKE     ShowWindow, hREdit, SW_SHOW
      INVOKE     SendMessage, hREdit, EM_SETSEL, 0, 0
      INVOKE     LockWindowUpdate, 0

ExtractDone:
         ret
Extract ENDP

end start
