AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Form-/Frame Create abfangen

Offene Frage von "DataCool"
Ein Thema von DataCool · begonnen am 7. Mai 2009 · letzter Beitrag vom 7. Mai 2009
Antwort Antwort
Benutzerbild von DataCool
DataCool

Registriert seit: 10. Feb 2003
Ort: Lingen
909 Beiträge
 
Delphi 10.3 Rio
 
#1

Re: Form-/Frame Create abfangen

  Alt 7. Mai 2009, 09:44
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
Der Horizont vieler Menschen ist ein Kreis mit Radius Null, und das nennen sie ihren Standpunkt.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:57 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz