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

CreateWindowEx erfolgreich ?!

  Alt 8. Okt 2007, 15:53
Hi,

Ich erstelle gerade ein Fenster mit CreateWindowEx:



Delphi-Quellcode:
procedure TNVCLImageEx.RegisterImageControl;
var ImgClass: TWndClassEx;
    m: TMethod;
begin
  m.Code := @TNVCLImageEx.ImgProc;
  m.Data := Self;

  FillChar(ImgClass,SizeOf(TWndClassEx),0);
  ImgClass.cbSize := SizeOf(TWndClassEx);
  ImgClass.hInstance := hInstance;
  ImgClass.style := CS_HREDRAW or CS_VREDRAW;
  ImgClass.lpszClassName := 'IMAGE';
  ImgClass.hbrBackground := GetSysColorBrush(COLOR_BACKGROUND);
  ImgClass.lpfnWndProc := MakeProcInstance(m);
  RegisterClassEx(ImgClass);
end;

constructor TNVCLImageEx.Create(AParent: TNVCLControl);
begin
  inherited Create(AParent);
  RegisterImageControl;
  FHeight := 300;
  FWidth := 300;
  FHandle := CreateWindowEx(0,'IMAGE',nil,WS_CHILD or WS_VISIBLE,0,0,
                            FWidth,FHeight,AParent.Handle,FID,hInstance,nil);
end;
Also ich bin mir nicht sicher ob das ganze jetzt erstellt wird aber FHandle ist 0. Und ich hab grad keine Ahnung was das Problem ist. ImgProc wird übrigens aufgerufen.

Delphi-Quellcode:
function TNVCLImageEx.ImgProc(wnd: HWND; uMsg: UINT; wp: WPARAM;
  lp: LPARAM): LResult;
begin
  if FHandle = 0 then
   FHandle := wnd; // wnd = gültig
Dort setzte ich das Handle nochmal nachträglich. Innerhalb der procedure ist FHandle dann auch gültig aber danach is es wieder 0 -.-

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