This is a GUI module of EuroTool program EuroConv for Windows.
EUROASM CPU=X64, SIMD=yes, Unicode=no
convwing PROGRAM Format=COFF, Width=64, MaxExpansions=120K,
%DROPMACRO *
INCLUDE1 winansi.htm, fastcall.htm, winabi.htm, winsgui.htm, winsdlg.htm
INCLUDE1 winsfile.htm, winf64.htm, memory64.htm, string64.htm,
INCLUDE1 cpuext.htm, cpuext64.htm, status32.htm,
INCLUDEHEAD argument.htm
LINK ../objlib/winapi.lib
%ControlList %SET \ List of nonstatic and moveable controls:
Iframe, \
IFbtn, \ idIFbtn=0x8002
IFedit, \
HStitle,\
HLtitle,\
FStitle,\
FLtitle,\
HSedit,\
HLedit,\
FSedit,\
FLedit,\
ADbtn, \ idADbtn=0x800C
IEcomb,\
HEIrad,\ idHEIrad=0x800E
HENrad,\ idHENrad=0x800F
HECrad,\ idHECrad=0x8010
Oframe,\
OFbtn, \ idOFbtn=0x8012
OFedit,\
BOMchk,\ idBOMchk=0x8014
ANSIbtn,\ idANSIbtn=0x8015
OEMbtn,\ idOEMbtn=0x8016
OEcomb,\
ICTrad,\ idICTrad=0x8018
ICCrad,\ idICCrad=0x8019
ICQrad,\ idICQrad=0x801A
ICOrad,\ idICOrad=0x801B
EXITbtn,\ idEXITbtn=0x801C
CONVERTbtn,\idCONVERTbtn=0x801D
; Identifiers of nonstatic controls:
%cid %SETA WM_APP
ctrl %FOR %ControlList
%cid %SETA %cid+1
id%ctrl:: EQU %cid
%ENDFOR ctrl
[.bss]
; Handles of nonstatic and moveable controls:
hMainWindow D QWORD
ctrl %FOR %ControlList
h%ctrl D QWORD
%ENDFOR ctrl
[.data] ; Variable data depending on window size.
OptimalWidth = 740
MinimalWidth = 640
MinimalHeight = 840
WindowWidth D DWORD OptimalWidth
WindowHeight D DWORD MinimalHeight
xFrame EQU 10 ; X-coordinates:
xEdit EQU 20
xTitleLong EQU 40
xTitle EQU 140
xRadio EQU 60
xBtn DD 720
xBtn2 DD 660
xBtn3 DD 600
xTitle1of4 DD 100
xTitle2of4 DD 200
xTitle3of4 DD 300
xTitle4of4 DD 400
xEdit1of4 DD 100
xEdit2of4 DD 200
xEdit3of4 DD 300
xEdit4of4 DD 400
yFrameI EQU 44 ; Y-coordinates:
yBtnIF EQU 56
yTitleIF EQU 62
yEditIF EQU 82
yTitleNum EQU 120
yEditNum EQU 138
yBtnAuto EQU 168
yTitleIE EQU 172
yEditIE EQU 193
yTitleEnt EQU 308
yHEI EQU 328
yHEN EQU 348
yHEC EQU 368
yFrameO EQU 424
yBtnOF EQU 436
yTitleOF EQU 442
yEditOF EQU 462
yBtnEnc EQU 490
yTitleOE EQU 495
yEditOE EQU 517
yTitleInv EQU 630
yICT EQU 650
yICC EQU 670
yICQ EQU 690
yICO EQU 710
yBtnConv EQU 760
wiFrame DD 720 ; Widths:
wiEdit DD 708
wiBtn EQU 80
wiTitleLong EQU 400
wiTitleNum EQU 140
wiEditNum EQU 66
heBtn EQU 22 ; Heights:
heTitle EQU 18
heEdit EQU 20
heEnc EQU 100
heFrameI EQU 360
heFrameO EQU 324
[.bss] ; Variable data.
Msg DS MSG ; Window message.
WndClassEx DS WNDCLASSEX ; Definition of the window class structure.
InpFileDlg DS OPENFILENAME
OutFileDlg DS OPENFILENAME
RectMainWindow DS RECT
; GUI-maintained arguments in text form, UTF-16.
GuiInputFile D MAX_PATH_SIZE * U
GuiOutputFile D MAX_PATH_SIZE * U
; GUI-maintained arguments in decimal text form, UTF-8.
GuiHeaderSize D 20*B
GuiHeaderLength D 20*B
GuiFooterSize D 20*B
GuiFooterLength D 20*B
[.text]
MainGui:: PROC
CALL WndCreate ; Initialize the main program window.
CALL Arg2Gui
WinABI ShowWindow,[hMainWindow],SW_SHOW
WinABI UpdateWindow,[hMainWindow]
.MsgLoop:
WinABI GetMessage, Msg,0,0,0
TEST RAX
JZ .MsgQuit: ; ZF signalizes message WM_QUIT - request for program termination.
WinABI IsDialogMessage,[hMainWindow],Msg
TEST RAX
JNZ .MsgLoop:
WinABI TranslateMessage, Msg ; Remap character keys from national keyboards.
WinABI DispatchMessage, Msg ; Let Windows call our WndProc.
JMP .MsgLoop: ; Wait for another message.
.MsgQuit:
RET ; Return to CUI module.
ENDP MainGui
[%hWnd], [%uMsg], [%wParam], [%lParam]), too, in the entire WndProc body.
Messages obtained from Windows are dispatched by WndProc to their handlers.
Unhandled messages are passed to DefWindowProc.
WndProc:: Procedure hWnd, uMsg, wParam, lParam ; These parameters are provided in RCX,RDX,R8,R9.
SaveToShadow
Uses RBX,RBP,RSI,RDI,R12,R13,R14,R15 ; It's only necessary if some of callee-save registers was used in this fastcalled procedure.
; Fork message uMsg=RDX to its handler using macro Dispatch:
Dispatch EDX,WM_SIZE, WM_DESTROY, WM_KEYDOWN, WM_SYSKEYDOWN, WM_COMMAND
.Def:WinABI DefWindowProc,[%hWnd],[%uMsg],[%wParam],[%lParam] ; Pass ignored event to DefWindowProc with unchanged arguments.
JMP .Ret: ; Go to EndProcedure with result value RAX as returned from DefWindowProc.
; All message handlers terminate with a jump to label .Def: or .Ret0:.
.WM_SIZE:
CALL WndResize
JMP .Def:
.WM_KEYDOWN: ; Non-character hot key R8D=wParam was pressed.
Dispatch R8D, VK_ESCAPE,'S','A','L','B','X','C','1','2','3','5','6','7','8'
JMP .Def: ; Pass unhandled keys to WinABI DefWindowProc.
.WM_SYSKEYDOWN: ; A key pressed together with Alt.
Dispatch R8D,'S','A','L','B','X','C'
JMP .Def: ; Pass unhandled keys to WinABI DefWindowProc.
.WM_COMMAND:: ; Window element Id=R8W was activated.
MOVZX EAX,R8W
Dispatch AX,idIFbtn,idADbtn,idOFbtn,idANSIbtn,idOEMbtn,idEXITbtn,idCONVERTbtn, \
idHEIrad,idHENrad,idHECrad,idICTrad,idICCrad,idICQrad,idICOrad
JMP .Def: ; Pass unhandled keys to WinABI DefWindowProc.
.S:
.idIFbtn: ; Hotkey or button &Select input file pressed.
WinABI GetOpenFileNameW,InpFileDlg
MOV RSI,[InpFileDlg.lpstrFile]
GetLength$ RSI, Unicode=yes
SHR ECX,1
LEA RDI,[GuiInputFile]
MOV RDX,RDI
REP MOVSW
WinABI SetWindowTextW,[hIFedit],RDX
JMP .Ret0
.A: ; Hotkey &Autoexec pressed.
.idADbtn:
CALL Gui2Arg
MOVD [ArgInputEncoding::],0
CALL AutoPrologue::
CALL Arg2Gui
JMP .Ret0:
.L:
.idOFbtn: ; Hotkey or button Se&lect output file pressed.
WinABI GetSaveFileNameW,OutFileDlg
MOV RSI,[OutFileDlg.lpstrFile]
GetLength$ RSI, Unicode=yes
SHR ECX,1
LEA RDI,[GuiOutputFile]
MOV RDX,RDI
REP MOVSW
WinABI SetWindowTextW,[hOFedit],RDX
JMP .Ret0
.idANSIbtn: ; Button Set [ANSI] output encoding pressed.
WinABI GetACP
.oe: MOV [ArgOutputEncoding::],EAX
CALL Arg2Gui:
JMP .Ret0:
.idOEMbtn: ; Button Set [OEM] output encoding pressed.
WinABI GetOEMCP
JMP .oe:
.B: ; Radiobox or hotkey pressed.
.1:
.2:
.3:
.5:
.6:
.7:
.8:
.idHEIrad:
.idHENrad:
.idHECrad:
.idICTrad:
.idICCrad:
.idICQrad:
.idICOrad:
CALL Gui2Arg:
JMP .Ret0:
.C:
.idCONVERTbtn:
RstSt [Status::],ArgCancel
CALL Gui2Arg:
JMP .WM_DESTROY:
.X: ; Hotkey E&xit pressed.
.idEXITbtn: ; Button E&xit pressed.
SetSt [Status::],ArgCancel
.VK_ESCAPE: ; Terminate program.
.WM_DESTROY: ; Program terminates.
WinABI ShowWindow,[hMainWindow],SW_HIDE
WinABI PostQuitMessage,0; Tell Windows to quit this program with errorlevel 0.
.Ret0:XOR EAX,EAX ; RAX=0 signalizes that the message was processed here.
.Ret:EndProcedure WndProc
Arg2Gui:: PROC
LEA RSI,[ArgInputFile::]
LEA RDI,[GuiInputFile]
WinABI MultiByteToWideChar,65001,0,RSI,-1,RDI,SIZE# GuiInputFile
WinABI SetWindowTextW,[hIFedit],RDI
LEA RSI,[ArgOutputFile::]
LEA RDI,[GuiOutputFile]
WinABI MultiByteToWideChar,65001,0,RSI,-1,RDI,SIZE# GuiOutputFile
WinABI SetWindowTextW,[hOFedit],RDI
MOV EAX,[ArgHeaderSize::]
LEA RDI,[GuiHeaderSize]
MOV RDX,RDI
StoD RDI
XOR EAX,EAX
STOSB
WinABI SetWindowTextA,[hHSedit],RDX
MOV EAX,[ArgHeaderLength::]
LEA RDI,[GuiHeaderLength]
MOV RDX,RDI
StoD RDI
XOR EAX,EAX
STOSB
WinABI SetWindowTextA,[hHLedit],RDX
MOV EAX,[ArgFooterSize::]
LEA RDI,[GuiFooterSize]
MOV RDX,RDI
StoD RDI
XOR EAX,EAX
STOSB
WinABI SetWindowTextA,[hFSedit],RDX
MOV EAX,[ArgFooterLength::]
LEA RDI,[GuiFooterLength]
MOV RDX,RDI
StoD RDI
XOR EAX,EAX
STOSB
WinABI SetWindowTextA,[hFLedit],RDX
LEA RDI,[CPid::]
LEA RDX,[RDI+2]
MOV ECX,[CodePagesLength::]
MOV EAX,[ArgInputEncoding::]
REPNE SCASW
JNE .40:
SUB RDI,RDX
SHR EDI,1
WinABI SendMessage,[hIEcomb],LB_SETCURSEL,RDI,0
.40:LEA RDI,[CPid::]
LEA RDX,[RDI+2]
MOV ECX,[CodePagesLength::]
MOV EAX,[ArgOutputEncoding::]
REPNE SCASW
JNE .50:
SUB RDI,RDX
SHR EDI,1
WinABI SendMessage,[hOEcomb],LB_SETCURSEL,RDI,0
.50:MOV CL,[ArgHtmlEntities::]
Dispatch CL,'I','N'
WinABI SendMessage,[hHECrad],BM_SETCHECK,BST_CHECKED,0
JMP .60:
.I: WinABI SendMessage,[hHEIrad],BM_SETCHECK,BST_CHECKED,0
JMP .60:
.N: WinABI SendMessage,[hHENrad],BM_SETCHECK,BST_CHECKED,0
.60:MOV CL,[ArgInvalidCharacter::]
Dispatch CL,'C','Q','O'
WinABI SendMessage,[hICTrad],BM_SETCHECK,BST_CHECKED,0
JMP .70:
.C: WinABI SendMessage,[hICCrad],BM_SETCHECK,BST_CHECKED,0
JMP .70:
.Q: WinABI SendMessage,[hICQrad],BM_SETCHECK,BST_CHECKED,0
JMP .70:
.O: WinABI SendMessage,[hICOrad],BM_SETCHECK,BST_CHECKED,0
.70:WinABI SendMessage,[hBOMchk],BM_SETCHECK,BST_CHECKED,0
JSt [Status::],ArgBOM,.90:
WinABI SendMessage,[hBOMchk],BM_SETCHECK,BST_UNCHECKED,0
.90:RET
ENDP Arg2Gui
Gui2Arg:: PROC
LEA RSI,[GuiInputFile]
WinABI GetWindowTextW,[hIFedit],RSI,MAX_PATH_SIZE
LEA RDI,[ArgInputFile::]
WinABI WideCharToMultiByte,65001,0,RSI,-1,RDI,MAX_PATH_SIZE
LEA RSI,[GuiOutputFile]
WinABI GetWindowTextW,[hOFedit],RSI,MAX_PATH_SIZE
LEA RDI,[ArgOutputFile::]
WinABI WideCharToMultiByte,65001,0,RSI,-1,RDI,MAX_PATH_SIZE
LEA RSI,[GuiHeaderSize]
WinABI GetWindowTextA,[hHSedit],RSI,SIZE# GuiHeaderSize
LodD RSI
MOV [ArgHeaderSize::],EAX
LEA RSI,[GuiHeaderLength]
WinABI GetWindowTextA,[hHLedit],RSI,SIZE# GuiHeaderLength
LodD RSI
MOV [ArgHeaderLength::],EAX
LEA RSI,[GuiFooterSize]
WinABI GetWindowTextA,[hFSedit],RSI,SIZE# GuiFooterSize
LodD RSI
MOV [ArgFooterSize::],EAX
LEA RSI,[GuiFooterLength]
WinABI GetWindowTextA,[hFLedit],RSI,SIZE# GuiFooterLength
LodD RSI
MOV [ArgFooterLength::],EAX
WinABI SendMessage,[hIEcomb],LB_GETCURSEL,0,0
XOR EDX,EDX
CMP RAX,LB_ERR
JE .10:
MOVZXW EDX,[2*EAX+CPid::]
.10:MOV [ArgInputEncoding::],EDX
WinABI SendMessage,[hOEcomb],LB_GETCURSEL,0,0
CMP RAX,LB_ERR
JE .20:
MOVZXW EDX,[2*EAX+CPid::]
.20:MOV [ArgOutputEncoding::],EDX
LEA RDI,[ArgHtmlEntities::]
WinABI SendMessage,[hHEIrad],BM_GETCHECK,0,0
LEA RSI,[=B"Ignore"]
TEST EAX
JNZ .30:
WinABI SendMessage,[hHENrad],BM_GETCHECK,0,0
LEA RSI,[=B"NonASCII"]
TEST EAX
JNZ .30:
WinABI SendMessage,[hHECrad],BM_GETCHECK,0,0
LEA RSI,[=B"Convert"]
TEST EAX
JZ .40:
.30:LODSB
STOSB
TEST AL
JNZ .30:
.40:LEA RDI,[ArgInvalidCharacter::]
WinABI SendMessage,[hICTrad],BM_GETCHECK,0,0
LEA RSI,[=B"Transliterate"]
TEST EAX
JNZ .50:
WinABI SendMessage,[hICCrad],BM_GETCHECK,0,0
LEA RSI,[=B"Convert"]
TEST EAX
JNZ .50:
WinABI SendMessage,[hICQrad],BM_GETCHECK,0,0
LEA RSI,[=B"Question-mark"]
TEST EAX
JNZ .50:
WinABI SendMessage,[hICOrad],BM_GETCHECK,0,0
LEA RSI,[=B"Omit"]
TEST EAX
JZ .60:
.50:LODSB
STOSB
TEST AL
JNZ .50:
.60:WinABI SendMessage,[hBOMchk],BM_GETCHECK,0,0
TEST EAX
JNZ .70:
RstSt [Status::],ArgBOM
JMP .90:
.70:SetSt [Status::],ArgBOM
.90:RET
ENDP Gui2Arg::
FillEncodings:: PROC
PUSH RSI,RDI,R14,R15
MOV R15,RAX ; Listbox handle.
PUSH RCX,RDX
WinABI SendMessage,R15,LB_RESETCONTENT,0,0
POP RDX,RCX
LEA RSI,[CPid::] ; Pointer in the section [CPid].
LEA RBX,[Names::] ; Pointer in the section [Names].
XOR EDX,EDX ; Zero-based index of selected encoding.
MOV R14D,[CodePagesLength::] ; Number of supported code pages.
.10:LEA RDI,[Work16::]
XOR EAX,EAX
LODSW
StoD RDI
MOV AX,': '
STOSW
.20:MOV AL,[RBX]
INC RBX
CMP AL,0
JE .30:
STOSB
JMP .20:
.30:MOV AL,' '
STOSB
.40:MOV AL,[RBX]
INC RBX
CMP AL,0
JE .50:
STOSB
JMP .40:
.50:STOSB
PUSH RCX,RDX
WinABI SendMessage,R15,LB_ADDSTRING,0,Work16::
POP RDX,RCX
CMP CX,[RSI-2]
JNE .60:
PUSH RCX
WinABI SendMessage,R15,LB_SETCURSEL,RDX,0
POP RCX
.60:INC EDX
DEC R14
JNZ .10:
POP R15,R14,RDI,RSI
RET
ENDP FillEncodings
WndCreate:: PROC
; Register WndClassEx for the main window.
MOV [WndClassEx.cbSize],SIZE# WndClassEx
MOV [WndClassEx.lpszClassName],EuroConv::
MOV [WndClassEx.style],CS_HREDRAW|CS_VREDRAW
MOV [WndClassEx.lpfnWndProc],WndProc
WinABI GetModuleHandle,0
MOV [WndClassEx.hInstance],RAX
WinABI LoadIcon,RAX,1
MOV [WndClassEx.hIcon],RAX
WinABI LoadCursor,0,IDC_ARROW
MOV [WndClassEx.hCursor],RAX
MOV [WndClassEx.hbrBackground],COLOR_BTNFACE+1
WinABI RegisterClassEx, WndClassEx
; Create the main window.
WinABI CreateWindowEx, 0, \ WS_EX_CLIENTEDGE, \
EuroConv::, EuroConv::, WS_OVERLAPPEDWINDOW, \
CW_USEDEFAULT,CW_USEDEFAULT,OptimalWidth,MinimalHeight, \
0, 0, [WndClassEx.hInstance], 0
MOV [hMainWindow],RAX
CALL WndRecalculate:
; Initialize InputFileSelect dialogue.
MOV [InpFileDlg.lStructSize],SIZE# OPENFILENAME
MOV RAX,[hMainWindow]
MOV [InpFileDlg.hwndOwner],RAX
LEA RSI,[GuiInputFile]
MOV [InpFileDlg.lpstrFile],RSI
MOV [InpFileDlg.nMaxFile],MAX_PATH_SIZE
MOV [InpFileDlg.Flags],OFN_FILEMUSTEXIST+OFN_PATHMUSTEXIST
; Initialize OutputFileSelect dialogue.
MOV [OutFileDlg.lStructSize],SIZE# OPENFILENAME
MOV RAX,[hMainWindow]
MOV [OutFileDlg.hwndOwner],RAX
LEA RSI,[GuiOutputFile]
MOV [OutFileDlg.lpstrFile],RSI
MOV [OutFileDlg.nMaxFile],MAX_PATH_SIZE
MOV [OutFileDlg.Flags],OFN_FILEMUSTEXIST+OFN_PATHMUSTEXIST
; Create child windows.
MOV RSI,[hMainWindow]
MOV RDI,[WndClassEx.hInstance]
LEA R12,[=B"STATIC"]
LEA R13,[=B"EDIT"]
LEA R14,[=B"BUTTON"]
LEA R15,[=B"LISTBOX"]
WinABI CreateWindowEx,0,R12,="#1",WS_CHILD+WS_VISIBLE+SS_ICON,12,0,16,16,RSI,0,RDI,0 ; Icon.
WinABI SendMessage,RAX,STM_SETICON,[WndClassEx.hIcon],0
WinABI CreateWindowEx,0,R12,Version::,WS_CHILD+WS_VISIBLE, \ Version
50,10,180,20,RSI,0,RDI,0
WinABI CreateWindowEx,0,R12,0, WS_CHILD+WS_VISIBLE+SS_BLACKFRAME,\ Black input frame.
xFrame,yFrameI,[wiFrame],heFrameI,RSI,0,RDI,0
MOV [hIframe],RAX
WinABI CreateWindowEx,0,R12,=B"Input file",WS_CHILD+WS_VISIBLE,\ Title Input file.
xTitle,yTitleIF,wiTitleLong,heTitle,RSI,0,RDI,0
WinABI CreateWindowEx,0,R14,=B"&Select",WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP,\ Button input file Select.
[xBtn],yBtnIF,wiBtn,heBtn,RSI,idIFbtn,RDI,0
MOV [hIFbtn],RAX
WinABI CreateWindowExW,WS_EX_ACCEPTFILES,=U"EDIT",GuiInputFile,WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP,\ Edit input file.
xEdit,yEditIF,[wiEdit],heEdit,RSI,idIFedit,RDI,0
MOV [hIFedit],RAX
WinABI CreateWindowEx,0,R12,=B"Header size (bytes)",WS_CHILD+WS_VISIBLE,\ Title Header size.
[xTitle1of4],yTitleNum,wiTitleNum,heTitle,RSI,0,RDI,0
MOV [hHStitle],RAX
WinABI CreateWindowEx,0,R12,=B"Header length (lines)",WS_CHILD+WS_VISIBLE,\ Title Header length.
[xTitle2of4],yTitleNum,wiTitleNum,heTitle,RSI,0,RDI,0
MOV [hHLtitle],RAX
WinABI CreateWindowEx,0,R12,=B"Footer size (bytes)",WS_CHILD+WS_VISIBLE,\ Title Footer size.
[xTitle3of4],yTitleNum,wiTitleNum,heTitle,RSI,0,RDI,0
MOV [hFStitle],RAX
WinABI CreateWindowEx,0,R12,=B"Footer length (lines)",WS_CHILD+WS_VISIBLE,\ Title Footer length.
[xTitle4of4],yTitleNum,wiTitleNum,heTitle,RSI,0,RDI,0
MOV [hFLtitle],RAX
WinABI CreateWindowEx,0,R13,GuiHeaderSize,WS_CHILD+WS_VISIBLE+WS_BORDER+ES_NUMBER+ES_RIGHT+WS_TABSTOP,\ Edit Header size.
[xEdit1of4],yEditNum,wiEditNum,heEdit,RSI,idHSedit,RDI,0
MOV [hHSedit],RAX
WinABI CreateWindowEx,0,R13,GuiHeaderLength,WS_CHILD+WS_VISIBLE+WS_BORDER+ES_NUMBER+ES_RIGHT+WS_TABSTOP,\ Edit Header length.
[xEdit2of4],yEditNum,wiEditNum,heEdit,RSI,idHLedit,RDI,0
MOV [hHLedit],RAX
WinABI CreateWindowEx,0,R13,GuiFooterSize,WS_CHILD+WS_VISIBLE+WS_BORDER+ES_NUMBER+ES_RIGHT+WS_TABSTOP,\ Edit Footer size.
[xEdit3of4],yEditNum,wiEditNum,heEdit,RSI,idFSedit,RDI,0
MOV [hFSedit],RAX
WinABI CreateWindowEx,0,R13,GuiFooterLength,WS_CHILD+WS_VISIBLE+WS_BORDER+ES_NUMBER+ES_RIGHT+WS_TABSTOP,\ Edit Footer length.
[xEdit4of4],yEditNum,wiEditNum,heEdit,RSI,idFLedit,RDI,0
MOV [hFLedit],RAX
WinABI CreateWindowEx,0,R12,=B"Input encoding",WS_CHILD+WS_VISIBLE,\ Title Input encoding.
xTitle,yTitleIE,wiTitleLong,heTitle,RSI,0,RDI,0
WinABI CreateWindowEx,0,R14,=B"&Autodetect",WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP,\ Button Autodetect.
[xBtn],yBtnAuto,wiBtn,heBtn,RSI,idADbtn,RDI,0
MOV [hADbtn],RAX
WinABI CreateWindowEx,0,R15,0,WS_CHILD+WS_VISIBLE+WS_BORDER+WS_VSCROLL+WS_HSCROLL+LBS_NOTIFY,\ Combo Input encoding.
xEdit,yEditIE,[wiEdit],heEnc,RSI,idIEcomb,RDI,0
MOV [hIEcomb],RAX
MOV ECX,[ArgInputEncoding::]
CALL FillEncodings
WinABI CreateWindowEx,0,R12,=B"What to do when HTML entity is recognized:",WS_CHILD+WS_VISIBLE,\ Title above radiobuttons.
xTitleLong, yTitleEnt,wiTitleLong,heTitle,RSI,0,RDI,0
WinABI CreateWindowEx,0,R14,=B"&1 Ignore (do not mind)",WS_CHILD+WS_VISIBLE+BS_AUTORADIOBUTTON+WS_GROUP,\ Radiobutton HEI
xRadio,yHEI,wiTitleLong,heTitle,RSI,idHEIrad,RDI,0
MOV [hHEIrad],RAX
WinABI CreateWindowEx,0,R14,=B"&2 Convert nonASCII entity to a character",WS_CHILD+WS_VISIBLE+BS_AUTORADIOBUTTON,\ Radiobutton HEN
xRadio,yHEN,wiTitleLong,heTitle,RSI,idHENrad,RDI,0
MOV [hHENrad],RAX
WinABI CreateWindowEx,0,R14,=B"&3 Convert all",WS_CHILD+WS_VISIBLE+BS_AUTORADIOBUTTON, \ Radiobutton HEC
xRadio,yHEC,wiTitleLong,heTitle,RSI,idHECrad,RDI,0
MOV [hHECrad],RAX
WinABI CreateWindowEx,0,R12,0, WS_CHILD+WS_VISIBLE+SS_BLACKFRAME,\ Black output frame.
xFrame,yFrameO,[wiFrame],heFrameO,RSI,0,RDI,0
MOV [hOframe],RAX
WinABI CreateWindowEx,0,R12,=B"Output file",WS_CHILD+WS_VISIBLE,\ Title Output file.
xTitle,yTitleOF,wiTitleLong,heTitle,RSI,0,RDI,0
WinABI CreateWindowEx,0,R14,=B"Se&lect",WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP, \ Button output file Select.
[xBtn],yBtnOF,wiBtn,heBtn,RSI,idOFbtn,RDI,0
MOV [hOFbtn],RAX
WinABI CreateWindowExW,WS_EX_ACCEPTFILES,=U"EDIT",GuiOutputFile,WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP,\ Edit output file.
xEdit,yEditOF,[wiEdit],heEdit,RSI,idOFedit,RDI,0
MOV [hOFedit],RAX
WinABI CreateWindowEx,0,R12,=B"Output encoding",WS_CHILD+WS_VISIBLE,\ Title Output encoding.
xTitle,yTitleOE,wiTitleLong,heTitle,RSI,0,RDI,0
WinABI CreateWindowEx,0,R14,=B"&BOM",WS_CHILD+WS_VISIBLE+BS_AUTOCHECKBOX+WS_TABSTOP,\ Checkbox BOM.
[xBtn3],yBtnEnc,wiBtn,heBtn,RSI,idBOMchk,RDI,0
MOV [hBOMchk],RAX
WinABI CreateWindowEx,0,R14,=B"ANSI",WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP,\ ANSI encoding button.
[xBtn2],yBtnEnc,wiBtn,heBtn,RSI,idANSIbtn,RDI,0
MOV [hANSIbtn],RAX
WinABI CreateWindowEx,0,R14,=B"OEM",WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP,\ OEM encoding button.
[xBtn],yBtnEnc,wiBtn,heBtn,RSI,idOEMbtn,RDI,0
MOV [hOEMbtn],RAX
WinABI CreateWindowEx,0,R15,0,WS_CHILD+WS_VISIBLE+WS_BORDER+WS_VSCROLL+WS_HSCROLL+LBS_NOTIFY,\ Combo output encoding.
xEdit,yEditOE,[wiEdit],heEnc,RSI,idOEcomb,RDI,0
MOV [hOEcomb],RAX
MOV ECX,[ArgOutputEncoding::]
CALL FillEncodings
WinABI CreateWindowEx,0,R12,=B"What to do with invalid output characters:",WS_CHILD+WS_VISIBLE, \ Title above radiobuttons.
xTitleLong,yTitleInv,wiTitleLong,heTitle,RSI,0,RDI,0
WinABI CreateWindowEx,0,R14,=B"&5 Transliterate to ASCII",WS_CHILD+WS_VISIBLE+BS_AUTORADIOBUTTON+WS_GROUP,\ Radiobutton ICT.
xRadio,yICT,wiTitleLong,heTitle,RSI,idICTrad,RDI,0
MOV [hICTrad],RAX
WinABI CreateWindowEx,0,R14,=B"&6 Convert to HTML entity",WS_CHILD+WS_VISIBLE+BS_AUTORADIOBUTTON, \ Radiobutton ICC.
xRadio,yICC,wiTitleLong,heTitle,RSI,idICCrad,RDI,0
MOV [hICCrad],RAX
WinABI CreateWindowEx,0,R14,=B"&7 Replace with question mark",WS_CHILD+WS_VISIBLE+BS_AUTORADIOBUTTON, \ Radiobutton ICQ.
xRadio,yICQ,wiTitleLong,heTitle,RSI,idICQrad,RDI,0
MOV [hICQrad],RAX
WinABI CreateWindowEx,0,R14,=B"&8 Omit from output",WS_CHILD+WS_VISIBLE+BS_AUTORADIOBUTTON, \ Radiobutton ICO.
xRadio,yICO,wiTitleLong,heTitle,RSI,idICOrad,RDI,0
MOV [hICOrad],RAX
WinABI CreateWindowEx,0,R14,=B"E&xit",WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP, \ CANCEL button.
xEdit,yBtnConv,wiBtn,heBtn,RSI,idEXITbtn,RDI,0
MOV [hEXITbtn],RAX
WinABI CreateWindowEx,0,R14,=B"&Convert",WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP, \ CONVERT button.
[xBtn],yBtnConv,wiBtn,heBtn,RSI,idCONVERTbtn,RDI,0
MOV [hCONVERTbtn],RAX
RET
ENDP WndCreate
WndRecalculate:: PROC
WinABI GetWindowRect,[hMainWindow],RectMainWindow ; Get new coordinates.
MOV ECX,[RectMainWindow.left]
MOV ESI,[RectMainWindow.right]
SUB ESI,ECX
CMP ESI,MinimalWidth
JA .10:
MOV ESI,MinimalWidth
.10:SUB ESI,26
MOV [WindowWidth],ESI
MOV EDX,[RectMainWindow.top]
MOV EDI,[RectMainWindow.bottom]
SUB EDI,EDX
CMP EDI,MinimalHeight
JA .20:
MOV EDI,MinimalHeight
.20:MOV [WindowHeight],EDI
; Recalculate coordinates of moveable elements. RSI=WindowWidth, RDI=WindowHeight.
LEA EAX,[ESI-wiBtn-10]
MOV [xBtn],EAX
SUB EAX,wiBtn+10
MOV [xBtn2],EAX
SUB EAX,wiBtn+10
MOV [xBtn3],EAX
LEA EDX,[ESI-4*wiTitleNum-2*16]
SHR EDX,2
LEA EAX,[EDX+10]
MOV [xTitle1of4],EAX
LEA EAX,[EAX+EDX+wiTitleNum]
MOV [xTitle2of4],EAX
LEA EAX,[EAX+EDX+wiTitleNum]
MOV [xTitle3of4],EAX
LEA EAX,[EAX+EDX+wiTitleNum]
MOV [xTitle4of4],EAX
LEA EAX,[EDX+16+10]
MOV [xEdit1of4],EAX
LEA EAX,[EAX+EDX+wiTitleNum]
MOV [xEdit2of4],EAX
LEA EAX,[EAX+EDX+wiTitleNum]
MOV [xEdit3of4],EAX
LEA EAX,[EAX+EDX+wiTitleNum]
MOV [xEdit4of4],EAX
LEA EAX,[ESI-10]
MOV [wiFrame],EAX
SUB EAX,20
MOV [wiEdit],EAX
RET
ENDP WndRecalculate
WndResize: PROC
CALL WndRecalculate
WinABI MoveWindow,[hIframe],xFrame,yFrameI,[wiFrame],heFrameI,0
WinABI MoveWindow,[hIFbtn],[xBtn],yBtnIF,wiBtn,heBtn,0
WinABI MoveWindow,[hIFedit],xEdit,yEditIF,[wiEdit],heEdit,0
WinABI MoveWindow,[hHStitle],[xTitle1of4],yTitleNum,wiTitleNum,heTitle,0
WinABI MoveWindow,[hHLtitle],[xTitle2of4],yTitleNum,wiTitleNum,heTitle,0
WinABI MoveWindow,[hFStitle],[xTitle3of4],yTitleNum,wiTitleNum,heTitle,0
WinABI MoveWindow,[hFLtitle],[xTitle4of4],yTitleNum,wiTitleNum,heTitle,0
WinABI MoveWindow,[hHSedit],[xEdit1of4],yEditNum,wiEditNum,heEdit,0
WinABI MoveWindow,[hHLedit],[xEdit2of4],yEditNum,wiEditNum,heEdit,0
WinABI MoveWindow,[hFSedit],[xEdit3of4],yEditNum,wiEditNum,heEdit,0
WinABI MoveWindow,[hFLedit],[xEdit4of4],yEditNum,wiEditNum,heEdit,0
WinABI MoveWindow,[hADbtn],[xBtn],yBtnAuto,wiBtn,heBtn,0
WinABI MoveWindow,[hIEcomb],xEdit,yEditIE,[wiEdit],heEnc,0
WinABI MoveWindow,[hOframe],xFrame,yFrameO,[wiFrame],heFrameO,0
WinABI MoveWindow,[hOFbtn],[xBtn],yBtnOF,wiBtn,heBtn,0
WinABI MoveWindow,[hOFedit],xEdit,yEditOF,[wiEdit],heEdit,0
WinABI MoveWindow,[hBOMchk],[xBtn3],yBtnEnc,wiBtn,heBtn,0
WinABI MoveWindow,[hANSIbtn],[xBtn2],yBtnEnc,wiBtn,heBtn,0
WinABI MoveWindow,[hOEMbtn],[xBtn],yBtnEnc,wiBtn,heBtn,0
WinABI MoveWindow,[hOEcomb],xEdit,yEditOE,[wiEdit],heEnc,0
WinABI MoveWindow,[hCONVERTbtn],[xBtn],yBtnConv,wiBtn,heBtn,0
RET
ENDP WndResize
ENDPROGRAM convwing