unit u_chrat_message; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, dxDBTLCl, dxGrClms, dxDBGrid, dxTL, dxDBCtrl, dxCntner, ComCtrls, StdCtrls, bsSkinCtrls, Menus,DB; type Tfrm_chart_message = class(TForm) dxDBGrid4: TdxDBGrid; dxDBGrid4Column1: TdxDBGridMaskColumn; dxDBGrid4Column3: TdxDBGridColumn; dxDBGrid4Column2: TdxDBGridMaskColumn; dxDBGrid4Column4: TdxDBGridCheckColumn; bsSkinPanel1: TbsSkinPanel; bsSkinPanel3: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinPanel2: TbsSkinPanel; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; Memo1: TMemo; ChatMsgRichEdit: TRichEdit; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; N5: TMenuItem; SaveDialog: TSaveDialog; procedure dxDBGrid4Exit(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure ChatMsgRichEditKeyPress(Sender: TObject; var Key: Char); procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure N5Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_chart_message: Tfrm_chart_message; implementation uses u_main; {$R *.dfm} procedure Tfrm_chart_message.dxDBGrid4Exit(Sender: TObject); begin if frm_main.t_chat_man.State in [dsedit,dsinsert] then frm_main.t_chat_man.post ; end; procedure Tfrm_chart_message.bsSkinButton1Click(Sender: TObject); var i,ChartMan :integer ; Mybook :TBookmark ; empMsg:string ; begin if trim(Memo1.text)=''then exit; empmsg:='' ; MYbook:=frm_main.t_chat_man.GetBookmark ; frm_main.t_chat_man.DisableControls ; frm_main.t_chat_man.First ; while not frm_main.t_chat_man.Eof do begin if frm_main.t_chat_man.FieldByName('发布').AsBoolean then ChartMan:=ChartMan+1 ; frm_main.t_chat_man.next ; end ; if bsSkinCheckRadioBox1.Checked then begin if ChartMan<=0 then begin showmessage('你选择了私聊,请选择相应的聊天对象!!'); frm_main.t_chat_man.GotoBookmark(myBook); frm_main.t_chat_man.FreeBookmark(MyBook); frm_main.t_chat_man.EnableControls ; exit; end; frm_main.t_chat_man.First ; while not frm_main.t_chat_man.eof do begin if frm_main.t_chat_man.fieldbyname('发布').asBoolean then begin // SendMsg_pri(frm_main.t_chat_man.fieldbyname('所在电脑').asstring,trim(Memo1.text)); empmsg:=empmsg+' '+'['+frm_main.t_chat_man.fieldbyname('在线职员').asstring+']' ; end; frm_main.t_chat_man.next; end; ChatMsgRichEdit.lines.add('您对'+empmsg+'说:(' +datetimetostr(now)+')'+trim(Memo1.text)); end else begin // SendMsg_all(trim(Memo1.text)); ChatMsgRichEdit.lines.add('您对所有人说:('+datetimetostr(now)+')'+trim(Memo1.text)); end; frm_main.t_chat_man.GotoBookmark(myBook); frm_main.t_chat_man.FreeBookmark(MyBook); frm_main.t_chat_man.EnableControls ; Memo1.text:=''; end; procedure Tfrm_chart_message.ChatMsgRichEditKeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; bsSkinButton1Click(Sender); end; end; procedure Tfrm_chart_message.N1Click(Sender: TObject); var mybook:tbookmark ; begin mybook:=frm_main.t_chat_man.GetBookmark ; frm_main.t_chat_man.DisableControls ; frm_main.t_chat_man.First ; while not frm_main.t_chat_man.Eof do begin if frm_main.t_chat_man.FieldByName('发布').asboolean=true then begin frm_main.t_chat_man.Edit ; frm_main.t_chat_man.FieldByName('发布').asboolean:=false ; frm_main.t_chat_man.Post ; end ; frm_main.t_chat_man.Next ; end ; frm_main.t_chat_man.GotoBookmark(mybook); frm_main.t_chat_man.FreeBookmark(mybook); frm_main.t_chat_man.EnableControls ; end; procedure Tfrm_chart_message.N2Click(Sender: TObject); begin ChatMsgRichEdit.Text :='' ; end; procedure Tfrm_chart_message.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_chart_message.Hide; frm_chart_message.ManualFloat(frm_chart_message.BoundsRect ); frm_main.freeTabs('frm_chart_message'); // SendLogoutMsg; action:=cafree; frm_chart_message:=nil; end; procedure Tfrm_chart_message.N5Click(Sender: TObject); begin with SaveDialog do begin DefaultExt :='txt'; Filter := '(*.txt)|*.txt'; if Execute then begin ChatMsgRichEdit.Lines.SaveToFile(filename); end; end; end; end.