ChatingFrm.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:88k
- unit ChatingFrm;
- interface
- uses
- SysUtils, Windows, Menus, MMDevice, MMMixer, MMObj, Dialogs,
- ExtCtrls, ImgList, Controls, StdCtrls, RxRichEd, MMSlider, MMMixCtl,
- OleCtrls, SHDocVw, ComCtrls, Graphics, Classes,
- Forms, UrlMon, Gauges,Messages,ShellApi,Color,
- Global,MSHTML,VFW,Registry,StrUtils,Variants,ActiveX,MMSystem,
- MMHook,WNDES, AppEvnts, StdActns, ActnList, Videocap, MMDesign, MMDIBCv, MMLevel,
- MMConect, MMDSPObj, MMWavIn, MMACMCvt, ACMWaveOut,MySocket, ACMWaveIn, bsSkinCtrls,
- BusinessSkinForm, fcButton, fcImgBtn;
- const
- CGID_MSHTML: TGUID = '{DE4BA900-59CA-11CF-9592-444553540000}';
- type
- TChatingForm = class(TForm)
- PnlLeftTop: TPanel;
- Image10: TImage;
- Image11: TImage;
- Image12: TImage;
- Image13: TImage;
- Image14: TImage;
- Image15: TImage;
- PnlLeftBottom: TPanel;
- Image16: TImage;
- Image17: TImage;
- Image18: TImage;
- Image19: TImage;
- Image20: TImage;
- Image21: TImage;
- ImgArrow: TImage;
- ImgListSend: TImageList;
- ImgListClose: TImageList;
- ImgListHistory: TImageList;
- ImgListArrow: TImageList;
- ImgFont: TImage;
- ImgSelFace: TImage;
- ImgListMax: TImageList;
- FontDialog1: TFontDialog;
- lblState: TLabel;
- ImgAddNew: TImage;
- ImgSendFile: TImage;
- ImgVoice: TImage;
- ImgVideo: TImage;
- TimerTopBar: TTimer;
- SaveDialog: TSaveDialog;
- ImgListInfo: TImageList;
- MMVolumeControl1: TMMVolumeControl;
- MMAudioLine2: TMMAudioLine;
- MMMixerDevice1: TMMMixerDevice;
- MMAudioLine1: TMMAudioLine;
- MMVolumeControl2: TMMVolumeControl;
- MMAudioLine3: TMMAudioLine;
- Panel1: TPanel;
- MsgContent: TWebBrowser;
- MsgInput: TRxRichEdit;
- TempRxRichEdit: TRxRichEdit;
- ImgSelBack: TImage;
- ImgBottomDraw: TImage;
- TimerBottomBar: TTimer;
- PnlSpplit: TPanel;
- WebPopupMenu: TPopupMenu;
- Copy1: TMenuItem;
- SelectAll1: TMenuItem;
- MMMixerSliderIn: TMMMixerSlider;
- ImgMic: TImage;
- MMMixerSliderOut: TMMMixerSlider;
- ImgSpk: TImage;
- ImgSpkDisabled: TImage;
- ImgMicDisabled: TImage;
- LblQuitAudio: TLabel;
- PnlYourCamera: TPanel;
- Image8: TImage;
- Image9: TImage;
- Image22: TImage;
- Image23: TImage;
- Image25: TImage;
- Image26: TImage;
- Image27: TImage;
- PnlRightBottom: TPanel;
- Image32: TImage;
- Image33: TImage;
- Image34: TImage;
- Image35: TImage;
- Image36: TImage;
- Image37: TImage;
- lblUserListTitle: TLabel;
- TimerShowInputing: TTimer;
- ImgSelColor: TImage;
- ImgListSendType: TImageList;
- SendTypePopupMenu: TPopupMenu;
- TMEnter: TMenuItem;
- TMCtrlEnter: TMenuItem;
- ImgGroupMsg: TImage;
- ApplicationEvents1: TApplicationEvents;
- MainMenu1: TMainMenu;
- ImgCopyScreen: TImage;
- PopupMenu1: TPopupMenu;
- A1: TMenuItem;
- B1: TMenuItem;
- C1: TMenuItem;
- D1: TMenuItem;
- E1: TMenuItem;
- F1: TMenuItem;
- G1: TMenuItem;
- H1: TMenuItem;
- O1: TMenuItem;
- B2: TMenuItem;
- X1: TMenuItem;
- X2: TMenuItem;
- OpenDialog: TOpenDialog;
- ActionList1: TActionList;
- EditCut1: TEditCut;
- EditCopy1: TEditCopy;
- EditPaste1: TEditPaste;
- EditSelectAll1: TEditSelectAll;
- EditUndo1: TEditUndo;
- EditDelete1: TEditDelete;
- PopupMenuEdit: TPopupMenu;
- Undo1: TMenuItem;
- N3: TMenuItem;
- Cut1: TMenuItem;
- Copy2: TMenuItem;
- Paste1: TMenuItem;
- Delete1: TMenuItem;
- N4: TMenuItem;
- SelectAll2: TMenuItem;
- ImgHaveVideoDevice: TImage;
- PnlMyCamera: TPanel;
- Image1: TImage;
- Image3: TImage;
- Image4: TImage;
- Image5: TImage;
- Image2: TImage;
- Image6: TImage;
- Image7: TImage;
- AviPanel: TPanel;
- AviPanelOut: TPanel;
- VideoCap: TVideoCap;
- LblFPS: TLabel;
- MMDesigner1: TMMDesigner;
- ImgOpenVideoForm: TImage;
- MMMixerDevice2: TMMMixerDevice;
- ACMWaveOut: TACMWaveOut;
- ACMWaveIn: TACMWaveIn;
- CopyScreenTypePopupMenu: TPopupMenu;
- MDirectCopyScreen: TMenuItem;
- MCopyScreenAfterMinWindow: TMenuItem;
- CopyScreenTimer: TTimer;
- TVUserList: TbsSkinTreeView;
- bsBusinessSkinForm1: TbsBusinessSkinForm;
- Image24: TImage;
- fcImageBtn1: TfcImageBtn;
- fcImageBtn2: TfcImageBtn;
- fcImageBtn3: TfcImageBtn;
- fcImageBtn4: TfcImageBtn;
- fcImageBtn5: TfcImageBtn;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- bsSkinPanel1: TbsSkinPanel;
- ImgHistory: TImage;
- ImgClose: TImage;
- ImgSend: TImage;
- ImgSendType: TImage;
- procedure FormCreate(Sender: TObject);
- procedure ImgSendMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgSendMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgCloseMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgCloseMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgHistoryMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgHistoryMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgArrowClick(Sender: TObject);
- procedure ImgCloseClick(Sender: TObject);
- procedure ImgFontMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgFontMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure ImgTitleMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgClosedClick(Sender: TObject);
- procedure ImgMaxClick(Sender: TObject);
- procedure ImgMinClick(Sender: TObject);
- procedure MsgInputChange(Sender: TObject);
- procedure ImgSendClick(Sender: TObject);
- procedure ImgHistoryClick(Sender: TObject);
- procedure FormResize(Sender: TObject);
- procedure ImgFontClick(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure TVUserListCustomDrawItem(Sender: TCustomTreeView;
- Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
- procedure ImgAddNewClick(Sender: TObject);
- procedure ImgSendFileClick(Sender: TObject);
- procedure ImgAddNewMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure TimerTopBarTimer(Sender: TObject);
- procedure ImgAddNewMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgAddNewMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgVideoClick(Sender: TObject);
- procedure ImgVoiceClick(Sender: TObject);
- procedure ImgSelFaceClick(Sender: TObject);
- procedure ImgFontMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure TimerBottomBarTimer(Sender: TObject);
- procedure ImgSelBackMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgSelBackMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgSelBackClick(Sender: TObject);
- procedure PnlSpplitMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure PnlSpplitMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure PnlSpplitMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Copy1Click(Sender: TObject);
- procedure SelectAll1Click(Sender: TObject);
- procedure MsgContentBeforeNavigate2(Sender: TObject;
- const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
- Headers: OleVariant; var Cancel: WordBool);
- procedure WebPopupMenuPopup(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- procedure FormDeactivate(Sender: TObject);
- procedure MMMixerSliderInChange(Sender: TObject);
- procedure ImgMicClick(Sender: TObject);
- procedure ImgSpkClick(Sender: TObject);
- procedure LblQuitAudioClick(Sender: TObject);
- procedure TimerShowInputingTimer(Sender: TObject);
- procedure MsgContentDocumentComplete(Sender: TObject;
- const pDisp: IDispatch; var URL: OleVariant);
- procedure ImgSelColorClick(Sender: TObject);
- procedure ImgSendTypeMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgSendTypeMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ImgSendTypeClick(Sender: TObject);
- procedure TMEnterClick(Sender: TObject);
- procedure TMCtrlEnterClick(Sender: TObject);
- procedure ImgGroupMsgClick(Sender: TObject);
- procedure TVUserListGetImageIndex(Sender: TObject; Node: TTreeNode);
- procedure ApplicationEvents1Message(var Msg: tagMSG;
- var Handled: Boolean);
- procedure X1Click(Sender: TObject);
- procedure X2Click(Sender: TObject);
- procedure MsgInputMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure VideoCapVideoStream(sender: TObject; lpVhdr: PVIDEOHDR);
- procedure AviPanelOutDblClick(Sender: TObject);
- procedure ACMWaveInData(data: Pointer; size: Integer);
- procedure MDirectCopyScreenClick(Sender: TObject);
- procedure ImgCopyScreenClick(Sender: TObject);
- procedure MCopyScreenAfterMinWindowClick(Sender: TObject);
- procedure CopyScreenTimerTimer(Sender: TObject);
- procedure lblTitleClick(Sender: TObject);
- procedure TVUserListClick(Sender: TObject);
- procedure fcImageBtn3Click(Sender: TObject);
- procedure fcImageBtn2Click(Sender: TObject);
- procedure fcImageBtn4Click(Sender: TObject);
- procedure fcImageBtn1Click(Sender: TObject);
- procedure fcImageBtn5Click(Sender: TObject);
- procedure Label1Click(Sender: TObject);
- procedure Label2Click(Sender: TObject);
- procedure Label3Click(Sender: TObject);
- procedure Label4Click(Sender: TObject);
- procedure Label5Click(Sender: TObject);
- protected
- private
- ShowInputingTimes,LastInputing:Cardinal;
- ImgIndex,LastImgIndex:Integer;
- CanMove: Boolean;
- OX,OY,OldTop:Integer;
- procedure CopyScreen;
- public
- Pushed:Boolean;
- Img:TImage;
- Lbl:TLabel;
- IsSystemMsg,
- InGroupMsg,
- AudioIsOn,
- VideoIsOn:Boolean;
- RoomInfo:ChatRoom;
- procedure CreateParams(var Params:TCreateParams);override;
- procedure ShowTitle(ShowList:Boolean=True);
- procedure SetBrowserStyle();
- procedure SetBrowserBg(Url:String);
- procedure SetDOMStyle(Doc:IHTMLDocument2);
- procedure ShowInputing(Show:Boolean);
- procedure ShowOffline(Name:String);
- procedure ShowInfo(Info:String);
- end;
- implementation
- uses
- SelUserFrm,SelFaceFrm, SelBackFrm,SelColorFrm,HistoryFrm,RealMessengerUnit,
- RealMessengerImpl,CopyScreenFrm, VideoFrm;
- {$R *.DFM}
- {------------------------------------------------------------------------------}
- procedure TChatingForm.TimerShowInputingTimer(Sender: TObject);
- begin
- if GetTickCount-ShowInputingTimes>TimerShowInputing.Interval then
- begin
- ShowInputing(False);
- TimerShowInputing.Enabled:=False;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ShowInfo(Info:String);
- begin
- if Img=nil then
- begin
- Img:=TImage.Create(Self);
- Img.Left:=4;
- Img.Top:=4;
- Img.AutoSize:=True;
- Img.Transparent:=True;
- PnlLeftTop.InsertControl(Img);
- Img.Refresh;
- end;
-
- ImgListInfo.GetBitmap(0,Img.Picture.Bitmap);
- if Lbl=nil then
- begin
- Lbl:=TLabel.Create(Self);
- Lbl.Left:=Img.Width + 8;
- Lbl.Top:=6;
- Lbl.Transparent:=True;
- PnlLeftTop.InsertControl(Lbl);
- end;
- Lbl.Caption:=Info;
- Lbl.Refresh;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ShowOffline(Name:String);
- begin
- if Img=nil then
- begin
- Img:=TImage.Create(Self);
- Img.Left:=4;
- Img.Top:=4;
- Img.AutoSize:=True;
- Img.Transparent:=True;
- PnlLeftTop.InsertControl(Img);
- end;
-
- ImgListInfo.GetBitmap(0,Img.Picture.Bitmap);
- if Lbl=nil then
- begin
- Lbl:=TLabel.Create(Self);
- Lbl.Left:=Img.Width + 8;
- Lbl.Top:=6;
- Lbl.Transparent:=True;
- PnlLeftTop.InsertControl(Lbl);
- end;
- Lbl.Caption:='因为没有联机,'+Name+' 可能无法收到您的消息!';
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ShowInputing(Show:Boolean);
- begin
- ShowInputingTimes:=GetTickCount;
- if Show then
- begin
- if Not TimerShowInputing.Enabled then TimerShowInputing.Enabled:=True;
- if Img=nil then
- begin
- Img:=TImage.Create(Self);
- Img.Left:=4;
- Img.Top:=4;
- Img.AutoSize:=True;
- Img.Transparent:=True;
- PnlLeftTop.InsertControl(Img);
- end;
- ImgListInfo.GetBitmap(0,Img.Picture.Bitmap);
- if Lbl=nil then
- begin
- Lbl:=TLabel.Create(Self);
- Lbl.Left:=Img.Width + 8;
- Lbl.Top:=6;
- Lbl.Transparent:=True;
- PnlLeftTop.InsertControl(Lbl);
- end;
- Lbl.Caption:=PEmployee(TVUserList.Items.GetFirstNode.Data).Name+' 正在输入消息...';
- end
- else
- begin
- if Lbl<>nil then
- begin
- PnlLeftTop.RemoveControl(Lbl);
- Lbl.Free;
- Lbl:=nil;
- end;
- if Img<>nil then
- begin
- PnlLeftTop.RemoveControl(Img);
- Img.Free;
- Img:=nil;
- end;
- end;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:设置窗口样式(无标题栏,有边框)
- }
- procedure TChatingForm.CreateParams(var Params: TCreateParams);
- begin
- inherited;
- Params.Style :=WS_THICKFRAME OR WS_POPUP OR WS_BORDER OR WS_SYSMENU or WS_MINIMIZEBOX;
- Params.wndParent := GetDesktopwindow;
end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ShowTitle(ShowList:Boolean=True);
- var
- iLoop:Integer;
- HaveOfflineUser:Integer;
- Node:TTreeNode;
- EmployeePointer,PEmployeeData:PEmployee;
- begin
- if IsSystemMsg then Exit;
- Caption:='';
- if InGroupMsg then
- begin
- Caption:='群发消息';
- // lblTitle.Caption:=Caption;
- lblUserListTitle.Caption:='当前对话('+IntToStr(TVUserList.Items.Count) + ')';
- exit;
- end;
- if ShowList then
- begin
- for iLoop:=0 to TVUserList.Items.Count-1 do FreeMem(TVUserList.Items[iLoop].Data,SizeOf(Employee));
- TVUserList.Items.Clear;
- ImgHaveVideoDevice.Visible:=False;
- end;
-
- lblUserListTitle.Caption:='当前对话('+IntToStr(RoomInfo.UserCount - 1) + ')';
- HaveOfflineUser:=0;
- for iLoop:=1 to RoomInfo.UserCount do
- begin
- if RoomInfo.Users[iLoop] = Me.ID then continue;
- if RoomInfo.Users[iLoop] = -1 then
- begin
- Caption:='系统消息';
- // lblTitle.Caption:=Caption;
- ImgArrowClick(ImgArrow);
- ImgArrow.Visible:=False;
- IsSystemMsg:=True;
- PnlLeftBottom.Visible:=False;
- ImgClose.Visible:=False;
- ImgSend.Visible:=False;
- Self.ImgSendType.Visible:=False;
- ConvertBitmapToColor(ImgAddNew.Picture.Bitmap,$DEDEDE);
- ConvertBitmapToColor(ImgSendFile.Picture.Bitmap,$DEDEDE);
- ConvertBitmapToColor(ImgVoice.Picture.Bitmap,$DEDEDE);
- ConvertBitmapToColor(ImgVideo.Picture.Bitmap,$DEDEDE);
- ConvertBitmapToColor(ImgGroupMsg.Picture.Bitmap,$DEDEDE);
- ImgAddNew.Enabled:=False;
- ImgSendFile.Enabled:=False;
- ImgVoice.Enabled:=False;
- ImgVideo.Enabled:=False;
- ImgGroupMsg.Enabled:=False;
- PnlSpplit.Visible:=False;
- PnlLeftTop.Height:=PnlLeftTop.Height+PnlLeftBottom.Height+PnlSpplit.Height;
- Exit;
- end;
- PEmployeeData:=FindEmployeeByID(RoomInfo.Users[iLoop]);
- if PEmployeeData=nil then continue;
- Caption:=Caption+PEmployeeData.Name+' ';
- if ShowList then
- begin
- ShowInputing(False);
- GetMem(EmployeePointer,SizeOf(Employee));
- CopyMemory(EmployeePointer,PEmployeeData,SizeOf(Employee));
- Node:=TVUserList.Items.AddChildObject(nil,EmployeePointer.Name,EmployeePointer);
- Node.StateIndex:=2;
- EmployeePointer.Node:=Node;
- RealMessengerX.UpdateListViewStates(TVUserList,Node);
- if AnsiSameText(PEmployeeData.State,'断开') or (AnsiSameText(PEmployeeData.State,'显示为脱机')) then HaveOfflineUser:=HaveOfflineUser+1;
- if (PEmployeeData.State<>'断开') and PEmployeeData.HaveVideoDevice and (RoomInfo.UserCount = 2) then ImgHaveVideoDevice.Visible:=True;
- end;
- end;
- if HaveOfflineUser>0 then
- begin
- if RoomInfo.UserCount = 2 then
- ShowOffline(PEmployee(TVUserList.Items.GetFirstNode.Data).Name)
- else
- if HaveOfflineUser = 1 then
- ShowOffline('某个用户')
- else
- ShowOffline('某些用户');
- end;
- Caption:=Caption+'- 对话';
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:对话窗口的OnCreate事件
- }
- procedure TChatingForm.FormCreate(Sender: TObject);
- var
- TempReg:TRegistry;
- begin
- try
- ImgArrow.OnClick(ImgArrow);
- DragAcceptFiles(MsgContent.handle,true);
- DoubleBuffered:=True;
- PnlLeftBottom.DoubleBuffered:=True;
- PnlLeftTop.DoubleBuffered:=True;
- PnlRightBottom.DoubleBuffered:=True;
- PnlSpplit.DoubleBuffered:=True;
- AviPanel.DoubleBuffered:=True;
- AviPanelOut.DoubleBuffered:=True;
- PnlYourCamera.DoubleBuffered:=True;
- MsgContent.DoubleBuffered:=False;
- MsgInput.DoubleBuffered:=False;
- MsgContent.Navigate('about:blank');
- TVUserList.Images:=ImgListMain;
- TempReg:=TRegistry.Create;
- try
- TempReg.RootKey:=HKEY_LOCAL_MACHINE;
- if TempReg.OpenKey(AppKey+''+LoginName+'ChatingFormStore', True) then
- begin
- if trim(TempReg.ReadString('Width')) <>'' then Width:=StrToInt(TempReg.ReadString('Width'));
- if trim(TempReg.ReadString('Height'))<>'' then Height:=StrToInt(TempReg.ReadString('Height'));
- if ChatingFormList.Count <= 0 then
- begin
- Left:=(Screen.WorkAreaWidth-Width) div 2;
- Top:=(Screen.WorkAreaHeight-Height) div 2;
- end
- else
- begin
- Left:=TForm(ChatingFormList.Items[ChatingFormList.Count - 1]).Left + 20;
- Top:=TForm(ChatingFormList.Items[ChatingFormList.Count - 1]).Top + 20;
- if (Left > Screen.WorkAreaWidth - Width) or (Top > Screen.WorkAreaHeight - Height) then
- begin
- Left:=0;
- Top:=0;
- end;
- end;
- if trim(TempReg.ReadString('SpplitTop'))<>'' then
- begin
- Self.PnlSpplitMouseDown(nil,mbLeft,[],0,0);
- PnlSpplit.Top:=StrToInt(TempReg.ReadString('SpplitTop'));
- Self.PnlSpplitMouseMove(nil,[],0,OY+1);
- Self.PnlSpplitMouseMove(nil,[],0,OY-1);
- Self.PnlSpplitMouseUp(nil,mbLeft,[],0,0);
- end;
- if trim(TempReg.ReadString('SendType'))='Enter' then
- begin
- TMEnter.Checked:=True;
- TMEnter.Enabled:=False;
- end
- else
- begin
- TMCtrlEnter.Checked:=True;
- TMCtrlEnter.Enabled:=False;
- end;
- end;
- if TempReg.OpenKey(AppKey+''+LoginName+'Font', True) then
- begin
- if trim(TempReg.ReadString('Name'))='' then
- TempReg.WriteString('Name','宋体');
- if trim(TempReg.ReadString('Color'))='' then
- TempReg.WriteString('Color','0');
- if trim(TempReg.ReadString('Size'))='' then
- TempReg.WriteString('Size','9');
- if trim(TempReg.ReadString('fsBold'))='' then
- TempReg.WriteString('fsBold','0');
- if trim(TempReg.ReadString('fsItalic'))='' then
- TempReg.WriteString('fsItalic','0');
- if trim(TempReg.ReadString('fsUnderline'))='' then
- TempReg.WriteString('fsUnderline','0');
- if trim(TempReg.ReadString('fsStrikeOut'))='' then
- TempReg.WriteString('fsStrikeOut','0');
-
- MsgInput.Font.Name :=TempReg.ReadString('Name');
- MsgInput.Font.Color :=StrToInt(TempReg.ReadString('Color'));
- MsgInput.Font.Size :=StrToInt(TempReg.ReadString('Size'));
- if trim(TempReg.ReadString('fsBold'))='1' then MsgInput.Font.Style := MsgInput.Font.Style+[fsBold];
- if trim(TempReg.ReadString('fsItalic'))='1' then MsgInput.Font.Style := MsgInput.Font.Style+[fsItalic];
- if trim(TempReg.ReadString('fsUnderline'))='1' then MsgInput.Font.Style := MsgInput.Font.Style+[fsUnderline];
- if trim(TempReg.ReadString('fsStrikeOut'))='1' then MsgInput.Font.Style := MsgInput.Font.Style+[fsStrikeOut];
- end;
- finally
- TempReg.Free;
- end;
- except
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgSendMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ImgListSend.GetBitmap(1,ImgSend.Picture.Bitmap);
- ConvertBitmapToColor(ImgSend.Picture.Bitmap,EndColor);
- ImgSend.Refresh;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgSendMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ImgListSend.GetBitmap(0,ImgSend.Picture.Bitmap);
- ConvertBitmapToColor(ImgSend.Picture.Bitmap,EndColor);
- ImgSend.Refresh;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgCloseMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ImgListClose.GetBitmap(1,ImgClose.Picture.Bitmap);
- ConvertBitmapToColor(ImgClose.Picture.Bitmap,EndColor);
- ImgClose.Refresh;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgCloseMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ImgListClose.GetBitmap(0,ImgClose.Picture.Bitmap);
- ConvertBitmapToColor(ImgClose.Picture.Bitmap,EndColor);
- ImgClose.Refresh;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgHistoryMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ImgListHistory.GetBitmap(0,ImgHistory.Picture.Bitmap);
- ConvertBitmapToColor(ImgHistory.Picture.Bitmap,EndColor);
- ImgHistory.Refresh;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgHistoryMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ImgListHistory.GetBitmap(1,ImgHistory.Picture.Bitmap);
- ConvertBitmapToColor(ImgHistory.Picture.Bitmap,EndColor);
- ImgHistory.Refresh;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgArrowClick(Sender: TObject);
- begin
- PnlRightBottom.Visible := not PnlRightBottom.Visible;
- (Sender As TImage).Picture.Bitmap.Canvas.Pen.Style:=psClear;
- (Sender As TImage).Picture.Bitmap.Canvas.Rectangle(0,0,20,20);
- if (PnlRightBottom.Visible = False) and (Width-PnlLeftBottom.Width>PnlRightBottom.Width) then
- begin
- PnlLeftBottom.Width :=PnlLeftBottom.Width + PnlRightBottom.Width + 2;
- ImgSendType.Left :=ImgSendType.Left + PnlRightBottom.Width + 2;
- ImgSend.Left :=ImgSend.Left + PnlRightBottom.Width + 2;
- ImgClose.Left :=ImgClose.Left + PnlRightBottom.Width + 2;
- ImgListArrow.GetBitmap(1,(Sender As TImage).Picture.Bitmap);
- ConvertBitmapToColor((Sender As TImage).Picture.Bitmap,EndColor);
- (Sender As TImage).Refresh;
- end
- else if (Width-PnlLeftBottom.Width<PnlRightBottom.Width) then
- begin
- PnlLeftBottom.Width :=PnlLeftBottom.Width - PnlRightBottom.Width - 2;
- ImgSendType.Left :=ImgSendType.Left - PnlRightBottom.Width - 2;
- ImgSend.Left :=ImgSend.Left - PnlRightBottom.Width - 2;
- ImgClose.Left :=ImgClose.Left - PnlRightBottom.Width - 2;
- ImgListArrow.GetBitmap(0,(Sender As TImage).Picture.Bitmap);
- ConvertBitmapToColor((Sender As TImage).Picture.Bitmap,EndColor);
- (Sender As TImage).Refresh;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgCloseClick(Sender: TObject);
- begin
- Close;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgFontMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- (Sender as TImage).Left:=(Sender as TImage).Left+1;
- (Sender as TImage).Top:=(Sender as TImage).Top+1;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgFontMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- (Sender as TImage).Left:=(Sender as TImage).Left-1;
- (Sender as TImage).Top:=(Sender as TImage).Top-1;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:对话窗口的OnClose事件
- }
- procedure TChatingForm.FormClose(Sender: TObject; var Action: TCloseAction);
- var
- iLoop,MissionCount:Integer;
- TransmitFile:TTransmitFile;
- AudioHandShake:TAudioHandShake;
- VideoHandShake:TVideoHandShake;
- begin
- try
- MissionCount:=0;
- with TransmitFiles.LockList do
- try
- for iLoop:=0 to Count - 1 do
- begin
- TransmitFile:=Items[iLoop];
- if TransmitFile.ChatingForm = Self then MissionCount:=MissionCount+1;
- end;
- finally
- TransmitFiles.UnlockList;
- end;
- with AudioHandShakes.LockList do
- try
- for iLoop:=0 to Count - 1 do
- begin
- AudioHandShake:=Items[iLoop];
- if AudioHandShake.ChatingForm = Self then MissionCount:=MissionCount+1;
- end;
- finally
- AudioHandShakes.UnlockList;
- end;
- with VideoHandShakes.LockList do
- try
- for iLoop:=0 to Count - 1 do
- begin
- VideoHandShake:=Items[iLoop];
- if VideoHandShake.ChatingForm = Self then MissionCount:=MissionCount+1;
- end;
- finally
- VideoHandShakes.UnlockList;
- end;
- if MissionCount>0 then
- begin
- if MessageBox(Handle,PChar('有 '+IntToStr(MissionCount)+' 个任务在本窗口还未结束,确定要关闭吗!'),'提示',MB_ICONQUESTION or MB_OKCANCEL) <> ID_OK then
- begin
- Action:=caNone;
- exit;
- end
- else
- begin
- with TransmitFiles.LockList do
- try
- for iLoop:=Count - 1 downto 0 do
- begin
- TransmitFile:=Items[iLoop];
- if TransmitFile.ChatingForm = Self then TransmitFile.Close;
- end;
- finally
- TransmitFiles.UnlockList;
- end;
- with AudioHandShakes.LockList do
- try
- for iLoop:=Count - 1 downto 0 do
- begin
- AudioHandShake:=Items[iLoop];
- if AudioHandShake.ChatingForm = Self then AudioHandShake.Close;
- end;
- finally
- AudioHandShakes.UnlockList;
- end;
- with VideoHandShakes.LockList do
- try
- for iLoop:=Count - 1 downto 0 do
- begin
- VideoHandShake:=Items[iLoop];
- if VideoHandShake.ChatingForm = Self then VideoHandShake.Close;
- end;
- finally
- VideoHandShakes.UnlockList;
- end;
- end;
- end;
- ChatingFormList.Remove(Self);
- Action:=caFree;
- except
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgTitleMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- if (Button = mbLeft) then
- begin
- ReleaseCapture;
- self.Perform(WM_SYSCOMMAND, $F012, 0);
- FormResize(nil);
- end;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:关闭窗口
- }
- procedure TChatingForm.ImgClosedClick(Sender: TObject);
- begin
- // Close;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:最大化
- }
- procedure TChatingForm.ImgMaxClick(Sender: TObject);
- begin
- { if WindowState = wsNormal then
- begin
- ImgListMax.GetBitmap(1,ImgMax.Picture.Bitmap);
- WindowState := wsMaximized;
- Left:=0;
- Top:=0;
- Width:=Screen.WorkAreaWidth;
- Height:=Screen.WorkAreaHeight;
- end
- else
- begin
- ImgListMax.GetBitmap(0,ImgMax.Picture.Bitmap);
- WindowState := wsNormal;
- end;
- ConvertBitmapToColor(ImgMax.Picture.Bitmap,EndColor);
- ImgMax.Refresh; }
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:最小化
- }
- procedure TChatingForm.ImgMinClick(Sender: TObject);
- begin
- // WindowState := wsMinimized;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.MsgInputChange(Sender: TObject);
- var
- I,L,S:Integer;
- Buffer :array[1..2048]of char;
- CBInputing :TCBInputing;
- EmployeeData :PEmployee;
- begin
- L:=Length(TRxRichEdit(Sender).Text);
- for I:=1 to Length(Faces) do
- begin
- S:=TRxRichEdit(Sender).FindText(FacesChar[I],0,L,[]);
- While S>=0 do
- begin
- TRxRichEdit(Sender).SelStart:=S;
- TRxRichEdit(Sender).SelLength:=Length(FacesChar[I]);
- TRxRichEdit(Sender).SelText:=Faces[I];
- TRxRichEdit(Sender).SelStart:=TRxRichEdit(Sender).SelStart+1;
- TRxRichEdit(Sender).SelLength:=0;
- S:=TRxRichEdit(Sender).FindText(FacesChar[I],TRxRichEdit(Sender).SelStart,L,[]);
- end;
- end;
- if (not InGroupMsg) and ((L=0) or ((GetTickCount-LastInputing>5000) and (TVUserList.Items.Count = 1) and (not AudioIsOn) and (not VideoIsOn) and (PEmployee(TVUserList.Items.GetFirstNode.Data).State<>'断开') and (PEmployee(TVUserList.Items.GetFirstNode.Data).State<>'显示为脱机'))) then
- begin
- LastInputing:=GetTickCount;
- CBInputing.Sender:=Me.ID;
- CBInputing.Receiver:=PEmployee(TVUserList.Items.GetFirstNode.Data).ID;
- CBInputing.Inputing:=(L>0);
- CBInputing.Room:=RoomInfo;
- Buffer[1]:=skInputing;
- CopyMemory(@Buffer[2],@CBInputing,SizeOf(CBInputing));
- EmployeeData:=FindEmployeeByID(CBInputing.Receiver);
- if EmployeeData=nil then exit;
- if EmployeeData.MySocket=nil then EmployeeData.MySocket:=TMySocket.Create(EmployeeData.ID,RealMessengerX.ClientTCP,True);
- EmployeeData.MySocket.SendBuffer(Buffer,SizeOf(CBInputing)+1); {正在输入消息}
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgSendClick(Sender: TObject);
- var
- StreamContent :array[1..99999] of Char;
- Buffer :array[1..2048]of char;
- Stream :TMemoryStream;
- Content :String;
- CB :TCBMessage;
- PCB :PCBMessage;
- i :Integer;
- EmployeeData :PEmployee;
- begin
- CB.Sender :=Me.ID;
- CB.SendDateTime :=Now;
- CB.Room:=RoomInfo;
- Stream:=TMemoryStream.Create;
- MsgInput.Lines.SaveToStream(Stream);
- Stream.Position:=0;
-
- if stream.Size > SizeOf(StreamContent) then
- begin
- messagebox(handle,'图标数量过多!','提示',MB_OK OR MB_ICONINFORMATION);
- exit;
- end;
- stream.Read(StreamContent,stream.Size);
- Content:=Copy(StreamContent,1,stream.Size);
- for i:=1 to Length(Faces) do
- Content:=AnsiReplaceStr(Content,FaceCodes[i],FacesChar[i]);
- for i:=1 to Length(Content) do StreamContent[i]:=Content[i];
-
- stream.Clear;
- stream.Write(StreamContent,Length(Content));
- stream.Position:=0;
- TempRxRichEdit.Clear;
- TempRxRichEdit.Lines.LoadFromStream(stream);
- if Length(Trim(TempRxRichEdit.Text)) <= 0 then
- begin
- messagebox(handle,'消息内容不能为空!','提示',MB_OK OR MB_ICONINFORMATION);
- exit;
- end;
- Content:=EncryStr(Copy(TempRxRichEdit.Text,1,SizeOf(CB.Content)-10),DESKEY);
- for i:=1 to Length(Content) do
- begin
- if i<SizeOf(CB.Content) then
- CB.Content[i]:=Content[i]
- else
- break;
- end;
- CB.Length :=Length(Content);
- CB.Name :=MsgInput.Font.Name;
- CB.Color :=MsgInput.Font.Color;
- CB.Size :=MsgInput.Font.Size;
- if fsBold in MsgInput.Font.Style then
- CB.fsBold:=True
- else
- CB.fsBold:=False;
- if fsItalic in MsgInput.Font.Style then
- CB.fsItalic:=True
- else
- CB.fsItalic:=False;
-
- if fsUnderline in MsgInput.Font.Style then
- CB.fsUnderline:=True
- else
- CB.fsUnderline:=False;
- if fsStrikeOut in MsgInput.Font.Style then
- CB.fsStrikeOut:=True
- else
- CB.fsStrikeOut:=False;
- MsgInput.Clear;
- Stream.Free;
- ShowMsg(Self,Self.MsgContent,Me.Name,CB,false);
- if InGroupMsg then //群发消息
- begin
- try
- for i:=0 to TVUserList.Items.Count - 1 do
- begin
- CB.Room.UserCount:=2;
- CB.Room.Users[1]:=Me.ID;
- CB.Room.Users[2]:=TVUserList.Items[i].StateIndex;
- CB.Receiver:=TVUserList.Items[i].StateIndex;
- CB.SendTicket:=GetTickCount;
- Buffer[1]:=skMessage;
- CopyMemory(@Buffer[2],@CB,SizeOf(CB));
- EmployeeData:=FindEmployeeByID(CB.Receiver);
- if EmployeeData=nil then continue;
- if EmployeeData.MySocket=nil then EmployeeData.MySocket:=TMySocket.Create(EmployeeData.ID,RealMessengerX.ClientTCP,True);
- EmployeeData.MySocket.SendBuffer(Buffer,SizeOf(CB)+1); {发送消息}
- if TVUserList.Items.Count>1 then
- begin
- Sleep(10);
- Application.ProcessMessages;
- end;
- GetMem(PCB,SizeOf(TCBMessage));
- CopyMemory(PCB,@CB,SizeOf(TCBMessage));
- MsgReturnCheck.Add(PCB);
- if not RealMessengerX.MsgTimer.Enabled then RealMessengerX.MsgTimer.Enabled:=True;
- SaveHistory(CB);
- end;
- finally
- end;
- end
- else
- begin
- try
- for i:=1 to CB.Room.UserCount do
- begin
- if CB.Room.Users[i]=Me.ID then continue;
- CB.Receiver:=CB.Room.Users[i];
- CB.SendTicket:=GetTickCount;
- Buffer[1]:=skMessage;
- CopyMemory(@Buffer[2],@CB,SizeOf(CB));
-
- EmployeeData:=FindEmployeeByID(CB.Receiver);
- if EmployeeData=nil then continue;
- if EmployeeData.MySocket=nil then EmployeeData.MySocket:=TMySocket.Create(EmployeeData.ID,RealMessengerX.ClientTCP,True);
- EmployeeData.MySocket.SendBuffer(Buffer,SizeOf(CB)+1); {发送消息}
- if CB.Room.UserCount>2 then
- begin
- Sleep(10);
- Application.ProcessMessages;
- end;
- GetMem(PCB,SizeOf(TCBMessage));
- CopyMemory(PCB,@CB,SizeOf(TCBMessage));
- MsgReturnCheck.Add(PCB);
- if not RealMessengerX.MsgTimer.Enabled then RealMessengerX.MsgTimer.Enabled:=True;
- SaveHistory(CB);
- end;
- finally
- end;
- end;
- MsgInput.SetFocus();
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgHistoryClick(Sender: TObject);
- begin
- if TVUserList.Items.Count > 1 then exit;
- if HistoryForm<>nil then HistoryForm.Close;
- HistoryForm:=THistoryForm.Create(Application);
- if IsSystemMsg then
- begin
- HistoryForm.ID:=-1;
- HistoryForm.Name:='系统消息';
- end
- else
- begin
- HistoryForm.ID:=PEmployee(TVUserList.Items.GetFirstNode.Data).ID;
- HistoryForm.Name:=PEmployee(TVUserList.Items.GetFirstNode.Data).Name;
- end;
- HistoryForm.Show;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.FormResize(Sender: TObject);
- var
- TempReg:TRegistry;
- OT,OH:Integer;
- begin
- ShowTitle(False);
-
- if PnlLeftTop.Height<145 then
- begin
- PnlLeftTop.Height:=145;
- OT:=PnlSpplit.Top;
- PnlSpplit.Top:=PnlLeftTop.Top+PnlLeftTop.Height;
- PnlLeftBottom.Top:=PnlLeftBottom.Top+(PnlSpplit.Top-OT);
- PnlRightBottom.Top:=PnlLeftBottom.Top;
- PnlMyCamera.Top:=PnlLeftBottom.Top;
- PnlLeftBottom.Height:=PnlLeftBottom.Height+(OT-PnlSpplit.Top);
- PnlRightBottom.Height:=PnlRightBottom.Height+(OT-PnlSpplit.Top);
- end;
-
- if PnlLeftBottom.Height<90 then
- begin
- OH:=PnlLeftBottom.Height;
- PnlLeftBottom.Height:=90;
- PnlRightBottom.Height:=115;
- PnlLeftTop.Height:=PnlLeftTop.Height-(PnlLeftBottom.Height-OH);
- OT:=PnlSpplit.Top;
- PnlSpplit.Top:=PnlLeftTop.Top+PnlLeftTop.Height;
- PnlLeftBottom.Top:=PnlLeftBottom.Top+(PnlSpplit.Top-OT);
- PnlRightBottom.Top:=PnlLeftBottom.Top;
- PnlMyCamera.Top:=PnlLeftBottom.Top;
- end;
- if WindowState = wsMaximized then exit;
- TempReg:=TRegistry.Create;
- try
- TempReg.RootKey:=HKEY_LOCAL_MACHINE;
- if TempReg.OpenKey(AppKey+''+LoginName+'ChatingFormStore', True) then
- begin
- TempReg.WriteString('Left',IntToStr(Left));
- TempReg.WriteString('Top',IntToStr(Top));
- TempReg.WriteString('Width',IntToStr(Width));
- TempReg.WriteString('Height',IntToStr(Height));
- TempReg.WriteString('SpplitTop',IntToStr(PnlSpplit.Top));
- end;
- finally
- TempReg.Free;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgFontClick(Sender: TObject);
- var
- TempReg:TRegistry;
- begin
- FontDialog1.Font:=MsgInput.Font;
- if FontDialog1.Execute then
- begin
- MsgInput.Font:=FontDialog1.Font;
- TempReg:=TRegistry.Create;
- try
- TempReg.RootKey:=HKEY_LOCAL_MACHINE;
- if TempReg.OpenKey(AppKey+''+LoginName+'Font', True) then
- begin
- TempReg.WriteString('Name',FontDialog1.Font.Name);
- TempReg.WriteString('Color',IntToStr(FontDialog1.Font.Color));
- TempReg.WriteString('Size',IntToStr(FontDialog1.Font.Size));
-
- if fsBold in FontDialog1.Font.Style then
- TempReg.WriteString('fsBold','1')
- else
- TempReg.WriteString('fsBold','0');
- if fsItalic in FontDialog1.Font.Style then
- TempReg.WriteString('fsItalic','1')
- else
- TempReg.WriteString('fsItalic','0');
- if fsUnderline in FontDialog1.Font.Style then
- TempReg.WriteString('fsUnderline','1')
- else
- TempReg.WriteString('fsUnderline','0');
- if fsStrikeOut in FontDialog1.Font.Style then
- TempReg.WriteString('fsStrikeOut','1')
- else
- TempReg.WriteString('fsStrikeOut','0')
- end;
- finally
- TempReg.Free;
- end;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.FormShow(Sender: TObject);
- var
- iLoop:Integer;
- Stream:TMemoryStream;
- BitMap:TBitMap;
- StreamContent:array[1..9999] of Char;
- Content,T:string;
- i,J:Integer;
- DRect,SRect:TRect;
- ImgFace:TImage;
- begin
- ShowTitle;
- OnResize:=FormResize;
- if FaceHasGeted then exit;
-
- ImgFace:=TImage.Create(nil);
- BitMap:=TBitMap.Create;
- try
- ImgFace.Picture.Bitmap.LoadFromFile(PicPath+'Faces.bmp');
- DRect.Left:=0;
- DRect.Top:=0;
- DRect.Right:=19;
- DRect.Bottom:=19;
- BitMap.Width:=20;
- BitMap.Height:=20;
- BitMap.Canvas.FillRect(DRect);
- for iLoop:=1 to Length(Faces) do
- begin
- SRect.Left:=((iLoop-1) mod 10)*30+6;
- SRect.Top:=((iLoop-1) div 10)*30+6;
- SRect.Right:=((iLoop-1) mod 10)*30+25;
- SRect.Bottom:=((iLoop-1) div 10)*30+25;
- BitMap.Canvas.CopyRect(DRect,ImgFace.Canvas,SRect);
- if Length(Faces[iLoop])<=0 then
- begin
- Faces[iLoop]:=ConvertBitmapToRTF(BitMap);
- TempRxRichEdit.Lines.Add('BmpStartBmpEnd');
- TempRxRichEdit.SelStart:=8;
- TempRxRichEdit.SelLength:=0;
- TempRxRichEdit.SelText:=Faces[iLoop];
- Stream:=TMemoryStream.Create;
- TempRxRichEdit.Lines.SaveToStream(Stream);
- Stream.Position:=0;
- stream.Read(StreamContent,stream.Size);
- Content:=Copy(StreamContent,1,stream.Size);
- J:=Pos('BmpStart', Content);
- T:=Copy(Content, J+8, Length(Content));
- I:=Pos('BmpEnd',T);
- FaceCodes[iLoop]:=Copy(Content,J+8,I-1);
- TempRxRichEdit.Clear;
- end;
- if iLoop mod 5=0 then Application.ProcessMessages;
- end;
- finally
- BitMap.Free;
- ImgFace.Free;
- FaceHasGeted:=True;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.TVUserListCustomDrawItem(Sender: TCustomTreeView;
- Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
- begin
- DefaultDraw:=true;
- if Node.Selected then
- begin
- TVUserList.Canvas.Font.Color:=clWhite;
- end
- else
- begin
- if (Node.StateIndex = 2) and (not InGroupMsg) then
- begin
- if (Node.ImageIndex = 6) or (Node.ImageIndex = 10) then
- TVUserList.Canvas.Font.Color:=clRed
- else
- TVUserList.Canvas.Font.Color:=clGreen;
- end
- else if Node.StateIndex = -1 then
- begin
- TVUserList.Canvas.Font.Color:=$00934A46;
- TVUserList.Canvas.Font.Style:=[fsBold];
- end
- else
- TVUserList.Canvas.Font.Color:=clBlack;
- end;
- TVUserList.Canvas.Textout(Node.DisplayRect(True).Left+2,Node.DisplayRect(True).Top+2,Node.Text);
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgAddNewClick(Sender: TObject);
- var
- ID:Integer;
- iLoop,jLoop:Integer;
- Finded:Boolean;
- CBAddUser:TCBAddUser;
- AddRoom:ChatRoom;
- Buffer:Array[1..2048]of char;
- begin
- if InGroupMsg=True then
- begin
- MessageBox(Handle,'群发消息状态下不能进入多人模式!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if AudioIsOn then
- begin
- MessageBox(Handle,'当前窗口已打开音频对话任务,不能进入多人模式!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if VideoIsOn then
- begin
- MessageBox(Handle,'当前窗口已打开视频对话任务,不能进入多人模式!','提示',MB_ICONINFORMATION);
- exit;
- end;
- SelUserForm:=TSelUserForm.Create(Self);
- try
- if SelUserForm.ShowModal = mrOk then
- begin
- CBAddUser.Room.UserCount:=RoomInfo.UserCount;
- for iLoop:=1 to RoomInfo.UserCount do CBAddUser.Room.Users[iLoop]:=RoomInfo.Users[iLoop];
- AddRoom.UserCount:=0;
- for iLoop := 0 to SelUserForm.TrevUserList.Items.Count - 1 do
- begin
- if (SelUserForm.TrevUserList.Items[iLoop].ImageIndex<6) or (SelUserForm.TrevUserList.Items[iLoop].ImageIndex>13) then continue;
- if IsNodeChecked(SelUserForm.TrevUserList.Items[iLoop])=False then continue;
- ID:=PEmployee(SelUserForm.TrevUserList.Items[iLoop].Data).ID;
- Finded:=False;
- for jLoop:=1 to RoomInfo.UserCount do
- begin
- if RoomInfo.Users[jLoop] = ID then
- begin
- Finded:=True;
- break;
- end;
- end;
- if not Finded then
- begin
- if RoomInfo.UserCount=16 then
- begin
- MessageBox(Handle,PChar('多人对话环境的最大收件人数不得超过 '+IntToStr(15)+' 个'),'提示',MB_OK);
- Break;
- end;
- AddRoom.UserCount:=AddRoom.UserCount+1;
- AddRoom.Users[AddRoom.UserCount]:=ID;
- RoomInfo.UserCount:=RoomInfo.UserCount+1;
- RoomInfo.Users[RoomInfo.UserCount]:=ID;
- end;
- end;
- if AddRoom.UserCount>0 then
- begin
- ImgHistory.Visible:=False;
- for jLoop:=1 to CBAddUser.Room.UserCount do
- begin
- if CBAddUser.Room.Users[jLoop]<>Me.ID then
- begin
- CBAddUser.Receiver:=CBAddUser.Room.Users[jLoop];
- CBAddUser.AddRoom:=AddRoom;
- Buffer[1]:=skAddUser;
- CopyMemory(@Buffer[2],@CBAddUser,SizeOf(CBAddUser));
- RealMessengerX.ClientTCP.WriteBuffer(Buffer,SizeOf(CBAddUser)+1);
- end;
- end;
- end;
- end;
- finally
- SelUserForm.Free;
- SelUserForm:=nil;
- end;
- ShowTitle();
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgSendFileClick(Sender: TObject);
- var
- Receiver:Integer;
- ReceiverName:String;
- Form:TChatingForm;
- Room:ChatRoom;
- begin
- if InGroupMsg=True then
- begin
- MessageBox(Handle,'群发消息状态下不能进行文件传输!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if TVUserList.Items.Count = 1 then
- begin
- Receiver :=PEmployee(TVUserList.Items.GetFirstNode.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Items.GetFirstNode.Data).Name;
- Form :=Self;
- end
- else
- begin
- if TVUserList.SelectionCount = 0 then
- begin
- MessageBox(Handle,'请先在 当前对话列表 中选择收件人!','提示',MB_ICONINFORMATION);
- exit;
- end;
- Receiver :=PEmployee(TVUserList.Selected.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Selected.Data).Name;
- Room.UserCount:=2;
- Room.Users[1] :=Me.ID;
- Room.Users[2] :=Receiver;
- Form:=OpenChatingForm(Room);
- Form.Show;
- end;
- OpenDialog.Title:='请选择要给 '+ReceiverName+' 发送的文件';
- if OpenDialog.Execute then
- begin
- TTransmitFile.Create(tfSend,Me.ID,Me.Name,Receiver,ReceiverName,OpenDialog.Files.Strings[0],Form,'',0,'',0);
- end;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:模拟Toolbar的按钮动作,MouseMove时显示为凸起状态
- }
- procedure TChatingForm.ImgAddNewMouseMove(Sender: TObject;
- Shift: TShiftState; X, Y: Integer);
- begin
- { ImgIndex:=(Sender as TImage).Tag;
- if ImgIndex=LastImgIndex then exit;
- ImgDraw.Canvas.lock;
- With ImgDraw.Canvas do
- begin
- Pen.Mode :=pmCopy;
- Pen.Style:=psClear;
- Rectangle(0,0,ImgDraw.Width+1,ImgDraw.Height+1);
- Pen.Style:=psSolid;
- Pen.Color:=$00FEFEFE;
- Pen.Width:=1;
- MoveTo((Sender as TImage).Left-ImgDraw.Left,50);
- LineTo(PenPos.X,2);
- LineTo(PenPos.X+(Sender as TImage).Width,2);
- Pen.Color:=EndColor;
- LineTo(PenPos.X,50);
- LineTo(PenPos.X-(Sender as TImage).Width,50);
- Pen.Mode :=pmWhite;
- Pen.Style:=psSolid;
- // Rectangle((Sender as TImage).Left-ImgDraw.Left+1,3,(Sender as TImage).Left-ImgDraw.Left+(Sender as TImage).Width,50);
- //Refresh;
- end;
- LastImgIndex:=ImgIndex;
- TimerTopBar.Enabled:=True;
- ImgDraw.Canvas.Unlock; }
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:检查Mouse是否还在指定的范围之内,如不在则复位ToolBar的显示状态
- }
- procedure TChatingForm.TimerTopBarTimer(Sender: TObject);
- var
- p : TPoint;
- begin
- { GetCursorPos(p);
- if (P.X < Left + ImgDraw.Left) or
- (P.X > Left + ImgDraw.Left + ImgDraw.Width) or
- (P.Y < Top + ImgDraw.Top) or
- (P.Y > Top + ImgDraw.Top + ImgDraw.Height) then
- begin
- With ImgDraw.Canvas do
- begin
- Pen.Mode :=pmCopy;
- Pen.Style:=psClear;
- Rectangle(0,0,ImgDraw.Width+1,ImgDraw.Height+1);
- end;
- ImgIndex:=-1;
- LastImgIndex:=-1;
- TimerTopBar.Enabled:=False;
- end; }
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:模拟Toolbar的按钮动作,MouseDown时显示为凹下状态
- }
- procedure TChatingForm.ImgAddNewMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- { With ImgDraw.Canvas do
- begin
- Pen.Mode :=pmCopy;
- Pen.Style:=psClear;
- Rectangle(0,0,ImgDraw.Width+1,ImgDraw.Height+1);
- Pen.Style:=psSolid;
- Pen.Color:=EndColor;
- Pen.Width:=1;
- MoveTo((Sender as TImage).Left-ImgDraw.Left,50);
- LineTo(PenPos.X,2);
- LineTo(PenPos.X+(Sender as TImage).Width,2);
- Pen.Color:=$00FEFEFE;
- LineTo(PenPos.X,50);
- LineTo(PenPos.X-(Sender as TImage).Width,50);
- Pen.Mode :=pmWhite;
- Pen.Style:=psSolid;
- //Rectangle((Sender as TImage).Left-ImgDraw.Left+1,3,(Sender as TImage).Left-ImgDraw.Left+(Sender as TImage).Width,50);
- end;
- ImgFontMouseDown(Sender,Button,Shift,X,Y);
- TimerTopBar.Enabled:=False; }
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:模拟Toolbar的按钮动作,MouseUp时显示为凸起状态
- }
- procedure TChatingForm.ImgAddNewMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- { ImgFontMouseUp(Sender,Button,Shift,X,Y);
- With ImgDraw.Canvas do
- begin
- Pen.Mode :=pmCopy;
- Pen.Style:=psClear;
- Rectangle(0,0,ImgDraw.Width+1,ImgDraw.Height+1);
- Pen.Style:=psSolid;
- Pen.Color:=$00FEFEFE;
- Pen.Width:=1;
- MoveTo((Sender as TImage).Left-ImgDraw.Left,50);
- LineTo(PenPos.X,2);
- LineTo(PenPos.X+(Sender as TImage).Width,2);
- Pen.Color:=EndColor;
- LineTo(PenPos.X,50);
- LineTo(PenPos.X-(Sender as TImage).Width,50);
- Pen.Mode :=pmWhite;
- Pen.Style:=psSolid;
- //Rectangle((Sender as TImage).Left-ImgDraw.Left+1,3,(Sender as TImage).Left-ImgDraw.Left+(Sender as TImage).Width,50);
- end;
- TimerTopBar.Enabled:=True; }
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:视频对话
- }
- procedure TChatingForm.ImgVideoClick(Sender: TObject);
- var
- Receiver:Integer;
- ReceiverName:String;
- Form:TChatingForm;
- Room:ChatRoom;
- begin
- if InGroupMsg=True then
- begin
- MessageBox(Handle,'群发消息状态下不能进行视频对话!','提示',MB_ICONINFORMATION);
- exit;
- end;
- RealMessengerX.TestVideoDevice();
- if TVUserList.Items.Count = 1 then
- begin
- if (not HaveVideoDevice) and (not PEmployee(TVUserList.Items.GetFirstNode.Data).HaveVideoDevice) then
- begin
- MessageBox(Handle,PChar('您和 '+String(PEmployee(TVUserList.Items.GetFirstNode.Data).Name)+' 的机器均没有安装视频捕获设备,不能开启网络摄像机功能'),'提示',MB_ICONINFORMATION);
- exit
- end;
- Receiver :=PEmployee(TVUserList.Items.GetFirstNode.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Items.GetFirstNode.Data).Name;
- Form :=Self;
- end
- else
- begin
- if TVUserList.SelectionCount = 0 then
- begin
- MessageBox(Handle,'请先在“当前对话列表”中选择您要邀请的开始进行视频对话的人!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if (not HaveVideoDevice) and (not PEmployee(TVUserList.Selected.Data).HaveVideoDevice) then
- begin
- MessageBox(Handle,PChar('您和 '+String(PEmployee(TVUserList.Selected.Data).Name)+' 的机器均没有安装视频捕获设备,不能开启网络摄像机功能'),'提示',MB_ICONINFORMATION);
- exit
- end;
- Receiver :=PEmployee(TVUserList.Selected.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Selected.Data).Name;
- Room.UserCount:=2;
- Room.Users[1] :=Me.ID;
- Room.Users[2] :=Receiver;
- Form:=OpenChatingForm(Room);
- Form.Show;
- end;
- TVideoHandShake.Create(vhRequest,Receiver,ReceiverName,Form,'',0,'',0,'',0,'',0);
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:音频对话
- }
- procedure TChatingForm.ImgVoiceClick(Sender: TObject);
- var
- Receiver:Integer;
- ReceiverName:String;
- Form:TChatingForm;
- Room:ChatRoom;
- begin
- if InGroupMsg=True then
- begin
- MessageBox(Handle,'群发消息状态下不能进行音频对话!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if not HaveAudioDevice then
- begin
- MessageBox(Handle,'您的机器没有安装声音设备,不能进行音频对话','提示',MB_ICONINFORMATION);
- exit
- end;
- if TVUserList.Items.Count = 1 then
- begin
- if not PEmployee(TVUserList.Items.GetFirstNode.Data).HaveAudioDevice then
- begin
- MessageBox(Handle,'对方的机器没有安装声音设备,不能进行音频对话','提示',MB_ICONINFORMATION);
- exit
- end;
- Receiver :=PEmployee(TVUserList.Items.GetFirstNode.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Items.GetFirstNode.Data).Name;
- Form :=Self;
- end
- else
- begin
- if TVUserList.SelectionCount = 0 then
- begin
- MessageBox(Handle,'请先在“当前对话列表”中选择您要邀请的开始进行音频对话的人!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if not PEmployee(TVUserList.Selected.Data).HaveAudioDevice then
- begin
- MessageBox(Handle,'对方的机器没有安装声音设备,不能进行音频对话','提示',MB_ICONINFORMATION);
- exit;
- end;
- Receiver :=PEmployee(TVUserList.Selected.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Selected.Data).Name;
- Room.UserCount:=2;
- Room.Users[1] :=Me.ID;
- Room.Users[2] :=Receiver;
- Form:=OpenChatingForm(Room);
- Form.Show;
- end;
- TAudioHandShake.Create(ahRequest,Receiver,ReceiverName,Form,'',0,'',0);
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.SetDOMStyle(Doc:IHTMLDocument2);
- var
- v: Variant;
- TempReg:TRegistry;
- begin
- v := VarArrayCreate([0, 0], varVariant);
- v[0] := '<body oncontextmenu="location.href=''PopMenu'';return false;"></body>';
- doc.write(PSafeArray(TVarData(v).VArray));
- try
- CssColor:='#'+Copy(IntToHex(EndColor,6),5,2)+Copy(IntToHex(EndColor,6),3,2)+Copy(IntToHex(EndColor,6),1,2);
- except
- end;
- Doc.body.style.cssText:='SCROLLBAR-FACE-COLOR:'+CssColor+';'+
- 'SCROLLBAR-HIGHLIGHT-COLOR: ButtonHighLight;'+
- 'SCROLLBAR-SHADOW-COLOR:ButtonShadow;'+
- 'SCROLLBAR-ARROW-COLOR: #333333;'+
- 'SCROLLBAR-3DLIGHT-COLOR:'+CssColor+';'+
- 'SCROLLBAR-TRACK-COLOR:'+CssColor+';'+
- 'SCROLLBAR-DARKSHADOW-COLOR:'+CssColor+';'+
- 'word-break:break-all;'+
- 'background-attachment: fixed;'+
- 'background-repeat: no-repeat;'+
- 'background-position: left top;';
- Doc.body.style.overflow:='auto';
- Doc.body.style.border:='0px solid';
- Doc.body.style.margin:='2px';
- Doc.body.style.fontFamily:='宋体';
- Doc.body.style.fontSize:='9pt';
- TempReg:=TRegistry.Create;
- try
- TempReg.RootKey:=HKEY_LOCAL_MACHINE;
- if TempReg.OpenKey(AppKey+''+LoginName+'ChatingFormStore', True) then
- begin
- Doc.body.style.backgroundImage:='url('+TempReg.ReadString('BackGroundImage')+')';
- end;
- finally
- TempReg.Free;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.SetBrowserStyle();
- begin
- SetDOMStyle(MsgContent.Document as IHTMLDocument2);
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.SetBrowserBg(Url:String);
- var
- TempReg:TRegistry;
- begin
- TempReg:=TRegistry.Create;
- try
- TempReg.RootKey:=HKEY_LOCAL_MACHINE;
- if TempReg.OpenKey(AppKey+''+LoginName+'ChatingFormStore', True) then
- begin
- TempReg.WriteString('BackGroundImage',Url);
- SetBrowserStyle();
- end;
- finally
- TempReg.Free;
- end;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:选择表情图标
- }
- procedure TChatingForm.ImgSelFaceClick(Sender: TObject);
- begin
- if SelFaceForm=nil then
- begin
- SelFaceForm:=TSelFaceForm.Create(Self);
- SelFaceForm.ParentForm:=Self;
- SelFaceForm.Show;
- end;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:模拟Toolbar的按钮动作,MouseMove时显示为凸起状态
- }
- procedure TChatingForm.ImgFontMouseMove(Sender: TObject;
- Shift: TShiftState; X, Y: Integer);
- begin
- ImgIndex:=(Sender as TImage).Tag;
- if ImgIndex=LastImgIndex then exit;
- With ImgBottomDraw.Canvas do
- begin
- Pen.Mode :=pmCopy;
- Pen.Style:=psClear;
- Rectangle(0,0,ImgBottomDraw.Width+1,ImgBottomDraw.Height+1);
- Pen.Style:=psSolid;
- Pen.Color:=$00FEFEFE;
- Pen.Width:=1;
- MoveTo((Sender as TImage).Left-ImgBottomDraw.Left,21);
- LineTo(PenPos.X,2);
- LineTo(PenPos.X+(Sender as TImage).Width,2);
- Pen.Color:=$00AAAAAA;
- LineTo(PenPos.X,21);
- LineTo(PenPos.X-(Sender as TImage).Width,21);
- Refresh;
- end;
- LastImgIndex:=ImgIndex;
- TimerBottomBar.Enabled:=True;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:检查Mouse是否还在指定的区域之内,如不在则复位按钮状态
- }
- procedure TChatingForm.TimerBottomBarTimer(Sender: TObject);
- var
- p : TPoint;
- begin
- GetCursorPos(p);
- if (P.X < Left + PnlLeftBottom.Left + ImgBottomDraw.Left) or
- (P.X > Left + PnlLeftBottom.Left + ImgBottomDraw.Left + ImgBottomDraw.Width) or
- (P.Y < Top + PnlLeftBottom.Top + ImgBottomDraw.Top) or
- (P.Y > Top + PnlLeftBottom.Top + ImgBottomDraw.Top + ImgBottomDraw.Height) then
- begin
- With ImgBottomDraw.Canvas do
- begin
- Pen.Mode :=pmCopy;
- Pen.Style:=psClear;
- Rectangle(0,0,ImgBottomDraw.Width+1,ImgBottomDraw.Height+1);
- end;
- ImgIndex:=-1;
- LastImgIndex:=-1;
- TimerBottomBar.Enabled:=False;
- end;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:模拟Toolbar的按钮动作,MouseDown时显示为凸起状态
- }
- procedure TChatingForm.ImgSelBackMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- With ImgBottomDraw.Canvas do
- begin
- Pen.Mode :=pmCopy;
- Pen.Style:=psClear;
- Rectangle(0,0,ImgBottomDraw.Width+1,ImgBottomDraw.Height+1);
- Pen.Style:=psSolid;
- Pen.Color:=$00AAAAAA;
- Pen.Width:=1;
- MoveTo((Sender as TImage).Left-ImgBottomDraw.Left,21);
- LineTo(PenPos.X,2);
- LineTo(PenPos.X+(Sender as TImage).Width,2);
- Pen.Color:=$00FEFEFE;
- LineTo(PenPos.X,21);
- LineTo(PenPos.X-(Sender as TImage).Width,21);
- Refresh;
- end;
- ImgFontMouseDown(Sender,Button,Shift,X,Y);
- TimerBottomBar.Enabled:=False;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:模拟Toolbar的按钮动作,MouseUp时显示为凹下状态
- }
- procedure TChatingForm.ImgSelBackMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ImgFontMouseUp(Sender,Button,Shift,X,Y);
- With ImgBottomDraw.Canvas do
- begin
- Pen.Mode :=pmCopy;
- Pen.Style:=psClear;
- Rectangle(0,0,ImgBottomDraw.Width+1,ImgBottomDraw.Height+1);
- Pen.Style:=psSolid;
- Pen.Color:=$00FEFEFE;
- Pen.Width:=1;
- MoveTo((Sender as TImage).Left-ImgBottomDraw.Left,21);
- LineTo(PenPos.X,2);
- LineTo(PenPos.X+(Sender as TImage).Width,2);
- Pen.Color:=$00AAAAAA;
- LineTo(PenPos.X,21);
- LineTo(PenPos.X-(Sender as TImage).Width,21);
- Refresh;
- end;
- TimerBottomBar.Enabled:=True;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:选择背景
- }
- procedure TChatingForm.ImgSelBackClick(Sender: TObject);
- begin
- if SelBackForm=nil then
- begin
- SelBackForm:=TSelBackForm.Create(Self);
- SelBackForm.ParentForm:=Self;
- SelBackForm.Show;
- end;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:调整输入框的高度(MouseMove事件)
- }
- procedure TChatingForm.PnlSpplitMouseMove(Sender: TObject; Shift: TShiftState;
- X, Y: Integer);
- var
- OT:Integer;
- begin
- if Not CanMove Then exit;
- if (PnlLeftTop.Height+(PnlSpplit.Top-OldTop)<145) and (PnlSpplit.Top>PnlSpplit.Top+(Y-OY)) then exit;
- if (PnlLeftBottom.Height+(OldTop-PnlSpplit.Top)<118) and (PnlSpplit.Top<PnlSpplit.Top+(Y-OY)) then exit;
- OT:=PnlSpplit.Top;
- PnlSpplit.Top:=PnlSpplit.Top+(Y-OY);
- if (PnlSpplit.Top<80) or (PnlSpplit.Top>Height-120) then PnlSpplit.Top:=OT
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:调整输入框的高度(MouseDown事件)
- }
- procedure TChatingForm.PnlSpplitMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- CanMove:=True;
- OX:=X;
- OY:=Y;
- OldTop:=PnlSpplit.Top;
- PnlSpplit.Color:=EndColor;
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:调整输入框的高度(MouseUp事件)
- }
- procedure TChatingForm.PnlSpplitMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if Not CanMove Then exit;
- PnlLeftTop.Height:=PnlLeftTop.Height+(PnlSpplit.Top-OldTop);
- PnlLeftBottom.Top:=PnlLeftTop.Top+PnlLeftTop.Height+3;
- PnlRightBottom.Top:=PnlLeftBottom.Top;
- PnlMyCamera.Top:=PnlLeftBottom.Top;
- PnlLeftBottom.Height:=PnlLeftBottom.Height+(OldTop-PnlSpplit.Top);
- PnlRightBottom.Height:=PnlRightBottom.Height+(OldTop-PnlSpplit.Top);
- FormResize(nil);
- CanMove:=False;
- PnlSpplit.ParentColor:=true;
- end;
- {复制}
- procedure TChatingForm.Copy1Click(Sender: TObject);
- var
- wb:IOleCommandTarget;
- hr:HRESULT;
- vv: olevariant;
- begin
- //Copy 复制
- try
- //MsgContent.ExecWB(OLECMDID_COPY, OLECMDEXECOPT_PROMPTUSER);
- MsgContent.document.QueryInterface(IOleCommandTarget,wb);
- if(wb=nil) then exit;
- hr:=wb.Exec(@CGID_MSHTML,15,OLECMDEXECOPT_DODEFAULT,EmptyParam,vv);
- except
- end;
- end;
- {全选}
- procedure TChatingForm.SelectAll1Click(Sender: TObject);
- begin
- //Select All 全选
- try
- MsgContent.ExecWB(OLECMDID_SELECTALL, OLECMDEXECOPT_PROMPTUSER);
- except
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.MsgContentBeforeNavigate2(Sender: TObject;
- const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
- Headers: OleVariant; var Cancel: WordBool);
- const
- hUrl = 'about:blank';
- var
- NewUrl:String;
- BaseID:String;
- TransmitFile:TTransmitFile;
- AudioHandShake:TAudioHandShake;
- VideoHandShake:TVideoHandShake;
- function GetBaseIDFromUrl(SrcUrl:String):String;
- begin
- result:=Copy(SrcUrl,AnsiPos('_',SrcUrl)+1,Length(SrcUrl));
- end;
- begin
- NewUrl:=Trim(AnsiReplaceStr(String(URL),hUrl,''));
- if AnsiSameText(NewUrl , 'PopMenu') then
- begin
- Cancel:=True;
- WebPopupMenu.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,8) , 'TFCancel') then
- begin
- Cancel:=True;
- BaseID:=GetBaseIDFromUrl(NewUrl);
- TransmitFile:=FindTransmitFileByBaseID(BaseID);
- if TransmitFile<>nil then TransmitFile.Cancel;
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,8) , 'TFAccept') then
- begin
- Cancel:=True;
- BaseID:=GetBaseIDFromUrl(NewUrl);
- TransmitFile:=FindTransmitFileByBaseID(BaseID);
- if TransmitFile<>nil then TransmitFile.Accept;
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,9) , 'TFdecline') then
- begin
- Cancel:=True;
- BaseID:=GetBaseIDFromUrl(NewUrl);
- TransmitFile:=FindTransmitFileByBaseID(BaseID);
- if TransmitFile<>nil then TransmitFile.Decline;
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,6) , 'TFStop') then
- begin
- Cancel:=True;
- BaseID:=GetBaseIDFromUrl(NewUrl);
- TransmitFile:=FindTransmitFileByBaseID(BaseID);
- if TransmitFile<>nil then TransmitFile.Stop(Me.ID);
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,7) , 'File://') then
- begin
- Cancel:=True;
- BaseID:=AnsiReplaceStr(GetBaseIDFromUrl(NewUrl),'%20',' ');
- ShellExecute(handle, 'open', PChar(BaseID), nil, nil, SW_SHOWNORMAL);
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,8) , 'AHCancel') then
- begin
- Cancel:=True;
- BaseID:=GetBaseIDFromUrl(NewUrl);
- AudioHandShake:=FindAudioHandShakeByBaseID(BaseID);
- if AudioHandShake<>nil then AudioHandShake.Cancel;
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,9) , 'AHdecline') then
- begin
- Cancel:=True;
- BaseID:=GetBaseIDFromUrl(NewUrl);
- AudioHandShake:=FindAudioHandShakeByBaseID(BaseID);
- if AudioHandShake<>nil then AudioHandShake.Decline;
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,8) , 'AHAccept') then
- begin
- Cancel:=True;
- BaseID:=GetBaseIDFromUrl(NewUrl);
- AudioHandShake:=FindAudioHandShakeByBaseID(BaseID);
- if AudioHandShake<>nil then AudioHandShake.Accept;
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,6) , 'AHStop') then
- begin
- Cancel:=True;
- LblQuitAudioClick(nil);
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,8) , 'VHCancel') then
- begin
- Cancel:=True;
- BaseID:=GetBaseIDFromUrl(NewUrl);
- VideoHandShake:=FindVideoHandShakeByBaseID(BaseID);
- if VideoHandShake<>nil then VideoHandShake.Cancel;
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,9) , 'VHdecline') then
- begin
- Cancel:=True;
- BaseID:=GetBaseIDFromUrl(NewUrl);
- VideoHandShake:=FindVideoHandShakeByBaseID(BaseID);
- if VideoHandShake<>nil then VideoHandShake.Decline;
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,8) , 'VHAccept') then
- begin
- Cancel:=True;
- BaseID:=GetBaseIDFromUrl(NewUrl);
- VideoHandShake:=FindVideoHandShakeByBaseID(BaseID);
- if VideoHandShake<>nil then VideoHandShake.Accept;
- exit;
- end;
- if AnsiSameText(Copy(NewUrl,1,6) , 'VHStop') then
- begin
- Cancel:=True;
- LblQuitAudioClick(nil);
- exit;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.WebPopupMenuPopup(Sender: TObject);
- begin
- //Edit Menu 编辑菜单
- if MsgContent.OleObject.Document.queryCommandEnabled('Copy') then
- Copy1.Enabled := True
- else
- Copy1.Enabled := False;
- end;
- {OnActivate事件}
- procedure TChatingForm.FormActivate(Sender: TObject);
- begin
- ActiveChatingForm:=Self;
- end;
- {OnDeactivate事件}
- procedure TChatingForm.FormDeactivate(Sender: TObject);
- begin
- ActiveChatingForm:=nil;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.MMMixerSliderInChange(Sender: TObject);
- var
- hexString:String;
- rVALUE, bVALUE, gVALUE: integer;
- hNewVALUE, sNewVALUE, lNewVALUE : Double;
- begin
- hexString:=IntToHex(EndColor,6);
- RGBtoHSL(StrToInt('$'+Copy(hexString,5,2)), StrToInt('$'+Copy(hexString,3,2)), StrToInt('$'+Copy(hexString,1,2)), hNewVALUE, sNewVALUE, lNewVALUE);
- HSLtorgb(hNewVALUE, sNewVALUE,90-30*((Sender as TMMMixerSlider).Position/(Sender as TMMMixerSlider).MaxValue), rVALUE, gVALUE, bVALUE);
- (Sender as TMMMixerSlider).Color:=TColor(bVALUE*256*256+gVALUE*256+rVALUE);
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:开启/关闭麦克风
- }
- procedure TChatingForm.ImgMicClick(Sender: TObject);
- begin
- ImgMicDisabled.Visible:=not ImgMicDisabled.Visible;
- if ImgMicDisabled.Visible then
- ACMWaveIn.Close
- else
- ACMWaveIn.Open(PWaveFormatEx(pwfx),MMMixerDevice1.DeviceID);
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:开启/关闭扬声器
- }
- procedure TChatingForm.ImgSpkClick(Sender: TObject);
- begin
- ImgSpkDisabled.Visible:=not ImgSpkDisabled.Visible;
- if ImgMicDisabled.Visible then
- ACMWaveOut.Close
- else
- ACMWaveOut.Open(PWaveFormatEx(pwfx),MMMixerDevice2.DeviceID);
- end;
- {------------------------------------------------------------------------------}
- {
- 功能:结束音频对话
- }
- procedure TChatingForm.LblQuitAudioClick(Sender: TObject);
- var
- iLoop:Integer;
- AudioHandShake:TAudioHandShake;
- VideoHandShake:TVideoHandShake;
- begin
- with AudioHandShakes.LockList do
- try
- for iLoop:=Count - 1 downto 0 do
- begin
- AudioHandShake:=Items[iLoop];
- if AudioHandShake.ChatingForm = Self then
- begin
- AudioHandShake.Stop(Me.ID);
- Break;
- end;
- end;
- finally
- AudioHandShakes.UnlockList;
- end;
- with VideoHandShakes.LockList do
- try
- for iLoop:=Count - 1 downto 0 do
- begin
- VideoHandShake:=Items[iLoop];
- if VideoHandShake.ChatingForm = Self then
- begin
- VideoHandShake.Stop(Me.ID);
- Break;
- end;
- end;
- finally
- VideoHandShakes.UnlockList;
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.MsgContentDocumentComplete(Sender: TObject;
- const pDisp: IDispatch; var URL: OleVariant);
- begin
- try
- SetDomStyle(MsgContent.Document as IHtmlDocument2 );
- MsgContent.OnDocumentComplete:=nil;
- except
- end;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgSelColorClick(Sender: TObject);
- begin
- if SelColorForm=nil then
- begin
- SelColorForm:=TSelColorForm.Create(Self);
- SelColorForm.ParentForm:=Self;
- SelColorForm.Show;
- end;
- end;
- {按钮被按下}
- procedure TChatingForm.ImgSendTypeMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ImgListSendType.GetBitmap(1,ImgSendType.Picture.Bitmap);
- ConvertBitmapToColor(ImgSendType.Picture.Bitmap,EndColor);
- ImgSendType.Refresh;
- end;
- {恢复按钮的初始状态}
- procedure TChatingForm.ImgSendTypeMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ImgListSendType.GetBitmap(0,ImgSendType.Picture.Bitmap);
- ConvertBitmapToColor(ImgSendType.Picture.Bitmap,EndColor);
- ImgSendType.Refresh;
- end;
- {------------------------------------------------------------------------------}
- procedure TChatingForm.ImgSendTypeClick(Sender: TObject);
- begin
- SendTypePopupMenu.Popup(Left+ImgSendType.Left+ImgSendType.Width+4,Top+ImgSendType.Top+3);
- end;
- procedure TChatingForm.TMEnterClick(Sender: TObject);
- var
- TempReg:TRegistry;
- begin
- TempReg:=TRegistry.Create;
- try
- TempReg.RootKey:=HKEY_LOCAL_MACHINE;
- if TempReg.OpenKey(AppKey+''+LoginName+'ChatingFormStore', True) then
- begin
- TempReg.WriteString('SendType','Enter');
- TMEnter.Enabled:=False;
- TMCtrlEnter.Enabled:=True;
- end;
- finally
- TempReg.Free;
- end;
- end;
- procedure TChatingForm.TMCtrlEnterClick(Sender: TObject);
- var
- TempReg:TRegistry;
- begin
- TempReg:=TRegistry.Create;
- try
- TempReg.RootKey:=HKEY_LOCAL_MACHINE;
- if TempReg.OpenKey(AppKey+''+LoginName+'ChatingFormStore', True) then
- begin
- TempReg.WriteString('SendType','CtrlEnter');
- TMEnter.Enabled:=True;
- TMCtrlEnter.Enabled:=False;
- end;
- finally
- TempReg.Free;
- end;
- end;
- procedure TChatingForm.ImgGroupMsgClick(Sender: TObject);
- var
- iLoop:Integer;
- Employee1:PEmployee;
- begin
- { if InGroupMsg=True then
- begin
- TVUserList.Items.Clear;
- InGroupMsg:=False;
- ShowTitle(True);
- Exit;
- end;
- if AudioIsOn then
- begin
- MessageBox(Handle,'当前窗口已打开音频对话任务,不能群发消息!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if VideoIsOn then
- begin
- MessageBox(Handle,'当前窗口已打开视频对话任务,不能群发消息!','提示',MB_ICONINFORMATION);
- exit;
- end;
- SelUserForm:=TSelUserForm.Create(Application);
- try
- if SelUserForm.ShowModal = mrOk then
- begin
- TVUserList.Items.Clear;
- for iLoop:=0 to SelUserForm.TrevUserList.Items.Count-1 do
- begin
- if (SelUserForm.TrevUserList.Items[iLoop].ImageIndex<6) or (SelUserForm.TrevUserList.Items[iLoop].ImageIndex>13) then continue;
- if IsNodeChecked(SelUserForm.TrevUserList.Items[iLoop])=False then continue;
- Employee1:=PEmployee(SelUserForm.TrevUserList.Items[iLoop].Data);
- if Employee1.ID<>Me.ID then
- with TVUserList.Items.AddChild(nil,Employee1.Node.Text) do
- begin
- ImageIndex:=7;
- SelectedIndex:=ImageIndex;
- StateIndex:=Employee1.ID;
- end;
- end;
- if TVUserList.Items.Count>0 then
- InGroupMsg:=True
- else
- InGroupMsg:=False;
- ShowTitle();
- end;
- finally
- SelUserForm.Free;
- SelUserForm:=nil;
- end; }
- if TVUserList.Items.Count > 1 then exit;
- if HistoryForm<>nil then HistoryForm.Close;
- HistoryForm:=THistoryForm.Create(Application);
- if IsSystemMsg then
- begin
- HistoryForm.ID:=-1;
- HistoryForm.Name:='系统消息';
- end
- else
- begin
- HistoryForm.ID:=PEmployee(TVUserList.Items.GetFirstNode.Data).ID;
- HistoryForm.Name:=PEmployee(TVUserList.Items.GetFirstNode.Data).Name;
- end;
- HistoryForm.Show;
- end;
- procedure TChatingForm.TVUserListGetImageIndex(Sender: TObject;
- Node: TTreeNode);
- begin
- { if InGroupMsg then exit;
- if Node.StateIndex = -1 then
- begin
- if Node.Expanded then
- Node.ImageIndex:=4
- else
- Node.ImageIndex:=5;
- end;
- if Node.StateIndex = 0 then
- begin
- if Node.Expanded then
- Node.ImageIndex:=1
- else
- Node.ImageIndex:=0;
- end;
- if Node.StateIndex = 1 then
- begin
- if Node.Expanded then
- Node.ImageIndex:=3
- else
- Node.ImageIndex:=2;
- end;
- Node.SelectedIndex:=Node.ImageIndex;}
- end;
- procedure TChatingForm.ApplicationEvents1Message(var Msg: tagMSG;
- var Handled: Boolean);
- var
- nFiles, I,j: Integer;
- Filename,DragFilename: string;
- Receiver:Integer;
- ReceiverName:String;
- Form:TChatingForm;
- Room:ChatRoom;
- begin
- if (Msg.message = WM_DROPFILES) then
- begin
- if InGroupMsg=True then
- begin
- MessageBox(Handle,'群发消息状态下不能进行文件传输!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if TVUserList.Items.Count = 1 then
- begin
- Receiver :=PEmployee(TVUserList.Items.GetFirstNode.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Items.GetFirstNode.Data).Name;
- Form :=Self;
- end
- else
- begin
- if TVUserList.SelectionCount = 0 then
- begin
- MessageBox(Handle,'请先在 当前对话列表 中选择收件人!','提示',MB_ICONINFORMATION);
- exit;
- end;
- Receiver :=PEmployee(TVUserList.Selected.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Selected.Data).Name;
- Room.UserCount:=2;
- Room.Users[1] :=Me.ID;
- Room.Users[2] :=Receiver;
- Form:=OpenChatingForm(Room);
- Form.Show;
- end;
-
- nFiles := DragQueryFile (Msg.wParam, $FFFFFFFF, nil, 0);
- try
- if nFiles>1 then nFiles:=1;
- for I := 0 to nFiles - 1 do
- begin
- SetLength (Filename, 255);
- DragQueryFile (Msg.wParam, I, PChar (Filename), 255);
- for j:=1 to 255 do
- begin
- if Ord(Filename[j])>0 then
- begin
- SetLength (DragFilename, j);
- DragFilename[j]:=Filename[j];
- end
- else
- Break;
- end;
- TTransmitFile.Create(tfSend,Me.ID,Me.Name,Receiver,ReceiverName,DragFilename,Form,'',0,'',0);
- end;
- finally
- DragFinish (Msg.wParam);
- Handled := True;
- end;
- end;
-
- if CopyScreenForm<>nil then exit;
- if msg.message<>wm_keydown then exit;
- if (GetKeyState(VK_CONTROL)<0) and (msg.hwnd<>MsgInput.Handle) then
- begin
- if (msg.wParam=Ord('C')) and MsgContent.OleObject.Document.queryCommandEnabled('Copy') then Copy1Click(nil);
- if msg.wParam=Ord('A') then SelectAll1Click(nil);
- end;
- end;
- procedure TChatingForm.X1Click(Sender: TObject);
- begin
- if TMCtrlEnter.Checked then ImgSendClick(ImgSend);
- end;
- procedure TChatingForm.X2Click(Sender: TObject);
- begin
- if TMEnter.Checked then
- ImgSendClick(ImgSend)
- else if MsgInput.Focused then
- begin
- MsgInput.SelText:=#13#10;
- MsgInput.SelStart:=MsgInput.SelStart+1;
- MsgInput.SelLength:=0;
- end;
- end;
- procedure TChatingForm.MsgInputMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if Button=mbRight then PopupMenuEdit.Popup(Left+PnlLeftBottom.Left+X,Top+PnlLeftBottom.Top+MsgInput.Top+Y);
- end;
- procedure TChatingForm.VideoCapVideoStream(sender: TObject;
- lpVhdr: PVIDEOHDR);
- begin
- CompareFrame(lpVhdr);
- end;
- procedure TChatingForm.AviPanelOutDblClick(Sender: TObject);
- var
- VideoHandShake:TVideoHandShake;
- begin
- if VideoForm=nil then
- begin
- VideoHandShake:=FindVideoHandShakeByID(PEmployee(TVUserList.Items.GetFirstNode.Data).ID);
- if VideoHandShake<>nil then
- begin
- VideoForm:=TVideoForm.Create(Self);
- VideoForm.VideoHandShake:=VideoHandShake;
- VideoHandShake.PDC:=GetDC(VideoForm.Handle);
- VideoForm.ChatingForm:=Self;
- VideoForm.Show;
- end;
- end;
- end;
- procedure TChatingForm.ACMWaveInData(data: Pointer; size: Integer);
- var
- CBAudio:TCBAudio;
- Buffer:Array[1..2048]of char;
- begin
- //Self.Caption:=IntToStr(size);
- if AudioReceiverID = 0 then exit;
- CBAudio.Receiver:=AudioReceiverID;
- CBAudio.Sender:=Me.ID;
- CopyMemory(@(CBAudio.lpData),data,size);
- CBAudio.dwBufferLength:=size;
- Buffer[1]:=skAudio;
- CopyMemory(@Buffer[2],@CBAudio,SizeOf(CBAudio));
- AudioMySocket.SendBuffer(Buffer,SizeOf(CBAudio)+1);{发送语音}
- end;
- procedure TChatingForm.CopyScreen;
- var
- Fullscreen:Tbitmap;
- FullscreenCanvas:TCanvas;
- dc:HDC;
- TransmitFile:TTransmitFile;
- iLoop,TFCount:Integer;
- begin
- if InGroupMsg=True then
- begin
- MessageBox(Handle,'群发消息状态下不能进行截屏操作!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if TVUserList.Items.Count > 1 then
- begin
- MessageBox(Handle,'多人模式下不能进行截屏操作','提示',MB_ICONINFORMATION);
- exit
- end;
- if PEmployee(TVUserList.Items.GetFirstNode.Data).State='断开' then
- begin
- MessageBox(Handle,'对方不在线,不能进行截屏操作','提示',MB_ICONINFORMATION);
- exit
- end;
- TFCount:=0;
- with TransmitFiles.LockList do
- try
- for iLoop:=0 to Count - 1 do
- begin
- TransmitFile:=Items[iLoop];
- if (TransmitFile.SenderID = Me.ID) and (TransmitFile.ReceiverID = PEmployee(TVUserList.Items.GetFirstNode.Data).ID) and (TransmitFile.IsAccepted=True) then
- begin
- if TransmitFile.IsScreen then
- begin
- messagebox(Handle,'请先等待前一张图片传输完毕!','提示',MB_ICONINFORMATION);
- exit;
- end;
- Inc(TFCount);
- if TFCount>=3 then
- begin
- messagebox(Handle,'在其它文件或图片发送完毕之前,您不能进行截屏操作!','提示',MB_ICONINFORMATION);
- exit;
- end;
- end;
- end;
- finally
- TransmitFiles.UnlockList;
- end;
- CopyScreenForm:=TCopyScreenForm.Create(Self);
- Fullscreen := TBitmap.Create;
- Fullscreen.Width := screen.width;
- Fullscreen.Height := screen.Height;
- DC := GetDC (0);
- FullscreenCanvas := TCanvas.Create;
- FullscreenCanvas.Handle := DC;
- Fullscreen.Canvas.CopyRect
- (Rect (0, 0, screen.Width, screen.Height), fullscreenCanvas,
- Rect (0, 0, Screen.Width, Screen.Height));
- FullscreenCanvas.Free;
- ReleaseDC (0, DC);
- CopyScreenForm.ImgScreen.picture.Bitmap:=fullscreen;
- CopyScreenForm.Width:=fullscreen.Width;
- CopyScreenForm.Height:=fullscreen.Height;
- fullscreen.free;
- CopyScreenForm.ParentForm:=Self;
- CopyScreenForm.Show;
- end;
- procedure TChatingForm.ImgCopyScreenClick(Sender: TObject);
- begin
- CopyScreenTypePopupMenu.Popup(Left+PnlLeftBottom.Left+ImgCopyScreen.Left+3,Top+PnlLeftBottom.Top+ImgCopyScreen.Top+ImgCopyScreen.Height+3);
- end;
- procedure TChatingForm.MDirectCopyScreenClick(Sender: TObject);
- begin
- CopyScreenTimer.Enabled:=True;
- end;
- procedure TChatingForm.MCopyScreenAfterMinWindowClick(Sender: TObject);
- begin
- ShowWindow(Handle,SW_HIDE);
- CopyScreenTimer.Enabled:=True;
- end;
- procedure TChatingForm.CopyScreenTimerTimer(Sender: TObject);
- begin
- CopyScreenTimer.Enabled:=False;
- CopyScreen;
- if CopyScreenForm=nil then ShowWindow(Handle,SW_SHOW);
- end;
- procedure TChatingForm.lblTitleClick(Sender: TObject);
- begin
- if WindowState = wsNormal then
- begin
- WindowState := wsMaximized;
- Left:=0;
- Top:=0;
- Width:=Screen.WorkAreaWidth;
- Height:=Screen.WorkAreaHeight;
- end
- else
- begin
- // ImgListMax.GetBitmap(0,ImgMax.Picture.Bitmap);
- WindowState := wsNormal;
- end;
- // ConvertBitmapToColor(ImgMax.Picture.Bitmap,EndColor);
- // ImgMax.Refresh;
- end;
- procedure TChatingForm.TVUserListClick(Sender: TObject);
- begin
- if TVUserList.selected <> nil then
- TVUserList.selected.imageindex:=TVUserList.selected.imageindex;
- //showmessage(inttostr(TVUserList.selected.imageindex));
- end;
- procedure TChatingForm.fcImageBtn3Click(Sender: TObject);
- var
- Receiver:Integer;
- ReceiverName:String;
- Form:TChatingForm;
- Room:ChatRoom;
- begin
- if InGroupMsg=True then
- begin
- MessageBox(Handle,'群发消息状态下不能进行文件传输!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if TVUserList.Items.Count = 1 then
- begin
- Receiver :=PEmployee(TVUserList.Items.GetFirstNode.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Items.GetFirstNode.Data).Name;
- Form :=Self;
- end
- else
- begin
- if TVUserList.SelectionCount = 0 then
- begin
- MessageBox(Handle,'请先在 当前对话列表 中选择收件人!','提示',MB_ICONINFORMATION);
- exit;
- end;
- Receiver :=PEmployee(TVUserList.Selected.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Selected.Data).Name;
- Room.UserCount:=2;
- Room.Users[1] :=Me.ID;
- Room.Users[2] :=Receiver;
- Form:=OpenChatingForm(Room);
- Form.Show;
- end;
- OpenDialog.Title:='请选择要给 '+ReceiverName+' 发送的文件';
- if OpenDialog.Execute then
- begin
- TTransmitFile.Create(tfSend,Me.ID,Me.Name,Receiver,ReceiverName,OpenDialog.Files.Strings[0],Form,'',0,'',0);
- end;
- end;
- procedure TChatingForm.fcImageBtn2Click(Sender: TObject);
- var
- ID:Integer;
- iLoop,jLoop:Integer;
- Finded:Boolean;
- CBAddUser:TCBAddUser;
- AddRoom:ChatRoom;
- Buffer:Array[1..2048]of char;
- begin
- if InGroupMsg=True then
- begin
- MessageBox(Handle,'群发消息状态下不能进入多人模式!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if AudioIsOn then
- begin
- MessageBox(Handle,'当前窗口已打开音频对话任务,不能进入多人模式!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if VideoIsOn then
- begin
- MessageBox(Handle,'当前窗口已打开视频对话任务,不能进入多人模式!','提示',MB_ICONINFORMATION);
- exit;
- end;
- SelUserForm:=TSelUserForm.Create(Self);
- try
- if SelUserForm.ShowModal = mrOk then
- begin
- CBAddUser.Room.UserCount:=RoomInfo.UserCount;
- for iLoop:=1 to RoomInfo.UserCount do CBAddUser.Room.Users[iLoop]:=RoomInfo.Users[iLoop];
- AddRoom.UserCount:=0;
- for iLoop := 0 to SelUserForm.TrevUserList.Items.Count - 1 do
- begin
- if (SelUserForm.TrevUserList.Items[iLoop].ImageIndex<6) or (SelUserForm.TrevUserList.Items[iLoop].ImageIndex>13) then continue;
- if IsNodeChecked(SelUserForm.TrevUserList.Items[iLoop])=False then continue;
- ID:=PEmployee(SelUserForm.TrevUserList.Items[iLoop].Data).ID;
- Finded:=False;
- for jLoop:=1 to RoomInfo.UserCount do
- begin
- if RoomInfo.Users[jLoop] = ID then
- begin
- Finded:=True;
- break;
- end;
- end;
- if not Finded then
- begin
- if RoomInfo.UserCount=16 then
- begin
- MessageBox(Handle,PChar('多人对话环境的最大收件人数不得超过 '+IntToStr(15)+' 个'),'提示',MB_OK);
- Break;
- end;
- AddRoom.UserCount:=AddRoom.UserCount+1;
- AddRoom.Users[AddRoom.UserCount]:=ID;
- RoomInfo.UserCount:=RoomInfo.UserCount+1;
- RoomInfo.Users[RoomInfo.UserCount]:=ID;
- end;
- end;
- if AddRoom.UserCount>0 then
- begin
- ImgHistory.Visible:=False;
- for jLoop:=1 to CBAddUser.Room.UserCount do
- begin
- if CBAddUser.Room.Users[jLoop]<>Me.ID then
- begin
- CBAddUser.Receiver:=CBAddUser.Room.Users[jLoop];
- CBAddUser.AddRoom:=AddRoom;
- Buffer[1]:=skAddUser;
- CopyMemory(@Buffer[2],@CBAddUser,SizeOf(CBAddUser));
- RealMessengerX.ClientTCP.WriteBuffer(Buffer,SizeOf(CBAddUser)+1);
- end;
- end;
- end;
- end;
- finally
- SelUserForm.Free;
- SelUserForm:=nil;
- end;
- ShowTitle();
- end;
- procedure TChatingForm.fcImageBtn4Click(Sender: TObject);
- var
- Receiver:Integer;
- ReceiverName:String;
- Form:TChatingForm;
- Room:ChatRoom;
- begin
- if InGroupMsg=True then
- begin
- MessageBox(Handle,'群发消息状态下不能进行音频对话!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if not HaveAudioDevice then
- begin
- MessageBox(Handle,'您的机器没有安装声音设备,不能进行音频对话','提示',MB_ICONINFORMATION);
- exit
- end;
- if TVUserList.Items.Count = 1 then
- begin
- if not PEmployee(TVUserList.Items.GetFirstNode.Data).HaveAudioDevice then
- begin
- MessageBox(Handle,'对方的机器没有安装声音设备,不能进行音频对话','提示',MB_ICONINFORMATION);
- exit
- end;
- Receiver :=PEmployee(TVUserList.Items.GetFirstNode.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Items.GetFirstNode.Data).Name;
- Form :=Self;
- end
- else
- begin
- if TVUserList.SelectionCount = 0 then
- begin
- MessageBox(Handle,'请先在“当前对话列表”中选择您要邀请的开始进行音频对话的人!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if not PEmployee(TVUserList.Selected.Data).HaveAudioDevice then
- begin
- MessageBox(Handle,'对方的机器没有安装声音设备,不能进行音频对话','提示',MB_ICONINFORMATION);
- exit;
- end;
- Receiver :=PEmployee(TVUserList.Selected.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Selected.Data).Name;
- Room.UserCount:=2;
- Room.Users[1] :=Me.ID;
- Room.Users[2] :=Receiver;
- Form:=OpenChatingForm(Room);
- Form.Show;
- end;
- TAudioHandShake.Create(ahRequest,Receiver,ReceiverName,Form,'',0,'',0);
- end;
- procedure TChatingForm.fcImageBtn1Click(Sender: TObject);
- var
- Receiver:Integer;
- ReceiverName:String;
- Form:TChatingForm;
- Room:ChatRoom;
- begin
- if InGroupMsg=True then
- begin
- MessageBox(Handle,'群发消息状态下不能进行视频对话!','提示',MB_ICONINFORMATION);
- exit;
- end;
- RealMessengerX.TestVideoDevice();
- if TVUserList.Items.Count = 1 then
- begin
- if (not HaveVideoDevice) and (not PEmployee(TVUserList.Items.GetFirstNode.Data).HaveVideoDevice) then
- begin
- MessageBox(Handle,PChar('您和 '+String(PEmployee(TVUserList.Items.GetFirstNode.Data).Name)+' 的机器均没有安装视频捕获设备,不能开启网络摄像机功能'),'提示',MB_ICONINFORMATION);
- exit
- end;
- Receiver :=PEmployee(TVUserList.Items.GetFirstNode.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Items.GetFirstNode.Data).Name;
- Form :=Self;
- end
- else
- begin
- if TVUserList.SelectionCount = 0 then
- begin
- MessageBox(Handle,'请先在“当前对话列表”中选择您要邀请的开始进行视频对话的人!','提示',MB_ICONINFORMATION);
- exit;
- end;
- if (not HaveVideoDevice) and (not PEmployee(TVUserList.Selected.Data).HaveVideoDevice) then
- begin
- MessageBox(Handle,PChar('您和 '+String(PEmployee(TVUserList.Selected.Data).Name)+' 的机器均没有安装视频捕获设备,不能开启网络摄像机功能'),'提示',MB_ICONINFORMATION);
- exit
- end;
- Receiver :=PEmployee(TVUserList.Selected.Data).ID;
- ReceiverName:=PEmployee(TVUserList.Selected.Data).Name;
- Room.UserCount:=2;
- Room.Users[1] :=Me.ID;
- Room.Users[2] :=Receiver;
- Form:=OpenChatingForm(Room);
- Form.Show;
- end;
- TVideoHandShake.Create(vhRequest,Receiver,ReceiverName,Form,'',0,'',0,'',0,'',0);
- end;
- procedure TChatingForm.fcImageBtn5Click(Sender: TObject);
- begin
- if TVUserList.Items.Count > 1 then exit;
- if HistoryForm<>nil then HistoryForm.Close;
- HistoryForm:=THistoryForm.Create(Application);
- if IsSystemMsg then
- begin
- HistoryForm.ID:=-1;
- HistoryForm.Name:='系统消息';
- end
- else
- begin
- HistoryForm.ID:=PEmployee(TVUserList.Items.GetFirstNode.Data).ID;
- HistoryForm.Name:=PEmployee(TVUserList.Items.GetFirstNode.Data).Name;
- end;
- HistoryForm.Show;
- end;
- procedure TChatingForm.Label1Click(Sender: TObject);
- begin
- fcImageBtn2.click;
- end;
- procedure TChatingForm.Label2Click(Sender: TObject);
- begin
- fcImageBtn3.click;
- end;
- procedure TChatingForm.Label3Click(Sender: TObject);
- begin
- fcImageBtn4.click;
- end;
- procedure TChatingForm.Label4Click(Sender: TObject);
- begin
- fcImageBtn1.click;
- end;
- procedure TChatingForm.Label5Click(Sender: TObject);
- begin
- fcImageBtn5.click;
- end;
- end.