Как использовать CreateWindow(Ex)

Материал из DRKB

Как использовать CreateWindow(Ex)[править | править код]

program winmin;

uses
  windows,
  messages;

var
  wc: TWndClassEx;
  MainWnd: HW;
  Mesg: TMsg;

function WindowProc(wnd: HWND; Msg: Integer; Wparam: Wparam; Lparam: Lparam): Lresult; stdcall;
begin
  case msg of
    wm_destroy:
    begin
      PostQuitMessage(0);
      Result := 0;
      exit;
    end;
  else
    Result := DefWindowProc(wnd, msg, wparam, lparam);
  end;
end;

var
  xPos, yPos, nWidth, nHeight: Integer;
begin
  wc.cbSize := SizeOf(wc);
  wc.style := cs_hredraw or cs_vredraw;
  wc.lpfnWndProc := @WindowProc;
  wc.cbClsExtra := 0;
  wc.cbWndExtra := 0;
  wc.hInstance := HInstance;
  wc.hIcon := LoadIcon(0, idi_application);
  wc.hCursor := LoadCursor(0, idc_arrow);
  wc.hbrBackground := COLOR_BTNFACE+1;
  wc.lpszMenuName := nil;
  wc.lpszClassName := 'WinMin : Main';

  RegisterClassEx(wc);
  xPos := 100;
  yPos := 150;
  nWidth := 400;
  nHeight := 250;

  MainWnd := CreateWindowEx(
    0,
    'WinMin : Main',
    'Win Min',
    ws_overlappedwindow,
    xPos,
    yPos,
    nWidth,
    nHeight,
    0,
    0,
    Hinstance,
    nil
  );

  ShowWindow(MainWnd, CmdShow);
  while GetMessage(Mesg, 0, 0, 0) do
  begin
    TranslateMessage(Mesg);
    DispatchMessage(Mesg);
  end;

end.


Source: http://delphiworld.narod.ru/
ID: 02152