Methods


function Open(const AFileName: WideString; ARedraw: Boolean = True): Boolean;
Opens a file and optionally redraws control.
Result is True if file was successfully opened or False if file was not found or other open error occured.
Pass the empty AFileName string to close the currently open file.
Note:
  • ARedraw parameter must be set to False in the case you create ATBinHex object at run-time and then call Open('')/OpenStream(nil) in your destructor to free data. In this case the control must not be redrawn because this will cause its parent access error.
function OpenStream(AStream: TStream; ARedraw: Boolean = True): Boolean;
Opens a stream and optionally redraws control.
Result is True if stream was successfully opened.
Pass nil to stop use the currently used stream.
Notes:
  • See note for Open.
  • Stream is not freed automatically, you should free it by yourself, but only after you call OpenStream(nil).
  • In Delphi 5 TStream.Size is declared as Longint, so if you are going to open streams larger than 2 Gb, you should use newer Delphi versions which declare TStream.Size as Int64.
procedure Reload;
Reloads current file or stream.
function FindFirst(const AText: WideString; AOptions: TATStreamSearchOptions): Boolean;
Starts text search.
AText: text to search (Note: Unicode string must be in the Little-Endian format).
AOptions: search options that are set of flags:
  • asoWholeWords: Search for whole words only
  • asoCaseSens: Case-sensitive search
  • asoBackward: Backward search (Note: not supported for RegEx search)
  • asoRegEx: RegEx (regular expressions) search
  • asoRegExMLine: Multiline regex search (used with asoRegEx)
  • asoFromPage: Starts search from the current page, otherwise in entire file
  • asoShowAll: Highlights all occurances of search string
Result is True if text was found.
Match position and length are saved in SearchResultStart and SearchResultLength properties. You should manually highlight found match using SetSelection method.
Notes:
  • RegEx search (asoRegEx option) is available only when RegEx library is compiled in. See ATStreamSearchOptions.inc file.
  • Unicode-named files can be handled during search only when Tnt Unicode Controls are compiled in. See ATStreamSearchOptions.inc file.
  • When non-RegEx search is performed, two different search functions are used: one for 1-byte Text/Binary/Hex modes and other for Unicode modes; they give different search results.
function FindNext(AFindPrevious: Boolean = False): Boolean;
Continues text search.
AFindPrevious: continue search in reverse direction (Note: not supported for RegEx search).
Result is the same as for FindFirst method.
Note:
  • After you change view mode or reload a file, you cannot continue search immediately, you must first call FindFirst.
procedure CopyToClipboard(AsHex: Boolean = False);
Copies current selection (AnsiString or WideString depending on current view mode) to Clipboard.
AsHex may be True in Text/Binary/Hex modes, in this case the hex-encoded string (bytes in the hex form separated by spaces) will be copied.
Notes:
  • This procedure may fail and show an error message if selection is too big to fit in memory.
  • To prevent visual "hanging" during copying of too large block, data size is internally limited by MaxClipboardDataSizeMb value.
procedure SetSelection(const AStart, ALength: Int64; AScroll: Boolean; AFireEvent: Boolean = True; ARedraw: Boolean = True);
Sets selection and optionally scrolls control to selection start.
AStart: selection start (0-based),
ALength: selection length,
AScroll: scroll control to selection start afterwards,
AFireEvent: fire the OnSelectionChange event afterwards,
ARedraw: redraw control afterwards.
Note:
  • If AScroll = True, control will be scrolled using the code:
      Scroll(AStart, TextSearchIndentVert, TextSearchIndentHorz);
procedure Scroll(const APos: Int64; AIndentVert, AIndentHorz: integer; ARedraw: Boolean = True);
Scrolls control to specified position.
Control will be scrolled vertically so that position APos (0-based) is visible by AIndentVert lines lower than top border; if after that the position is still out of screen, control will be scrolled horizontally so that position is visible by AIndentHorz chars righter than left border.
ARedraw: allow to redraw control afterwards.
procedure SelectAll;
procedure SelectNone;
Selects all text.
Deselects text.
procedure Print( APrintRange: TPrintRange; AFromPage: Integer = 1; AToPage: Integer = MaxInt; ACopies: Integer = 1; const ACaption: string = '');
Shows "Print preview" dialog and allows user to print text.
APrintRange: print range (type declared in Dialogs.pas):
  • prAllPages: prints all text.
  • prSelection: prints selection only.
  • prPageNums: prints pages from AFromPage to AToPage.
ACopies: number of print copies,
ACaption: caption of print job.
Notes:
  • This method shows "Print preview" form only when ATPrintPreview component is used by enabling the "PREVIEW" define in ATBinHexOptions.inc. Otherwise it just prints the text without questions.
  • Resulting page sizes are affected by Margin* properties and printer page sizes, not by visible control size.
procedure PrintPreview;
Shows "Print preview" dialog for current selection.
When text is selected (SelLength <> 0), this method calls Print(prSelection), otherwise it calls Print(prAllPages). Note:
  • This method works only when ATPrintPreview component is used by enabling the "PREVIEW" define in ATBinHexOptions.inc. Otherwise it does nothing.
function IncreaseFontSize(AIncrement: Boolean): Boolean;
Increases (AIncrement = True) or decreases current font size.
Result is True if font size was changed or False if minimal or maximal size value is already set.
Note:
  • For raster fonts (the default OEM font is raster) this size change is not simple increment by one.
procedure TextEncodingsMenu(AX, AY: Integer);
Shows menu of all available encodings for the current mode.
Menu is shown at point (AX, AY).
Note:
  • In Unicode modes this method displays the special Unicode menu, which contains only "UTF-16 LE" and "UTF-16 BE" items.