程序5-8 Clover
来源:互联网 发布:2345小说软件下载 编辑:程序博客网 时间:2024/05/12 10:44
program Clover;
//程序5-8 Clover
uses
Windows, Messages, Math;
function WndProc(hWindow: HWND; Msg, wParam, lParam: LongInt): LRESULT; stdcall;
const
{$J+}
hRgnClip: HRGN = 0;
cxClient: Integer = 0; // 窗体当前宽度
cyClient: Integer = 0; // 窗体当前高度
{$J-}
var
ps: TPaintStruct;
hWndc: HDC;
hRgnTmp: array[0..5] of HRGN;
i: integer;
hCursor1: HCURSOR;
fAngle, fRadius: Real;
twopi: Real;
begin
Result:= 0;
case Msg of
WM_SIZE:
begin
cxClient:= LoWord(lParam);
cyClient:= HiWord(lParam);
// hCursor1:= SetCursor(LoadCursor(0, IDC_WAIT));
// ShowCursor(True);
// Sleep(10); //自己加的
if hRgnClip <> 0 then
begin
DeleteObject(hRgnClip);
hRgnClip:= 0;
end;
//左椭圆
hRgnTmp[0]:= CreateEllipticRgn(0, cyClient div 3, cxClient div 2, 2*cyClient div 3);
//右椭圆
hRgnTmp[1]:= CreateEllipticRgn(cxClient div 2, cyClient div 3, cxClient, 2*cyClient div 3);
//上椭圆
hRgnTmp[2]:= CreateEllipticRgn(cxClient div 3, 0, 2*cxClient div 3, cyClient div 2);
//下椭圆
hRgnTmp[3]:= CreateEllipticRgn(cxClient div 3, cyClient div 2, 2*cxClient div 3, cyClient);
//临时指向某个区域,,使其有效。
hRgnTmp[4]:= CreateRectRgn(0, 0, 1, 1);
hRgnTmp[5]:= CreateRectRgn(0, 0, 1, 1);
hRgnClip:= CreateRectRgn(0, 0, 1, 1);
//左右组合
CombineRgn(hRgnTmp[4], hRgnTmp[0], hRgnTmp[1], RGN_OR);
//上下组合
CombineRgn(hRgnTmp[5], hRgnTmp[2], hRgnTmp[3], RGN_OR);
CombineRgn(hRgnClip, hRgnTmp[4], hRgnTmp[5], RGN_XOR);
// CombineRgn(hRgnClip, hRgnTmp[4], hRgnTmp[5], RGN_AND);
for i := 0 to 5 do
DeleteObject(hRgnTmp[i]);
// Sleep(10);//自己加的
// SetCursor(hCursor1);
// ShowCursor(False);
end;
WM_PAINT:
begin
hWndc:= BeginPaint(hWindow, ps);
//SelectObject(hWndc, hRgnClip);
SelectClipRgn(hWndc, hRgnClip);
SetViewportOrgEx(hWndc, cxClient div 2, cyClient div 2, nil);
//返回直角三角形斜边的长度
//作为Cos值的系数
fRadius := Hypot(cxClient / 2.0, cyClient / 2.0);
twopi:= 2 * pi;
while (fAngle < twopi) do
begin
MoveToEx(hWndc, 0, 0, nil);
LineTo(hWndc, Trunc(fRadius*Cos(fAngle)), Trunc(-fRadius*Sin(fAngle)));
fAngle:= fAngle + twopi / 360;
end;
EndPaint(hWindow, ps);
end;
WM_DESTROY:
begin
DeleteObject(hRgnClip);//可别忘了
PostQuitMessage(0);
end
else
Result:= DefWindowProc(hWindow, Msg, wParam, lParam);
end;
end;
const
szAppName = 'Clover';
var
wndclass1: TWndClass;
Msg: TMsg;
hWindow: HWND;
begin
wndclass1.style:= CS_VREDRAW or CS_HREDRAW;
wndclass1.lpfnWndProc:= @WndProc;
wndclass1.cbClsExtra:= 0;
wndclass1.cbWndExtra:= 0;
wndclass1.hInstance:= HInstance;
wndclass1.hIcon:= LoadIcon(0, 0);
wndclass1.hCursor:= LoadCursor(0, 0);
wndclass1.hbrBackground:= GetStockObject(0);
wndclass1.lpszMenuName:= nil;
wndclass1.lpszClassName:= szAppName;
if RegisterClass(wndclass1) = 0 then
begin
MessageBox(0, 'This program requires windows NT!', szAppname, MB_ICONERROR);
exit;
end;
hWindow:= CreateWindow(szAppName, 'Draw a Clover', WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, HInstance, nil);
ShowWindow(hWindow, CmdShow);
UpdateWindow(hWindow);
while Getmessage(Msg, 0, 0, 0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end.
- 程序5-8 Clover
- Clover
- 矩形与区域的剪裁——CLOVER程序
- nescafe29 clover
- clover的无限制license
- maven clover 注册
- Draw a Clover
- 代码覆盖率-clover- 介绍
- Clover 的使用方法解读
- 第五章 CLOVER
- Linux安装Clover
- 软件推荐之Clover
- Clover查看代码覆盖率
- 使用Clover 3
- 成功驱动HD4600-Clover引导
- Clover 引导器.配置助手
- clover分布式任务调度系统
- java单元测试覆盖率工具-clover
- 《使用VIM开发软件项目》
- Memcachedb简介
- webService发布
- 名称以无效字符开头。处理资源 'http://localhost/ws/Service.asmx' 时出错。第 1 行,位置: 2
- 经典期刊文献资源帐号
- 程序5-8 Clover
- 两个简单的画验证码图形程序
- C#来创建和读取XML文档
- 提升需求分析的能力
- VC编码规范(转)
- 决定一生成就的21个信念
- Cisco路由技术基础知识详解
- 序列化ESRI COM 对象
- 病毒式营销