我想在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.
答案 0 :(得分:0)
似乎可以解决问题,而不是
ImgView321.Invalidate;
或
ImgView321.Refresh;
我只是这样做:
ImgView321.ScrollBars.Visibility := svHidden;
ImgView321.ScrollBars.Visibility := svAuto;
重新绘制滚动条似乎是一个问题。