谁能将此delphi语句翻译成bcb?很急,多谢(100分)

  • 主题发起人 主题发起人 xinhe53
  • 开始时间 开始时间
X

xinhe53

Unregistered / Unconfirmed
GUEST, unregistred user!
var
Method: TMethod;
begin
QButtonGroup_clicked_Event(Method) := Self.ClickedHook;


==================================================================
我翻译成以下,但无法通过编译
TMethod Method;
QButtonGroup_clicked_Event(&Method) = ClickedHook;

谁能讲讲?多谢
 
TMethod是一个结构
type
TMethod = record
Code, Data: Pointer;
end;
对象方法是一个指针
取TMethod的地址好像说不通把
 
查头文件可知
QButtonGroup_clicked_Event 为
typedef void __cdecl (__closure *QButtonGroup_clicked_Event)(int id);

有人能帮忙想想办法么?
 

QButtonGroup_clicked_Event= ClickedHook;
 
QButtonGroup_clicked_Event= ClickedHook 肯定不对

可以看看以下源码
procedure TCustomRadioGroup.HookEvents;
var
Method: TMethod;
begin
QButtonGroup_clicked_Event(Method) := Self.ClickedHook;
QButtonGroup_hook_hook_clicked(QButtonGroup_hookH(Hooks), Method);
inherited HookEvents;
end;
 
怎么就没人能将
var
Method: TMethod;
begin
QButtonGroup_clicked_Event(Method) := Self.ClickedHook;
翻译成C++Builder么?
 
在 C++里就不能用这样用,当然错了,,
 
难道就没有人知道如何将此语句转换成c++语法吗?
 
QButtonGroup_clicked_Event(Method) = Self->ClickedHook
 
拜托,是将Delphi翻译成BCB!!!

BCB中有Self么?
 
BCB中当然没有Self,不过使用this
 
我来了
unit main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ActnList, ScktComp, ExtCtrls, Menus, StdCtrls, ComCtrls,winsock;

type
POnlineinf=^TOnlineinf;
TOnlineinf=record
username:string[255];
soc:Tsocket;
strIP:string;
end;
TfrmMain = class(TForm)
statusb: TStatusBar;
Lonlines: TListBox;
Rtalk: TRichEdit;
MMenu: TMainMenu;
Aoptions: TActionList;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
Panel1: TPanel;
ServerS: TServerSocket;
Abeginser: TAction;
Astopser: TAction;
Aexitpro: TAction;
Aparaset: TAction;
Aabout: TAction;
procedure AstopserExecute(Sender: TObject);
procedure AbeginserExecute(Sender: TObject);
procedure ServerSClientRead(Sender: TObject; Socket: TCustomWinSocket);
procedure ServerSClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure LonlinesDblClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure AexitproExecute(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
private
Onlines:Tlist;
{ Private declarations }
public
{ Public declarations }
end;

var
frmMain: TfrmMain;

implementation
const contrallen=16;
{$R *.dfm}

procedure TfrmMain.AstopserExecute(Sender: TObject);
begin
if ServerS.Active then
begin
Servers.Active:= false;
Statusb.SimpleText:='キホ?ムセュヘ」ヨケ」。';
while(Onlines.count<>0) do
begin
dispose(Onlines.First);
onlines.Delete(0);
end;
Lonlines.Clear;
end
else
begin
Messagebox(handle,'キホ?ムヘ」ヨケ」。','フ睫セ',MB_OK);
end;
end;

procedure TfrmMain.AbeginserExecute(Sender: TObject);
begin
if not Servers.Active then
begin
Servers.Active:=true;
statusb.SimpleText:='キホ??ムシ、サ釤。';
end
else
begin
Messagebox(handle,'キホ??ムシ、サ釤。','フ睫セ!',MB_OK);
end;
end;

procedure TfrmMain.ServerSClientRead(Sender: TObject;
Socket: TCustomWinSocket);
type
nowinfor=(ISININFO,ISOUTINFO,ISTRANSINFO,ISTRANSFILE,INCEPTFILE,REJECTFILE,NONE);
procedure proininfo(inbuf:array of byte;len:integer;s:Tsocket);
var
tempinf:POnlineinf;
templen:integer;
begin
if inbuf[len-1]<>0 then exit;
tempinf:= new(POnlineinf);
templen:= len-contrallen-1;
tempinf.username[0]:=char(lo(templen));
//showmessage(char(lo(templen)));
copymemory(@tempinf.username[1],@inbuf[contrallen],templen);
tempinf.soc:=s;
tempinf.strIP:=socket.RemoteAddress;
onlines.Add(tempinf);
lonlines.Items.Add('モテサァテ訒コ'+tempinf.username+'チャスモsocket」コ'+inttostr(s));
Lonlines.OnDblClick(Lonlines);
end;
procedure prooutinfo(inbuf:array of byte;len:integer;s:Tsocket);
var
tempinf:TOnlineinf;
templen:integer;
i:integer;
tempcount:integer;
begin
if inbuf[len-1]<>0 then exit;
templen:=len-contrallen-1;
tempinf.username[0]:=char(lo(templen));
copymemory(@tempinf.username[1],@inbuf[contrallen],templen);
tempinf.soc:= s;
tempcount:= onlines.Count-1;
for i:=0 to tempcount do
if (ponlineinf(Onlines.Items).username=tempinf.username)
and (POnlineinf(onlines.Items).soc= tempinf.soc)
then
begin
dispose(Onlines.Items);
onlines.Delete(i);
break;
end;
tempcount:=Lonlines.Items.Count-1;
for i:= 0 to tempcount do
begin
if ('モテサァテ訒コ'+tempinf.username+'チャスモsocket:'+inttostr(s))=Lonlines.Items
then
begin
Lonlines.Items.Delete(i);
break;
end;
end;
Lonlines.OnDblClick(lonlines);

end;
procedure protransinfo(inbuf:array of byte;len:integer;s:tsocket);
var
i:integer;
sourcename,targetname,talkstr:string;
istransinf:boolean;
idnum:integer;
templen:integer;
basepos:integer;
begin
istransinf:= true;
for i:= 0 to contrallen-1 do
begin
if ((i mod 2 )=0) then istransinf:=istransinf and (inbuf=$F)
else istransinf:= istransinf and (inbuf=$A);
if not istransinf then break;
end;
if not istransinf then
begin
rtalk.Lines.Add('ウ?ヨイサテ?キオトミナマ「ー・?ス」ャアサコ?ヤ」。');
exit;
end;

for i:= 0 to onlines.Count -1 do
if (ponlineinf(onlines.Items).soc=s) then
begin
sourcename:=POnlineinf(Onlines.Items).username;
break;
end;

if sourcename='' then
sourcename:='トウホサイサヨェテ遧トチトフ・゚」ィソノトワメムセュマツマ゚」ゥ';

basepos:=contrallen;
idnum:=Pinteger(@inbuf[basepos])^;
for i:=0 to onlines.count-1 do
begin
if(POnlineinf(onlines.Items).soc=idnum) then
begin
targetname:= POnlineinf(onlines.Items).username;
break;
end;
end;
if targetname='' then
targetname:='トウホサイサヨェテ遧トチトフ・゚」ィソノトワメムセュマツマ゚」ゥ';

talkstr:= sourcename+'カヤ'+targetname+'ヒオ」コ';
Pinteger(@inbuf[basepos])^:=s;
inc(basepos,sizeof(integer));
while(basepos<len) and (inbuf[basepos]<>0) do
inc(basepos);

if basepos>=len then
begin
talkstr:='エ﨔?トエォハ菽??ス」ャコ?ヤ」。';
Rtalk.Lines.Add(talkstr);
exit;
end;
templen:=length(talkstr);
setlength(talkstr,templen+basepos-(contrallen+sizeof(integer)));
copymemory
(@talkstr[templen+1],@inbuf[contrallen+sizeof(integer)],basepos-(contrallen+
sizeof(integer)));
rtalk.Lines.Add(talkstr) ;

if (targetname<>'トウホサイサヨェテ遧トチトフ・゚」ィソノトワメムセュマツマ゚」ゥ') then
send(idnum,inbuf[0],length(inbuf),0);
end;
procedure protransfile(inbuf:array of byte;len:integer;s:Tsocket);
var
i:integer;
SourceName:string;
TargetName: string;
idnum: integer;
begin
for i:=0 to Onlines.Count -1 do
begin
if(POnlineinf(ONlines.Items).soc=s) then
begin
SourceName:= POnlineinf(Onlines.Items).username;
break;
end;
end;
if SourceName='' then
SourceName:= 'トウホサイサヨェテ遧トチトフ・゚」ィソノトワメムマツマ゚」ゥ';
idnum:= Pinteger(@inbuf[contrallen])^;
for i:=0 to Onlines.Count-1 do
begin
if (POnlineinf(Onlines.Items).soc=idnum) then
begin
targetname:= POnlineinf(Onlines.Items).username;
break;
end;
end;
if targetname='' then
targetname:='トウホサイサヨェテ遧トチトフ・゚」ィソノトワメムマツマ゚」ゥ';
Rtalk.Lines.Add(SourceName+'ヌ・?・+targetname+'キ「ヒヘホトシ');
Pinteger(@inbuf[contrallen])^:= s;
if (targetname<>'トウホサイサヨェテ遧トチトフ・゚」ィソノトワメムマツマ゚」ゥ') then
send(idNum,inbuf[0],length(inbuf),0);
end;
procedure proinceptfile(inbuf:array of byte;len:integer;s:Tsocket);
var
UserId: integer;
TargetName: string;
SourceName: string;
tempstr: string;
i: integer;
begin
UserId:= Pinteger(@inbuf[contrallen])^;
for i:=0 to contrallen-1 do
begin
if POnlineinf(Onlines.Items).soc=UserId then
begin
SourceName:= POnlineinf(Onlines.Items).username;
break;
end;
end;
for I:=0 to contrallen -1 do
begin
if POnlineinf(Onlines.Items).soc=s then
begin
TargetName:= POnlineinf(Onlines.Items).username;
break;
end;
end;
tempstr:=TargetName+'ヘャメ篆モハユ'+SourceName+'ヒ?ォヒヘオトホトシ';
Rtalk.Lines.Add(tempstr) ;
send(Userid,inbuf[0],len,0);
end;
procedure prorejectfile(inbuf:array of byte;len:integer;s:Tsocket);
var
UserId: integer;
TargetName: string;
SourceName: string;
tempstr: string;
i: integer;
begin
UserId:= Pinteger(@inbuf[contrallen])^;
for i:=0 to contrallen-1 do
begin
if POnlineinf(Onlines.Items).soc=UserId then
begin
SourceName:= POnlineinf(Onlines.Items).username;
break;
end;
end;
for I:=0 to contrallen -1 do
begin
if POnlineinf(Onlines.Items).soc=s then
begin
TargetName:= POnlineinf(Onlines.Items).username;
break;
end;
end;
tempstr:=TargetName+'イサヘャメ篆モハユ'+SourceName+'ヒ?ォヒヘオトホトシ';
Rtalk.Lines.Add(tempstr) ;
send(Userid,inbuf[0],len,0);
end;


var
buf:array of byte;
len:integer;
i:integer;
tag:nowinfor;
nowtag:boolean;
begin
len:=socket.ReceiveLength;
setlength(buf,len);
socket.ReceiveBuf(buf[0],len) ;

if len<contrallen then exit;

nowtag:=true;

for i:=0 to contrallen -1 do
begin
if ((i mod 2)=0 )then nowtag:=nowtag and (buf=$E)
else nowtag:=nowtag and (buf=$A);
if not nowtag then break;
end;

if nowtag then tag:=ISININFO
else
begin
nowtag:= true;
for i:=0 to contrallen-1 do
begin
if ((i mod 2) =0)then
nowtag:=nowtag and (buf=$A)
else nowtag:=nowtag and (buf=$E);
if not nowtag then break;
end;

if nowtag then tag:=ISOUTINFO
else
begin
nowtag:=true;
for i:=0 to contrallen-1 do
begin
if ((i mod 2)=0 ) then
nowtag := nowtag and (buf=$F)
else nowtag:= nowtag and (buf=$A);
if not nowtag then break;
end;
if nowtag then tag:=ISTRANSINFO else
begin
nowtag:= true;
for i:=0 to contrallen-1 do
begin
if ((i mod 2)=0) then nowtag:=nowtag and (buf=$C)
else nowtag:=nowtag and (buf=$D);
if not nowtag then break;
end;
end ;
if nowtag then tag:=ISTRANSFILE else
begin
nowtag:= true;
for i:=0 to contrallen-1 do
begin
if ((i mod 2)=0) then nowtag:=nowtag and (buf=$D)
else nowtag:=nowtag and (buf=$C);
if not nowtag then break;
end;
if nowtag then tag:=INCEPTFILE else
begin
nowtag:= true;
for i:=0 to contrallen-1 do
begin
if ((i mod 2)=0) then nowtag:=nowtag and (buf=$B)
else nowtag:=nowtag and (buf=$A);
if not nowtag then break;
end;
if nowtag then tag:=REJECTFILE else
tag:= NONE;
end;
end;
end;
end;
case tag of
ISININFO:proininfo(buf,len,socket.sockethandle);
ISOUTINFO:prooutinfo(buf,len,socket.SocketHandle);
ISTRANSINFO:protransinfo(buf,len,socket.SocketHandle);
ISTRANSFILE:protransfile(buf,len,socket.SocketHandle);
INCEPTFILE:proinceptfile(buf,len,socket.sockethandle);
REJECTFILE:prorejectfile(buf,len,socket.SocketHandle);
NONE:Rtalk.Lines.Add('ウ?ヨイサテ?キオトミナマ「ー・?ス」ャアサコ?ヤ!') ;
end;
end;

procedure TfrmMain.ServerSClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
var
i:integer;
temstr:string;
tempcount:integer;
begin
tempcount:= onlines.Count-1;
for i:= 0 to tempcount do
begin
if (POnlineinf(onlines.Items).soc=socket.SocketHandle) then
begin
dispose(onlines.items);
onlines.Delete(i);
break;
end;
end;
temstr:='チャスモsocket:'+inttostr(socket.sockethandle);
tempcount:=Lonlines.Items.Count-1 ;
for i:=0 to tempcount do
begin
if pos(temstr,Lonlines.items)<>0 then
begin
Lonlines.Items.Delete(i);
break;
end;
end;
Lonlines.OnDblClick(Lonlines);
end;

procedure TfrmMain.LonlinesDblClick(Sender: TObject);
var
I:integer;
templen,len:integer;
buf:array of byte;
lenIP:integer;
tempIP:string;
tempUsername:string;
begin
setlength(buf,contrallen+sizeof(integer));
for i:= 0 to contrallen-1 do
if ((i mod 2)=0 ) then buf:=$A
else buf:=$F;
Pinteger(@buf[contrallen])^:=Onlines.Count;
for i:=0 to onlines.count-1 do
begin
tempUsername:=POnlineinf(Onlines.Items).username;
len:=length(tempUsername);
templen:=length(buf);
tempIP:=POnlineinf(Onlines.Items).strIP;
lenIP:= length(tempIP);
setlength(buf,templen+sizeof(integer)+len+sizeof(integer)+sizeof(integer)+lenIP);
Pinteger(@buf[templen])^:=len;
copymemory(@buf[templen+sizeof(integer)],@tempUsername[1],len);
Pinteger(@buf[templen+sizeof(integer)+len])^:=POnlineinf(onlines.Items).soc;
Pinteger(@buf[templen+sizeof(integer)+len+sizeof(integer)])^:=lenIP;
copymemory(@buf[templen+sizeof(integer)+len+sizeof(integer)+sizeof(integer)],
@tempIP[1],lenIP);
end;

len:=length(buf);

for i:= 0 to onlines.Count-1 do
send(POnlineinf(onlines.Items).soc,buf[0],len,0);
end;
procedure TfrmMain.FormDestroy(Sender: TObject);
begin
while (onlines.count>0) do
begin
dispose(onlines.first);
onlines.Delete(0);
end;
onlines.Free;
end;

procedure TfrmMain.AexitproExecute(Sender: TObject);
begin
close;
end;

procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if ServerS.Active then
servers.Active:= false;
end;

procedure TfrmMain.FormCreate(Sender: TObject);
begin
onlines:=tlist.Create;
end;

end.
 
哈哈![:D][:D][:D][:D][:D][:D][:D][:D][:D][:D][:D][:D]
 
接受答案了.
 

Similar threads

后退
顶部