1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78:
| program NonVCL;
uses Windows, Messages ;
const ClassName = 'WndClass'; AppName = 'NonVCL Test'; WindowWidth = 500; WindowHeight = 350; IDC_CLOSE = 1; IDC_CAPTION = 1;
var hClose: DWORD; MyFont: HFONT;
function WndProc(hWnd: HWND; uMsg: UINT; wParam: wParam; lParam: LParam): lresult; stdcall; var x, y : integer; begin Result:=0; case uMsg of WM_CREATE: begin x:=GetSystemMetrics(SM_CXSCREEN); y:=GetSystemMetrics(SM_CYSCREEN); MoveWindow(hWnd,(x div 2)-(WindowWidth div 2),(y div 2)-(WindowHeight div 2),WindowWidth,WindowHeight,true); hClose:=CreateWindowEx(WS_EX_CLIENTEDGE, 'BUTTON', '&Schließen',WS_VISIBLE or WS_CHILD, WindowWidth-115, WindowHeight-60, 100, 25,hWnd, IDC_CLOSE, hInstance, nil); MyFont := GetStockObject(DEFAULT_GUI_FONT); if MyFont <> 0 then SendMessage(hClose, WM_SETFONT, Integer(MyFont), Integer(true)); end; WM_DESTROY: begin DeleteObject(MyFont); PostQuitMessage(0); end; WM_SIZE: MoveWindow(hClose, LoWord(lParam)-115, HiWord(lParam)-40, 100, 25, true); WM_COMMAND: begin if hiword(wParam)=BN_CLICKED then case loword(wParam) of IDC_CLOSE: SendMessage(hWnd,WM_DESTROY,0,0); end; end; else Result:=DefWindowProc(hWnd,uMsg,wParam,lParam); end; end;
var wc: TWndClassEx = ( cbSize : SizeOf(TWndClassEx); Style : CS_HREDRAW or CS_VREDRAW; lpfnWndProc : @WndProc; cbClsExtra : 0; cbWndExtra : 0; hbrBackground : COLOR_APPWORKSPACE; lpszMenuName : nil; lpszClassName : ClassName; hIconSm : 0; ); msg: TMsg;
begin wc.hInstance := hInstance; wc.hIcon := LoadIcon(0,IDI_APPLICATION); wc.hCursor := LoadCursor(0,IDC_ARROW); RegisterClassEx(wc); CreateWindowEx(0,ClassName,AppName,WS_CAPTION or WS_VISIBLE or WS_SYSMENU or WS_MINIMIZEBOX or WS_MAXIMIZEBOX or WS_SIZEBOX,Integer(CW_USEDEFAULT),Integer(CW_USEDEFAULT),WindowWidth,WindowHeight,0,0,hInstance,nil); while true do begin if not GetMessage(msg,0,0,0) then break else begin TranslateMessage(msg); DispatchMessage(msg); end; end; end. |