怎么在WINDOWS开始按钮中绘图
么在WINDOWS开始按钮中绘图 问题点数:100、回复次数:1Top
1 楼codecb(阿星)回复于 2002-06-01 13:38:08 得分 100
HWND wnd;
HDC hdcButton, hdcDesktop;
TPoint pt;
3、Form1的FormCreate 过程代码如下
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Application->MessageBox("利用C++Builder在Windows开始按钮上绘图演示程序", "特别说明", MB_OK + MB_DEFBUTTON1);
wnd = FindWindow("Shell_TrayWnd", NULL);
wnd = FindWindowEx(wnd, 0, "Button", NULL);
hdcButton = GetDC(wnd);
wnd = GetDesktopWindow();
hdcDesktop = GetDC(wnd);
Timer1->Enabled = False;
Timer1->Interval = 1;
BitBtn1->Tag = 0;//开始绘图
}
4、Form1的BitBtn1Click过程代码如下:
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
if (BitBtn1->Tag == 0)
Timer1->Enabled = True;
BitBtn1->Caption = "结束绘图";
BitBtn1->Tag = 1;
}
else
Close();
}
5、Form1的Timer1Timer过程代码如下:
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
GetCursorPos(&pt);
StretchBlt(hdcButton, 0, 0, 60, 25, hdcDesktop, pt.x - 30, pt.y - 12, 60, 25, SRCCOPY);
}
7、按F9运行程序。以上程序在C++ Builder 5.0、Windows95/98/NT/2000简体中文版环境下调试通过。
三.程序清单
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
HWND wnd;
HDC hdcButton, hdcDesktop;
TPoint pt;
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
}
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
GetCursorPos(&pt);
StretchBlt(hdcButton, 0, 0, 60, 25, hdcDesktop, pt.x - 30, pt.y - 12, 60, 25, SRCCOPY);
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Application->MessageBox("利用C++Builder在Windows开始按钮上绘图演示程序", "特别说明", MB_OK + MB_DEFBUTTON1);
wnd = FindWindow("Shell_TrayWnd", NULL);
wnd = FindWindowEx(wnd, 0, "Button", NULL);
hdcButton = GetDC(wnd);
wnd = GetDesktopWindow();
hdcDesktop = GetDC(wnd);
Timer1->Enabled = False;
Timer1->Interval = 1;
BitBtn1->Tag = 0;//开始绘图
}
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
if (BitBtn1->Tag == 0)
Timer1->Enabled = True;
BitBtn1->Caption = "结束绘图";
BitBtn1->Tag = 1;
else
Close();
}
是我下的!
给分!
谢!Top




