;<ff
Window frmExternalOptions, 3, 0, 'TForm', 'Debugers and emulators', $46000000, $10000, 0, 243, 191, 337, 256, frmExternalOptionsProc;
Window NONE, 0, 0, 'STATIC', 'Hint: In order to run Linux applications in Windows,  you have to install "andLinux".', $50000000, $0, 0, 8, 8, 320, 32, 0;
Window NONE, 0, 0, 'STATIC', 'andLinux &shared directory:', $50000000, $0, 0, 168, 48, 144, 16, 0;
Window NONE, 0, 0, 'STATIC', 'Win32 E&xternal debugger:', $50000000, $0, 0, 8, 176, 144, 16, 0;
Window NONE, 0, 0, 'TButtonEdit', '', $50810080, $0, 105, 8, 192, 312, 19, 0;
Window NONE, 0, 0, 'TButtonEdit', '', $50810080, $0, 106, 8, 64, 152, 19, 0;
Window NONE, 0, 0, 'TButtonEdit', '', $50810080, $0, 107, 168, 64, 152, 19, 0;
Window NONE, 0, 0, 'STATIC', 'Linux terminal:', $50000000, $0, 0, 168, 96, 96, 16, 0;
Window NONE, 0, 0, 'STATIC', 'and&Linux directory:', $50000000, $0, 0, 8, 48, 96, 16, 0;
Window NONE, 0, 0, 'EDIT', '', $50810080, $0, 109, 168, 112, 152, 19, 0;
Window NONE, 0, 0, 'STATIC', 'Linux debugger:', $50000000, $0, 0, 8, 96, 96, 16, 0;
Window NONE, 2, 0, 'EDIT', '', $50810080, $0, 108, 8, 112, 152, 19, 0;
;ff>

  cAndLinuxKey        text 'andLinux'
  cAndLinuxSharedKey  text 'LinuxSharedDir'
  cLinuxDbgKey        text 'LinuxDebugger'
  cLinuxTerminalKey   text 'LinuxTerminal'

  cAndTitle    text 'Select andLinux directory:'
  cSharedTitle text 'Select andLinux shared directory:'
  cDbgTitle    text 'Select external debuger:'

iglobal
  cExecutablesFilter db 'Executables (*.exe)',0,'*.exe',0
                     db 0
endg


idDebuggerEdit     = 105
idAndLinuxDirEdit  = 106
idSharedDirEdit    = 107
idLinuxDebugEdit   = 108
idLinuxTerminalEdit = 109

winproc frmExternalOptionsProc
  .str rb 1024
begin

ondefault
        stc
        return

onmessage WM_CLOSE
          clc
          return

onmessage FM_AFTERCREATE
        invoke  SendDlgItemMessageA, [.hwnd], idDebuggerEdit, BEM_SETBUTTONTEXT, 0, cTitleBtnEdit
        invoke  SendDlgItemMessageA, [.hwnd], idAndLinuxDirEdit, BEM_SETBUTTONTEXT, 0, cTitleBtnEdit
        invoke  SendDlgItemMessageA, [.hwnd], idSharedDirEdit, BEM_SETBUTTONTEXT, 0, cTitleBtnEdit
        clc
        return

onmessage OM_LOADOPTIONS

        stdcall GetParamFromINI, cAndLinuxKey
        jc      @f
        push    eax
        stdcall StrPtr, eax
        invoke  SendDlgItemMessageA, [.hwnd], idAndLinuxDirEdit, WM_SETTEXT, 0, eax
        stdcall StrDel ; from the stack
@@:
        stdcall GetParamFromINI, cAndLinuxSharedKey
        jc      @f
        push    eax
        stdcall StrPtr, eax
        invoke  SendDlgItemMessageA, [.hwnd], idSharedDirEdit, WM_SETTEXT, 0, eax
        stdcall StrDel ; from the stack
@@:
        stdcall GetParamFromINI, cLinuxDbgKey
        jc      @f
        push    eax
        stdcall StrPtr, eax
        invoke  SendDlgItemMessageA, [.hwnd], idLinuxDebugEdit, WM_SETTEXT, 0, eax
        stdcall StrDel ; from the stack
@@:
        stdcall GetParamFromINI, cDebugerKey
        jc      @f
        push    eax
        stdcall StrPtr, eax
        invoke  SendDlgItemMessageA, [.hwnd], idDebuggerEdit, WM_SETTEXT, 0, eax
        stdcall StrDel ; from the stack
@@:
        stdcall GetParamFromINI, cLinuxTerminalKey
        jc      @f
        push    eax
        stdcall StrPtr, eax
        invoke  SendDlgItemMessageA, [.hwnd], idLinuxTerminalEdit, WM_SETTEXT, 0, eax
        stdcall StrDel ; from the stack
@@:

        clc
        return


onmessage OM_SAVEOPTIONS

        stdcall StrPtr, [hIniFileName]
        mov     esi, eax
        lea     edi,[.str]

        invoke  SendDlgItemMessageA, [.hwnd], idAndLinuxDirEdit, WM_GETTEXT, 1024, edi
        invoke  WritePrivateProfileStringA, cParamSection, cAndLinuxKey, edi, esi

        invoke  SendDlgItemMessageA, [.hwnd], idSharedDirEdit, WM_GETTEXT, 1024, edi
        invoke  WritePrivateProfileStringA, cParamSection, cAndLinuxSharedKey, edi, esi

        invoke  SendDlgItemMessageA, [.hwnd], idLinuxDebugEdit, WM_GETTEXT, 1024, edi
        invoke  WritePrivateProfileStringA, cParamSection, cLinuxDbgKey, edi, esi

        invoke  SendDlgItemMessageA, [.hwnd], idDebuggerEdit, WM_GETTEXT, 1024, edi
        invoke  WritePrivateProfileStringA, cParamSection, cDebugerKey, edi, esi

        invoke  SendDlgItemMessageA, [.hwnd], idLinuxTerminalEdit, WM_GETTEXT, 1024, edi
        invoke  WritePrivateProfileStringA, cParamSection, cLinuxTerminalKey, edi, esi

        clc
        return


onmessage BEM_BUTTONCLICK

        lea     edi, [.str]

        cmp     [.wparam], idAndLinuxDirEdit
        je      .linuxdir

        cmp     [.wparam], idSharedDirEdit
        je      .shareddir

        cmp     [.wparam], idDebuggerEdit
        je      .debugfile

        clc
        return

.linuxdir:
        invoke  GetDlgItem, [.hwnd], idAndLinuxDirEdit
        mov     esi, cAndTitle
        jmp     .commondirButtonEdit

.shareddir:
        invoke  GetDlgItem, [.hwnd], idSharedDirEdit
        mov     esi, cSharedTitle

.commondirButtonEdit:
        mov     ebx, eax
        invoke  SendMessageA, ebx, WM_GETTEXT, 1024, edi
        stdcall SelectPathDialog, [hApplication], esi, edi
        test    eax,eax
        jz      .nodir

        push    eax
        stdcall StrPtr, eax
        invoke  SendMessageA, ebx, WM_SETTEXT, 0, eax
        stdcall StrDel ; From stack

.nodir:
        clc
        return

.debugfile:
        invoke  GetDlgItem, [.hwnd], idDebuggerEdit
        mov     esi, cDbgTitle
        mov     ebx, eax

        invoke  SendMessageA, ebx, WM_GETTEXT, 1024, edi
        stdcall OpenFilesDialog, esi, FALSE, cExecutablesFilter, ButtonEditFileSelect, edi, ebx
        clc
        return

endwp



