Einzelnen Beitrag anzeigen

OLDIE1950

Registriert seit: 2. Jan 2018
22 Beiträge
 
#4

AW: Delphi XE7 ignoriert Form AfterCreate

  Alt 31. Jan 2018, 20:46
Du hast wahrscheinlich vergessen, die Proceduren im Objektinspektor einzutragen.
Das *.dfm-File muss dann so aussehen:
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 201
ClientWidth = 447
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
end

Code:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

const
  WM_AFTER_SHOW = WM_USER + 300; // custom message
  WM_AFTER_CREATE = WM_USER + 301; // custom message

type
  TForm1 = class(TForm)
    // OnShow event
    procedure FormShow(Sender: TObject);
    // OnCreate event
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
    procedure WmAfterShow(var Msg: TMessage); message WM_AFTER_SHOW;
    procedure WmAfterCreate(var Msg: TMessage); message WM_AFTER_CREATE;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WmAfterShow(var Msg: TMessage);
begin
  ShowMessage('WM_AFTER_SHOW received!');
end;

procedure TForm1.WmAfterCreate(var Msg: TMessage);
begin
  ShowMessage('WM_AFTER_CREATE received!');
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  // Post the custom message WM_AFTER_SHOW to our form
  PostMessage(Self.Handle, WM_AFTER_SHOW, 0, 0);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Post the custom message WM_AFTER_CREATE to our form
  PostMessage(Self.Handle, WM_AFTER_CREATE, 0, 0);
end;

end.

Geändert von OLDIE1950 (31. Jan 2018 um 21:08 Uhr)
  Mit Zitat antworten Zitat