Einzelnen Beitrag anzeigen

schwa226

Registriert seit: 4. Apr 2008
400 Beiträge
 
#1

CreateWindowEx, Parent + Child erzeugen

  Alt 12. Jul 2009, 10:29
Hi,

ich habe da so meine Probleme mit CreateWindowEx.

Ich kann ein Fenster erzeugen, aber ich kann kein Child dazu machen!?

Variante 1:
Delphi-Quellcode:
Procedure CreateWindows;
var
  wa, wb, wc, wd: TWndClass;
  hWindowParent, hWindowChild : Thandle;
  hMyChild : THandle;
begin

  if FindWindow('MyParent','') = 0 then
    begin

      with wa do begin
        lpszClassName := 'MyParent';
        lpfnWndProc := @MainWndProc;
        Style := CS_VREDRAW or CS_HREDRAW;
        hInstance := hInstance;
        hIcon := LoadIcon(0, IDI_APPLICATION);
        hCursor := LoadCursor(0, IDC_ARROW);
        hbrBackground := (COLOR_WINDOW + 1);
        lpszMenuName := nil;
        cbClsExtra := 0;
        cbWndExtra := 0;
      end;

      with wb do begin
        lpszClassName := 'MyChild';
        lpfnWndProc := @ChildWndProc;
        Style := CS_VREDRAW or CS_HREDRAW;
        hInstance := hMyChild;
        hIcon := LoadIcon(0, IDI_APPLICATION);
        hCursor := LoadCursor(0, IDC_ARROW);
        hbrBackground := (COLOR_WINDOW + 1);
        lpszMenuName := nil;
        cbClsExtra := 0;
        cbWndExtra := 0;
      end;

      Windows.RegisterClass(wa);


  //create main hwnd:
      hWindowParent := CreateWindowEx(WS_EX_TOPMOST Or WS_EX_TOOLWINDOW,
        'MyParent',
        nil,
        WS_POPUP,
        CW_USEDEFAULT, 0,
        0, 0,
        0,
        0,
        hInstance,
        nil);

  Windows.RegisterClass(wb);

  hWindowChild := CreateWindowEx(WS_EX_TOPMOST Or WS_EX_TOOLWINDOW,
    'MyChild',
    nil,
    WS_CHILD,
    CW_USEDEFAULT, 0,
    0, 0,
    hWindowParent,
    0,
    hMyChild,
    nil);

  end;
end;
Hier wird das Parent erzeugt, aber das Handle meines Childs bleibt 0!

Komisch ist auch, wenn ich aus der Prozedure ein Function mache dann gibt mir der Parent auch immer 0!?
  Mit Zitat antworten Zitat