?? frind_friends.~pas
字號:
unit Frind_friends;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, RXCtrls, dximctrl, Buttons, jpeg;
type
TFrmFindFriends = class(TForm)
Panel1: TPanel;
Image1: TImage;
GroupBox1: TGroupBox;
RxLabel1: TRxLabel;
FriendsLstBox: TdxImageListBox;
BtnClose: TBitBtn;
BtnAdd: TBitBtn;
BtnReflash: TBitBtn;
// procedure CreateParams(var Params:TCreateParams);override;
procedure BtnCloseClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BtnReflashClick(Sender: TObject);
procedure BtnAddClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmFindFriends: TFrmFindFriends;
aFndLst:array[0..255] of String;//查找用戶時,在線用戶返回的信息數組,最大值為256,我想同時在人數應該不會超過這個數吧:-)
implementation
uses dm_share, Var_Share, by_user;
{$R *.dfm}
{procedure TFrmFindFriends.CreateParams(var Params:TCreateParams);
begin
inherited CreateParams(Params);
Params.WndParent:=GetDesktopWindow;
end;}
procedure TFrmFindFriends.BtnCloseClick(Sender: TObject);
begin
self.Close;
end;
procedure TFrmFindFriends.FormCreate(Sender: TObject);
begin
Caption:='查找用戶';
FriendsLstBox.ImageList:=DMShare.ImgLarge;
// BtnReflash.Click;
end;
procedure TFrmFindFriends.BtnReflashClick(Sender: TObject);
var
MyStream:TMemoryStream;
sMsg:string;
i:integer;
begin
FriendsLstBox.Clear;//清空在線用戶列表
for i := 0 to 255 do //清空存放在線用戶信息的數組 aFndLst
begin
aFndLst[i]:=''
end;
sMsg:='FIN*';
Mystream := TMemoryStream.Create;
try
DMShare.Udp.LocalPort:=8089;
DMShare.Udp.RemotePort:=8088;
DMShare.Udp.RemoteHost:=GetGBIP(g_sIP);
Mystream.Write(sMsg[1],Length(sMsg));
DMShare.Udp.SendStream(Mystream);
finally
Mystream.Free;
end;
end;
procedure TFrmFindFriends.BtnAddClick(Sender: TObject);
var
s:string;
i,iPos:integer;
aMsg:array[1..4] of string;
begin
//判斷是否找到在線用戶
if FriendsLstBox.Items.Count=0 then
begin
MessageBox(GetActiveWindow(),'未查找到在線用戶,無法添加!','提示',MB_OK+MB_ICONINFORMATION);
Abort;
end;
if FriendsLstBox.ItemIndex=-1 then
begin
MessageBox(GetActiveWindow(),'請先選擇要添加的好友!','提示',MB_OK+MB_ICONINFORMATION);
Exit;
end;
//分解信息
s:=aFndLst[FriendsLstBox.ItemIndex];
for i := 1 to 4 do
begin
iPos:=Pos('*',s);
aMsg[i]:=Copy(s,1,iPos-1);
Delete(s,1,iPos);
// showmessage(aMsg[i]);
end;
//寫入好友數據庫
with DMShare.TblFriends do
begin
Append;
FieldValues['QQNumber']:=aMsg[1];
FieldValues['UserName']:=aMsg[2];
FieldValues['FaceID']:=StrToInt(aMsg[3]);
FieldValues['IP']:=aMsg[4];
FieldValues['IsBaddy']:=False;
Post;
end;
{以下代碼含義:
單擊“加為好友”后,在在線用戶列表中被選中的用戶加為好友,并從在線用戶列表
中被刪除,并且,要將數組aFndLst中,將上被加好友刪除,否則會出現選中的好友
與數組aFndLst中的用戶信息對不上號
以下代碼還未經過證實,不知是否正確,尚待證}
for i := FriendsLstBox.ItemIndex to FriendsLstBox.Items.Count-FriendsLstBox.ItemIndex-1 do
begin
aFndLst[i]:=aFndLst[i+1];
end;
FriendsLstBox.Items.Delete(FriendsLstBox.ItemIndex);
//將所添加的好友信息寫入數組aAddFndLst,以便在“查找好友”窗體關閉后添加進SideBar
(*{ for i := 0 to 255 do
begin
if aAddFndLst[i,0]='' then
begin
} i:=0; aAddFndLst[i,0]:=aMsg[1];
aAddFndLst[i,1]:=aMsg[2];
aAddFndLst[i,2]:=aMsg[3];
// end;
// end;*)
{下面的代碼還需驗證!!!!!!!!!在多臺機器同時在線時驗證}
for i := 0 to 255 do
begin
if aAddFndLst[i,0]='' then
begin
aAddFndLst[i,0]:=aMsg[1];
aAddFndLst[i,1]:=aMsg[2];
aAddFndLst[i,2]:=aMsg[3];
Break;
end;
end;
end;
procedure TFrmFindFriends.FormShow(Sender: TObject);
begin
BtnReflash.Click;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -