📄 ychatu4.pas
字号:
unit YchatU4;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Richedit, ComCtrls, StdCtrls, ExtCtrls, MyRicheditEx,ActiveX, OleConsts,OleStd,
Buttons,Dialogs, DynamicSkinForm, SkinCtrls, SkinBoxCtrls,
ComObj, ShellApi, RicheditFuncs, TTS;
Type TInterFaceSettings = Record
I,U,B: Boolean;
Fade: Boolean;
Color: Tcolor;
Font: String;
Size: Integer;
End;
Type PSmileyInfo = ^TSmileyInfo;
TSmileyInfo = Record
FileName: String[50];
KeyCombo: String[8];
End;
Type
TOnPlainText = Procedure(S: String) Of Object;
type
TForm4 = class(TForm)
spDynamicSkinForm1: TspDynamicSkinForm;
spSkinPanel1: TspSkinPanel;
spSkinCheckComboBox1: TspSkinCheckComboBox;
spSkinCheckComboBox2: TspSkinCheckComboBox;
spSkinStdLabel1: TspSkinStdLabel;
spSkinStdLabel2: TspSkinStdLabel;
spSkinPanel3: TspSkinPanel;
spSkinSplitter1: TspSkinSplitter;
spSkinPanel4: TspSkinPanel;
spSkinPanel5: TspSkinPanel;
spSkinButton1: TspSkinButton;
RichEdit1: TMyRichEdit;
SpeedButton1: TSpeedButton;
spSkinCheckRadioBox1: TspSkinCheckRadioBox;
BoldP: TspSkinCheckRadioBox;
spSkinStdLabel3: TspSkinStdLabel;
ItalicP: TspSkinCheckRadioBox;
spSkinStdLabel4: TspSkinStdLabel;
UnderlineP: TspSkinCheckRadioBox;
spSkinStdLabel5: TspSkinStdLabel;
spSkinFontComboBox1: TspSkinFontComboBox;
spSkinComboBox2: TspSkinComboBox;
spSkinColorComboBox1: TspSkinColorComboBox;
Button1: TButton;
Timer1: TTimer;
spSkinPanel2: TspSkinPanel;
spSkinButton2: TspSkinButton;
spSkinButton3: TspSkinButton;
spSkinButton4: TspSkinButton;
spSkinButton5: TspSkinButton;
spSkinStdLabel6: TspSkinStdLabel;
Timer2: TTimer;
Richedit2: TMyRichEdit;
spSkinButton6: TspSkinButton;
CloseButton: TspSkinButton;
spSkinButton8: TspSkinButton;
spSkinButton7: TspSkinButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Richedit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Richedit2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure spSkinButton1Click(Sender: TObject);
procedure BoldPClick(Sender: TObject);
procedure ItalicPClick(Sender: TObject);
procedure UnderlinePClick(Sender: TObject);
procedure spSkinColorComboBox1Change(Sender: TObject);
procedure spSkinFontComboBox1Change(Sender: TObject);
procedure spSkinComboBox2Change(Sender: TObject);
procedure spSkinButton2Click(Sender: TObject);
procedure spSkinCheckRadioBox1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Richedit1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Richedit1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Richedit1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure spSkinButton3Click(Sender: TObject);
procedure spSkinButton4Click(Sender: TObject);
procedure spSkinButton5Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure spSkinButton6Click(Sender: TObject);
procedure spSkinButton7Click(Sender: TObject);
procedure ProfileButtonClick(Sender: TObject);
procedure CloseButtonClick(Sender: TObject);
private
{ Private declarations }
FOleInterface : TREOleCallback;
procedure UpdateColorStatus(RichCont: TCustomRichedit);
procedure OnFilter(MsgStr, FullStr: String; var Allow: Boolean);
public
Funcs: TRicheditFuncsC;
TimeOpen: TDateTime;
UserCreated: Boolean;
Typing: Boolean;
PmCounter: Integer;
LastPmMessage: String;
ToUser: String;
WordStr: String;
MousePressed: Boolean;
procedure CreateParams(var Params : TCreateParams); override;
{ Public declarations }
end;
var
Form4: TForm4;
Const
ReadError = $0001;
WriteError = $0002;
NoError = $0000;
YCustom: String = #27+'[';
yBlack: String = #27+'[30m';
yBlue: String = #27+'[31m';
yRed: String = #27+'[38m';
yPurple: String = #27+'[36m';
yPink: String = #27+'[35m';
yLime: String = #27+'[39m';
yCyan: String = #27+'[32m';
yGray: String = #27+'[33m';
yGreen: String = #27+'[34m';
yGreen2: String = #27+'[30m';
yOrange: String = #27+'[37m';
yBold: String = #27+'[1m';
yNoBold: String = #27+'[x1m';
yItalic: String = #27+'[2m';
yNoI: String = #27+'[x2m';
yUn: String = #27+'[4m';
yNoUn: String = #27+'[x4m';
implementation
uses YchatU1, YchatU9, YchatU14, YchatU7, YchatU10;
{$R *.DFM}
procedure TForm4.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle and WS_EX_TOOLWINDOW or
WS_EX_APPWINDOW;
end; //WS_EX_OVERLAPPEDWINDOW fixes}
procedure TForm4.FormCreate(Sender: TObject);
begin
Richedit1.ScrollBars:=SSVertical;
Funcs:=TRicheditFuncsC.Create(Richedit1);
Funcs.OnFilter:=OnFilter;
end;
procedure TForm4.Button1Click(Sender: TObject);
Var
N: Integer;
FadeTagText: String;
FullStr,S,BuildStr: String;
begin
// FullStr:=Funcs.FormHTMLStr(Self.Richedit2.Text,SpSkinFontComboBox1.Text,SpSkinComboBox2.Text,SpSkinColorComboBox1.Selected,BoldP.checked,ItalicP.Checked,UnderLineP.Checked,False,False,SpSkinCheckRadioBox1.Checked,Form1.FadeData);
Funcs.Packet(FullStr,SpSkinCheckComboBox2.Text,True,ClBlack,Richedit1,False,False,True);
//SB,SI,SU: Boolean; Emote,Plain: Boolean; Fade: Boolean): String;
end;
procedure TForm4.SpeedButton1Click(Sender: TObject);
begin
Form9.ShowModal;
end;
Procedure TForm4.OnFilter(MsgStr,FullStr: String; Var Allow: Boolean);
Begin
// ShowMessage(FullStr);
Allow:=True;
End;
procedure TForm4.Timer1Timer(Sender: TObject);
Var
FullSTr: String;
begin
{ FullStr:=Funcs.FormHTMLStr(Richedit2.Text,SpSkinFontComboBox1.Text,SpSkinComboBox2.Text,SpSkinColorComboBox1.Selected,BoldP.checked,ItalicP.Checked,UnderLineP.Checked,False,False,SpSkinCheckRadioBox1.Checked);
Richedit2.Clear;
Funcs.Packet(FullStr,SpSkinCheckComboBox2.Text,False,Richedit2,False,False);}
end;
procedure TForm4.Richedit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
Timer2.Enabled:=True;
If Richedit2.Text<>'' Then
if key=vk_return then
begin
Richedit2.SelStart:=-1;
Funcs.ScrollToEnd(Richedit1);
SpSkinButton1.OnClick(Self);
Richedit2.clear;
End;
end;
procedure TForm4.Richedit2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
Richedit2.Clear;
end;
Procedure TForm4.UpdateColorStatus(RichCont: TCustomRichedit);
Begin
RichCont.SelAttributes.Color:=SpSkinColorComboBox1.Selected;
RichCont.SelAttributes.Style:=[];
RichCont.SelAttributes.Size:=StrToInt(SpSkinComboBox2.Text);
RichCont.SelAttributes.Name:=Form1.CheckFont(SpSkinFontComboBox1.Text);
If BoldP.checked=true Then
RichCont.SelAttributes.Style:=RichCont.SelAttributes.Style+[FsBold];
IF italicP.checked=true Then
RichCont.SelAttributes.Style:=RichCont.SelAttributes.Style+[FsItalic];
If UnderLineP.checked=true Then
RichCont.SelAttributes.Style:=RichCont.SelAttributes.Style+[FsUnderline];
End;
procedure TForm4.spSkinButton1Click(Sender: TObject);
Var
FullStr: String;
begin
Funcs.ScrollToEnd(Richedit1);
FullStr:=Funcs.FormHTMLStr(Richedit2.Text,SpSkinFontComboBox1.Text,SpSkinComboBox2.Text,SpSkinColorComboBox1.Selected,BoldP.checked,ItalicP.Checked,UnderLineP.Checked,False,False,SpSkinCheckRadioBox1.Checked,Form1.FadeData);
Form1.SayPm(SpSkinCheckComboBox1.Text,SpSkinCheckComboBox2.Text,FullStr);
If Form10.CheckBox23.Checked=True Then
Form1.WriteLogData(LoggedInName,SpSkinCheckComboBox1.Text,Richedit2.Text,False);
Funcs.Packet(FullStr,SpSkinCheckComboBox2.Text,True,Form10.ColorBox1.ColorValue,Richedit1,False,False,True);
Funcs.BufferRichedit(Richedit1,300);
Funcs.ScrollToEnd(Richedit1);
Richedit2.SetFocus;
Richedit2.Clear;
end;
procedure TForm4.BoldPClick(Sender: TObject);
begin
UpdateColorStatus(Richedit2);
end;
procedure TForm4.ItalicPClick(Sender: TObject);
begin
UpdateColorStatus(Richedit2);
end;
procedure TForm4.UnderlinePClick(Sender: TObject);
begin
UpdateColorStatus(Richedit2);
end;
procedure TForm4.spSkinColorComboBox1Change(Sender: TObject);
begin
UpdateColorStatus(Richedit2);
end;
procedure TForm4.spSkinFontComboBox1Change(Sender: TObject);
begin
UpdateColorStatus(Richedit2);
end;
procedure TForm4.spSkinComboBox2Change(Sender: TObject);
begin
UpdateColorStatus(Richedit2);
end;
procedure TForm4.spSkinButton2Click(Sender: TObject);
Var
Obj: TObject;
begin
Friends.Add(SpSkinCheckComboBox1.Text,Obj);
ShowMessage(SpSkinCheckComboBox1.Text+' Added As A Buddy');
// Form1.SendText(Form1.AddSprtBuddy(Form1.LoggedInName,SpSkinCheckComboBox1.Text));
end;
procedure TForm4.spSkinCheckRadioBox1Click(Sender: TObject);
begin
UpdateColorStatus(Richedit2);
end;
procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
begin
// Form1.SetInterfaceSettings(TForm4(Sender));
Form1.DestroyPmwindow(SpSkinCheckComboBox1.Text);
end;
procedure TForm4.Richedit1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
iCharIndex, iLineIndex, iCharOffset, i, j: Integer;
Pt: TPoint;
s: string;
begin
If Button=MBLeft Then
Begin
with TRichEdit(Sender) do
begin
mousepressed:=true;
Pt := Point(X, Y);
// Get Character Index from word under the cursor
iCharIndex := Perform(Messages.EM_CHARFROMPOS, 0, Integer(@Pt));
if iCharIndex < 0 then Exit;
// Get line Index
iLineIndex := Perform(EM_EXLINEFROMCHAR, 0, iCharIndex);
iCharOffset := iCharIndex - Perform(EM_LINEINDEX, iLineIndex, 0);
if Lines.Count - 1 < iLineIndex then Exit;
// store the current line in a variable
s := Lines[iLineIndex];
// Search the beginning of the word
i := iCharOffset + 1;
while (i > 0) and (s[i] <> ' ') do Dec(i);
// Search the end of the word
j := iCharOffset + 1;
while (j <= Length(s)) and (s[j] <> ' ') do Inc(j);
// Display Text under Cursor
WordStr := Trim(Copy(s, i, j - i));
If Form1.GetUrl(WordStr,False)<>'' Then
Begin
// Form35.Edit1.Text:=WordStr;
// Form35.showModal;
ShellExecute(Self.Handle,'open',Pchar(WordStr),Nil,Nil,sw_show);
Richedit1.SelStart:=-1;
Richedit2.Focused;
End;
End;
End;
end;
procedure TForm4.Richedit1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
iCharIndex, iLineIndex, iCharOffset, i, j: Integer;
Pt: TPoint;
s: string;
begin
with TRichEdit(Sender) do
begin
Pt := Point(X, Y);
// Get Character Index from word under the cursor
iCharIndex := Perform(Messages.EM_CHARFROMPOS, 0, Integer(@Pt));
if iCharIndex < 0 then Exit;
// Get line Index
// iLineIndex := Perform(EM_EXLINEFROMCHAR, 0, iCharIndex);
iCharOffset := iCharIndex - Perform(EM_LINEINDEX, iLineIndex, 0);
if Lines.Count - 1 < iLineIndex then Exit;
// store the current line in a variable
s := Lines[iLineIndex];
// Search the beginning of the word
i := iCharOffset + 1;
If I<Length(S) then
Begin
while (i > 0) and (s[i] <> ' ') do Dec(i);
// Search the end of the word
j := iCharOffset + 1;
while (j <= Length(s)) and (s[j] <> ' ') do Inc(j);
// Display Text under Cursor
WordStr := Trim(Copy(s, i, j - i));
End
else
WordStr:='';
End;
end;
procedure TForm4.Richedit1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
mousepressed:=false;
end;
procedure TForm4.spSkinButton3Click(Sender: TObject);
begin
Form1.IgnoreUser(spSkinCheckComboBox1.text,False,True,True,False);
Close;
end;
procedure TForm4.spSkinButton4Click(Sender: TObject);
begin
Form14.Obj:=Richedit2;
Form14.Show;
end;
procedure TForm4.spSkinButton5Click(Sender: TObject);
begin
Form1.CreateSkin(Form7);
Form7.Show;
end;
procedure TForm4.Timer2Timer(Sender: TObject);
begin
Inc(PmCounter);
// If PmCounter=1 Then
// Form1.SprtMakePmAuth(Self.spSkinCheckComboBox2.Text,Self.spSkinCheckComboBox1.Text,1);
end;
procedure TForm4.spSkinButton6Click(Sender: TObject);
begin
PmIgnore.Add(spSkinCheckComboBox1.text);
Form1.Panel10.Caption:=spSkinCheckComboBox1.text+' Ignored from IM/PMing you.';
Form1.SayPm(spSkinCheckComboBox1.text,LoggedInName,'You have been ignored from IM/PMing me, however if you want to chat, you can do so in the main chat room - thank you.');
Close;
end;
procedure TForm4.spSkinButton7Click(Sender: TObject);
Var
LastPmMsg: String;
begin
LastPmMsg:=LastPmMessage;
LastPmMsg:=Form1.remove(LastPmMsg,'<','>');
Form1.Say(Form1.Richedit1,'PM From ['+spSkinCheckComboBox1.Text+']: '+LastPmMsg,false,false,False);
end;
procedure TForm4.ProfileButtonClick(Sender: TObject);
begin
ShellExecute(handle,'open',Pchar('http://profiles.yahoo.com/'+SpSkinCheckComboBox1.Text+'?warn=1'),'','',0);
end;
procedure TForm4.CloseButtonClick(Sender: TObject);
begin
Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -