| Index | Manual | Download | Source | Macros | Embedded word Case ins.
Sitemap | Links | Forum | Tests | Projects

# sortwing.htm
Data
Data
Procedures
Gui2Arg
MainGui
WndCreate
WndProc
WndResize

This is a GUI module of EuroTool program EuroSort.

             EUROASM CPU=X64,SIMD=Yes,Unicode=No
    sortwing PROGRAM Format=COFF,Width=64, MaxExpansions=120K,
             %DROPMACRO *
             INCLUDEHEAD1 argument.htm
             INCLUDE1 winansi.htm, fastcall.htm, winabi.htm, winsgui.htm, winsdlg.htm, winsfile.htm, \
                      winf64.htm, cpuext64.htm, cpuext.htm, status32.htm, memory64.htm, string64.htm
             LINK ../objlib/winapi.lib

↑ Data

                     ; Constants.
    OptimalWidth     = 740
    MinimalWidth     = 560
    MinimalHeight    = 440
    ; Window menu identifiers.
    IdInputFile      = 0x8011
    IdInputBtn       = 0x8012
    IdNum            = 0x8013  ; Edit numeric fields.
    IdOutputFile     = 0x8021
    IdOutputBtn      = 0x8022
    IdEncoding       = 0x8031
    IdLocale         = 0x8032
    IdKeyOffset      = 0x8033
    IdKeyLength      = 0x8034
    IdBox            = 0x8041  ; Boolean checkboxes.
    IdBtnCancel      = 0x8051
    IdBtnExec        = 0x8052
    [.rodata]              ; Text constants.
    TitleMainWindow        DU "EuroSort",0
    TitleInputFile         DB "Input file",0
    TitleOutputFile        DB "Output file",0
    TitleRecordSize        DB "  Record",10,"size (bytes)",0
    TitleHeaderSize        DB "  Header",10,"size (bytes)",0
    TitleHeaderLength      DB "  Header",10,"length (lines)",0
    TitleFooterSize        DB "  Footer",10,"size (bytes)",0
    TitleFooterLength      DB "  Footer",10,"length (lines)",0
    TitleLocale            DB 10,"Locale",0
    TitleKeyOffset         DB "  Key",10,"offset",10,"(chars)",0
    TitleKeyLength         DB "  Key",10,"length",10,"(chars)",0
    TitleKeyReverse        DB "  Key",10,"reverse",0
    TitleDigitFirst        DB " Digit",10,"  first",0
    TitlePunctuationFirst  DB "Punct.",10,"  first",0
    TitleUpperFirst        DB "Upper",10," first",0
    TitleMergeSpaces       DB "Merge",10,"spaces",0
    TitleEncoding          DB "Encoding",10,0
    [.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
    hMainWindow            D QWORD                   ; Window handles.
    hTitleInputFile        D QWORD
    hTitleRecordSize       D QWORD
    hTitleHeaderSize       D QWORD
    hTitleHeaderLength     D QWORD
    hTitleFooterSize       D QWORD
    hTitleFooterLength     D QWORD
    hTitleEncoding         D QWORD
    hTitleLocale           D QWORD
    hTitleKeyOffset        D QWORD
    hTitleKeyLength        D QWORD
    hTitleKeyReverse       D QWORD
    hTitleDigitFirst       D QWORD
    hTitlePunctuationFirst D QWORD
    hTitleUpperFirst       D QWORD
    hTitleMergeSpaces      D QWORD
    hEditInputFile         D QWORD
    hEditOutputFile        D QWORD
    hEditRecordSize        D QWORD
    hEditHeaderSize        D QWORD
    hEditHeaderLength      D QWORD
    hEditFooterSize        D QWORD
    hEditFooterLength      D QWORD
    hEditEncoding          D QWORD
    hEditLocale            D QWORD
    hEditKeyOffset         D QWORD
    hEditKeyLength         D QWORD
    hEditKeyReverse        D QWORD
    hEditDigitFirst        D QWORD
    hEditPunctuationFirst  D QWORD
    hEditUpperFirst        D QWORD
    hEditMergeSpaces       D QWORD
    hBtnInputFile          D QWORD
    hBtnOutputFile         D QWORD
    hBtnCancel             D QWORD
    hBtnExec               D QWORD
    EncIndex               D DWORD
    WindowWidth            D DWORD
    WindowHeight           D DWORD
    ; GUI-maintained arguments in text form, UTF-16.
    GuiEuroSortExe::       D MAX_PATH_SIZE * U
    GuiInputFile           D MAX_PATH_SIZE * U
    GuiOutputFile          D MAX_PATH_SIZE * U
    ; GUI-maintained arguments in text form, UTF-8.
    GuiRecordSize          D 20*B
    GuiHeaderSize          D 20*B
    GuiHeaderLength        D 20*B
    GuiFooterSize          D 20*B
    GuiFooterLength        D 20*B
    GuiEncoding            D 20*B
    GuiLocale              D 20*B
    GuiKeyOffset           D 20*B
    GuiKeyLength           D 20*B

MainGui
  This is the graphic entry procedure.
Called by
  MainCon.
Calls
  WndCreate, WndResize

    [.text]
    MainGui:: PROC
         CALL WndCreate               ; Initialize the main program window.
         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:
         CALL Gui2Arg
         RET                                          ; Return to CUI module.
       ENDP MainGui

WndProc, hWnd, uMsg, wParam, lParam
  This is a callback procedure which receives and handles messages for the MainWindow. Message parameters are by FastCall convention provided in registers RCX, RDX, R8, R9, we'll save them to shadow space with macro SaveToShadow . Thanks to this their contents will be available by formal names ( `[%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.

Handler input
  RCX=[%hWnd] is the main window handle (the same as static [hMainWindow] obtained by WndCreate).
  RDX=[%uMsg] is message identifier,
  R8=[%wParam] is message w-parameter,
  R9=[%lParam] is message l-parameter.
Handler output
  RAX=0 if the message was completely processed by the handler. Otherwise the message is processed by WinAPI DefWindowProc and RAX outputs its return value.
  Scratch registers RCX,RDX,R8..R11 may be destroyed in the handlers.
  Callee-save registers RBX,RSI,RDI,R12..R15 must be restored, if used in the handlers. This provides macro Uses.
Invoked by
  WinAPI DispatchMessage.

    WndProc:: Procedure hWnd, uMsg, wParam, lParam ; These parameters are provided in RCX,RDX,R8,R9.
        SaveToShadow
        Uses RBX,RBP,RSI,RDI ; 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','E','X','C'
         JMP .Def: ; Pass unhandled keys to WinABI DefWindowProc.
    .WM_SYSKEYDOWN:     ; A key pressed together with Alt.
         Dispatch R8D,'S','E','X','C'
         JMP .Def: ; Pass unhandled keys to WinABI DefWindowProc.
    .WM_COMMAND:: ; Window element Id=LOWORD R8 was activated.
         MOVZX EDX,R8W
         Dispatch EDX,IdInputBtn, IdOutputBtn, IdBtnCancel,IdBtnExec
        JMP .Def:               ; Let other commands handle by DefWindowProc().
    .S:                         ; Hotkey 'S' pressed.
    .IdInputBtn:                ; Button [Select] input file pressed.
         WinABI GetOpenFileNameW,InpFileDlg
         WinABI SetWindowTextW,[hEditInputFile],GuiInputFile
         JMP .Ret0
    .E:                          ; Hotkey 'E' pressed.
    .IdOutputBtn:                ; Button [Select] output file pressed.
         WinABI GetSaveFileNameW,OutFileDlg
         WinABI SetWindowTextW,[hEditOutputFile],GuiOutputFile
         JMP .Ret0:
    .IdBtnCancel:
    .C: SetSt [Status::],ArgCancel
    .IdBtnExec:
    .X:                          ; Hotkey 'X' pressed.
    .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

Gui2Arg
  Copy arguments from GUI module g** back to global form Arg**.

    Gui2Arg:: PROC
        PUSH RSI,RDI
    arg %FOR InputFile,OutputFile
         LEA RDI,[Gui%arg]
         WinABI GetWindowTextW,[hEdit%arg],RDI,MAX_PATH_SIZE
         WinABI WideCharToMultiByte,65001,0,Gui%arg,-1,Arg%arg::,MAX_PATH_SIZE,0,0
        %ENDFOR arg
    arg %FOR RecordSize,HeaderSize,HeaderLength,FooterSize,FooterLength,KeyOffset,KeyLength
         LEA RDI,[Gui%arg]
         WinABI GetWindowTextA,[hEdit%arg],RDI,20
         LodD RDI
         MOV [Arg%arg::],EAX
        %ENDFOR arg
        WinABI SendMessage,[hEditEncoding],CB_GETCURSEL,0,0
        XOR ECX,ECX
        CMP RAX,CB_ERR
        JE .2:
        LEA RSI,[GuiEncoding]
        MOVB [RSI],0
        WinABI SendMessage,[hEditEncoding],CB_GETLBTEXT,RAX,RSI
        LodD RSI
        MOV ECX,EAX
    .2: MOV [ArgInputEncoding::],ECX
        WinABI SendMessage,[hEditLocale],CB_GETCURSEL,0,0
        XOR ECX,ECX
        CMP RAX,CB_ERR
        JE .3:
        LEA RSI,[GuiLocale]
        MOVD [RSI],0
        WinABI SendMessage,[hEditLocale],CB_GETLBTEXT,RAX,RSI
        MOVZXW ECX,[RSI]
    .3: MOV [ArgLocale::],ECX
    arg %FOR KeyReverse,DigitFirst,PunctuationFirst,UpperFirst,MergeSpaces
         WinABI SendMessage,[hEdit%arg],BM_GETCHECK,0,0
         CMP EAX,BST_CHECKED
         JE .4%arg:
         RstSt [Status::],Arg%arg
         JMP .5%arg:
    .4%arg:
        SetSt [Status::],Arg%arg
    .5%arg:
        %ENDFOR arg
        POP RDI,RSI
        RET
       ENDP Gui2Arg

WndCreate
  Register window class and create all windows.

    WndCreate:: PROC
    xTitleIO         = 300
    yTitleInputFile  =  38
    yEditInputFile   =  60
    yTitleNumFields  =  90
    yEditNumFields   = 126
    yTitleOutputFile = 178
    yEditOutputFile  = 200
    yTitleBoxFields  = 234
    yEditBoxFields   = 286
    yTitleCmdLine    = 346
    heBtnIO          =  20
    heTitle1         =  18 ; Height of title with one line.
    heTitle2         =  36 ; Height of title with two lines.
    heTitle3         =  54 ; Height of title with three lines.
    ;heTitleIO        =  20
    heEdit           =  20
    wiBorder         =  10
    wiBtnIO          =  60
    wiTitleIO        =  64
    wiTitleNumFields =  88
    wiEditNumFields  =  45
    wiTitleEncoding  =  56
    wiEditEncoding   = 180
    wiTitleLocale    =  48
    wiEditLocale     =  50
    wiTitleKeyFields =  48
    wiTitleBoxFields =  48
    wiEditBoxFields  =  20
        PUSH RBX,RSI,RDI,R12
        ; Register WndClassEx for the main window.
        MOV [WndClassEx.cbSize],SIZE# WndClassEx
        MOV [WndClassEx.lpszClassName],TitleMainWindow
        MOV [WndClassEx.style],CS_HREDRAW|CS_VREDRAW
        MOV [WndClassEx.lpfnWndProc],WndProc
        WinABI GetModuleHandle,0
        MOV [WndClassEx.hInstance],RAX
        WinABI LoadIcon,RAX,1             ; The 1st and only icon from [.rsrc] section.
        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, TitleMainWindow, TitleMainWindow, WS_OVERLAPPEDWINDOW,  \
               CW_USEDEFAULT,CW_USEDEFAULT,OptimalWidth,MinimalHeight, \
               0, 0, [WndClassEx.hInstance], 0
        MOV [hMainWindow],RAX
        WinABI GetClientRect,[hMainWindow],RectMainWindow
        MOV EDX,[RectMainWindow.right]
        MOV ECX,[RectMainWindow.bottom]
        SUB EDX,20
        MOV [WindowWidth],EDX
        MOV [WindowHeight],ECX
        ; Initialize InputFileSelect dialogue.
        MOV [InpFileDlg.lStructSize],SIZE# OPENFILENAME
        MOV RAX,[hMainWindow]
        MOV [InpFileDlg.hwndOwner],RAX
        LEA RSI,[GuiInputFile]
        MOV [InpFileDlg.lpstrFile],RSI
        WinABI MultiByteToWideChar,65001,0,ArgInputFile::,-1,RSI,MAX_PATH_SIZE ; Convert UTF-8 to UTF-16, initialize gInputFile from ArgInputFile.
        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
        WinABI MultiByteToWideChar,65001,0,ArgOutputFile::,-1,RSI,MAX_PATH_SIZE ; Convert UTF-8 to UTF-16, initialize GuiOutputFile from ArgOutputFile.
        MOV [OutFileDlg.nMaxFile],MAX_PATH_SIZE
        MOV [OutFileDlg.Flags],OFN_FILEMUSTEXIST+OFN_PATHMUSTEXIST
        ; Create child windows of the MainWindow.
        ; EuroDirs icon.
        WinABI CreateWindowEx,0,="STATIC",="#1",WS_CHILD+WS_VISIBLE+SS_ICON,\
               12,0,16,16,[hMainWindow],0,[WndClassEx.hInstance],0
        WinABI SendMessage,RAX,STM_SETICON,[WndClassEx.hIcon],0
       ; Title EuroSort version.
        WinABI CreateWindowExW,0,=U"STATIC", Version::,WS_CHILD+WS_VISIBLE, \
                50,10,180,20,[hMainWindow],0,[WndClassEx.hInstance],0
       ; Title input file.
        WinABI CreateWindowExA,0,=B"STATIC",TitleInputFile,WS_CHILD+WS_VISIBLE ,\
              xTitleIO,yTitleInputFile,wiTitleIO,heTitle1,[hMainWindow],0,[WndClassEx.hInstance],0
        MOV [hTitleInputFile],RAX
       ; Button input file select.
        MOV ECX,[WindowWidth]
        SUB ECX,wiBorder+wiBtnIO
        WinABI CreateWindowExA,0,=B'BUTTON',=B"&Select",WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP, \
               RCX,yTitleInputFile,wiBtnIO,heBtnIO,[hMainWindow],IdInputBtn,[WndClassEx.hInstance],0
        MOV [hBtnInputFile],RAX
       ; Edit input file.
        MOV ECX,[WindowWidth]
        SUB ECX,2*wiBorder
        WinABI CreateWindowExW,WS_EX_ACCEPTFILES,=U'EDIT',GuiInputFile,WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP, \
               wiBorder,yEditInputFile,RCX,heEdit,[hMainWindow],IdInputFile,[WndClassEx.hInstance],0
        MOV [hEditInputFile],RAX
       ; Compute interelement space of numeric fields to R12.
        MOV EAX,[WindowWidth]
        SUB EAX,2*wiBorder+5*wiTitleNumFields
        SAR EAX,2
        LEA R12D,[EAX+wiTitleNumFields]
        MOV ESI,wiBorder
    %i  %SETA 0
    arg %FOR RecordSize,HeaderSize,HeaderLength,FooterSize,FooterLength
         LEA RDI,[Title%arg]
         CALL .CreateTitle:
         MOV [hTitle%arg],RAX
         LEA RDI,[Gui%arg]
         MOV EAX,[Arg%arg::]
         StoD RDI
         LEA RDI,[Gui%arg]
         MOV EAX,IdNum+%i
         CALL .CreateEdit:
         MOV [hEdit%arg],RAX
         ADD ESI,R12D
         %i %SETA %i+1
       %ENDFOR arg
    .CreateTitle PROC1
        WinABI CreateWindowExA,0,=B"STATIC",RDI,WS_CHILD+WS_VISIBLE ,\
             RSI,yTitleNumFields,wiTitleNumFields,heTitle2,[hMainWindow],0,[WndClassEx.hInstance],0
         RET
        ENDP1 .CreateTitle
    .CreateEdit PROC1
        WinABI CreateWindowExA,0,=B'EDIT',RDI,WS_CHILD+WS_VISIBLE+WS_BORDER+ES_NUMBER+ES_RIGHT+WS_TABSTOP, \
               RSI,yEditNumFields,wiEditNumFields,heEdit,[hMainWindow],RAX,[WndClassEx.hInstance],0
         RET
        ENDP1 .CreateEdit

         ; Title output file.
        WinABI CreateWindowExA,0,=B"STATIC",TitleOutputFile,WS_CHILD+WS_VISIBLE ,\
              xTitleIO,yTitleOutputFile,wiTitleNumFields,heTitle1,[hMainWindow],0,[WndClassEx.hInstance],0
        MOV [hTitleInputFile],RAX
       ; Button output file.
        MOV ECX,[WindowWidth]
        SUB ECX,wiBorder+wiBtnIO
        WinABI CreateWindowExA,0,=B'BUTTON',=B"S&elect",WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP, \
               RCX,yTitleOutputFile,wiBtnIO,heBtnIO,[hMainWindow],IdOutputBtn,[WndClassEx.hInstance],0
        MOV [hBtnOutputFile],RAX
       ; Edit output file.
        MOV ECX,[WindowWidth]
        SUB ECX,2*wiBorder
        WinABI CreateWindowExW,WS_EX_ACCEPTFILES,=U'EDIT',GuiOutputFile::,WS_CHILD+WS_VISIBLE+WS_BORDER+ES_AUTOHSCROLL+WS_TABSTOP, \
               wiBorder,yEditOutputFile,RCX,heEdit,[hMainWindow],IdOutputFile,[WndClassEx.hInstance],0
        MOV [hEditOutputFile],RAX

        ; Compute 8 interelement spaces of mixed fields to R12.
        MOV EAX,[WindowWidth]
        SUB EAX,2*wiBorder+wiEditEncoding+wiEditLocale+2*wiEditNumFields+5*wiEditBoxFields
        SHR EAX,3
        MOV R12D,EAX
        ; Title Encoding.
        MOV ESI,wiBorder+40
        WinABI CreateWindowExA,0,=B'STATIC',TitleEncoding,WS_CHILD+WS_VISIBLE, \
               RSI,yTitleBoxFields+18,wiTitleEncoding+18,heTitle2,[hMainWindow],0,[WndClassEx.hInstance],0
        MOV [hTitleEncoding],RAX
        ; Edit Encoding.
        SUB ESI,40
        WinABI CreateWindowExA,0,=B'COMBOBOX',0,CBS_DROPDOWN+CBS_UPPERCASE+CBS_HASSTRINGS+WS_CHILD+WS_OVERLAPPED+WS_VISIBLE+WS_VSCROLL+WS_TABSTOP, \
                RSI,yEditBoxFields,wiEditEncoding,7*heEdit,[hMainWindow],IdEncoding,[WndClassEx.hInstance],0
        MOV [hEditEncoding],RAX
        ; Fill Encoding with one numeric value and one text value.
        WinABI SendMessageA,[hEditEncoding],CB_ADDSTRING,0,=B'0 (autodetect)'
        WinABI SendMessageA,[hEditEncoding],CB_SETCURSEL,0,0
        LEA RBX,[Encodings::]              ; Definition of Encodings in argument.htm.
        LEA RDI,[EndEncodings::]
        MOV [EncIndex],1
    .30:CMP RBX,RDI
        JNB .40:
        PUSH RSI,RDI
          LEA RDI,[GuiEncoding]
          MOV ECX,[RBX+VAL.ValNameSize]
          LEA RSI,[RBX+VAL.ValName]
          REP MOVSB
          MOV AX,' ('
          STOSW
          ADD RBX,SIZE# VAL
          MOV ECX,[RBX+VAL.ValNameSize]
          LEA RSI,[RBX+VAL.ValName]
          REP MOVSB
          MOV AX,')'
          STOSW
          LEA RDI,[GuiEncoding]
          WinABI SendMessageA,[hEditEncoding],CB_ADDSTRING,0,RDI
          MOV ECX,[RBX+VAL.ValValue]
          CMP ECX,[ArgInputEncoding::]
          JNE .35:
          WinABI SendMessage,[hEditEncoding],CB_SETCURSEL,[EncIndex],0
    .35:  INC [EncIndex]
        POP RDI,RSI
        ADD RBX,SIZE# VAL
        JMP .30:
    .40:; Title Locale.
        LEA ESI,[ESI+wiEditEncoding+R12D]
        WinABI CreateWindowExA,0,=B'STATIC',TitleLocale,WS_CHILD+WS_VISIBLE, \
               RSI,yTitleBoxFields,wiTitleLocale,heTitle3,[hMainWindow],0,[WndClassEx.hInstance],0
        MOV [hTitleLocale],RAX
        ; Edit Locale.
        WinABI CreateWindowExA,0,=B'COMBOBOX',0,CBS_DROPDOWN+CBS_UPPERCASE+WS_CHILD+WS_VISIBLE+WS_VSCROLL+WS_TABSTOP, \
               RSI,yEditBoxFields,wiEditLocale,7*heEdit,[hMainWindow],IdLocale,[WndClassEx.hInstance],0
        MOV [hEditLocale],RAX
        ; Fill Locale with two-letter values.
        WinABI SendMessageA,[hEditLocale],CB_ADDSTRING,0,=B "  "
        LEA RBX,[Locales::]
        LEA RDI,[EndLocales::]
    .50:CMP RBX,RDI
        JNB .60:
        MOV AX,[RBX+VAL.ValName]   ; "az","cz","de" etc.
        LEA RDX,[GuiLocale]
        MOV [RDX],AX
        WinABI SendMessageA,[hEditLocale],CB_ADDSTRING,0,RDX
        MOV ECX,[RBX+VAL.ValValue]
        CMP ECX,[ArgLocale::]
        JNE .55:
        WinABI SendMessage,[hEditLocale],CB_SETCURSEL,RAX,0
    .55:ADD RBX,SIZE# VAL
        JMP .50:
    .60:; Title KeyOffset
        LEA ESI,[ESI+wiEditLocale+R12D]
        WinABI CreateWindowExA,0,=B'STATIC',TitleKeyOffset,WS_CHILD+WS_VISIBLE, \
               RSI,yTitleBoxFields,wiTitleKeyFields,heTitle3,[hMainWindow],0,[WndClassEx.hInstance],0
        MOV [hTitleKeyOffset],RAX
        ; Edit KeyOffset
         LEA RDI,[GuiKeyOffset]
         MOV EAX,[ArgKeyOffset::]
         StoD RDI
        WinABI CreateWindowExA,0,=B'EDIT',GuiKeyOffset,WS_CHILD+WS_VISIBLE+WS_BORDER+ES_NUMBER+ES_RIGHT+WS_TABSTOP, \
               RSI,yEditBoxFields,wiEditNumFields,heEdit,[hMainWindow],IdKeyOffset,[WndClassEx.hInstance],0
        MOV [hEditKeyOffset],RAX
        ; Title KeyLength
        LEA ESI,[ESI+wiEditNumFields+R12D]
        WinABI CreateWindowExA,0,=B'STATIC',TitleKeyLength,WS_CHILD+WS_VISIBLE, \
               RSI,yTitleBoxFields,wiTitleKeyFields,heTitle3,[hMainWindow],0,[WndClassEx.hInstance],0
        MOV [hTitleKeyLength],RAX
        ; Edit KeyLength
        LEA RDI,[GuiKeyLength]
        MOV EAX,[ArgKeyLength::]
        CDQE
        StoD RDI
        WinABI CreateWindowExA,0,=B'EDIT',GuiKeyLength::,WS_CHILD+WS_VISIBLE+WS_BORDER+ES_NUMBER+ES_RIGHT+WS_TABSTOP, \
               RSI,yEditBoxFields,wiEditNumFields,heEdit,[hMainWindow],IdKeyLength,[WndClassEx.hInstance],0
        MOV [hEditKeyLength],RAX
        ; Title boxes.
        LEA ESI,[ESI+wiEditBoxFields+R12D]
        %i %SETA 0
    arg %FOR KeyReverse,DigitFirst,PunctuationFirst,UpperFirst,MergeSpaces
         LEA RDI,[Title%arg]
         CALL .CreateBoxTitle:
         MOV [hTitle%arg],RAX
         ADD ESI,16
         MOV EAX,IdBox+%i
         %i %SETA %i+1
         CALL .CreateBoxEdit:
         MOV [hEdit%arg],RAX
         LEA ESI,[ESI+wiEditBoxFields+R12D-16]
         MOV EDX,BST_UNCHECKED
         JNSt [Status::],Arg%arg, .2%arg:
         MOV EDX,BST_CHECKED
    .2%arg:WinABI SendMessage,[hEdit%arg],BM_SETCHECK,RDX,0
        %ENDFOR arg
    .CreateBoxTitle PROC1
        WinABI CreateWindowExA,0,=B"STATIC",RDI,WS_CHILD+WS_VISIBLE, \
               RSI,yTitleBoxFields+18,wiTitleBoxFields,heTitle3,[hMainWindow],0,[WndClassEx.hInstance],0
        RET
       ENDP1 .CreateBoxTitle
    .CreateBoxEdit PROC1
        WinABI CreateWindowExA,0,=B"BUTTON",RDI,WS_CHILD+WS_VISIBLE+BS_AUTOCHECKBOX+WS_TABSTOP, \
               RSI,yEditBoxFields,wiEditBoxFields,heEdit,[hMainWindow],RAX,[WndClassEx.hInstance],0
        RET
        ENDP1 .CreateBoxEdit

       ; Button Cancel.
        WinABI CreateWindowExA,0,=B'BUTTON',=B"&Cancel",WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP, \
               wiBorder,yTitleCmdLine,wiBtnIO,heBtnIO,[hMainWindow],IdBtnCancel,[WndClassEx.hInstance],0
        MOV [hBtnCancel],RAX
       ; Button Exec.
        MOV ECX,[WindowWidth]
        SUB ECX,wiBorder+wiBtnIO
        WinABI CreateWindowExA,0,=B'BUTTON',=B"E&xec",WS_CHILD+WS_VISIBLE+WS_BORDER+WS_TABSTOP, \
               RCX,yTitleCmdLine,wiBtnIO,heBtnIO,[hMainWindow],IdBtnExec,[WndClassEx.hInstance],0
        MOV [hBtnExec],RAX
        POP R12,RDI,RSI,RBX
        RET
       ENDP WndCreate

WndResize
  Dimensions of the MainWindow changed.
Called from
  WndProc.WM_SIZE.

    WndResize:: PROC
        PUSH RBX,RSI,RDI,R12
        LEA RBX,[RectMainWindow]
        WinABI GetWindowRect,[hMainWindow],RBX
        MOV ESI,[RBX+RECT.left]
        MOV ECX,[RBX+RECT.right]
        SUB ECX,ESI
        CMP ECX,MinimalWidth
        JA .10:
        MOV ECX,MinimalWidth
    .10:SUB ECX,15
        MOV [WindowWidth],ECX
        ADD ECX,15
        MOV EDI,[RBX+RECT.top]
        MOV EDX,[RBX+RECT.bottom]
        SUB EDX,EDI
       CMP EDX,MinimalHeight
       JA .20:
       MOV EDX,MinimalHeight
    .20:MOV [WindowHeight],EDX
        WinABI MoveWindow,[hMainWindow],RSI,RDI,RCX,RDX,-1
        ; Resize moveable elements.
        ; Button input file select.
        MOV ECX,[WindowWidth]
        SUB ECX,wiBorder+wiBtnIO
        WinABI MoveWindow,[hBtnInputFile],RCX,yTitleInputFile,wiBtnIO,heBtnIO,1
        ; Edit input file.
        MOV ECX,[WindowWidth]
        SUB ECX,2*wiBorder
        WinABI MoveWindow,[hEditInputFile],wiBorder,yEditInputFile,RCX,heEdit,1
        ; Compute interelement space of numeric fields to R12.
        MOV EAX,[WindowWidth]
        SUB EAX,2*wiBorder+5*wiTitleNumFields
        SAR EAX,2
        LEA R12D,[EAX+wiTitleNumFields]
        MOV ESI,wiBorder
    arg %FOR RecordSize,HeaderSize,HeaderLength,FooterSize,FooterLength
         WinABI MoveWindow,[hTitle%arg],RSI,yTitleNumFields,wiTitleNumFields,heTitle2,1
         WinABI MoveWindow,[hEdit%arg],RSI,yEditNumFields,wiEditNumFields,heEdit,1
         ADD ESI,R12D
       %ENDFOR arg
        ; Button output file.
        MOV ECX,[WindowWidth]
        SUB ECX,wiBorder+wiBtnIO
        WinABI MoveWindow,[hBtnOutputFile],RCX,yTitleOutputFile,wiBtnIO,heBtnIO,1
        ; Edit output file.
        MOV ECX,[WindowWidth]
        SUB ECX,2*wiBorder
        WinABI MoveWindow,[hEditOutputFile],wiBorder,yEditOutputFile,RCX,heEdit,1
       ; Compute interelement space of mixed fields to R12.
        MOV EAX,[WindowWidth]
        SUB EAX,2*wiBorder+wiEditEncoding+wiEditLocale+2*wiEditNumFields+5*wiEditBoxFields
        SHR EAX,3
        MOV R12D,EAX
        MOV ESI,wiBorder
        ; Title Locale.
        LEA ESI,[ESI+wiEditEncoding+R12D]
        WinABI MoveWindow,[hTitleLocale],RSI,yTitleBoxFields,wiTitleLocale,heTitle3,1
        ; Edit Locale.
        WinABI MoveWindow,[hEditLocale],RSI,yEditBoxFields,wiEditLocale,7*heEdit,1
        ; Title KeyOffset
        LEA ESI,[ESI+wiEditLocale+R12D]
        WinABI MoveWindow,[hTitleKeyOffset],RSI,yTitleBoxFields,wiTitleKeyFields,heTitle3,1
        ; Edit KeyOffset
        WinABI MoveWindow,[hEditKeyOffset],RSI,yEditBoxFields,wiEditNumFields,heEdit,1
      ; Title KeyLength
        LEA ESI,[ESI+wiEditNumFields+R12D]
        WinABI MoveWindow,[hTitleKeyLength],RSI,yTitleBoxFields,wiTitleKeyFields,heTitle3,1
         ; Edit KeyLength
        WinABI MoveWindow,[hEditKeyLength],RSI,yEditBoxFields,wiEditNumFields,heEdit,1
        LEA ESI,[ESI+wiEditBoxFields+R12D]
    arg %FOR KeyReverse,DigitFirst,PunctuationFirst,UpperFirst,MergeSpaces
         WinABI MoveWindow,[hTitle%arg],RSI,yTitleBoxFields+18,wiTitleBoxFields,heTitle3,1
         ADD ESI,16
         WinABI MoveWindow,[hEdit%arg],RSI,yEditBoxFields,wiEditBoxFields,heEdit,1
         LEA ESI,[ESI+wiEditBoxFields+R12D-16]
        %ENDFOR arg
        ; Button Exec.
        MOV ECX,[WindowWidth]
        SUB ECX,wiBorder+wiBtnIO
        WinABI MoveWindow,[hBtnExec],RCX,yTitleCmdLine,wiBtnIO,heBtnIO,1
       POP R12,RDI,RSI,RBX
       RET
    ENDP WndResize

      ENDPROGRAM sortwing

▲Back to the top▲