Graphics32的TImgView32中损坏的滚动条

问题描述 投票:0回答:1

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

Broken scrollbar

我已将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.
delphi delphi-7 graphics32
1个回答
0
投票

似乎代替时解决了问题

ImgView321.Invalidate;

ImgView321.Refresh;

我就是这样:

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

似乎重新绘制滚动条有问题。

© www.soinside.com 2019 - 2024. All rights reserved.