; Constants;

fdlgFindButtonID           = MR_OK
fdlgReplaceButtonID        = MR_OK
fdlgTextEditID             = 10
fdlgReplaceTextEditID      = 11
fdlgCaseSensitiveCheckID   = 20
fdlgWholeWordsCheckID      = 21
fdlgPromptOnReplaceCheckID = 22
fdlgDirectionRadioID       = 30
fdlgSearchInRadioID        = 40

fdlgMaxFindStrLen = 0x50

struct TFindOptions
  .search_type       dd ?
  .search_strw       rw fdlgMaxFindStrLen
  .replace_strw      rw fdlgMaxFindStrLen
  .range             dd ?
  .case_sensitive    dd ?
  .direction         dd ?
  .whole_words       dd ?
  .prompt_on_replace dd ?
ends

; Initialized data.

iglobal
; Search dialog.
  Window  FindDialog, wtParent or wtEnd, waNone, 'TForm', 'Find', ComDlgStyle, 0, NULL, 0, 0, 296, 310, FindDialogProc
  Window  NONE, wtChild, 0, 'Static', "Text to find:", WS_VISIBLE or WS_CHILD, 0, 0, 10, 8, 60, 13, NULL
  Window  NONE, wtChild, 0, 'Combobox', '', WS_VISIBLE or WS_CHILD or CBS_DROPDOWN or CBS_AUTOHSCROLL or WS_VSCROLL or WS_TABSTOP, 0, fdlgTextEditID, 10, 24, 270, 120, NULL
  Window  NONE, wtChild, 0, 'Button', "Options", WS_VISIBLE or WS_CHILD or BS_GROUPBOX, 0, 0, 150, 50, 130, 70, NULL
  Window  NONE, wtChild, 0, 'Button', "Case sensitive", WS_VISIBLE or WS_CHILD or BS_AUTOCHECKBOX or WS_TABSTOP , 0, fdlgCaseSensitiveCheckID, 160, 72, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "Whole words only", WS_VISIBLE or WS_CHILD or BS_AUTOCHECKBOX or WS_TABSTOP, 0, fdlgWholeWordsCheckID, 160, 95, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "Direction", WS_VISIBLE or WS_CHILD or BS_GROUPBOX, 0, 0, 10, 50, 130, 70, NULL
  Window  NONE, wtChild, 0, 'Button', "Forward", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_GROUP or WS_TABSTOP, 0, fdlgDirectionRadioID, 20, 72, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "Backward", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_TABSTOP, 0, fdlgDirectionRadioID or 1, 20, 95, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "Search in:", WS_VISIBLE or WS_CHILD or BS_GROUPBOX, 0, 0, 10, 130, 130, 110, NULL
  Window  NONE, wtChild, 0, 'Button', "C&urrent file", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_GROUP or WS_TABSTOP, 0, fdlgSearchInRadioID, 20, 152, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "&Whole current file", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_TABSTOP, 0, fdlgSearchInRadioID+1, 20, 174, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "&All open files", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_TABSTOP, 0, fdlgSearchInRadioID+2, 20, 196, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "Whole &project", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_TABSTOP, 0, fdlgSearchInRadioID+3, 20, 218, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "&Find first", WS_VISIBLE or WS_CHILD or BS_DEFPUSHBUTTON or WS_TABSTOP, 0, fdlgFindButtonID, 10, 250, 80, 24, NULL
  Window  NONE, wtEnd, 0, 'Button', 'Cancel', WS_VISIBLE or WS_CHILD or WS_TABSTOP, 0, MR_CANCEL, 100, 250, 80, 24, NULL

; Replace dialog
  Window  ReplaceDialog, wtParent or wtEnd, waNone, 'TForm', "Replace", ComDlgStyle, 0, NULL, 0, 0, 296, 350, FindDialogProc
  Window  NONE, wtChild, 0, 'Static', "Text to find:", WS_VISIBLE or WS_CHILD, 0, 0, 10, 8, 60, 13, NULL
  Window  NONE, wtChild, 0, 'Combobox', '', WS_VISIBLE or WS_CHILD or CBS_DROPDOWN or CBS_AUTOHSCROLL or WS_VSCROLL or WS_TABSTOP, 0, fdlgTextEditID, 10, 24, 270, 120, NULL
  Window  NONE, wtChild, 0, 'Static', "New text:", WS_VISIBLE or WS_CHILD, 0, 0, 10, 50, 60, 13, NULL
  Window  NONE, wtChild, 0, 'Combobox', '', WS_VISIBLE or WS_CHILD or CBS_DROPDOWN or CBS_AUTOHSCROLL or WS_VSCROLL or WS_TABSTOP, 0, fdlgReplaceTextEditID, 10, 65, 270, 120, NULL
  Window  NONE, wtChild, 0, 'Button', "Options", WS_VISIBLE or WS_CHILD or BS_GROUPBOX, 0, 0, 150, 90, 130, 190, NULL
  Window  NONE, wtChild, 0, 'Button', "Case sensitive", WS_VISIBLE or WS_CHILD or BS_AUTOCHECKBOX or WS_TABSTOP, 0, fdlgCaseSensitiveCheckID, 160, 112, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "Whole words only", WS_VISIBLE or WS_CHILD or BS_AUTOCHECKBOX or WS_TABSTOP, 0, fdlgWholeWordsCheckID, 160, 135, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "Prompt on replace", WS_VISIBLE or WS_CHILD or BS_AUTOCHECKBOX or WS_TABSTOP, 0, fdlgPromptOnReplaceCheckID, 160, 157, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "Direction", WS_VISIBLE or WS_CHILD or BS_GROUPBOX, 0, 0, 10, 90, 130, 70, NULL
  Window  NONE, wtChild, 0, 'Button', "Forward", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_GROUP or WS_TABSTOP, 0, fdlgDirectionRadioID, 20, 112, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "Backward", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_TABSTOP, 0, fdlgDirectionRadioID+1, 20, 135, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "Search in:", WS_VISIBLE or WS_CHILD or BS_GROUPBOX, 0, 0, 10, 170, 130, 110, NULL
  Window  NONE, wtChild, 0, 'Button', "C&urrent file", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_GROUP or WS_TABSTOP, 0, fdlgSearchInRadioID, 20, 192, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "&Whole current file", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_TABSTOP, 0, fdlgSearchInRadioID+1, 20, 214, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "&All open files", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_TABSTOP, 0, fdlgSearchInRadioID+2, 20, 236, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', "Whole &project", WS_VISIBLE or WS_CHILD or BS_AUTORADIOBUTTON or WS_TABSTOP, 0, fdlgSearchInRadioID+3, 20, 258, 105, 13, NULL
  Window  NONE, wtChild, 0, 'Button', 'Replace', WS_VISIBLE or WS_CHILD or BS_DEFPUSHBUTTON or WS_TABSTOP, 0, fdlgReplaceButtonID, 10, 290, 80, 24, NULL
  Window  NONE, wtEnd, 0, 'Button', 'Cancel', WS_VISIBLE or WS_CHILD or WS_TABSTOP, 0, MR_CANCEL, 100, 290, 80, 24, NULL
endg

cSearchTitle      text  "Search"
cReplacePrompt    text  "Replace this occurrence?"
cPerformingSearch text  "Performing search..."

cSearchOneFile1 text "Search for """
cSearchOneFile2 text """ in file "
cSearchResults1 text " (total "
cSearchResults2 text " results)"
cSearchLine1    text "line: "
cSearchLine2    text " ["
cSearchLine3    text "]"


uglobal
  FindOptions        TFindOptions
  hFindHistory       dd ?
  string_buffer      rw 0x100
  hwnd_find_progress dd ?
  find_cancel_flag   dd ?
endg