Z
ZBJ2001_KF
Unregistered / Unconfirmed
GUEST, unregistred user!
{***********************************************************}<br>{ 程序:通过API创建窗体 ,并创建不规则窗体 }<br>{ 首先要注册窗体类 }<br>{ }<br>{ Copyright (c) 1998-2001 Shanghai Power Inc. }<br>{ }<br>{ }<br><br>{ }<br>{***********************************************************}<br><br>program ApiCreateWindow;<br><br>uses<br> windows,messages;<br><br>function winproc(TheWindow: Hwnd; Msg: Uint; wParam, lParam: LongInt): longint;<br> stdcall;<br>begin<br> case msg of<br> WM_DESTROY:<br> begin<br> PostQuitMessage(0);<br> exit;<br> end;<br><br><br> end;<br><br> Result := DefWindowProc(TheWindow, Msg, wParam, lParam);<br>end;<br>function RegisterClass: Boolean; stdcall;<br>var<br> WndClass: TWndClass;<br>begin<br><br> WndClass.style := CS_HREDRAW or CS_VREDRAW;<br> WndClass.lpfnWndProc := @WinProc;<br> WndClass.cbClsExtra := 0;<br> WndClass.cbWndExtra := 0;<br> WndClass.hInstance := hInstance; <br> Wndclass.hIcon := 0;<br> WndClass.hCursor := 0;<br> WndClass.hbrBackground := Color_window;<br> WndClass.lpszMenuName := nil;<br> WndClass.lpszClassName := 'zbjtest';<br> Result := windows.RegisterClass(WndClass) <> 0 ;<br>end;<br>{$R *.res}<br>var<br> msg: Tmsg;//消息结构<br> OurWindow: Hwnd;<br>begin<br> if not RegisterClass then<br> begin<br> messageBox(0,'注册失败',nil,mb_ok);<br> exit;<br> end;<br> OurWindow := CreateWindowEx(0, //没有扩展风格<br> 'zbjtest', //已注册的类名称,WINDOWS已预定很多类名<br> 'zbj', //标题栏名称<br> WS_OVERLAPPEDWINDOW or WS_VISIBlE,//通用窗口风格 和 初始化可见<br> CW_USEDEFAULt, //默认水平位置<br> CW_USEDEFAULt, //垂直位置<br> 800, //默认宽度<br> 600, //默认高度<br> 0, //父窗口句柄<br> 0, //没有菜单<br> hInstance, //程序实例<br> nil //没有附加信息<br> <br> if Ourwindow = 0 then<br> begin<br> MessageBox(0,'创建失败!',nil,mb_ok);<br> Exit;<br> end;<br><br> While GetMessage(msg,0,0,0) do<br> begin<br> TranslateMessage(msg);<br> DispatchMessage(msg);<br> end;<br><br>end.