龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > C/C++开发 >

在桌面上画图

时间:2009-12-22 15:42来源:未知 作者:admin 点击:
分享到:
在桌面上画图,只要几个api函数既可以实现,下面给出在c++builder中具体的方法如下: 1、在头文件中定义变量 private: graphics::tbitmap *bmp; 2、图象变量的初始化: bmp=new graphics::tbitmap();

在桌面上画图,只要几个api函数既可以实现,下面给出在c++builder中具体的方法如下:

  

1、在头文件中定义变量

  

private:

  

graphics::tbitmap *bmp;

  

2、图象变量的初始化:

  

bmp=new graphics::tbitmap();

  

bmp->loadfromfile("c:aboutlogo.bmp");

  

3、在paint的事件中

  

void __fastcall tform1::formpaint(tobject *sender)

  

{

  

hdc hdk;

  

trect rect;

  

application->minimize();

  

hdk=getwindowdc(getdesktopwindow());

  

getwindowrect(getdesktopwindow(),&rect);

  

bitblt(hdk,(rect.width()-bmp->width)/2,(rect.height()-bmp->height)/2,bmp->width,bmp->height,bmp->canvas->handle,0,0,srccopy);

  

}

  

4。销毁tbitmap对象

  

delete bmp;

  

  

以上程序在c++ builder 5+winnt 4.0下实现.

  

精彩图集

赞助商链接