⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adfview.pas

📁 Async Professional 4.04
💻 PAS
📖 第 1 页 / 共 2 页
字号:
          HMult := 1;
          HDiv  := 1;
          VMult := 1;
          VDiv  := 1;
        end
      else
        FillScaleSettings(Settings);

      CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, LongInt(@Settings)));
    end;
  end;

  procedure TApdCustomFaxViewer.SetHorizMult(const NewHorizMult : Cardinal);
  var
    Settings : TScaleSettings;

  begin
    if (NewHorizMult = FHorizMult) or (NewHorizMult = 0) then
      Exit;

    FHorizMult := NewHorizMult;

    if FScaling then begin
      FillScaleSettings(Settings);
      Settings.HMult := NewHorizMult;
      CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, LongInt(@Settings)));
    end;
  end;

  procedure TApdCustomFaxViewer.SetHorizDiv(const NewHorizDiv : Cardinal);
  var
    Settings : TScaleSettings;

  begin
    if (NewHorizDiv = FHorizDiv) or (NewHorizDiv = 0) then
      Exit;

    FHorizDiv := NewHorizDiv;

    if FScaling then begin
      FillScaleSettings(Settings);
      Settings.HDiv := NewHorizDiv;
      CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, LongInt(@Settings)));
    end;
  end;

  procedure TApdCustomFaxViewer.SetVertMult(const NewVertMult : Cardinal);
  var
    Settings : TScaleSettings;

  begin
    if (NewVertMult = FVertMult) or (NewVertMult = 0) then
      Exit;

    FVertMult := NewVertMult;

    if FScaling then begin
      FillScaleSettings(Settings);
      Settings.VMult := NewVertMult;
      CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, LongInt(@Settings)));
    end;
  end;

  procedure TApdCustomFaxViewer.SetVertDiv(const NewVertDiv : Cardinal);
  var
    Settings : TScaleSettings;

  begin
    if (NewVertDiv = FVertDiv) or (NewVertDiv = 0) then
      Exit;

    FVertDiv := NewVertDiv;

    if FScaling then begin
      FillScaleSettings(Settings);
      Settings.VDiv := NewVertDiv;
      CheckException(Self, SendMessage(Handle, apw_ViewSetScale, 0, LongInt(@Settings)));
    end;
  end;

  procedure TApdCustomFaxViewer.SetAutoScaleMode(const NewAutoScaleMode : TAutoScaleMode);
  var
    Opt : Word;

  begin
    if (NewAutoScaleMode = FAutoScaleMode) then
      Exit;
    case NewAutoScaleMode of
      asDoubleHeight: Opt := ufAutoDoubleHeight;
      asHalfWidth   : Opt := ufAutoHalfWidth;
      else
        Opt := 0;
    end;
    SendMessage(Handle, apw_ViewSetAutoScale, Opt, 0);

    FAutoScaleMode := NewAutoScaleMode;
  end;

  procedure TApdCustomFaxViewer.SetWhitespaceCompression(const NewCompression : Boolean);
  begin
    if (FWhitespaceCompression <> NewCompression) then begin
      FWhitespaceCompression := NewCompression;

      if not FWhitespaceCompression then
        CheckException(Self, SendMessage(Handle, apw_ViewSetWhitespace, 0, 0))
      else
        CheckException(Self, SendMessage(Handle, apw_ViewSetWhitespace, FWhitespaceFrom, FWhitespaceTo));
    end;
  end;

  procedure TApdCustomFaxViewer.SetWhitespaceFrom(const NewWhitespaceFrom : Cardinal);
  begin
    if (NewWhitespaceFrom <> FWhitespaceFrom) then begin
      FWhitespaceFrom := NewWhitespaceFrom;

      if FWhitespaceCompression then
        CheckException(Self, SendMessage(Handle, apw_ViewSetWhitespace, FWhitespaceFrom, FWhitespaceTo));
    end;
  end;

  procedure TApdCustomFaxViewer.SetWhitespaceTo(const NewWhitespaceTo : Cardinal);
  begin
    if (NewWhitespaceTo <> FWhitespaceTo) then begin
      FWhitespaceTo := NewWhitespaceTo;

      if FWhitespaceCompression then
        CheckException(Self, SendMessage(Handle, apw_ViewSetWhitespace, FWhitespaceFrom, FWhitespaceTo));
    end;
  end;

  procedure TApdCustomFaxViewer.SetHorizScroll(const NewHorizScroll : Cardinal);
  begin
    if (NewHorizScroll <> FHorizScroll) then begin
      FHorizScroll := NewHorizScroll;

      SendMessage(Handle, apw_ViewSetScroll, FHorizScroll, FVertScroll);
    end;
  end;

  procedure TApdCustomFaxViewer.SetVertScroll(const NewVertScroll : Cardinal);
  begin
    if (NewVertScroll <> FVertScroll) then begin
      FVertScroll := NewVertScroll;

      SendMessage(Handle, apw_ViewSetScroll, FHorizScroll, FVertScroll);
    end;
  end;

  procedure TApdCustomFaxViewer.SetAcceptDragged(const NewAccept : Boolean);
  begin
  end;

  procedure TApdCustomFaxViewer.SetLoadWholeFax(const NewLoadWholeFax : Boolean);
  begin
    if (NewLoadWholeFax = FLoadWholeFax) then
      Exit;

    SendMessage(Handle, apw_ViewsetLoadWholeFax, Ord(NewLoadWholeFax), 0);
    FLoadWholeFax := NewLoadWholeFax;
  end;

  procedure TApdCustomFaxViewer.SetFileName(const NewFileName : String);
  var
    FNameZ : array[0..255] of Char;
{$IFDEF TRIALRUN}
  {$I TRIAL05.INC}
{$ENDIF}
  begin
    FFileName := NewFileName;

    if not (csDesigning in ComponentState) then begin
{$IFDEF TRIALRUN}
  TC;
{$ENDIF}
      CheckException(Self, SendMessage(Handle, apw_ViewSetFile, 0, LongInt(StrPCopy(FNameZ, FFileName))));

      FRotation  := vr0;
      FHorizMult := 1;
      FHorizDiv  := 1;
      FVertMult  := 1;
      FVertDiv   := 1;
    end;
  end;

  procedure TApdCustomFaxViewer.SetRotation(const NewRotation : TViewerRotation);
  begin
    if (NewRotation = FRotation) then
      Exit;

    CheckException(Self, SendMessage(Handle, apw_ViewSetRotation, Ord(NewRotation), 0));
    FRotation := NewRotation;
  end;

  procedure TApdCustomFaxViewer.SetBusyCursor(const NewBusyCursor : TCursor);
  begin
    if (NewBusyCursor = BusyCursor) then
      Exit;

    SendMessage(Handle, apw_ViewSetBusyCursor, Screen.Cursors[NewBusyCursor], 0);
    FBusyCursor := NewBusyCursor;
  end;

  procedure TApdCustomFaxViewer.SetActivePage(const NewPage : Cardinal);
  begin
    if (ActivePage <> NewPage) and (FFileName <> '') then begin
      if (NewPage = 0) or (NewPage > NumPages) then
        CheckException(Self, ecBadArgument);

      CheckException(Self, SendMessage(Handle, apw_ViewGotoPage, NewPage, 0));
    end;
  end;

  function TApdCustomFaxViewer.GetPageBitmaps(const PageNum : Integer) : TBitmap;
  var
    H : HBitmap;
    P : TPoint;

  begin
    if (PageNum = 0) or (PageNum > Integer(NumPages)) then           
      CheckException(Self, ecBadArgument);

    H := SendMessage(Handle, apw_ViewGetBitmap, PageNum, LongInt(@P));
    if (H = 0) then
      Result := nil
    else begin
      Result := TBitmap.Create;
      Result.Handle := H;
    end;
  end;

  function TApdCustomFaxViewer.GetNumPages : Cardinal;
  begin
    Result := SendMessage(Handle, apw_ViewGetNumPages, 0, 0);
  end;

  function TApdCustomFaxViewer.GetActivePage : Cardinal;
  begin
    Result := SendMessage(Handle, apw_ViewGetCurPage, 0, 0);
  end;

  function TApdCustomFaxViewer.GetPageWidth : Cardinal;
  var
    R : TRect;

  begin
    SendMessage(Handle, apw_ViewGetPageDim, 0, LongInt(@R));
    Result := Succ(R.Right);
  end;

  function TApdCustomFaxViewer.GetPageHeight : Cardinal;
  var
    R : TRect;

  begin
    SendMessage(Handle, apw_ViewGetPageDim, 0, LongInt(@R));
    Result := Succ(R.Bottom);
  end;

  function TApdCustomFaxViewer.GetPageFlags : Word;                  
  begin
    Result := SendMessage(Handle, apw_ViewGetPageFlags, 0, 0);
  end;

  procedure TApdCustomFaxViewer.FileDropped;
    {-Called when a file is dropped into the viewer}
  begin
    FFileName := StrPas(PChar(SendMessage(Handle, apw_ViewGetFileName, 0, 0))); 
    if Assigned(FFileDrop) then
      FFileDrop(Self, FileName);
  end;

  procedure TApdCustomFaxViewer.PageChange;
    {-Called when the active page changes}
  begin
    if Assigned(FPageChange) then
      FPageChange(Self);
  end;

  procedure TApdCustomFaxViewer.ViewerError(var Msg : TMessage);
    {-Called when an error occurs and no result can be returned}
  begin
    if Assigned(FViewerError) then
      FViewerError(Self, Integer(Msg.wParam));
  end;

  procedure TApdCustomFaxViewer.wmDropFiles(var Msg : wMsg);
  {-get a dropped file}
  begin
    inherited;
    FileDropped;
  end;

  procedure TApdCustomFaxViewer.wmEraseBkGnd(var Msg : TMessage);
  {-erase background}
  begin
    Msg.Result := 1;
  end;

  procedure TApdCustomFaxViewer.FillScaleSettings(var Settings : TScaleSettings);
    {-Fill a TScaleSettings structure with current scaling settings}
  begin
    with Settings do begin
      HMult := FHorizMult;
      HDiv  := FHorizDiv;
      VMult := FVertMult;
      VDiv  := FVertDiv;
    end;
  end;

  constructor TApdCustomFaxViewer.Create(AOwner : TComponent);
    {-Create a TApdCustomFaxViewer component}
  begin
    inherited Create(AOwner);

    {inits}
    FBorderStyle           := afvDefViewBorderStyle;
    FFGColor               := afvDefFGColor;
    FBGColor               := afvDefBGColor;
    FScaling               := afvDefScaling;
    FHorizMult             := afvDefHorizMult;
    FHorizDiv              := afvDefHorizDiv;
    FVertMult              := afvDefVertMult;
    FVertDiv               := afvDefVertDiv;
    FAutoScaleMode         := afvDefViewAutoScaleMode;               
    FWhitespaceCompression := afvDefWhitespaceCompression;
    FWhitespaceFrom        := afvDefWhitespaceFrom;
    FWhitespaceTo          := afvDefWhitespaceTo;
    FHorizScroll           := afvDefHorizScroll;
    FVertScroll            := afvDefVertScroll;
    FFileName              := afvDefFileName;
    FAcceptDragged         := afvDefAcceptDragged;
    FLoadWholeFax          := afvDefLoadWholeFax;
    FFileDrop              := nil;
    FPageChange            := nil;
    FViewerError           := nil;
    FRotation              := vr0;
    FBusyCursor            := afvDefBusyCursor;
    Height                 := afvDefViewerHeight;
    Width                  := afvDefViewerWidth;
    TabStop                := True;
    HasBeenCreated         := False;
  end;

  procedure TApdCustomFaxViewer.BeginUpdate;
    {-Begin changing the properties of the viewer--no visual changes}
  begin
    SendMessage(Handle, apw_ViewStartUpdate, 0, 0);
  end;

  procedure TApdCustomFaxViewer.EndUpdate;
    {-Invalidates the window and repaints}
  begin
    SendMessage(Handle, apw_ViewEndUpdate, 0, 0);
  end;

  procedure TApdCustomFaxViewer.FirstPage;
    {-Move to first page}
  begin
    if (FFileName <> '') then
      ActivePage := 1;
  end;

  procedure TApdCustomFaxViewer.LastPage;
    {-Move to last page}
  begin
    if (FFileName <> '') then
      ActivePage := NumPages;
  end;

  procedure TApdCustomFaxViewer.NextPage;
    {-Move to next page}
  begin
    if (FFileName <> '') and (ActivePage <> NumPages) then
      ActivePage := ActivePage + 1;
  end;

  procedure TApdCustomFaxViewer.PrevPage;
    {-Move to previous page}
  begin
    if (FFileName <> '') and (ActivePage <> 1) then
      ActivePage := ActivePage - 1;
  end;

  procedure TApdCustomFaxViewer.SelectRegion(const R : TRect);
    {-Select the image bounded by R}
  begin
    SendMessage(Handle, apw_ViewSelect, 0, LongInt(@R));
  end;

  procedure TApdCustomFaxViewer.SelectImage;
    {-Select entire image}
  begin
    SendMessage(Handle, apw_ViewSelectAll, 0, 0);
  end;

  procedure TApdCustomFaxViewer.CopyToClipBoard;
    {-Copy selected text to clipboard}
  begin
    SendMessage(Handle, apw_ViewCopy, 0, 0);
  end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -