首页 > 编程 > Java > 正文

拷屏代码

2019-09-06 23:33:56
字体:
来源:转载
供稿:网友

                    TCanvas *dtCanvas = new TCanvas;
dtCanvas->Handle=GetDC(0);

Graphics::TBitmap *bitmap=new Graphics::TBitmap;
bitmap->Width=Width;
bitmap->Height=Height;

int nColors=GetDeviceCaps(Canvas->Handle,SIZEPALETTE);
LOGPALETTE* logPal=(LOGPALETTE*)new Byte[sizeof(LOGPALETTE)+(nColors-1)*sizeof(PALETTEENTRY)];
logPal->palVersion=0x300; logPal->palNumEntries=(Word)nColors;
GetSystemPaletteEntries(Canvas->Handle,0,nColors,logPal->palPalEntry);
bitmap->Palette=CreatePalette(logPal);
delete[] logPal;

TRect src=BoundsRect;
TRect dest=Rect(0,0,Width,Height);
bitmap->Canvas->CopyRect(dest,dtCanvas,src);

bitmap->SaveToFile("Screen.bmp");

delete bitmap;
delete dtCanvas;
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选