【问题标题】:Broken scrollbars in Graphics32's TImgView32Graphics32 的 TImgView32 中的滚动条损坏
【发布时间】:2020-02-06 00:05:49
【问题描述】:

我想在 TImgView32 上显示图像,但滚动条明显坏了。 当我放大,调整窗口大小,然后缩小时,我可以看到:

我已将 ImgView321.ScrollBars.Visibility 设置为 svAuto,因此现在不应该有任何滚动条。

这是我的全部代码。 Unit1.dfm:

object Form1: TForm1
  Left = 414
  Top = 179
  Width = 711
  Height = 494
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  OnMouseWheelDown = FormMouseWheelDown
  OnMouseWheelUp = FormMouseWheelUp
  PixelsPerInch = 96
  TextHeight = 13
  object ImgView321: TImgView32
    Left = 0
    Top = 0
    Width = 695
    Height = 454
    Align = alClient
    Bitmap.ResamplerClassName = 'TNearestResampler'
    BitmapAlign = baCustom
    Scale = 1.000000000000000000
    ScaleMode = smScale
    ScrollBars.ShowHandleGrip = True
    ScrollBars.Style = rbsDefault
    ScrollBars.Size = 17
    ScrollBars.Visibility = svAuto
    OverSize = 0
    TabOrder = 0
  end
end

和 Unit1.pas:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, GR32_Image;

type
  TForm1 = class(TForm)
    ImgView321: TImgView32;
    procedure FormCreate(Sender: TObject);
    procedure FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
      MousePos: TPoint; var Handled: Boolean);
    procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
      MousePos: TPoint; var Handled: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  ImgView321.Bitmap.LoadFromFile('1.bmp');
end;

procedure TForm1.FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
  MousePos: TPoint; var Handled: Boolean);
begin
  ImgView321.Scale := ImgView321.Scale / 2;

  ImgView321.Refresh;  
end;

procedure TForm1.FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
  MousePos: TPoint; var Handled: Boolean);
begin
  ImgView321.Scale := ImgView321.Scale * 2;

  ImgView321.Refresh;
end;

end.

【问题讨论】:

  • 好久没用GR32了,你用的是什么版本?难道是它与Delphi 7不完全兼容?
  • @JerryDodge 它在源代码中说它是“2.0.0 alpha”,其他一切都很好。

标签: delphi delphi-7 graphics32


【解决方案1】:

似乎解决了这个问题而不是

ImgView321.Invalidate;

ImgView321.Refresh;

我只是这样做:

ImgView321.ScrollBars.Visibility := svHidden;  
ImgView321.ScrollBars.Visibility := svAuto;

重绘滚动条似乎有问题。

【讨论】:

    猜你喜欢
    • 2019-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多