Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Form-/Frame Create abfangen (https://www.delphipraxis.net/133702-form-frame-create-abfangen.html)

DataCool 7. Mai 2009 07:47


Form-/Frame Create abfangen
 
Hi Leute,

ich möchte in der Main-Form bzw. nachher in einer Komponente
abfangen, wenn eine Form oder ein Frame erzeugt wird.

Ich dachte eigentlich das ich mit dem überschreiben der WndProc der Main-Form und abfangen von WM_Create
zum Ziel komme, leider ist das nicht so.

Kann mich jemand mal in die richtige Richtung schubsen ?

Danke,

Greetz Data

mkinzler 7. Mai 2009 08:35

Re: Form-/Frame Create abfangen
 
Handelt es sich spezielle (eigene) Formulare oder allgemein?

DataCool 7. Mai 2009 09:44

Re: Form-/Frame Create abfangen
 
Hi,

ich möchte in der eigenen Anwendung mitbekommen, wann andere Forms oder Frames erzeugt(Created) werden.

Ich habe das ganze jetzt per Hook (WH_CALLWNDPROC) realisieren können.

Delphi-Quellcode:
function WndProcCallback(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
   cwps: TCWPStruct;
   tmpControl : TControl;
   tmpCustomForm : TCustomForm;
   tmpCustomFrame : TCustomFrame;
   sTmp : String;
begin
   case nCode < HC_ACTION of
      True:
         begin
            Result := CallNextHookEx(FWndProcHook, nCode, wParam, lParam);
         end;
      else begin
         CopyMemory(@cwps, Pointer(lParam), SizeOf(CWPSTRUCT));
         case cwps.message of
            WM_CREATE :
               begin
                  sTmp := 'WM_CREATE WP: '+inttostr(cwps.wParam)+'  LP: '+inttostr(cwps.LParam)+' hwnd: '+inttostr(cwps.hwnd);
                  tmpControl := FindControl(cwps.hwnd);
                  if Assigned(tmpControl) then begin
                     sTmp := sTmp + tmpControl.ClassName;
                     if tmpControl is TCustomForm then begin
                        tmpCustomForm := TCustomForm(tmpControl);
                        frmMain.mem_Output.Lines.Insert(0,'Create of form: "'+tmpCustomForm.Name+'"');
                     end;
                     if tmpControl is TCustomFrame then begin
                        tmpCustomFrame := TCustomFrame(tmpControl);
                        frmMain.mem_Output.Lines.Insert(0,'Create of frame: "'+tmpCustomFrame.Name+'"');
                     end;
                  end
                  else
                     sTmp := sTmp + 'Control to hwnd: '+inttostr(cwps.hwnd)+' not found';
                  frmMain.mem_Output.lines.Insert(0,sTmp);
               end;
            end;               
         end;
      end;

      Result := CallNextHookEx(fWndProcHook, nCode, wParam, lParam);
         
   end;

end;
Aber eigentlich hätte es doch über die WndProc der Main-Form gehen müssen, oder nicht ?

Gruß Data


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:16 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz