unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, NMUDP, IdUDPServer, IdBaseComponent, IdComponent,
IdUDPBase, IdUDPClient, IdAntiFreezeBase, IdAntiFreeze, IDSOCKETHANDLE,
Grids, Menus,shellapi, ComCtrls, ImgList, xmldom, XMLIntf, msxmldom,
XMLDoc, Buttons;
const MY_MESSAGE = WM_USER + 100;
type
TForm1 = class(TForm)
Sendword: TEdit;
NMUDP1: TNMUDP;
Label1: TLabel;
name: TEdit;
Label2: TLabel;
remotehost: TEdit;
speaklist: TStringGrid;
sendto: TEdit;
MainMenu1: TMainMenu;
F1: TMenuItem;
Save1: TMenuItem;
Exit1: TMenuItem;
Help1: TMenuItem;
About1: TMenuItem;
SendStatic: TLabel;
PopupMenu1: TPopupMenu;
Saveasfile1: TMenuItem;
Sendtothem1: TMenuItem;
EXIT2: TMenuItem;
ListView1: TListView;
ImageList1: TImageList;
SendXML: TXMLDocument;
ReceivedXML: TXMLDocument;
Sendbutton: TSpeedButton;
Config1: TMenuItem;
Setup1: TMenuItem;
procedure sendbtClick(Sender: TObject);
procedure NMUDP1DataReceived(Sender: TComponent; NumberBytes: Integer;
FromIP: String; Port: Integer);
procedure FormCreate(Sender: TObject);
procedure speaklistDblClick(Sender: TObject);
procedure speaklistRowMoved(Sender: TObject; FromIndex,
ToIndex: Integer);
procedure Saveasfile1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure About1Click(Sender: TObject);
procedure EXIT2Click(Sender: TObject);
procedure Sendtothem1Click(Sender: TObject);
private
procedure OnIconNotify(var Message: TMessage);
message MY_MESSAGE;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Busy: Boolean;
implementation
{$R *.dfm}
procedure TForm1.OnIconNotify(var Message: TMessage);
begin
if not Busy then
begin
Busy :=true;
if Message.LParam=WM_LBUTTONDOWN then
begin
form1.Show;
application.BringToFront;
sendmessage(form1.Handle,WM_ERASEBKGND,0,0);
end;
if Message.LParam=WM_RBUTTONDOWN then
begin
popupmenu1.Popup(mouse.CursorPos.X,mouse.CursorPos.Y);
end;
Busy := false;
end;
end;
procedure TForm1.sendbtClick(Sender: TObject);
var
MyStream: TMemoryStream;
// TmpStr: String;
tmpV
levariant;
Begin
NMUDP1.ReportLevel := Status_Basic;
NMUDP1.RemoteHost := remotehost.Text;
sendxml.Active:=true;
tmpv:=sendword.Text;
sendxml.DocumentElement.NodeValue:=tmpv;
tmpv:=inttostr(sendword.Color);
sendxml.DocumentElement.Attributes['color']:=tmpv;
sendxml.DocumentElement.Attributes['to']:=sendto.Text;
sendxml.DocumentElement.Attributes['sendname']:=name.Text;
MyStream := TMemoryStream.Create;
sendxml.SaveToStream(mystream);
try
// MyStream.Write(TmpStr[1], Length(tmpstr));
NMUDP1.SendStream(MyStream);
sendstatic.Caption:='You sended To ['+sendto.Text+']:"'+sendword.Text+'" --Success!!';
finally
MyStream.Free;
end;
sendword.SetFocus;
end;
procedure TForm1.NMUDP1DataReceived(Sender: TComponent;
NumberBytes: Integer; FromIP: String; Port: Integer);
var
MyStream: TMemoryStream;
// TmpStr: String;
fromname:string;
BeSend:string;
postword:string;
// s:integer;
// t:integer;
// w:integer;
begin
MyStream := TMemoryStream.Create;
try
NMUDP1.ReadStream(MyStream);
receivedxml.LoadFromStream(MyStream);
postword:=receivedxml.DocumentElement.NodeValue;
Fromname:=receivedxml.DocumentElement.Attributes['sendname'];
besend:=receivedxml.DocumentElement.Attributes['to'];
speaklist.RowCount:=speaklist.RowCount+1;
speaklist.Cells[0,speaklist.rowcount-2]:=fromip;
speaklist.cells[1,speaklist.RowCount-2]:=fromname;
speaklist.cells[2,speaklist.RowCount-2]:='['+fromname+'] To-['+besend+']: '+postword;
beep();
//sendmessage(speaklist.Handle,WM_VSCROLL,SB_BOTTOM,0);
finally
MyStream.Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
nid: TNotifyIconData;
begin
//hide taskbar 標題
//SetWindowLong(application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
busy:=false;
nid.cbSize := sizeof(nid); // nid??????
nid.Wnd := Handle; // ?????
nid.uID:=4567;
nid.hIcon := Application.Icon.Handle; // ????????,?????
nid.szTip := 'LANICQ --- Design by DongPing.FAN;MiTAC LTD. JUN.2002'; // ?????
nid.uCallbackMessage := MY_MESSAGE; // ??????
nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; // ????????
if not Shell_NotifyIcon(NIM_ADD,@nid) then begin
ShowMessage('Failed!');
Application.Terminate;
end;
{??????????TOOL??,??????????}
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
end;
procedure TForm1.speaklistDblClick(Sender: TObject);
var
i:integer;
//t:string;
begin
i:=speaklist.Selection.Top;
remotehost.Text:=speaklist.Cells[0,i];
sendto.Text:=speaklist.Cells[1,i];
end;
procedure TForm1.speaklistRowMoved(Sender: TObject; FromIndex,
ToIndex: Integer);
begin
speaklist.Canvas.Brush.Color:=234567;
end;
procedure TForm1.Saveasfile1Click(Sender: TObject);
var
//t:string;
i:integer;
begin
for i:=0 to speaklist.RowCount-1 do
begin
//t:=t+speaklist.Cols
.Text;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
nid: TNotifyIconData;
begin
nid.cbSize := sizeof(nid); // nid??????
nid.cbSize := sizeof(nid); // nid??????
nid.uID :=4567; //????,???????????
nid.Wnd := Handle; //?????
Shell_NotifyIcon(NIM_DELETE,@nid); //?????
Shell_NotifyIcon(NIM_DELETE,@nid); //?????
enD;
procedure TForm1.About1Click(Sender: TObject);
begin
SHOWMESSAGE('LANICQ--- Design by DongPing.Fan;MiTAC LTD. JUN.2002');
end;
procedure TForm1.EXIT2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Sendtothem1Click(Sender: TObject);
begin
form1.SetFocus;
case form1.WindowState of
wsMinimized :form1.WindowState:=wsnormal;
// wsnormal :form1.WindowState:=wsnormal;
wsmaximized :form1.WindowState:=wsnormal;
//showmessage('minized')//
end;
end;
end.