1、
“{$O-}”关闭优化
“{$O-}”打开优化
2、
unit NativeWindow;
interface
uses
Windows, Messages, SysUtils;
procedure CreateWindow;
implementation
function ProcWindow(_hWnd :HWND;
_uMsg :UINT;
_wParam :WPARAM;
_lParam :LPARAM):longint;stdcall;
var
hDc1 :HDC;
ps :PAINTSTRUCT;
begin
if (_uMsg = WM_LBUTTONUP) then
begin
MessageBox(, 'Up', '', );
end
else if (_uMsg = WM_PAINT) then
begin
hDc1 := BeginPaint(_hWnd, ps);
TextOut(hDc1, , , 'ASDFG zxcvb', strlen('ASDFG zxcvb'));
EndPaint(_hWnd, ps);
Result := ;
Exit;
end
else if (_uMsg = WM_DESTROY) then
begin
DestroyWindow(_hwnd);
PostQuitMessage();
Result := ;
Exit;
end;
Result := DefWindowProc(_hWnd, _uMsg, _wParam, _lParam);
end;
{$O-}
procedure CreateWindow;
var wndcls :WNDCLASS;
hInstance :THandle;
hWnd1 :HWND;
iErr :integer;
begin
hInstance := Windows.GetModuleHandle(nil);
ZeroMemory(@wndcls, sizeof(wndcls));
wndcls.cbClsExtra := ;
wndcls.cbWndExtra := ;
wndcls.hbrBackground := HBRUSH(GetStockObject(WHITE_BRUSH)); // 背景画刷
wndcls.hCursor := LoadCursor(, IDC_CROSS);
wndcls.hIcon := LoadIcon(, IDI_ERROR); // 窗口图标
wndcls.hInstance := hInstance;
wndcls.lpfnWndProc := @ProcWindow;
wndcls.lpszClassName:= 'zc20110929';
wndcls.lpszMenuName := nil;
wndcls.style := CS_HREDRAW or CS_VREDRAW;
RegisterClass(wndcls);
hWnd1 := CreateWindowEx(
WS_EX_CLIENTEDGE,
wndcls.lpszClassName,
'ZC Window',
WS_OVERLAPPEDWINDOW,
, ,
, ,
,
, //g_hMenu,
hInstance,
);
if (hWnd1 = ) then
iErr := GetLastError;
// ShowWindow(hWnd1, SW_SHOWNORMAL);
UpdateWindow(hWnd1);
end;
{$O+}
end.
3、
手机扫一扫
移动阅读更方便
你可能感兴趣的文章