P
plzh
Unregistered / Unconfirmed
GUEST, unregistred user!
请大家帮我诊断一段程序:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
mscreen:Tbitmap;
mscreenCanvas:TCanvas;
w,h:integer;
dc:HDC;
str:Tmemorystream;
begin
mscreen := TBitmap.Create;
mscreen.Width := screen.width;
mscreen.Height := screen.Height;
DC := GetDC (0);
mscreenCanvas := TCanvas.Create;
mscreenCanvas.Handle := DC;
w:=screen.width div 2;
h:=screen.height div 2;
mscreen.Canvas.CopyRect (Rect (0, 0,w,h ), mscreenCanvas,
Rect (0, 0, Screen.Width, Screen.Height));
mscreenCanvas.Free;
ReleaseDC (0, DC);
//*******************************
str:=Tmemorystream.Create;
mscreen.SaveToStream(str);//?我故意将其读入流中然后再读出
image1.Picture.Bitmap.LoadFromStream(str);//?
str.free;
mscreen.free;
end;
mscreen.SaveToStream(str);
image1.Picture.Bitmap.LoadFromStream(str);
这两句有错误吗?不知道为什么image1 中不能显示图象?请指正。
procedure TForm1.BitBtn1Click(Sender: TObject);
var
mscreen:Tbitmap;
mscreenCanvas:TCanvas;
w,h:integer;
dc:HDC;
str:Tmemorystream;
begin
mscreen := TBitmap.Create;
mscreen.Width := screen.width;
mscreen.Height := screen.Height;
DC := GetDC (0);
mscreenCanvas := TCanvas.Create;
mscreenCanvas.Handle := DC;
w:=screen.width div 2;
h:=screen.height div 2;
mscreen.Canvas.CopyRect (Rect (0, 0,w,h ), mscreenCanvas,
Rect (0, 0, Screen.Width, Screen.Height));
mscreenCanvas.Free;
ReleaseDC (0, DC);
//*******************************
str:=Tmemorystream.Create;
mscreen.SaveToStream(str);//?我故意将其读入流中然后再读出
image1.Picture.Bitmap.LoadFromStream(str);//?
str.free;
mscreen.free;
end;
mscreen.SaveToStream(str);
image1.Picture.Bitmap.LoadFromStream(str);
这两句有错误吗?不知道为什么image1 中不能显示图象?请指正。