NativeWindow_01
Posted CodeSkill
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NativeWindow_01相关的知识,希望对你有一定的参考价值。
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(0, ‘Up‘, ‘1‘, 0); end else if (_uMsg = WM_PAINT) then begin hDc1 := BeginPaint(_hWnd, ps); TextOut(hDc1, 0, 0, ‘ASDFG zxcvb‘, strlen(‘ASDFG zxcvb‘)); EndPaint(_hWnd, ps); Result := 0; Exit; end else if (_uMsg = WM_DESTROY) then begin DestroyWindow(_hwnd); PostQuitMessage(0); Result := 0; 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 := 0; wndcls.cbWndExtra := 0; wndcls.hbrBackground := HBRUSH(GetStockObject(WHITE_BRUSH)); // 背景画刷 wndcls.hCursor := LoadCursor(0, IDC_CROSS); wndcls.hIcon := LoadIcon(0, 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, 100, 100, 400, 300, 0, 0, //g_hMenu, hInstance, 0); if (hWnd1 = 0) then iErr := GetLastError; // ShowWindow(hWnd1, SW_SHOWNORMAL); UpdateWindow(hWnd1); end; {$O+} end.
3、
以上是关于NativeWindow_01的主要内容,如果未能解决你的问题,请参考以下文章
NativeWindow_01_CreateWindow(Ex)_VC6
NativeWindow_02_DialogBoxParam_VC6
NativeWindow_02_DialogBoxParam_VC6