码迷,mamicode.com
首页 > Windows程序 > 详细

NativeWindow_01

时间:2016-11-25 00:32:31      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:error   windows   win   ace   stdcall   打开   out   err   cal   

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

标签:error   windows   win   ace   stdcall   打开   out   err   cal   

原文地址:http://www.cnblogs.com/CodeSkill/p/6099954.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!