Methods, General


function Open(const AFileName: WideString; APicture: TPicture = nil): Boolean;
Opens a file.
Result is True if file was successfully opened or False if file was not found or other open error occured.
Pass the empty string to close the currently opened file.
APicture optional parameter can specify the preloaded image object.
Notes:
  • APicture parameter is introduced to reduce flickering when user loads multiple images. For example, user goes through an image directory using "File -- Next" interface command. After user has loaded an image, you can create a thread, that will load the next image in background and save it into TPicture object. When user performs "File -- Next" command again, you can quickly load the preloaded object using APicture parameter, and then create a thread that will load the next image etc.
  • APicture parameter is used only when Image mode is activated (this depends on filename and mode detection properties).
function OpenStream(AStream: TStream; AMode: TATViewerMode): Boolean;
Opens a stream in a given view mode.
Pass nil to stop use the currently used stream.
Result is True if stream was successfully read.
The AMode parameter can be:
  • vmodeText, vmodeBinary, vmodeHex, vmodeUnicode: Stream is passed to ATBinHex control. You can free stream object only after you call OpenStream(nil), because stream is constantly read.
  • vmodeRTF: Stream is read into RichEdit control.
  • vmodeMedia: Stream must contain image data, which will be read into ATImageBox control using OnLoadImageStream event handler.
  • vmodeWeb: Stream must contain data valid for WebBrowser control, it will be read using OnLoadWebStream event handler.
Notes:
  • See "ViewerStream" demo for example of OnLoadImageStream / OnLoadWebStream event handlers.
  • Mode property cannot be changed while stream is opened.
function OpenFolder(const AFolderName: WideString): Boolean;
Opens a folder using Lister plugin.
Result is True if folder was opened using some plugin.
Pass the empty string to close the currently opened plugin (you can also call Open('') for this).
Notes:
  • Examples of Lister plugins which can show folders are VisualDirSize and IEView.
  • Mode property cannot be changed while folder is opened: internal viewers cannot be used for folders.
procedure Reload;
Reloads the currently opened file or folder.
Note:
  • This method just reassigns the old value of Mode property. As the result:
    • when performed in Unicode mode, it switches between pure Unicode and Unicode/Hex modes;
    • when performed in Plugins mode, it loads the next matched plugin.
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 in RTF mode and for RegEx)
  • asoRegEx: RegEx search (Note: supported only in Text/Binary/Hex/Unicode modes)
  • asoRegExMLine: Multiline regex search (used with asoRegEx)
  • asoFromPage: Starts search from the current page, otherwise in entire file (Note: supported in all text modes)
  • asoShowAll: Highlights all occurances of search string (Note: supported in all text modes)
Result is True if text was found and highlighted.
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 another for Unicode mode; they give different search results.
  • In Text/Binary/Hex modes, when TextEncoding <> vencANSI, text is automatically decoded during search.
function FindFirst_(const AText: WideString; AOptions: Integer): Boolean;
Starts text search (the same as FindFirst, it is for ActiveX).
AText: text to search.
AOptions: search options that are sum of flags:
  • vfo_Words = 1: Search for whole words only
  • vfo_Case = 2: Case-sensitive search
  • vfo_Back = 4: Backward search (Note: not supported in RTF mode and for RegEx)
  • vfo_RegEx = 8: RegEx search (Note: supported only in Text/Binary/Hex/Unicode modes)
  • vfo_FromPage = 16: Starts search from the current page, otherwise in entire file (Note: supported in all text modes)
  • vfo_ShowAll = 32: Highlights all occurances of search string (Note: supported in all text modes)
Result is True if text was found and highlighted.
function FindNext(AFindPrevious: Boolean = False): Boolean;
Continues text search.
AFindPrevious: continue search in reverse direction.
Result is the same as for FindFirst method.
Notes:
  • AFindPrevious option can be used only in Text/Binary/Hex/Unicode modes and cannot be used for RegEx search.
  • After you change view mode or reload a file, you cannot continue search immediately, you must first call FindFirst method.
function FindDialog(AFindNext: Boolean): Boolean;
Calls custom search dialog, specific to the current view mode or plugin.
This may be MSIE search dialog in Internet mode, or active plugin's custom dialog.
AFindNext should be set to True for "Find next" command.
Result is True if custom dialog was successfully shown. In this case you don't need to show your own dialog. If Result is False, then you need to show your own dialog and then call FindFirst / FindNext methods.
procedure CopyToClipboard(AsHex: Boolean = False);
Copies data to Clipboard.
This method works differently in various view modes:
  • Text/Binary/Hex: data is the current selection (AnsiString). AsHex parameter may be True, in this case the hex-encoded string (bytes in the hex form separated by spaces) will be copied.
  • Unicode: data is the current selection (WideString).
  • Multimedia: when an image is loaded (IsImage = True): data is the whole image.
  • Internet: data is the current selection (usually HTML text).
  • Plugins: data is the current selection; data type depends on plugin and plugin is responsible for performing the copying operation.
  • RTF: data is the current selection (plain or RTF text).
Note:
  • This method may fail and show an error message if data size selected is too big.
procedure SelectAll;
procedure SelectNone;

  • SelectAll: Selects all text. Works in text, Internet, Plugins modes.
  • SelectNone: Deselects text. Works in text, Internet modes.
procedure PrintDialog;
procedure PrintSetup;
procedure PrintPreview;

  • PrintDialog: Shows "Print" dialog. Works in all modes.
  • PrintSetup: Shows "Page Setup" dialog. Works in all modes.
  • PrintPreview: Shows "Print Preview" dialog. Works in Text/Binary/Hex/Unicode, Multimedia (IsImage = True), Internet modes.
Notes:
  • PrintDialog / PrintPreview methods show preview form in text/Multimedia modes, but only when ATPrintPreview component is used by enabling the "PREVIEW" define in ATBinHexOptions.inc / ATViewerOptions.inc files.
  • PrintSetup / PrintPreview methods show MSIE dialogs in Internet mode.
  • PrintSetup does nothing in Delphi 5-6, because TPageSetupDialog is not available.
procedure FocusActiveControl;
Focuses the active embedded control (TATBinHex, TRichEdit, TWebBrowser etc).
Notes:
  • If you have ATViewer as main form control, you should call FocusActiveControl in your form's WM_ACTIVATE message handler to put focus back to ATViewer after some dialog has been shown.
  • See also IsFocused property.
procedure IncreaseScale(AIncrement: Boolean);
Increases (AIncrement = True) or decreases current font size or image scale.
Works in text, Multimedia (IsImage = True), Internet modes.