很简单的问题!!怎样把窗体中的某一块,截取成位图流,并传给IMAGE控件!!!! 比如:窗体 中有一个 PANEL ,PANEL 的 中间放一个 Image1怎样把Panel 包括 Image1 ,截取成位图流,然后赋给Image2 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 procedure TClient.ScreenCap(LeftPos,TopPos,RightPos,BottomPos:integer);varRectWidth,RectHeight:integer;SourceDC,DestDC,Bhandle:integer;Bitmap:TBitmap;beginTRYRectWidth:=RightPos-LeftPos;RectHeight:=BottomPos-TopPos;SourceDC:=CreateDC('DISPLAY','','',nil);DestDC:=CreateCompatibleDC(SourceDC);Bhandle:=CreateCompatibleBitmap(SourceDC,RectWidth,RectHeight);SelectObject(DestDC,Bhandle);BitBlt(DestDC,0,0,RectWidth,RectHeight,SourceDC,LeftPos,TopPos,SRCCOPY);Bitmap:=TBitmap.Create;Bitmap.Handle:=BHandle;BitMap.SaveToStream(BmpStream);BmpStream.Position:=0;LeftSize:=BmpStream.Size;Bitmap.Free;DeleteDC(DestDC);ReleaseDC(Bhandle,SourceDC);EXCEPTEND;end 下面是取整个屏幕的列子procedure TForm1.Button1Click(Sender: TObject);var Fullscreen: Tbitmap; FullscreenCanvas: TCanvas; dc: HDC;begin Fullscreen := TBitmap.Create; //创建一个BITMAP来存放图象 Fullscreen.Width := screen.width; Fullscreen.Height := screen.Height; DC := GetDC(0); //取得屏幕的 DC,参数0指的是屏幕 FullscreenCanvas := TCanvas.Create; //创建一个CANVAS对象 FullscreenCanvas.Handle := DC; Fullscreen.Canvas.CopyRect (Rect(0, 0, screen.Width, screen.Height), fullscreenCanvas, Rect(0, 0, Screen.Width, Screen.Height)); //把整个屏幕复制到BITMAP中 FullscreenCanvas.Free; //释放CANVAS对象 ReleaseDC(0, DC); //释放DC //******************************* image1.picture.Bitmap := fullscreen; //拷贝下的图象赋给IMAGE对象 image1.Width := fullscreen.Width; image1.Height := fullscreen.Height; fullscreen.free; //释放bitmapend;取窗体即改变GetDC()中的参数,取某个区域即改变Rect()中的区域 取窗体即改变GetDC()中的参数,取某个区域即改变Rect()中的区域function GetDC(hWnd: HWND): HDC; stdcall;{$EXTERNALSYM GetDCEx}------------没办法啊 SendMessage WM_GETTEXT 的问题 idmessage控件接收邮件怎样判断为新邮件? 请教一个调试的问题 怎么加快查询速度呀? 请教一下,我做了一个存储过程,那怎么执行这个存储过程呢? DEMO字段怎么处理? 菜问? 简单问题 Delphi7的MessageBox的第二、三个参数类型的问题 Remote Control Easy V3.12的注册码谁有? 采鸟的一个dbgrid的问题?快看看吧,求求各位大侠了! 关于图形色彩填充问题,请大家帮助。代码如下。
RightPos,BottomPos:integer);
var
RectWidth,RectHeight:integer;
SourceDC,DestDC,Bhandle:integer;
Bitmap:TBitmap;
begin
TRY
RectWidth:=RightPos-LeftPos;
RectHeight:=BottomPos-TopPos;
SourceDC:=CreateDC('DISPLAY','','',nil);
DestDC:=CreateCompatibleDC(SourceDC);
Bhandle:=CreateCompatibleBitmap(SourceDC,
RectWidth,RectHeight);
SelectObject(DestDC,Bhandle);
BitBlt(DestDC,0,0,RectWidth,RectHeight,SourceDC,
LeftPos,TopPos,SRCCOPY);
Bitmap:=TBitmap.Create;
Bitmap.Handle:=BHandle;
BitMap.SaveToStream(BmpStream);
BmpStream.Position:=0;
LeftSize:=BmpStream.Size;
Bitmap.Free;
DeleteDC(DestDC);
ReleaseDC(Bhandle,SourceDC);
EXCEPT
END;
end
procedure TForm1.Button1Click(Sender: TObject);
var
Fullscreen: Tbitmap;
FullscreenCanvas: TCanvas;
dc: HDC;
begin
Fullscreen := TBitmap.Create; //创建一个BITMAP来存放图象
Fullscreen.Width := screen.width;
Fullscreen.Height := screen.Height;
DC := GetDC(0); //取得屏幕的 DC,参数0指的是屏幕
FullscreenCanvas := TCanvas.Create; //创建一个CANVAS对象
FullscreenCanvas.Handle := DC; Fullscreen.Canvas.CopyRect
(Rect(0, 0, screen.Width, screen.Height), fullscreenCanvas,
Rect(0, 0, Screen.Width, Screen.Height));
//把整个屏幕复制到BITMAP中
FullscreenCanvas.Free; //释放CANVAS对象
ReleaseDC(0, DC); //释放DC
//*******************************
image1.picture.Bitmap := fullscreen; //拷贝下的图象赋给IMAGE对象
image1.Width := fullscreen.Width;
image1.Height := fullscreen.Height;
fullscreen.free; //释放bitmap
end;取窗体即改变GetDC()中的参数,取某个区域即改变Rect()中的区域
function GetDC(hWnd: HWND): HDC; stdcall;
{$EXTERNALSYM GetDCEx}
------------
没办法啊