Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
192 views
in Technique[技术] by (71.8m points)

Delphi XE2: how to define not members of a class functions in the component unit

I have problem with not members of a class functions. I want to use that functions in a new component unit but they did not work in a component unit!

these two functions must assign to another function in a dll as parameter.

When I used this 2 functions(not members of class) in main form they can work but in the new component unit, the dll function cannot call back these two functions any more! How can I resolve this problem ? Is this delphi bug ? because I am using Delphi XE Update 2 this is lastest version of delphi maybe it is a bug!

  TComp12 = class(TCustomPanel)
  private
  ....
  protected
  ....
  public
  ....
  end;

  function function1(opaque: Pointer; plane: Pointer): Pointer; cdecl;
  function function2(opaque: Pointer; picture: Pointer; plane: Pointer) : Pointer; cdecl;

procedure Register;

implementation


procedure Register;
begin
  RegisterComponents('Comp1', [TComp12]);
end;

function function1(opaque: Pointer; plane: Pointer): Pointer; cdecl;
begin
......
end;
function function2(opaque: Pointer; picture: Pointer; plane: Pointer) : Pointer; cdecl;
begin
......
end;
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I looked at your code, and it is not a bug in Delphi.

There is a bug in the following code:

function VLCLock(opaque: Pointer; plane: Pointer): Pointer; cdecl;
var
  ctx: TCTX;
begin
  ctx := TCTX(opaque);
  Pointer(plane^) := @(ctx.FBuffer.StartLine[0]);
  Result := nil;
end;

TCTX(opaque) should be TCTX(opaque^). You must fix all similar occurrences in your code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...