var
tmpBitmap:TBitmap ;
MyRect, MyOther: TRect;
begin
if SSleft in Shift then
tmpBitmap:=TBitmap.Create();
tmpBitmap.Width:=ImgPic.Picture.Width;
tmpBitmap.Height:=ImgPic.Picture.Height;
MyRect := Rect(0,0,ImgZoom.Width ,ImgZoom.Height); MyOther:= Rect(X-ImgZoom.Width div 4,Y-ImgZoom.Height div 4,X+ImgZoom.Width div 4,Y+ImgZoom.Height div 4);
tmpBitmap.Canvas.CopyRect(MyRect,ImgPic.Picture.Bitmap.Canvas,MyOther);
ImgZoom.Picture.Graphic := tmpBitmap;
ImgZoom.Left:=X-ImgZoom.Width div 2 ;
ImgZoom.Top:=Y-ImgZoom.Height div 2;
if (x>=ImgPic.Width)or(Y>=ImgPic.Height) then
begin
ImgZoom.Visible:=false;
end else begin
ImgZoom.Visible:=true;
end;
ImgZoom.Refresh;
tmpBitmap.Free;
end;编译时候tmpBitmap.Width:=ImgPic.Picture.Width;通不过,请高手帮助!!!!!
tmpBitmap:TBitmap ;
MyRect, MyOther: TRect;
begin
if SSleft in Shift then
tmpBitmap:=TBitmap.Create();
tmpBitmap.Width:=ImgPic.Picture.Width;
tmpBitmap.Height:=ImgPic.Picture.Height;
MyRect := Rect(0,0,ImgZoom.Width ,ImgZoom.Height); MyOther:= Rect(X-ImgZoom.Width div 4,Y-ImgZoom.Height div 4,X+ImgZoom.Width div 4,Y+ImgZoom.Height div 4);
tmpBitmap.Canvas.CopyRect(MyRect,ImgPic.Picture.Bitmap.Canvas,MyOther);
ImgZoom.Picture.Graphic := tmpBitmap;
ImgZoom.Left:=X-ImgZoom.Width div 2 ;
ImgZoom.Top:=Y-ImgZoom.Height div 2;
if (x>=ImgPic.Width)or(Y>=ImgPic.Height) then
begin
ImgZoom.Visible:=false;
end else begin
ImgZoom.Visible:=true;
end;
ImgZoom.Refresh;
tmpBitmap.Free;
end;编译时候tmpBitmap.Width:=ImgPic.Picture.Width;通不过,请高手帮助!!!!!
如果是,那它的Picture確定有圖片?如果沒圖片,當然錯誤了,不存在圖片對象
你的程序应该没有问题
按照你代碼,沒錯,不會有問題了
現在上班呢,估計不能幫你看,晚上下班才幫你看看吧,如果你急到現在就要解決,那沒辦法幫你啊
if SSleft in Shift then
tmpBitmap:=TBitmap.Create();
tmpBitmap.Width:=ImgPic.Picture.Width;
这三句。
if SSleft in Shift then
begin
tmpBitmap:=TBitmap.Create();
tmpBitmap.Width:=ImgPic.Picture.Width;
...
procedure TForm1.ImgPicMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);begin
tmpBitmap:=TBitmap.Create();
ImgZoom.Visible:=true;
tmpBitmap.Width:=Imgpic.Picture.Width;tmpBitmap.Height:=ImgPic.Picture.Height;MyRect := Rect(0,0,ImgZoom.Width ,ImgZoom.Height);MyOther:= Rect(X-ImgZoom.Width div 4,Y-ImgZoom.Height div 4,X+ImgZoom.Width div 4,Y+ImgZoom.Height div 4);
tmpBitmap.Canvas.CopyRect(MyRect,ImgPic.Picture.Bitmap.Canvas,MyOther);
ImgZoom.Picture.Graphic:= tmpBitmap;ImgZoom.Left:=X-ImgZoom.Width div 2 ;
ImgZoom.Top:=Y- ImgZoom.Height div 2;
if (x>=ImgPic.Width)or(Y>=ImgPic.Height) then
begin
ImgZoom.Visible:=false;
end else begin
ImgZoom.Visible:=true;end;
end;
有问题