Thema: Delphi Non-VCL Fensterklasse

Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#1

Non-VCL Fensterklasse

  Alt 3. Okt 2007, 15:44
Hi,

Ich versuche mir grad eine Klasse zu bauen die mir das erstellen von Fenstern ohne die VCL vereinfachen soll.
Das Problem ist das ich das Fenster nicht zu Gesicht bekomme. Beim WndProc kommt auch soweit ich das nachverfolgen konnte nie ein WM_CREATE an.

Delphi-Quellcode:
unit uNCVLClasses;

interface

uses Windows, Messages, SysUtils;

type
  TWndProc = function (wnd: HWND; uMsg: UINT; wp: WPARAM; lp: LPARAM): LRESULT of Object; stdcall;

  TNVCLControl = class
  private
    FHandle: THandle;
    FID: HMENU;
  public
    property Handle: THandle read FHandle;
    property ID: HMENU read FID;
  end;

  TNVCLForm = class(TNVCLControl)
  private
    wc: TWndClassEx;
    FWndProc: TWndProc;
    function WndProc(wnd: HWND; uMsg: UINT; wp: WPARAM; lp: LPARAM): LRESULT; stdcall;
  public
    constructor Create(x,y,width,height: Cardinal);
  end;

var
  frmCount: Integer = 1;

implementation

{ TNVCLForm }

constructor TNVCLForm.Create(x, y, width, height: Cardinal);
begin
  FWndProc := WndProc;
  with wc do
  begin
    cbSize := SizeOf(TWndClassEx);
    lpfnWndProc := @FWndProc;
    hInstance := SysInit.hInstance;
    hbrBackground := COLOR_APPWORKSPACE;
    lpszClassName := Pchar('wnd' + IntToStr(frmCount));
  end;
  RegisterClassEx(wc);
  inc(frmCount);
  FHandle := CreateWindowEx(0,wc.lpszClassName,'Test',
                            WS_VISIBLE or WS_CAPTION or WS_SYSMENU or WS_SIZEBOX,
                            x,y,width,height,0,FID,hInstance,nil);
end;



function TNVCLForm.WndProc(wnd: HWND; uMsg: UINT; wp: WPARAM;
  lp: LPARAM): LRESULT;
begin
  Result := 0;
  case uMsg of
    WM_CREATE: begin
                  // nix
                end;
    WM_DESTROY: begin
                 PostQuitMessage(0);
                end;
    else Result := DefWindowProc(wnd, uMsg, wp, lp);
  end;
end;

end.
Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat