// Delphi 下调用Windows API 创建窗体. //
//
模板-------BY Hottey 2004-4-13-0:18 //
// 作者网站:http://
asp.itdrp.com/hottey //
program delphi;
uses
windows,
messages;
const
hellostr=''Hello World!'';
{$R delphi.res}
//窗口消息处理函数.
function MyWinProc(hWnd:THandle;uMsg:UINT;wParam,lParam:Cardinal):Cardinal;exp
ort;stdcall;
var
hdca,hdcb:THandle; //设备描述表句柄.
rect:TRect; //矩形结构.
font:HFont;
ps:TPaintStruct; //绘图结构.
begin
result:=0;
case uMsg of
WM_PAINT:
begin
hdca:=BeginPaint(hWnd,ps);
SetBkMode(hdca, Transparent);
SetBkColor(hdca,GetBkColor(hdca));
GetClientRect(hWnd,rect); //获取窗口客户区的尺寸.
DrawText(hdca,Pchar(hellostr),-1,rect,DT_SINGLELINE or DT_CENTER or DT
_VCENTER);
// TextOut(hdc,100,40,hellostr,Length(hellostr));
EndPaint(hWnd,ps);
end;
WM_CREATE:
begin
hdcb := GetDC(hWnd);
font := CreateFont(45, 0, 0, 0, FW_normal, 0, 0, 0, ansi_charset, out
_default_precis, clip_default_precis,
default_quality, 34, PChar(''Arial''));
SelectObject(hdcb, font);
ReleaseDC(hWnd, hdcb);
end;
WM_DESTROY:
PostQuitMessage(0)
else
//使用缺省的窗口消息处理函数.
result:=DefWindowProc(hWnd,uMsg,wParam,lParam);
end;
end;
//主
程序开始.
var
Msg :TMsg; //消息结构.
hWnd,hInst :THandle; //Windows 窗口句柄.
WinClass :TWndClassEx; //Windows 窗口类结构.
begin
hInst:=GetModuleHandle(nil); // get the application instance
WinClass.cbSize:=S