summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/test/units/classes/tmakeobjinst.pp
blob: 97a5272877ff5d5ee6e871f52de330b87a5938f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{ %opt=-S2 }
{ %target=win32 }
uses
  windows,messages,classes;

type
  tc1 = class
    procedure p(var msg : TMessage);
  end;

  tf = function (Window: HWND; Message, WParam: WPARAM;LParam: LPARAM): HRESULT; stdcall;

procedure tc1.p(var msg : TMessage);
  begin
    if (msg.msg<>1) or (msg.wparam<>2) or (msg.lparam<>3) then
      halt(1);
    msg.result:=4;
  end;

var
  f : tf;
  c : tc1;
begin
  c:=tc1.create;
  f:=tf(MakeObjectInstance(@c.p));

  if f(0,1,2,3)<>4 then
    halt(1);

  c.free;

  FreeObjectInstance(f);
  writeln('ok');
end.