L
luke_hn
Unregistered / Unconfirmed
GUEST, unregistred user!
unit ReceivedUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls, ExtCtrls, WinSkinData;
type
TReceivedMsgForm = class(TForm)
StatusBar: TStatusBar;
Notebook: TNotebook;
ReceivedMsgMemo: TMemo;
btnAnswer: TButton;
btnCancel: TButton;
btnPre: TButton;
btnNext: TButton;
SendMsgMemo: TMemo;
btnSend: TButton;
btnClose: TButton;
btnClear: TButton;
btnMsg: TButton;
SkinData1: TSkinData;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure SendMsgMemoKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btnAnswerClick(Sender: TObject);
procedure btnClearClick(Sender: TObject);
procedure btnMsgClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnCancelClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure btnSendClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btnPreClick(Sender: TObject);
procedure btnNextClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
MsgList:TStringList;
FromIP,RemoteComputerName:String;
MsgPointer:Integer;
end;
var
ReceivedMsgForm: TReceivedMsgForm;
implementation
uses main;
{$R *.DFM}
procedure TReceivedMsgForm.FormCreate(Sender: TObject);
begin
MsgList := TStringList.Create;
MsgPointer := 0;
end;
procedure TReceivedMsgForm.FormDestroy(Sender: TObject);
begin
MsgList.Free;
end;
procedure TReceivedMsgForm.SendMsgMemoKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (Key = 13) and (ssCtrl in Shift) then
btnSend.Click;
end;
procedure TReceivedMsgForm.btnAnswerClick(Sender: TObject);
begin
NoteBook.ActivePage:='Answer';
end;
procedure TReceivedMsgForm.btnClearClick(Sender: TObject);
begin
SendMsgMemo.Clear;
end;
procedure TReceivedMsgForm.btnMsgClick(Sender: TObject);
begin
NoteBook.ActivePage:='ReceivedMsg';
end;
procedure TReceivedMsgForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TReceivedMsgForm.btnCancelClick(Sender: TObject);
begin
Close;
end;
procedure TReceivedMsgForm.btnCloseClick(Sender: TObject);
begin
if MsgPointer>=MsgList.Count-1 then
Close
else
NoteBook.ActivePage:='ReceivedMsg';
end;
procedure TReceivedMsgForm.btnSendClick(Sender: TObject);
var
Msg:String;
begin
with MainForm do
begin
Msg:=Format('%-15s%-6s',[LocalIP,'Chat']);
Msg := Msg+SendMsgMemo.Text;
SendMsg(FromIP,Msg);
end;
if MsgPointer>=MsgList.Count-1 then
Close
else
NoteBook.ActivePage:='ReceivedMsg';
end;
procedure TReceivedMsgForm.FormShow(Sender: TObject);
begin
StatusBar.Panels[0].Text:='IP:'+FromIP;
StatusBar.Panels[1].Text:='名称:'+RemoteComputerName;
if MsgList.Count = 0 then
btnMsg.Enabled := False
else
btnMsg.Enabled := True;
if MsgPointer <= 0 then
btnPre.Enabled := False
else
btnPre.Enabled := True;
if MsgPointer >= MsgList.Count - 1 then
btnNext.Enabled := False
else
btnNext.Enabled := True;
ShowMessage(IntToStr(MsgPointer));
ReceivedMsgMemo.Text := MsgList.Strings[MsgPointer]; //这句有问题
end;
procedure TReceivedMsgForm.btnPreClick(Sender: TObject);
begin
Dec(MsgPointer);
if MsgPointer <= 0 then
btnPre.Enabled := False;
if MsgPointer < MsgList.Count-1 then
btnNext.Enabled := True;
ReceivedMsgMemo.Text := MsgList.Strings[MsgPointer];
end;
procedure TReceivedMsgForm.btnNextClick(Sender: TObject);
begin
Inc(MsgPointer);
if MsgPointer > 0 then
btnPre.Enabled:=True;
if MsgPointer >= MsgList.Count-1 then
btnNext.Enabled := False;
ReceivedMsgMemo.Text := MsgList.Strings[MsgPointer];
end;
end.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls, ExtCtrls, WinSkinData;
type
TReceivedMsgForm = class(TForm)
StatusBar: TStatusBar;
Notebook: TNotebook;
ReceivedMsgMemo: TMemo;
btnAnswer: TButton;
btnCancel: TButton;
btnPre: TButton;
btnNext: TButton;
SendMsgMemo: TMemo;
btnSend: TButton;
btnClose: TButton;
btnClear: TButton;
btnMsg: TButton;
SkinData1: TSkinData;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure SendMsgMemoKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure btnAnswerClick(Sender: TObject);
procedure btnClearClick(Sender: TObject);
procedure btnMsgClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnCancelClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure btnSendClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btnPreClick(Sender: TObject);
procedure btnNextClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
MsgList:TStringList;
FromIP,RemoteComputerName:String;
MsgPointer:Integer;
end;
var
ReceivedMsgForm: TReceivedMsgForm;
implementation
uses main;
{$R *.DFM}
procedure TReceivedMsgForm.FormCreate(Sender: TObject);
begin
MsgList := TStringList.Create;
MsgPointer := 0;
end;
procedure TReceivedMsgForm.FormDestroy(Sender: TObject);
begin
MsgList.Free;
end;
procedure TReceivedMsgForm.SendMsgMemoKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (Key = 13) and (ssCtrl in Shift) then
btnSend.Click;
end;
procedure TReceivedMsgForm.btnAnswerClick(Sender: TObject);
begin
NoteBook.ActivePage:='Answer';
end;
procedure TReceivedMsgForm.btnClearClick(Sender: TObject);
begin
SendMsgMemo.Clear;
end;
procedure TReceivedMsgForm.btnMsgClick(Sender: TObject);
begin
NoteBook.ActivePage:='ReceivedMsg';
end;
procedure TReceivedMsgForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TReceivedMsgForm.btnCancelClick(Sender: TObject);
begin
Close;
end;
procedure TReceivedMsgForm.btnCloseClick(Sender: TObject);
begin
if MsgPointer>=MsgList.Count-1 then
Close
else
NoteBook.ActivePage:='ReceivedMsg';
end;
procedure TReceivedMsgForm.btnSendClick(Sender: TObject);
var
Msg:String;
begin
with MainForm do
begin
Msg:=Format('%-15s%-6s',[LocalIP,'Chat']);
Msg := Msg+SendMsgMemo.Text;
SendMsg(FromIP,Msg);
end;
if MsgPointer>=MsgList.Count-1 then
Close
else
NoteBook.ActivePage:='ReceivedMsg';
end;
procedure TReceivedMsgForm.FormShow(Sender: TObject);
begin
StatusBar.Panels[0].Text:='IP:'+FromIP;
StatusBar.Panels[1].Text:='名称:'+RemoteComputerName;
if MsgList.Count = 0 then
btnMsg.Enabled := False
else
btnMsg.Enabled := True;
if MsgPointer <= 0 then
btnPre.Enabled := False
else
btnPre.Enabled := True;
if MsgPointer >= MsgList.Count - 1 then
btnNext.Enabled := False
else
btnNext.Enabled := True;
ShowMessage(IntToStr(MsgPointer));
ReceivedMsgMemo.Text := MsgList.Strings[MsgPointer]; //这句有问题
end;
procedure TReceivedMsgForm.btnPreClick(Sender: TObject);
begin
Dec(MsgPointer);
if MsgPointer <= 0 then
btnPre.Enabled := False;
if MsgPointer < MsgList.Count-1 then
btnNext.Enabled := True;
ReceivedMsgMemo.Text := MsgList.Strings[MsgPointer];
end;
procedure TReceivedMsgForm.btnNextClick(Sender: TObject);
begin
Inc(MsgPointer);
if MsgPointer > 0 then
btnPre.Enabled:=True;
if MsgPointer >= MsgList.Count-1 then
btnNext.Enabled := False;
ReceivedMsgMemo.Text := MsgList.Strings[MsgPointer];
end;
end.