You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RnQ/RnQ/mainDlg.pas

4070 lines
120 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
This file is part of R&Q.
Under same license
}
unit mainDlg;
{$I RnQConfig.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls, ExtCtrls, Menus, ActiveX, ActnList, Threading,
Generics.Collections, System.Actions, Vcl.Imaging.GIFImg,
RDGlobal, RQMenuItem, RnQButtons, RnQDialogs, RnQTrayLib, RnQBinUtils, RnQCrypt, ICQContacts,
chatDlg, pluginLib, utilLib, groupsLib, VirtualTrees, SynCrypto, Base64, GR32, Vcl.AppEvnts;
{$I NoRTTI.inc}
type
TVirtualDrawTree = class(VirtualTrees.TVirtualDrawTree)
private
FOnMouseLeave: TNotifyEvent;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
protected
property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
end;
TRnQmain = class(TForm)
roster: TVirtualDrawTree;
menu: TPopupMenu;
Status1: TMenuItem;
byUIN1: TMenuItem;
Whitepages1: TMenuItem;
Password1: TMenuItem;
Showlogwindow1: TMenuItem;
contactMenu: TPopupMenu;
Sendmessage1: TMenuItem;
Sendcontacts1: TMenuItem;
Viewinfo1: TMenuItem;
Delete1: TMenuItem;
Addtocontactlist1: TMenuItem;
N1: TMenuItem;
UIN1: TMenuItem;
N2: TMenuItem;
divisorMenu: TPopupMenu;
Newgroup1: TMenuItem;
Rename1: TMenuItem;
groupMenu: TPopupMenu;
Renamegroup1: TMenuItem;
Deletegroup1: TMenuItem;
N4: TMenuItem;
Contactsdatabase1: TMenuItem;
Moveallcontactsto1: TMenuItem;
ShowEmptyGrps: TMenuItem;
Showgroups2: TMenuItem;
movetogroup1: TMenuItem;
Viewinfoof1: TMenuItem;
Lock1: TMenuItem;
Sendemail1: TMenuItem;
N7: TMenuItem;
Openallgroups1: TMenuItem;
Closeallgroups1: TMenuItem;
Deleteallemptygroups1: TMenuItem;
N6: TMenuItem;
Showonlyonlinecontacts1: TMenuItem;
Checkforupdates1: TMenuItem;
SendanSMS1: TMenuItem;
Newgroup2: TMenuItem;
N3: TMenuItem;
timer: TTimer;
Ignorelist1: TMenuItem;
Searchinhist1: TMenuItem;
RQhomepage1: TMenuItem;
menushowonlyimvisibleto1: TMenuItem;
mainmenusupport1: TMenuItem;
mainmenuspecial1: TMenuItem;
mainmenuprivacysecurity1: TMenuItem;
mainmenuaddcontacts1: TMenuItem;
mainmenuvisibility1: TMenuItem;
mainmenuchangeadduser1: TMenuItem;
mainmenuoutbox1: TMenuItem;
mainmenureloadlang1: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
bar: TPanel;
menuBtn: TRnQSpeedButton;
statusBtn: TRnQSpeedButton;
visibilityBtn: TRnQSpeedButton;
ActList: TActionList;
ASendmessage1: TAction;
ASendcontacts1: TAction;
ASendemail1: TAction;
Asplit1: TAction;
AViewinfo1: TAction;
AReadautomessage1: TAction;
AAddtocontactlist1: TAction;
cmAmovetogroup: TAction;
ARename1: TAction;
ADelete1: TAction;
Asplit2: TAction;
AIgnorelist1: TAction;
Asplit3: TAction;
AUIN1: TAction;
mainmenuthemes1: TMenuItem;
mainmenureloadtheme2: TMenuItem;
mainmenugetthemes1: TMenuItem;
N10: TMenuItem;
ANewgroup1: TAction;
AOpenallgroups1: TAction;
ACloseallgroups1: TAction;
ADeleteallemptygroups1: TAction;
AShowgroups1: TAction;
AShowonlyonlinecontacts1: TAction;
Amenushowonlyimvisibleto1: TAction;
ADivisor1: TAction;
Adivisor2: TAction;
gmANewgroup: TAction;
gmAdivisor1: TAction;
gmARenamegroup: TAction;
gmADeletegroup: TAction;
gmAMoveallcontactsto: TAction;
gmADivisor2: TAction;
gmAShowgroups: TAction;
mAStatus: TAction;
mAvisibility: TAction;
mAaddcontacts: TAction;
mAWhitepages: TAction;
mAbyUIN: TAction;
mAprivacysecurity: TAction;
mAPassword: TAction;
mALock: TAction;
mAspecial: TAction;
mAchangeadduser: TAction;
mAoutbox: TAction;
mAViewinfoof: TAction;
mAOpenchatwith: TAction;
mAContactsdatabase: TAction;
mAShowlogwindow: TAction;
mASendanSMS: TAction;
mAreloadlang: TAction;
mAreloadtheme: TAction;
mAsupport: TAction;
mACheckforupdates: TAction;
mAthemes: TAction;
mARequestCL: TAction;
mmrequestCL: TMenuItem;
cARemFrHisCL: TAction;
menuremovedyou1: TMenuItem;
cAAuthGrant: TAction;
Authgrant: TMenuItem;
mARefreshThemeList: TAction;
mASinchrCL: TAction;
Showallcontactsinone1: TMenuItem;
AContInOne: TAction;
authReq: TMenuItem;
Requestavatar1: TMenuItem;
ARequestAvt: TAction;
cAAuthReqst: TAction;
cADeleteWH: TAction;
Deletewithhistory1: TMenuItem;
Newcontact1: TMenuItem;
gmANewContact: TAction;
Addcontact1: TMenuItem;
TopLbl: TLabel;
FilterBar: TPanel;
FilterEdit: TEdit;
FilterClearBtn: TRnQSpeedButton;
gmANewContactLocal: TAction;
cAAdd2Server: TAction;
Addtoserver1: TMenuItem;
gmAAdd2Server: TAction;
Addtoserver2: TMenuItem;
cAMakeLocal: TAction;
Makelocal1: TMenuItem;
gmAMakeLocal: TAction;
Makelocal2: TMenuItem;
RQHelp1: TMenuItem;
mAThmCntEdt: TAction;
Opencontactstheme: TMenuItem;
N5: TMenuItem;
SmilesMenu: TMenuItem;
mASmiles: TAction;
SoundsMenu: TMenuItem;
mASounds: TAction;
Deleteonlyhistory1: TMenuItem;
cADeleteOH: TAction;
SendSMS1: TMenuItem;
ASendSMS: TAction;
Openincomingfolder1: TMenuItem;
MMGenError: TMenuItem;
mASearchInHist: TAction;
Openchatwith1: TMenuItem;
Showgroups3: TMenuItem;
AShowEmptyGroups1: TAction;
Mute1: TMenuItem;
AMuteUnmute: TAction;
procedure mASinchrCLUpdate(Sender: TObject);
procedure cADeleteWHUpdate(Sender: TObject);
procedure ADelete1Update(Sender: TObject);
procedure cADeleteWHExecute(Sender: TObject);
procedure mAHelpUpdate(Sender: TObject);
procedure mAHelpExecute(Sender: TObject);
procedure ARequestAvtUpdate(Sender: TObject);
procedure Requestavatar1Click(Sender: TObject);
procedure authReqClick(Sender: TObject);
procedure AContInOneUpdate(Sender: TObject);
procedure Showallcontactsinone1Click(Sender: TObject);
procedure menuPopup(Sender: TObject);
procedure StatusMenuPopup(Sender: TObject);
// procedure Aautomessage1splitUpdate(Sender: TObject);
procedure mAXStatusUpdate(Sender: TObject);
procedure mAXStatusExecute(Sender: TObject);
procedure statusBtnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Exit1Click(Sender: TObject);
procedure StatusMenuClick(Sender: TObject);
procedure VisMenuClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure password1Click(Sender: TObject);
procedure Delete1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure byUIN1Click(Sender: TObject);
procedure Whitepages1Click(Sender: TObject);
procedure Sendmessage1Click(Sender: TObject);
procedure Hide1Click(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure viewinfo1Click(Sender: TObject);
procedure About1Click(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure Sendcontacts1Click(Sender: TObject);
procedure Showlogwindow1Click(Sender: TObject);
procedure Preferences1Click(Sender: TObject);
procedure Changeoradduser1Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Viewmyinfo1Click(Sender: TObject);
procedure UIN1Click(Sender: TObject);
procedure Newgroup1Click(Sender: TObject);
procedure Rename1Click(Sender: TObject);
procedure Renamegroup1Click(Sender: TObject);
procedure Opengroup1Click(Sender: TObject);
procedure Closegroup1Click(Sender: TObject);
procedure Deletegroup1Click(Sender: TObject);
procedure Closeallgroups1Click(Sender: TObject);
procedure Openallgroups1Click(Sender: TObject);
procedure Contactsdatabase1Click(Sender: TObject);
procedure Deleteallemptygroups1Click(Sender: TObject);
procedure movecontactsAction(Sender: TObject);
procedure displayHint(Sender: TObject);
procedure AppActivate(Sender: TObject);
procedure Viewinfoof1Click(Sender: TObject);
procedure Outbox1Click(Sender: TObject);
procedure Lock1Click(Sender: TObject);
procedure SendanSMS1Click(Sender: TObject);
procedure Sendemail1Click(Sender: TObject);
procedure AddContactAction(Sender: TObject);
procedure MoveContactAction(Sender: TObject);
procedure menuBtnClick(Sender: TObject);
procedure divisorMenuPopup(Sender: TObject);
procedure groupMenuPopup(Sender: TObject);
procedure contactMenuPopup(Sender: TObject);
procedure Showonlyonlinecontacts1Click(Sender: TObject);
procedure statusBtnClick(Sender: TObject);
procedure visibilityBtnClick(Sender: TObject);
procedure Checkforupdates1Click(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure OnTimer(Sender: TObject);
procedure Ignorelist1Click(Sender: TObject);
procedure Openchatwith1Click(Sender: TObject);
procedure RQhomepage1Click(Sender: TObject);
// procedure RQforum1Click(Sender: TObject);
// procedure RQwhatsnew1Click(Sender: TObject);
procedure rosterKeyPress(Sender: TObject; var Key: Char);
procedure rosterMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure rosterDblClick(Sender: TObject);
procedure rosterKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure rosterCompareNodes(Sender: TBaseVirtualTree; Node1, Node2: PVirtualNode; Column: TColumnIndex; var Result: Integer);
procedure rosterMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure rosterCollapsed(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure rosterCollapsing(Sender: TBaseVirtualTree; Node: PVirtualNode; var Allowed: Boolean);
procedure rosterDragOver(Sender: TBaseVirtualTree; Source: TObject; Shift: TShiftState; State: TDragState; Pt: TPoint;
Mode: TDropMode; var Effect: Integer; var Accept: Boolean);
procedure rosterDragDrop(Sender: TBaseVirtualTree; Source: TObject; DataObject: IDataObject; Formats: TFormatArray;
Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode);
procedure rosterFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
procedure menushowonlyimvisibleto1Click(Sender: TObject);
procedure rosterDrawNode(Sender: TBaseVirtualTree; const PaintInfo: TVTPaintInfo);
procedure rosterFocusChanging(Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex;
var Allowed: Boolean);
procedure mainmenureloadtheme1Click(Sender: TObject);
procedure mainmenureloadlang1Click(Sender: TObject);
procedure menuDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
procedure menuMeasureItem(Sender: TObject; ACanvas: TCanvas; var Width, Height: Integer);
procedure FormCreate(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure rosterKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure rosterMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure rosterGetHintSize(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var R: TRect);
procedure rosterDrawHint(Sender: TBaseVirtualTree; HintCanvas: TCanvas; Node: PVirtualNode; R: TRect; Column: TColumnIndex);
procedure minBtnClick(Sender: TObject);
procedure AUIN1Update(Sender: TObject);
procedure ASendemail1Update(Sender: TObject);
procedure cmAmovetogroupUpdate(Sender: TObject);
procedure mainmenugetthemes1Click(Sender: TObject);
procedure AShowgroups1Update(Sender: TObject);
procedure AShowonlyonlinecontacts1Update(Sender: TObject);
procedure Amenushowonlyimvisibleto1Update(Sender: TObject);
procedure ANothingExecute(Sender: TObject);
procedure AIgnorelist1Update(Sender: TObject);
procedure mAStatusUpdate(Sender: TObject);
procedure mAvisibilityUpdate(Sender: TObject);
procedure mARequestCLExecute(Sender: TObject);
procedure cARemFrHisCLExecute(Sender: TObject);
procedure cAAuthGrantExecute(Sender: TObject);
procedure cAAuthGrantUpdate(Sender: TObject);
procedure sbarDblClick(Sender: TObject);
procedure sbarMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure sbarMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure mAhideUpdateEx(Sender: TObject);
procedure FilterClearBtnClick(Sender: TObject);
procedure FilterEditChange(Sender: TObject);
procedure FilterEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure TopLblDblClick(Sender: TObject);
procedure cAAdd2ServerUpdate(Sender: TObject);
procedure cAAdd2ServerExecute(Sender: TObject);
procedure ARename1Update(Sender: TObject);
procedure gmAAdd2ServerUpdate(Sender: TObject);
procedure gmAAdd2ServerExecute(Sender: TObject);
procedure cAMakeLocalUpdate(Sender: TObject);
procedure cAMakeLocalExecute(Sender: TObject);
procedure gmAMakeLocalUpdate(Sender: TObject);
procedure gmAMakeLocalExecute(Sender: TObject);
procedure cAAuthReqstUpdate(Sender: TObject);
procedure PntBarPaint(Sender: TObject);
procedure mARequestCLUpdate(Sender: TObject);
procedure RQHelp1Click(Sender: TObject);
procedure mAThmCntEdtExecute(Sender: TObject);
procedure cADeleteOHUpdate(Sender: TObject);
procedure cADeleteOHExecute(Sender: TObject);
procedure ASendSMSUpdate(Sender: TObject);
procedure ASendSMSExecute(Sender: TObject);
procedure Openincomingfolder1Click(Sender: TObject);
procedure WMDisplayChange(var pMsg: TWMDisplayChange); message WM_DISPLAYCHANGE;
procedure WMExitSizeMove(var pMsg: TMessage); message WM_EXITSIZEMOVE;
procedure MMGenErrorClick(Sender: TObject);
procedure rosterClick(Sender: TObject);
procedure rosterMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure FormAfterMonitorDpiChanged(Sender: TObject; OldDPI, NewDPI: Integer);
procedure mASearchInHistExecute(Sender: TObject);
procedure OnTrayEvent(Sender: TObject; ev: TTrayEvent);
procedure AShowgroups1Execute(Sender: TObject);
procedure AShowEmptyGroups1Execute(Sender: TObject);
procedure AShowEmptyGroups1Update(Sender: TObject);
procedure AViewinfo1Update(Sender: TObject);
procedure AMuteUnmuteUpdate(Sender: TObject);
procedure AMuteUnmuteExecute(Sender: TObject);
procedure gmARenamegroupUpdate(Sender: TObject);
procedure gmADeletegroupUpdate(Sender: TObject);
procedure gmAMoveallcontactstoUpdate(Sender: TObject);
private
FMouseInControl: Boolean;
FToggling: Boolean;
procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
procedure WMNCActivate(var Msg: TWMNCActivate); message WM_NCACTIVATE;
procedure WMRestoreApp(var Msg: TMessage);
procedure SelectTheme(Sender: TObject);
procedure SelectSmiles(Sender: TObject);
procedure SelectSounds(Sender: TObject);
procedure CreateMenus;
public
clickedOnAcontact: Boolean;
vismenuExt: TPopupMenu;
statusMenuNEW: TPopupMenu;
oldHandle: THandle;
PntBar: TRnQPntBox;
procedure RosterMouseLeave(Sender: TObject);
procedure ReStart(Sender: TObject);
procedure WndProc(var Msg: TMessage); override;
procedure UpdateCaption;
function clickedGroupList: TRnQCList;
procedure AddContactsAction(Sender: TObject);
procedure SendContactsAction(Sender: TObject);
procedure toggleVisible;
procedure doAutosize;
procedure closeAllChildWindows;
procedure doSearch;
procedure UpdateStatusGlyphs;
procedure roasterKeyEditing(Sender: TObject; var Key: Char);
procedure roasterStopEditing(Sender: TObject);
procedure pwdBoxKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
// procedure CreateParams(var Params: TCreateParams); override;
procedure wmNCHitTest(VAR Msg: TWMNCHitTest); message WM_NCHITTEST;
procedure onCloseSomeWindows(Sender: TObject; var Action: TCloseAction);
procedure previewFormKeyPress(Sender: TObject; var Key: Char);
procedure imgMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure imgMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure MemoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
// function AddMainMenuItem(wPar: WPARAM; lPar: LPARAM): Integer; cdecl;
function AddContactMenuItem(pMI: PCLISTMENUITEM): Integer; // cdecl;
{ function AddContactMenuItem(pPluginProc : Pointer; menuIcon: hIcon; menuCaption:String;
menuHint:string; //procIdx : Integer;
position : Integer;
PopupName : String; popupPosition : Integer;
hotKey : DWORD; PicName : String = ''):integer; }
// function UpdateContactMenuItem(menuHandle: hmenu; pMI : PCLISTMENUITEM): Integer;// cdecl;
procedure UpdateContactMenuItem(menuHandle: hmenu; pMI: PCLISTMENUITEM); // cdecl;
procedure DelContactMenuItem(menuHandle: hmenu);
procedure OnPluginMenuClick(Sender: TObject);
procedure CreateParams(var Params: TCreateParams); override;
procedure ViewICQProfile(Sender: TObject);
procedure SaveFormPositionForCurrentMonitorCount;
procedure DefaultHandler(var Message); override;
end; // TmainFrm
TFormPos = class
Left: Integer;
Top: Integer;
end;
procedure KillHint;
procedure KillChatTabHint;
var
RnQmain: TRnQmain;
hintwnd: THintWindowEx;
StartX, StartY, LastMonCnt: Integer;
MonPositions: TDictionary;
WM_FINDINSTANCE: Integer;
implementation
uses
UxTheme, Themes, addContactDlg,
aboutDlg, selectContactsDlg,
incapsulate, usersDlg, changePwdDlg, // dbDlg,
outboxDlg, Types, globalLib, authreqDlg,
events, roasterLib, themesLib, history, iniLib,
// smsDlg,
Clipbrd, ShellAPI, strutils, langLib, outboxLib, uinlistLib,
RnQGlobal, RnQPics,
pluginutil,
RnQPrefsLib,
hook,
RDFileUtil, RDUtils, RnQSysUtils,
RQUtil, RQLog, RQThemes, RnQdbDlg, RnQTips, RnQMenu, tipDlg,
Protocols_All,
ICQCommon, ICQConsts, ICQSession,
Protocol_icq,
RnQLangs, RnQMacros, RnQStrings, RnQNet,
RnQGraphics32,
{$IFDEF RNQ_AVATARS}
RnQ_Avatars,
{$ENDIF}
{$IFDEF RNQ_PLAYER}
uSimplePlayer,
{$ENDIF RNQ_PLAYER}
menusUnit, statusform, Math;
{$R *.DFM}
procedure TVirtualDrawTree.CMMouseLeave(var Message: TMessage);
begin
inherited;
if (Message.LParam = 0) and Assigned(FOnMouseLeave) then
FOnMouseLeave(Self);
end;
procedure KillHint;
begin
if Assigned(hintwnd) then
try
hintwnd.Hide;
if not (csDestroying in hintwnd.ComponentState) then
FreeAndNil(hintwnd);
except end;
end;
procedure KillChatTabHint;
begin
if Assigned(chatFrm) then
chatFrm.StopTimer(HintTimerOpen);
KillHint;
end;
procedure TRnQmain.RosterMouseLeave(Sender: TObject);
begin
KillChatTabHint;
end;
procedure TRnQmain.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := (Params.ExStyle and not WS_SYSMENU and (not WS_EX_WINDOWEDGE) and (not WS_EX_STATICEDGE) and (not WS_EX_DLGMODALFRAME) and (not WS_EX_CLIENTEDGE));
Params.Style := (Params.Style and (not WS_CAPTION) and (not DS_MODALFRAME) and (not WS_DLGFRAME) and (not WS_THICKFRAME));
Params.Style := (Params.Style or WS_SYSMENU or WS_MAXIMIZEBOX or WS_MINIMIZEBOX and not WS_SIZEBOX);
end;
procedure TRnQmain.FormShow(Sender: TObject);
begin
utilLib.dockSet;
autosizeDelayed := TRUE;
mainfrmHandleUpdate;
applySnap;
{$IFDEF DEBUG_PACKETS}
// Account.AccProto.getMyInfo.ViewInfo;
Showlogwindow1Click(Sender);
{$ENDIF DEBUG_PACKETS}
end;
procedure TRnQmain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := not QuitConfirmation or (MessageDlg(GetTranslation('Really quit?'), mtConfirmation, [mbYes, mbNo], 0) = mrYes);
end;
procedure TRnQmain.FormAfterMonitorDpiChanged(Sender: TObject; OldDPI, NewDPI: Integer);
begin
themeslib.applySizes(NewDPI);
end;
procedure TRnQmain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
quit;
end;
procedure TRnQmain.closeAllChildWindows;
var
i: Integer;
c: Tcomponent;
begin
i := childWindows.Count - 1;
while i >= 0 do
begin
c := childWindows.Items[i];
if c is TForm then
with c as TForm do
if visible then
begin
// childWindows.Items[i] := NIL;
close;
end;
dec(i);
end;
i := componentcount - 1;
while i >= 0 do
begin
c := components[i];
if c is TForm then
with c as TForm do
if visible then
close;
dec(i);
end;
{$IFDEF RNQ_PLAYER}
FreeAndNil(RnQPlayer);
{$ENDIF RNQ_PLAYER}
FreeAndNil(RnQdbFrm);
end; // closeAllChildWindows
procedure TRnQmain.UpdateCaption;
var
MyInf: TICQContact;
begin
MyInf := NIL;
if Assigned(Account.AccProto) then
MyInf := Account.AccProto.getMyInfo;
if Assigned(MyInf) then
// and Assigned(Account.AccProto.MyInfo) then
with MyInf do
caption := template(rosterTitle, ['%nick%', nick, '%uin%', uin2Show, '%build%', IntToStr(RnQBuild)])
else
caption := template(rosterTitle, ['%title%', Application.Title, '%nick%', Str_unk, '%uin%', Str_unk, '%build%',
IntToStr(RnQBuild)]);
chatFrm.caption := RnQmain.caption + ' - ' + getTranslation('Chat window');
end; // updateCaption
procedure TRnQmain.toggleVisible;
var
timeout: Integer;
begin
if FToggling then
Exit;
try
FToggling := True;
if formVisible(Self) and (windowstate <> wsMinimized) then
begin
if minimizeRoster then
begin
{ tipfrm is hided anyway, but if we don't do it manually it will reapper
{ just as the roster repops up }
TipsHideAll;
// ShowWindow()
// if transparency.forRoster then
// AnimateWindow(self.Handle, 1000, AW_HIDE);
// else
// AnimateWindow(self.Handle, 100, AW_BLEND or AW_HIDE);
if Self.Floating then
windowstate := wsMinimized
else if docking.Dock2Chat and docking.Docked2chat then
chatFrm.windowstate := wsMinimized;
end;
{ sometimes form is not hided after minimization, maybe it is a matter of
{ timeouts. this loop could fix the problem }
timeout := 0;
if docking.Dock2Chat and docking.Docked2chat AND NOT Self.Floating then
repeat
if timeout > 0 then
sleep(10);
chatFrm.Hide;
inc(timeout);
until not formVisible(chatFrm) or (timeout = 100)
else
repeat
if timeout > 0 then
sleep(10);
Hide;
inc(timeout);
until not formVisible(Self) or (timeout = 100);
end
else
begin
{ if Self.Floating then
if windowstate=wsMinimized then
windowstate:=wsNormal
else
windowstate:=wsMinimized;
}
// if windowstate = wsNormal then
if docking.Dock2Chat and docking.Docked2chat and not Self.Floating then
begin
try
chatFrm.show;
except
end;
Application.BringToFront;
ForceForegroundWindow(chatFrm.Handle);
end
else
begin
try
// if transparency.forRoster then
// AnimateWindow(self.Handle, 50, AW_ACTIVATE);
// else
// AnimateWindow(self.Handle, 100, AW_BLEND);
if windowstate <> wsMinimized then
windowstate := wsMinimized;
windowstate := wsNormal;
show;
except
end;
Application.BringToFront;
ForceForegroundWindow(Handle);
end;
end;
finally
FToggling := False;
mainfrmHandleUpdate;
end;
end; // toggleVisible
procedure TRnQmain.Exit1Click(Sender: TObject);
begin
close;
// Application.Terminate;
end;
procedure TRnQmain.StatusMenuClick(Sender: TObject);
begin
if Sender is TMenuItem then
Account.AccProto.UserSetStatus(TMenuItem(Sender).Tag, Account.AccProto.GetVisibility);
end;
procedure TRnQmain.VisMenuClick(Sender: TObject);
begin
if Sender is TMenuItem then
Account.AccProto.SetVisibility(TMenuItem(Sender).Tag);
end;
procedure TRnQmain.password1Click(Sender: TObject);
begin
if Account.AccProto.IsOnline then
begin
if not Assigned(changePwdFrm) then
begin
changePwdFrm := TchangePwdFrm.Create(Account.AccProto, False);
translateWindow(changePwdFrm);
end;
changePwdFrm.showModal
end else
Account.AccProto.enterPWD;
end;
procedure TRnQmain.Delete1Click(Sender: TObject);
begin
if Assigned(clickedContact) then
if messageDlg(getTranslation('Are you sure you want to delete %s from your list?', [clickedContact.displayed]),
mtConfirmation, [mbYes, mbNo], 0) = mrYes then
RemoveFromRoster(clickedContact);
end; // delete1click
procedure TRnQmain.byUIN1Click(Sender: TObject);
var
addContactFrm: TaddContactFrm;
begin
addContactFrm := TaddContactFrm.Create(Self, Account.AccProto);
translateWindow(addContactFrm);
showForm(addContactFrm)
end;
procedure TRnQmain.Whitepages1Click(Sender: TObject);
begin
Account.AccProto.ShowWP;
end;
procedure TRnQmain.Sendmessage1Click(Sender: TObject);
begin
chatFrm.openOn(clickedContact)
end;
procedure TRnQmain.AddContactsAction(Sender: TObject);
var
wnd: TselectCntsFrm;
cl: TRnQCList;
begin
wnd := (Sender as TControl).Parent as TSelectCntsFrm;
cl := wnd.SelectedList;
cl.resetEnumeration;
while cl.hasMore do
AddToRoster(cl.getNext);
cl.free;
wnd.close;
end; // AddContactsAction
procedure TRnQmain.Hide1Click(Sender: TObject);
begin
toggleVisible
end;
procedure TRnQmain.FormResize(Sender: TObject);
begin
// exit;
if rosterbarOnTop then
begin
bar.align := alTop;
// bar.BevelEdges := [beBottom];
end
else
begin
bar.align := alBottom;
// bar.BevelEdges := [beTop];
end;
if filterbarOnTop then
begin
FilterBar.align := alTop;
FilterEdit.Margins.Bottom := 3;
FilterEdit.Margins.Top := 2;
FilterClearBtn.Margins.Bottom := 3;
FilterClearBtn.Margins.Top := 2;
end
else
begin
FilterBar.align := alBottom;
if showMainBorder then
begin
FilterEdit.Margins.Bottom := 2;
FilterEdit.Margins.Top := 3;
FilterClearBtn.Margins.Bottom := 2;
FilterClearBtn.Margins.Top := 3;
end
else
begin
FilterEdit.Margins.Bottom := 0;
FilterEdit.Margins.Top := 4;
FilterClearBtn.Margins.Bottom := 0;
FilterClearBtn.Margins.Top := 4;
end;
end;
if showMainBorder then
begin
FilterEdit.Margins.Left := 2;
FilterClearBtn.Margins.Right := 2;
end
else
begin
FilterEdit.Margins.Left := 0;
FilterClearBtn.Margins.Right := 0;
end;
// menuBtn.left:=0;
// statusBtn.left:=menuBtn.boundsrect.right+1;
// visibilityBtn.left:=statusBtn.boundsrect.right+1;
{ sbar.left:=visibilityBtn.BoundsRect.right+1;
sbar.width:=clientWidth-visibilityBtn.BoundsRect.right-1;
sbar.top:=0;
sbar.Height:=bar.ClientHeight;
}
// PntBar.Left := visibilityBtn.BoundsRect.right+1;
{
if Assigned(PntBar) then
PntBar.width := max(clientWidth-visibilityBtn.BoundsRect.right-1, 1);
}
// rosterLib.formresized;
autosizeDelayed := TRUE;
end;
procedure TRnQmain.viewinfo1Click(Sender: TObject);
begin
if Assigned(clickedContact) then
clickedContact.ViewInfo;
end;
procedure TRnQmain.About1Click(Sender: TObject);
// var
// af : TaboutFrm;
begin
if not Assigned(aboutFrm) then
begin
aboutFrm := TaboutFrm.Create(Application);
translateWindow(aboutFrm);
end;
aboutFrm.view;
end;
procedure TRnQmain.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
function its(sc: Tshortcut): Boolean;
var
k: Word;
s: TShiftState;
begin
ShortCutToKey(sc, k, s);
Result := (k = Key) and (s = Shift);
end; // its
var
i: Integer;
begin
if (Shift = [ssAlt]) and (Key = VK_F4) then
close
else if (Shift = [ssCtrl]) and (Key = VK_F) then
begin
if not FilterBar.visible then
if rosterbarOnTop then
FilterBar.Top := 100
else
FilterBar.Top := 0;
FilterBar.visible := not FilterBar.visible;
if FilterBar.visible then
try
if RnQmain.Floating then
ActiveControl := FilterEdit
else
chatFrm.ActiveControl := FilterEdit
// SetFocusedControl(FilterEdit)
except
end
else
begin
try
if RnQmain.Floating then
ActiveControl := roster
else
chatFrm.ActiveControl := roster
// SetFocusedControl(FilterEdit)
except
end;
if (FilterEdit.Text <> '') or (roasterLib.FilterTextBy <> '') then
FilterClearBtnClick(nil);
end;
Key := 0;
end
else
for i := 0 to length(macros) - 1 do
if not macros[i].sw and its(macros[i].hk) then
executeMacro(macros[i].opcode);
end; // formkeydown
procedure TRnQmain.Sendcontacts1Click(Sender: TObject);
begin
OpenSendContacts(clickedContact)
end;
procedure TRnQmain.SendContactsAction(Sender: TObject);
var
// i:integer;
// s : String;
s: RawByteString;
cnt: TICQContact;
wnd: TselectCntsFrm;
cl: TRnQCList;
begin
wnd := (Sender as Tcontrol).parent as TselectCntsFrm;
cl := wnd.selectedList;
if not cl.empty then
begin
s := (wnd.extra as Tincapsulate).str;
if s > '' then
begin
// cnt := contactsDB.get(TICQContact, s);
cnt := wnd.proto.getContact(s);
begin
Account.outbox.add(OE_CONTACTS, cnt, 0, cl);
if Assigned(outboxFrm) then
outboxFrm.updateList;
end;
end;
end;
cl.free;
wnd.extra.free;
wnd.close;
end;
procedure TRnQmain.Showlogwindow1Click(Sender: TObject);
begin
if not Assigned(logFrm) then
begin
logFrm := TlogFrm.Create(Application);
translateWindow(logFrm);
end;
// BeginThread(NIL, 1024, )
showForm(logFrm)
end;
procedure TRnQmain.PntBarPaint(Sender: TObject);
var
X, Y: Integer;
cnv: TCanvas;
R: TRect;
vImgElm: TRnQThemedElementDtls;
// thmTkn : Integer;
// picLoc : TPicLocation;
// picIdx : Integer;
oldMode: Integer;
// bmp : TBitmap;
// TextLen: Integer;
TextRect: TRect;
// TextFlags: Cardinal;
// Options: TDTTOpts;
PaintOnGlass: Boolean;
MemDC: HDC;
PaintBuffer: HPAINTBUFFER;
br: HBRUSH;
oldF: HFONT;
s: String;
progress: Double;
begin
cnv := (Sender as TPaintBox).Canvas;
cnv.Font.Assign(Screen.MenuFont);
theme.ApplyFont('roaster.bar', cnv.Font); // roaster.barfont);
R := (Sender as TPaintBox).ClientRect;
// cnv.font.color := clRed;
// cnv.font.color := clBlack;
// cnv.font.color := clWhite;
// cnv.brush.color:=statusbar.color;
// cnv.brush.color:= bar.Color;
// cnv.fillRect(r);
// cnv.fillRect(R);
// cnv.Lock;
Y := R.Top + (R.Bottom - R.Top - cnv.TextHeight('1')) div 2;
// PaintOnGlass := StyleServices.Enabled and DwmCompositionEnabled and
// not (csDesigning in ComponentState);
// if PaintOnGlass then
// begin
// PaintOnGlass := self.GlassFrame.Enabled and self.GlassFrame.FrameExtended;
// end;
PaintOnGlass := False;
PaintBuffer := 0;
progress := 0;
if progStart > 0 then
progress := progStart
else if Assigned(Account.AccProto) then
progress := Account.AccProto.progLogon;
if progress > 0 then
begin
try
TextRect := rect(R.Left, R.Top + 2, R.Left + round((R.Right - R.Left) * progress), R.Bottom - 2);
cnv.Font.color := clHighlightText;
if PaintOnGlass then
begin
PaintBuffer := BeginBufferedPaint(cnv.Handle, TextRect, BPBF_TOPDOWNDIB, nil, MemDC);
end
else
MemDC := cnv.Handle;
// br := CreateSolidBrush(ColorToRGB(clHighlight));
br := GetSysColorBrush(COLOR_GRAYTEXT);
FillRect(MemDC, TextRect, br);
// br := 0;
// DeleteObject(br);
oldMode := SetBkMode(MemDC, TRANSPARENT);
oldF := SelectObject(MemDC, cnv.Font.Handle);
s := IntToStr(round(progress * 100)) + '%';
TextOut(MemDC, R.Left + 2, Y, PChar(s), length(s));
SetBkMode(MemDC, oldMode);
SelectObject(MemDC, oldF);
finally
if PaintOnGlass then
begin
BufferedPaintMakeOpaque(PaintBuffer, @TextRect);
EndBufferedPaint(PaintBuffer, TRUE);
end;
end;
end
else
begin
if Assigned(Account.outbox) and not Account.outbox.empty then
begin
vImgElm.picName := PIC_OUTBOX;
vImgElm.ThemeToken := -1;
vImgElm.Element := RQteDefault;
vImgElm.pEnabled := TRUE;
with theme.getPicSize(vImgElm) do
// outboxSbarRect:=rect(r.left+3,r.top+1 + (r.Bottom-r.Top - cy)div 2,r.Left+cx, r.Top+cy);
outboxSbarRect := rect(R.Left + 3, 1 + (R.Top + R.Bottom - cy) div 2, R.Left + cx, R.Top + cy);
theme.drawPic(cnv.Handle, outboxSbarRect.TopLeft, vImgElm);
end
else
// if Assigned(MainProto) then
begin
outboxSbarRect := rect(-1, -1, -1, -1);
vImgElm.picName := GetXStsPic(nil, True);
if vImgElm.picName > '' then
begin
vImgElm.ThemeToken := -1;
vImgElm.Element := RQteDefault;
vImgElm.pEnabled := TRUE;
with theme.getPicSize(vImgElm) do
// theme.drawPic(cnv.Handle, Point(r.left+3,r.top+1 + (r.Bottom-r.Top - cy)div 2), vImgElm);
theme.drawPic(cnv.Handle, Types.Point(R.Left + 3, 1 + (R.Top + R.Bottom - cy) div 2), vImgElm);
end
end;
// TextOut(cnv.Handle, r.Right-cnv.textWidth(contactsPnlStr)-4,y, pansiChar(contactsPnlStr), Length(contactsPnlStr));
X := cnv.textWidth(contactsPnlStr);
// bmp := createBitmap(x, r.Bottom - r.Top);
// if ThemeControl(Self) then
// begin
if PaintOnGlass then
begin
TextRect := R;
// TextRect.Left := r.Right - x - 4;
TextRect.Left := R.Right - X - 10;
TextRect.Top := Y - 1;
DrawText32(cnv.Handle, TextRect, contactsPnlStr, cnv.Font, DT_CENTER or DT_VCENTER);
// DrawTextTransparent(cnv.Handle, r.Right - x - 4, y-1, contactsPnlStr, cnv.Font, 255, 0);
{ TextLen := Length(contactsPnlStr);
TextFlags := DT_CENTER or DT_VCENTER;
// inc(TextRect.Bottom, 1);
FillChar(Options, SizeOf(Options), 0);
Options.dwSize := SizeOf(Options);
Options.dwFlags := DTT_COMPOSITED or DTT_GLOWSIZE or DTT_TEXTCOLOR;
Options.iGlowSize := 10;
Options.crText := ColorToRGB(cnv.Font.Color);
// Options.dwFlags := Options.dwFlags or DTT_FONTPROP;
// Options.iFontPropId := GetThemeSysFont(nil, 0,
// FillRect(cnv.Handle, TextRect, GetStockObject(BLACK_BRUSH));
// DrawThemeTextEx(StyleServices.Theme[teWindow], cnv.Handle, 0, 0,
// PWideChar(WideString(contactsPnlStr)), TextLen, TextFlags, @TextRect, Options);
PaintBuffer := BeginBufferedPaint(cnv.Handle, TextRect, BPBF_TOPDOWNDIB, nil, MemDC);
try
BufferedPaintClear(PaintBuffer, @TextRect);
with StyleServices.GetElementDetails(twCaptionActive) do
DrawThemeTextEx(StyleServices.Theme[element], MemDC, Part, State,
// with StyleServices.GetElementDetails(teEditTextNormal) do
// DrawThemeTextEx(StyleServices.Theme[teEdit], Memdc, Part, State,
PWideChar(WideString(contactsPnlStr)), TextLen, TextFlags, @TextRect, Options);
// BufferedPaintMakeOpaque(PaintBuffer, @R);
finally
EndBufferedPaint(PaintBuffer, True);
end; }
end
else
begin
oldMode := SetBkMode(cnv.Handle, TRANSPARENT);
cnv.TextOut(R.Right - X - 4, Y, contactsPnlStr);
SetBkMode(cnv.Handle, oldMode);
end;
end;
// cnv.Unlock;
end;
procedure TRnQmain.Preferences1Click(Sender: TObject);
begin
showForm(WF_SHEET)
end;
procedure TRnQmain.Changeoradduser1Click(Sender: TObject);
var
s: String;
usePass: String;
vMutex: Cardinal;
uin2Start: TUID;
begin
uin2Start := showUsers(usePass);
if (uin2Start = '') or (Assigned(Account.AccProto) and Account.AccProto.getMyInfo.equals(uin2Start)) then
Exit;
repeat
s := 'R&Q' + uin2Start;
vMutex := OpenMutex(MUTEX_MODIFY_STATE, False, PChar(s));
if vMutex <> 0 then
begin
CloseHandle(vMutex);
// mutex := 0;
msgDlg(Str_already_run, TRUE, mtWarning);
uin2Start := showUsers(usePass);
if (uin2Start = '') or (Assigned(Account.AccProto) and Account.AccProto.getMyInfo.equals(uin2Start)) then
Exit;
// Halt(0);
end;
until vMutex = 0;
if uin2Start = '' then
Exit;
if Assigned(Account.AccProto) then
if not Account.AccProto.IsOffline then
begin
if messageDlg(getTranslation('This is gonna disconnect you. Proceed?'), mtConfirmation, [mbYes, mbNo], 0) <> mrYes then
Exit;
Account.AccProto.Disconnect;
end;
try
hideForm(Self);
if Assigned(Account.AccProto) then
quitUser;
AccPass := usePass;
startUser(uin2Start);
// during resetCFG the form enters a weird state, this should fix
// ShowWindow(handle,SW_HIDE);
finally
if startMinimized = formVisible(Self) then
// temporary fix: showing the form with no delay sometimes causes an AV
showRosterTimer := 10;
end;
end;
// change or add user
procedure TRnQmain.doAutosize;
var
Y, limit, delta: Integer;
begin
if not autoSizeRoster or docking.active or (not Self.Floating) or not formVisible(Self) then
Exit;
if autosizeFullRoster then
Y := roasterLib.fullMaxY
else
Y := roasterLib.onlineMaxY;
if Y > 20 then
begin
inc(Y, 5);
// if bar.Visible then inc(y, sbar.height);
if bar.visible then
inc(Y, PntBar.Height);
if TopLbl.visible then
inc(Y, TopLbl.Height);
if FilterBar.visible then
inc(Y, FilterBar.Height);
// limit:=desktopWorkArea.Bottom - self.clientToScreen(point(0, 0)).y;
if autosizeUp then
begin
limit := Top + Height - Screen.MonitorFromWindow(Self.Handle).WorkareaRect.Top;
// limit:= Screen.DesktopTop + Screen.DesktopHeight - clientToScreen(point(0,0)).y;
if Y > limit then
Y := limit;
delta := Y - clientheight;
Top := Top - delta;
clientheight := Y;
end
else
begin
limit := Screen.MonitorFromWindow(Self.Handle).WorkareaRect.Bottom - Self.clientToScreen(Types.Point(0, 0)).Y;
// limit:= Screen.DesktopTop + Screen.DesktopHeight - clientToScreen(point(0,0)).y;
if Y > limit then
Y := limit;
clientheight := Y;
end;
SaveFormPositionForCurrentMonitorCount;
end;
end; // doAutosize
procedure TRnQmain.Viewmyinfo1Click(Sender: TObject);
begin
// viewInfoabout(MainProto.myinfo)
Account.AccProto.getMyInfo.ViewInfo;
end;
procedure TRnQmain.ViewICQProfile(Sender: TObject);
begin
OpenICQURL('https://icq.com/people/' + Account.AccProto.MyAccNum + '/edit/');
end;
procedure TRnQmain.UIN1Click(Sender: TObject);
begin
clipboard.asText := clickedContact.uid
end;
procedure TRnQmain.AppActivate(Sender: TObject);
begin
inactiveTime := 0;
TipsShowTop;
end;
procedure TRnQmain.Newgroup1Click(Sender: TObject);
begin
roasterLib.AddGroup(GetTranslation('New group'));
roasterLib.Edit(roasterLib.focused, GA_Add);
end;
procedure TRnQmain.Rename1Click(Sender: TObject);
begin
if not childParent(getFocus, Self.Handle) then
roasterLib.focus(chatFrm.thisChat.who);
roasterLib.Edit(roasterLib.focused)
end;
procedure TRnQmain.Renamegroup1Click(Sender: TObject);
begin
roasterLib.Edit(roasterLib.focused, GA_Rename)
end;
procedure TRnQmain.Requestavatar1Click(Sender: TObject);
begin
reqAvatarsQ.Add(clickedContact);
end;
procedure TRnQmain.authReqClick(Sender: TObject);
var
uid: TUID;
begin
if not Assigned(clickedContact) or (Account.AccProto = nil) then
Exit;
try
uid := clickedContact.uid;
except
uid := '';
end;
if uid = '' then
Exit;
if OnlFeature(Account.AccProto) then
begin
Account.AccProto.AuthRequest(TICQContact(clickedContact), '');
plugins.castEv(PE_AUTHREQ_SENT, uid, '');
end;
end;
procedure TRnQmain.Opengroup1Click(Sender: TObject);
begin
roasterLib.expand(roasterLib.focused)
end;
procedure TRnQmain.Openincomingfolder1Click(Sender: TObject);
// var
// s : String;
begin
if Assigned(clickedContact) then
begin
// s := fileIncomePath(clickedContact);
if DirectoryExists(Openincomingfolder1.Hint) then
exec(Openincomingfolder1.Hint);
end;
end;
procedure TRnQmain.Closegroup1Click(Sender: TObject);
begin
roasterLib.collapse(roasterLib.focused)
end;
procedure TRnQmain.Deletegroup1Click(Sender: TObject);
var
id: Integer;
begin
if roasterLib.focused = nil then
Exit;
id := roasterLib.focused.groupId;
with groups.Get(id) do
if messageDlg(getTranslation('Are you sure you want to delete the group "%s" ?', [name]), mtConfirmation, [mbYes, mbNo], 0) = mrYes
then
begin
if Account.AccProto.readList(LT_ROSTER).getCount(id) > 0 then
if messageDlg(getTranslation('This group (%s) is not empty! All contacts in it will be lost!\nAre you sure you want to continue?', [name]),
mtWarning, [mbYes, mbNo], 0) = mrNo then
Exit;
// place over the first instance of the group that contains a contact
roasterLib.RemoveGroup(id);
end;
end; // delete group
procedure TRnQmain.Closeallgroups1Click(Sender: TObject);
var
i: Integer;
d: Tdivisor;
g: TPair;
begin
for g in groups.GList do
with g.Value do
if Assigned(clickedNode) and (clickedNode.kind = NODE_DIV) then
roasterLib.Collapse(Node[clickedNode.divisor])
else
for d := Low(TDivisor) to High(TDivisor) do
roasterLib.Collapse(Node[d]);
end; // close all groups
procedure TRnQmain.Openallgroups1Click(Sender: TObject);
var
i: Integer;
d: Tdivisor;
g: TPair;
begin
for g in groups.GList do
with g.Value do
if Assigned(clickedNode) and (clickedNode.kind = NODE_DIV) then
roasterLib.Expand(Node[clickedNode.divisor])
else
for d := Low(TDivisor) to High(TDivisor) do
roasterLib.Expand(Node[d]);
end; // open all groups
procedure TRnQmain.Contactsdatabase1Click(Sender: TObject);
begin
{ dbFrm := TdbFrm.Create(Application);
translateWindow(dbFrm);
showForm(dbFrm); }
if not Assigned(RnQdbFrm) then
begin
RnQdbFrm := TRnQdbFrm.Create(Application);
applyCommonsettings(RnQdbFrm);
translateWindow(RnQdbFrm);
end;
showForm(RnQdbFrm);
end;
procedure TRnQmain.Deleteallemptygroups1Click(Sender: TObject);
var
i, id: Integer;
g: TPair;
begin
for g in groups.GList do
begin
id := g.Value.ID;
if Account.AccProto.readList(LT_ROSTER).getCount(id) = 0 then
roasterLib.RemoveGroup(id);
end;
end;
procedure TRnQmain.movecontactsAction(Sender: TObject);
var
OldID, NewID: Integer;
c: TICQContact;
begin
if roasterLib.focused = nil then
Exit;
with roasterLib.focused do
if kind = NODE_GROUP then
OldID := groupId
else
Exit;
NewID := (Sender as TMenuItem).Tag;
if NewID = 2000 then
NewID := 0; // 2000 means no group
roster.BeginUpdate;
try
for c in Account.AccProto.readList(LT_ROSTER) do
if c.group = OldID then
SetNewGroupFor(c, newID);
finally
roster.EndUpdate;
end;
end; // move contacts action
procedure TRnQmain.AddContactAction(Sender: TObject);
begin
if Assigned(clickedContact) then
AddToRoster(clickedContact, (Sender as TMenuItem).Tag, clickedContact.CntIsLocal)
end;
procedure TRnQmain.MoveContactAction(Sender: TObject);
var
NewID: Integer;
c: TICQContact;
begin
if not Assigned(clickedContact) then
Exit;
NewID := (Sender as TMenuItem).Tag;
if NewID = 2000 then
NewID := 0; // 2000 means no group
roster.BeginUpdate;
try
SetNewGroupFor(clickedContact, NewID);
finally
roster.EndUpdate;
end;
end;
procedure TRnQmain.doSearch;
function twiceOrMore(const s: string): Boolean;
var
i: Integer;
begin
Result := TRUE;
if length(s) < 2 then
Result := False
else
for i := 1 to length(s) do
if s[i] <> s[1] then
begin
Result := False;
Exit;
end;
end; // twiceOrMore
var
i, cnt, maxcnt: Integer;
Node, found: Tnode;
s: string;
begin
if twiceOrMore(searching) then
begin
// search for next one
Node := roasterLib.focused;
if Assigned(Node) then
repeat
Node := getNode(roster.GetNextVisible(Node.treenode));
until (Node = NIL) or (Node.kind = NODE_CONTACT) and AnsiStartsText(searching[1], Node.contact.displayed);
// found, exit
if Node <> NIL then
begin
roasterLib.focusTemp(Node);
Exit;
end;
// not found, restart from top
Node := getNode(roster.GetFirst);
if Assigned(Node) then
repeat
Node := getNode(roster.GetNextVisible(Node.treenode));
until (Node = NIL) or (Node.kind = NODE_CONTACT) and AnsiStartsText(searching[1], Node.contact.displayed);
// found
if Node <> NIL then
roasterLib.focusTemp(Node);
Exit;
end;
// cnt is how many chars of the the current node matches the search
// maxcnt is the highest valor reached by cnt
found := NIL;
maxcnt := 0;
i := 0;
while i < roasterLib.contactsPool.Count do
begin
Node := Tnode(roasterLib.contactsPool[i]);
s := uppercase(Node.contact.displayed);
cnt := 0;
while (cnt < length(s)) and (cnt < length(searching)) and (s[cnt + 1] = upcase(searching[cnt + 1])) do
inc(cnt);
if (cnt > maxcnt) or (cnt = maxcnt) and (found <> NIL) and (found.treenode.index > Node.treenode.index) then
begin
maxcnt := cnt;
found := Node;
end;
if s = searching then
break;
inc(i);
end;
if found <> NIL then
roasterLib.focusTemp(found);
end; // doSearch
function TRnQmain.clickedGroupList: TRnQCList;
var
c: TICQContact;
begin
Result := TRnQCList.Create;
for c in Account.AccProto.readList(LT_ROSTER) do
if c.group = clickedGroup then
Result.add(c);
end; // clickedGroupList
procedure TRnQmain.TopLblDblClick(Sender: TObject);
begin
toggleVisible;
end;
// group to normal
procedure TRnQmain.sbarMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
if into(Types.Point(X, Y), outboxSbarRect) then
begin
if not Assigned(outboxFrm) then
begin
outboxFrm := ToutboxFrm.Create(Application);
translateWindow(outboxFrm);
end;
outboxFrm.open;
end;
if Button = mbRight then
// with boundsrect do
// menu.Popup(left,utilLib.IfThen(roasterbarOnTop,integer(Top), bottom))
with bar.boundsrect do
with clientToScreen(Types.Point(Left, Bottom)) do
menu.Popup(X, Y)
end;
procedure TRnQmain.Viewinfoof1Click(Sender: TObject);
var
uid: TUID;
cnt: TICQContact;
begin
if enterUinDlg(Account.AccProto, uid, getTranslation('View info of...')) then
begin
// viewInfoabout(MainProto.getContact(uid));
cnt := Account.AccProto.getContact(uid);
if Assigned(cnt) then
cnt.ViewInfo;
end;
end;
procedure TRnQmain.Outbox1Click(Sender: TObject);
begin
if not Assigned(outboxFrm) then
begin
outboxFrm := ToutboxFrm.Create(Application);
translateWindow(outboxFrm);
end;
outboxFrm.open
end;
procedure TRnQmain.Lock1Click(Sender: TObject);
begin
doLock
end;
procedure TRnQmain.SendanSMS1Click(Sender: TObject);
begin
// TsmsFrm.doAll(self,'','')
end;
procedure TRnQmain.displayHint(Sender: TObject);
begin
if Assigned(chatFrm) and chatFrm.Visible then
chatFrm.setStatusbar(Application.Hint);
// HM_url: chatFrm.setStatusbar(getURLfromFav(application.Hint));
end;
procedure TRnQmain.Sendemail1Click(Sender: TObject);
begin
clickedContact.sendEmailTo
end;
{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
function GetActiveMonitorCount: Integer;
var
lpDisplayDevice: TDisplayDevice;
dwFlags: DWORD;
cc: DWORD;
begin
lpDisplayDevice.cb := sizeOf(lpDisplayDevice);
dwFlags := 0;
cc := 0;
Result := 0;
while EnumDisplayDevices(nil, cc, lpDisplayDevice, dwFlags) do
begin
inc(cc);
if lpDisplayDevice.StateFlags and $01 {AttachedToDesktop} <> 0 then
inc(Result)
end;
end;
procedure TRnQmain.SaveFormPositionForCurrentMonitorCount;
var
size: TFormPos;
begin
size := TFormPos.Create;
size.Top := Top;
size.Left := Left;
MonPositions.AddOrSetValue(LastMonCnt, size);
size.Free;
end;
procedure TRnQmain.WMDisplayChange(var pMsg: TWMDisplayChange);
var
size: TFormPos;
cnt: Integer;
begin
cnt := GetActiveMonitorCount;
if LastMonCnt <> cnt then
begin
LastMonCnt := cnt;
if MonPositions.TryGetValue(LastMonCnt, size) then
begin
TTask.Create(procedure
begin
sleep(1000);
TThread.Synchronize(nil, procedure
begin
Left := size.Left;
Top := size.Top;
end);
end, TThreadPool.Default).Start;
end;
end;
end;
procedure TRnQmain.WMExitSizeMove(var pMsg: TMessage);
begin
SaveFormPositionForCurrentMonitorCount;
end;
procedure TRnQmain.menuBtnClick(Sender: TObject);
begin
with bar.boundsrect do
with clientToScreen(Types.Point(Left, Bottom)) do
menu.Popup(X, Y);
end;
procedure TRnQmain.sbarDblClick(Sender: TObject);
begin
DoConnect
end;
procedure TRnQmain.divisorMenuPopup(Sender: TObject);
begin
Newgroup1.visible := showGroups;
// Openallgroups1
// Closeallgroups1
end;
procedure TRnQmain.gmAAdd2ServerExecute(Sender: TObject);
var
p: TGroup;
begin
if clickedGroup <= 0 then
Exit;
p := groups.Get(clickedGroup);
if p.IsLocal and Account.AccProto.IsReady then
if p.ServerUpdate(GA_Add) then
groups.SetLocal(p.ID, False);
end;
procedure TRnQmain.gmAAdd2ServerUpdate(Sender: TObject);
begin
if clickedGroup > 0 then
if Assigned(Account.AccProto) and (groups.Get(clickedGroup).IsLocal) then
begin
TAction(Sender).Visible := True;
TAction(Sender).Enabled := Account.AccProto.IsOnline;
end else
TAction(Sender).Visible := False;
end;
procedure TRnQmain.gmADeletegroupUpdate(Sender: TObject);
begin
if (clickedGroup > 0) and (groups.Get(clickedGroup).IsLocal) then
TAction(Sender).Enabled := True
else if Assigned(Account.AccProto) then
TAction(Sender).Enabled := Account.AccProto.IsOnline;
end;
procedure TRnQmain.gmAMakeLocalExecute(Sender: TObject);
var
p: TGroup;
begin
if clickedGroup <= 0 then
Exit;
p := groups.Get(clickedGroup);
if not p.IsLocal and Account.AccProto.IsReady then
if p.ServerUpdate(GA_Remove) then
groups.SetLocal(p.ID, True);
end;
procedure TRnQmain.gmAMakeLocalUpdate(Sender: TObject);
begin
if clickedGroup > 0 then
if Assigned(Account.AccProto) and not groups.Get(clickedGroup).IsLocal then
begin
TAction(Sender).Visible := True;
TAction(Sender).Enabled := Account.AccProto.IsOnline;
end else
TAction(Sender).Visible := False
else
TAction(Sender).Visible := False;
end;
procedure TRnQmain.gmAMoveallcontactstoUpdate(Sender: TObject);
begin
TAction(Sender).Enabled := Account.AccProto.IsOnline;
end;
procedure TRnQmain.gmARenamegroupUpdate(Sender: TObject);
begin
if (clickedGroup > 0) and (groups.Get(clickedGroup).IsLocal) then
TAction(Sender).Enabled := True
else if Assigned(Account.AccProto) then
TAction(Sender).Enabled := Account.AccProto.IsOnline;
end;
procedure TRnQmain.groupMenuPopup(Sender: TObject);
begin
addGroupsToMenu(Self, Moveallcontactsto1, movecontactsAction, False);
end;
procedure TRnQmain.contactMenuPopup(Sender: TObject);
var
i: Integer;
ShowHidden: Boolean;
begin
if clickedContact = nil then
Exit;
ShowHidden := GetShiftState and (1 + 2) > 0; // shift OR control
// menusendaddedyou1.tag:=PIC_ADDEDYOU;
UIN1.Caption := GetTranslation('%s (copy UIN)', [clickedContact.uin2Show]);
Sendemail1.Visible := not (TICQContact(clickedContact).Email = '') and not TryStrToInt(TICQContact(clickedContact).Email, i);
movetogroup1.Visible := clickedContact.IsInRoster and not (clickedContact.UID2cmp = spamsFilename);
if clickedContact.group = 0 then
movetogroup1.Caption := GetTranslation('Move to group')
else
movetogroup1.Caption := GetTranslation('Move from %s to group', [dupAmpersand(groups.id2name(clickedContact.group))]);
Addtocontactlist1.Visible := not movetogroup1.Visible and not (clickedContact.UID2cmp = spamsFilename);
Sendcontacts1.Visible := not (clickedContact.UID2cmp = spamsFilename);
if movetogroup1.Visible then
addGroupsToMenu(Self, movetogroup1, MoveContactAction, clickedContact.CntIsLocal)
else
addGroupsToMenu(Self, Addtocontactlist1, AddContactAction, True);
Openincomingfolder1.Hint := fileIncomePath(clickedContact);
Openincomingfolder1.visible := DirectoryExists(Openincomingfolder1.Hint);
end;
procedure TRnQmain.Showonlyonlinecontacts1Click(Sender: TObject);
begin
toggleOnlyOnline
end;
procedure TRnQmain.statusBtnClick(Sender: TObject);
begin
with MousePos do
statusMenuNEW.Popup(X, Y)
end;
procedure TRnQmain.visibilityBtnClick(Sender: TObject);
//var
// SL: TStringList;
// TmpJSON: TJSONValue;
// ev: Thevent;
begin
//SL := TStringList.Create;
//SL.LoadFromFile('C:\SpeedProgs\Inet\Chat\RnQ\Build\Distro\CL.json');
//TmpJSON := TJSONObject.ParseJSONValue(TEncoding.UTF8.GetBytes(SL.Text), 0);
//Account.AccProto.ProcessContactList(TJSONArray(TmpJSON));
//roasterLib.rebuild;
//Exit;
//Account.AccProto.Test;
//ev := Thevent.new(EK_Msg, Account.AccProto.GetContact('230490'), Account.AccProto.GetContact('230490'), Now, 'test+', [], 0, 0, '');
//chatFrm.ChatBox.AddEvent('230490', ev);
//ev := Thevent.new(EK_Msg, Account.AccProto.GetContact('230490'), Account.AccProto.GetContact('230490'), Now, 'test-', [], 0, 0, '');
//chatFrm.ChatBox.AddEvent('230490', ev);
//Exit;
if Assigned(vismenuExt) then
with MousePos do
vismenuExt.Popup(X, Y)
end;
procedure TRnQmain.UpdateStatusGlyphs;
var
i: Integer;
sa: TStatusArray;
begin
if Assigned(Account.AccProto) then
begin
i := Account.AccProto.GetVisibility;
sa := Account.AccProto.GetVisibilities;
if Assigned(sa) then
begin
if (i >= Low(sa)) and (i <= High(sa)) then
visibilityBtn.ImageName := sa[i].ImageName;
end;
if Account.AccProto.IsOnline then
statusBtn.ImageName := Account.AccProto.getStatuses[Account.AccProto.getStatus].ImageName
else
statusBtn.ImageName := status2imgName(byte(SC_OFFLINE), False);
end
else
begin
statusBtn.ImageName := status2imgName(byte(SC_UNK), False);
visibilityBtn.ImageName := statusBtn.ImageName;
end;
{ statusBtn.ImageName := statusImgName;
//theme.getPic(statusImgName, statusBtn.glyph);
statusBtn.Repaint;
visibilityBtn.ImageName := visibilityImgName;
//theme.getPic(visibilityImgName, visibilityBtn.glyph);
visibilityBtn.Repaint; }
end;
procedure TRnQmain.Checkforupdates1Click(Sender: TObject);
begin
CheckUpdate.AutoChecking := False;
Check4Update;
end;
procedure TRnQmain.FilterClearBtnClick(Sender: TObject);
begin
FilterEdit.Text := '';
roasterLib.FilterTextBy := '';
rebuild;
end;
procedure TRnQmain.FilterEditChange(Sender: TObject);
begin
lastFilterEditTime := now;
end;
procedure TRnQmain.FilterEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
FormKeyDown(Sender, Key, Shift)
end;
procedure TRnQmain.FormHide(Sender: TObject);
begin
clickedContact := NIL;
// dockSet(FALSE);
docking.appbarFlag := False;
// utilLib.dockSet;
dockSet(Self.Handle, False, WM_DOCK);
end;
procedure TRnQmain.WndProc(var Msg: TMessage);
var
i: Integer;
ScrLeft, ScrWidth: Integer;
R: TRect;
begin
case Msg.Msg of
{$IFDEF RNQ_PLAYER}
WM_USER:
begin
if Msg.WParam = IPC_STARTPLAY then
mARnQPlayerExecute(Self) // Запускаем проигрыватель
{ case msg.lParam of // что делаем
IPC_STARTPLAY : mARnQPlayerExecute(self);// Запускаем проигрыватель
// IPC_ISPLAYING : executeMacro( := 'is plaing!';
IPC_SETVOLUME : begin
if Assigned(frmPlayer) then
begin
frmPlayer.volumeslider.Position := msg.wParam; // := 'Set volume';
end
end }
else // Label1.Caption := 'other ipc...'
inherited;
// end;
end;
{$ENDIF RNQ_PLAYER}
{ WM_COMMAND:
try
case TWMCommand(msg).ItemID of
// WA_FILE_PLAY : Label1.Caption := 'Play file';
WINAMP_BUTTON1 : executeMacro(OP_PLR_PREV); // 'Button prev track';
WINAMP_BUTTON3 : executeMacro(OP_PLR_PAUSE); //'Play/Stop';
WINAMP_BUTTON4 : executeMacro(OP_PLR_STOP); //'Pause';
WINAMP_BUTTON5 : executeMacro(OP_PLR_NEXT); //'Button next track';
// WINAMP_REW5S : Label1.Caption := 'rewind 5 sec';
// WINAMP_FFWD5S : Label1.Caption := 'forward 5 sec'
else ...
inherited;
end;
except //showmessage ('WM_COMMAND error!')
end;
}
WM_QUIT:
begin
inherited;
quit;
end;
WM_SHOWWINDOW:
if ((Msg.WParam = 0) or running) and Floating then
inherited;
WM_HOTKEY:
if not locked and hotkeysEnabled then
executeMacro(macros[Msg.WParam].opcode);
WM_SYSCOMMAND:
case Msg.WParam and $FFF0 of // first four bits are reserved
SC_CLOSE:
toggleVisible;
SC_MINIMIZE:
toggleVisible;
else
autosizeDelayed := TRUE;
inherited;
end;
WM_MOVING:
begin
if not docking.Enabled then
begin
inherited;
docking.Active := False;
Exit;
end;
i := MousePos.X;
// ScrWidth := screen.width
// r := Screen.MonitorFromWindow(self.Handle).WorkareaRect;
R := desktopWorkArea(mainDlg.RnQmain.Handle);
begin
ScrWidth := R.Right;
ScrLeft := R.Left;
end;
// limit:=Screen.MonitorFromWindow(self.Handle).WorkareaRect.Bottom - self.clientToScreen(point(0, 0)).y;
// if not docking.active and ((iscreen.width-DOCK_SNAP)) then
if not docking.active and ((i < ScrLeft + DOCK_SNAP) or (i > ScrWidth - DOCK_SNAP)) then
begin
docking.active := TRUE;
docking.pos := DP_right;
if i < ScrLeft + DOCK_SNAP then
docking.pos := DP_left;
docking.bakOfs := Types.Point(MousePos.X - boundsrect.Left, MousePos.Y - boundsrect.Top);
docking.bakSize := Types.Point(Width, Height);
end;
if docking.active and (i > ScrLeft + DOCK_SNAP) and (i < ScrWidth - DOCK_SNAP) then
begin
docking.active := False;
with TRect(Pointer(Msg.LParam)^) do
begin
Left := MousePos.X - docking.bakOfs.X;
Top := MousePos.Y - docking.bakOfs.Y;
Right := Left + docking.bakSize.X;
Bottom := Top + docking.bakSize.Y;
end;
end;
utilLib.dockSet(TRect(Pointer(Msg.LParam)^));
if not docking.active then
inherited;
end;
WM_SIZING:
begin
if docking.active then
utilLib.dockSet(TRect(Pointer(Msg.LParam)^));
inherited;
end;
//WM_MOUSEHOVER:
// CMMouseEnter(msg);
//WM_MOUSELEAVE:
// MMouseLeave(msg);
WM_ENTERMENULOOP:
begin
inherited;
end;
WM_EXITMENULOOP:
begin
inherited;
end;
WM_WTSSESSION_CHANGE:
// begin
case Msg.WParam of
WTS_CONSOLE_CONNECT:
isLocked := False;
// msgdlg('WTS_CONSOLE_CONNECT', mtInformation);
WTS_CONSOLE_DISCONNECT:
isLocked := TRUE;
// msgdlg('WTS_CONSOLE_DISCONNECT', mtInformation);
WTS_REMOTE_CONNECT:
isLocked := False;
// msgdlg('WTS_REMOTE_CONNECT', mtInformation);
WTS_REMOTE_DISCONNECT:
isLocked := TRUE;
// msgdlg('WTS_REMOTE_DISCONNECT', mtInformation);
WTS_SESSION_LOGON:
isLocked := False;
// msgdlg('WTS_SESSION_LOGON', mtInformation);
WTS_SESSION_LOGOFF:
isLocked := TRUE;
// msgdlg('WTS_SESSION_LOGOFF', mtInformation);
WTS_SESSION_LOCK:
isLocked := TRUE;
// msgdlg('WTS_SESSION_LOCK', mtInformation);
WTS_SESSION_UNLOCK:
isLocked := False;
// msgdlg('WTS_SESSION_UNLOCK', mtInformation);
{ WTS_SESSION_REMOTE_CONTROL:
begin
msgdlg('WTS_SESSION_REMOTE_CONTROL', mtInformation);
// GetSystemMetrics(SM_REMOTECONTROL);
end; }
// else
// msgdlg('WTS_Unknown', mtInformation);
end
else
inherited;
end;
end; // wndproc
procedure TRnQmain.OnTimer(Sender: TObject);
procedure updateClocks;
var
i: Integer;
begin
if Assigned(childWindows) then
with childWindows do
begin
i := Count - 1;
while i >= 0 do
begin
if TObject(Items[i]) is TRnQViewInfoForm then
TRnQViewInfoForm(Items[i]).UpdateClock;
dec(i);
end;
end;
end; // updateClocks
procedure processOutbox;
var
oe: Toevent;
begin
if outboxCount > 0 then
dec(outboxCount);
if outboxCount = 0 then
if Assigned(Account.AccProto) and Account.AccProto.IsOnline and outboxprocessChk then
begin
oe := Account.outbox.popVisible;
if oe = NIL then
Exit;
outboxCount := timeBetweenMsgs;
if Assigned(outboxFrm) then
outboxFrm.updateList;
processOevent(oe);
oe.free;
end;
end; // processOutbox
var
i: Integer;
vi1: TRnQViewInfoForm;
Fcs: THandle;
cnt: TICQContact;
cntarr: TArray;
aNewDawn: Boolean; // TRUE once after each midnight
// vLastInput : DWord;
IsSSRuning: BOOL;
b: Boolean;
begin
aNewDawn := False;
if not running then
Exit;
// things to do once per second
{ flapSecs:=succ(flapSecs) mod 10;
if flapSecs = 0 then
begin
if SendedFlaps >= ICQMaxFlaps then
icq.sock.Resume;
SendedFlaps := 0;
end; }
if not Assigned(Account.AccProto) then
Exit;
// keyboard search timeout
if now - lastSearchTime > 1.2 * DTseconds then
begin
searching := '';
roasterLib.expandedByTempFocus := NIL;
end;
// keyboard search timeout
if now - lastFilterEditTime > 1.2 * DTseconds then
if AnsiUpperCase(roasterLib.FilterTextBy) <> AnsiUpperCase(FilterEdit.Text) then
begin
roasterLib.FilterTextBy := AnsiUpperCase(FilterEdit.Text);
rebuild;
// roasterLib.Filter(roasterLib.FilterTextBy);
if roasterLib.FilterTextBy > '' then
try
if RnQmain.Floating then
ActiveControl := FilterEdit
else
chatFrm.ActiveControl := FilterEdit
// SetFocusedControl(FilterEdit);
except
end;
end;
// hide taskbar button
hideTaskButtonIfUhave2;
// trackingMouse;
longdelayCount := succ(longdelayCount) mod 50;
reconnectdelayCount := succ(reconnectdelayCount) mod boundInt(toReconnectTime, 50, 600);
if longdelayCount = 1 then
begin
aNewDawn := trunc(now) - trunc(lastOnTimer) = 1;
lastOnTimer := now;
// windows colors could have been changed, so lets recalculate "selectedColor"
selectedColor := blend(clHighlight, clBtnFace, 0.4);
// trayicon could disappear on crash, lets replace it
if Assigned(StatusIcon) and Assigned(StatusIcon.TrayIcon) then
StatusIcon.TrayIcon.Update;
// update recently offline
if EnableRecentlyOffline then
begin
cntarr := roasterLib.GetDivContacts(d_recent);
if Length(cntarr) > 0 then
for cnt in cntarr do
if Assigned(cnt) then
if not TICQContact(cnt).IsRecent then
Account.AccProto.UpdateContact(TICQContact(cnt));
SetLength(cntarr, 0);
end;
// each 24hours check for updates
if CheckUpdate.Enabled and (Now - CheckUpdate.Last > CheckUpdate.Every) and not CheckUpdate.Checking and not StartingLock then
begin
CheckUpdate.AutoChecking := True;
Check4Update;
end;
end;
/// ////////////////// USER RELATED EVENTS //////////////////////
if usertime < 0 then
Exit;
inc(usertime); // keep track of user time
if aNewDawn then // if new day begin
begin
if Account.AccProto is TicqSession then
TicqSession(Account.AccProto).applyBalloon;
CheckBDays;
end;
// have messages been seen
if AutoConsumeEvents and Assigned(chatFrm) and chatFrm.IsVisible then
chatFrm.SawAllHere;
processOutbox;
// query contacts infos
if usertime mod 20 = 0 then
begin
if Assigned(retrieveQ) and (Account.AccProto.IsOnline) and not retrieveQ.empty then
begin
Account.AccProto.GetProfile(retrieveQ.getAt(0).UID2cmp);
retrieveQ.delete(0);
SaveListsDelayed := True;
end;
{$IFDEF RNQ_AVATARS}
if Assigned(reqAvatarsQ) and Account.AccProto.AvatarsSupport and not reqAvatarsQ.empty then
begin
DownloadAvatar(TICQCOntact(reqAvatarsQ.getAt(0)));
reqAvatarsQ.delete(0);
end;
{$ENDIF RNQ_AVATARS}
// if Assigned(reqXStatusQ) and not reqXStatusQ.empty and Assigned(Account.AccProto) and Account.AccProto.IsOnline then
// begin
// TicqSession(Account.AccProto.ProtoElem).RequestXStatus(reqXStatusQ.getAt(0).uid);
// reqXStatusQ.delete(0);
// end;
end;
if Self.Floating then
begin
Fcs := getFocus;
// Fcs := GetForegroundWindow;
if ((Self.Floating and not childParent(Fcs, Self.Handle)) or (not Self.Floating and not childParent(Fcs, chatFrm.Handle))) and
not OpenedXStForm then
inc(inactiveTime)
else
inactiveTime := 0;
end;
{ autohide triggers if
{ - it is enabled
{ - time set has passed
{ - the windows is visible
{ - the mouse is not over the window
}
if inactivehide and (inactiveTime >= inactivehideTime) and formVisible(Self) and not into(MousePos, Self.boundsrect)
// and not formVisible(xStatusForm)
// and not formVisible(xMRAStatusForm)
then
toggleVisible;
TipsProced;
// decay events
i := 0;
with eventQ do
while i < Count do
try
with Thevent(Items[i]) do
if expires = 0 then
begin
free;
removeAt(i);
end
else
begin
if expires > 0 then
dec(expires);
inc(i);
end;
except
end;
// do blink!
blinkCount := succ(blinkCount) mod blinkSpeed;
if blinkCount = 0 then
begin
blinking := not blinking;
if Assigned(StatusIcon) then
begin
if StatusIcon.TrayIcon.Hidden and not BossMode.isBossKeyOn then
StatusIcon.TrayIcon.Show
else if not StatusIcon.TrayIcon.Hidden and BossMode.isBossKeyOn then
StatusIcon.TrayIcon.Hide;
StatusIcon.Update;
end;
// roster blinking
i := 0;
with eventQ do
while i < Count do
begin
cnt := Thevent(items[i]).otherpeer;
if Assigned(cnt) and (cnt is TICQContact) then
roasterLib.redraw(cnt)
else
begin
cnt := Thevent(items[i]).who;
if Assigned(cnt) and (cnt is TICQContact) then
roasterLib.redraw(cnt);
end;
inc(i);
end;
end;
if saveDBtimer2 > 0 then
begin
dec(saveDBtimer2);
if saveDBtimer2 = 0 then
// saveDB;
begin
saveListsDelayed := False;
// saveCfgDelayed := false;
saveInboxDelayed := False;
saveOutboxDelayed := False;
saveGroupsDelayed := False;
saveAllListsAsync(Account.ProtoPath, Account.AccProto, AllProxies);
end;
if saveDBtimer2 > 3000 then
saveDBtimer2 := 3000;
end;
if showRosterTimer > 0 then
begin
dec(showRosterTimer);
if showRosterTimer = 0 then
if not formVisible(Self) then
toggleVisible();
end;
if (reconnectdelayCount = 0) and running then
begin
// auto-reconnection
if StayConnected and Account.AccProto.IsOffline and ConnectionAvailable then
begin
Account.AccProto.SetStatus(LastStatus, True);
Inc(toReconnectTime, 50);
BoundInt(toReconnectTime, 50, 600);
end;
if ConnectOnConnection and Account.AccProto.IsOffline and not enteringProtoPWD and (LastStatusUserSet <> Byte(SC_OFFLINE)) and ConnectionAvailable then
Account.AccProto.SetStatus(LastStatusUserSet, True);
end;
if longdelayCount = 0 then
begin
// screen size could change, so update window position
if docking.active then
utilLib.dockSet
else
begin
fixWindowPos(Self);
fixWindowPos(chatFrm);
end;
// runs along the whole roster
b := False;
i := 0;
with Account.AccProto, readList(LT_ROSTER) do
while i < Count do
begin
with getAt(i) do
with TCE(data^) do
if toQuery then
if CntIsLocal then
begin
b := TRUE;
toQuery := False;
incDBTimer;
retrieveQ.add(getAt(i));
end;
inc(i);
end;
saveDBtimer2 := min(saveDBtimer2, 600);
if not fantomWork then
begin
if b then
saveListsDelayed := TRUE;
if saveCfgDelayed then
begin
UpdateProperties;
saveListsDelayed := False;
saveCfgDelayed := False;
saveInboxDelayed := False;
saveOutboxDelayed := False;
saveGroupsDelayed := False;
saveDBtimer2 := 0;
saveAllListsAsync(Account.ProtoPath, Account.AccProto, AllProxies);
end;
if saveInboxDelayed or saveOutboxDelayed or saveListsDelayed or saveGroupsDelayed or saveCfgDelayed then
begin
saveListsDelayed := False;
saveCfgDelayed := False;
saveInboxDelayed := False;
saveOutboxDelayed := False;
saveGroupsDelayed := False;
saveDBtimer2 := 0;
saveAllListsAsync(Account.ProtoPath, Account.AccProto, AllProxies);
end;
end;
end;
if autosizeDelayed then
begin
PntBar.Invalidate;
autosizeDelayed := False;
end;
// things to do twice per second
delayCount := succ(delayCount) mod 5;
if delayCount = 0 then
begin
FlushLogPktFile();
FlushLogEvFile();
updateClocks();
with updateViewInfoQ do
begin
resetEnumeration;
while hasMore do
begin
// if MainProto.ProtoElem is TicqSession then
begin
vi1 := findViewInfo(getNext);
if Assigned(vi1) then
begin
vi1.updateInfo;
if not formVisible(vi1) then
begin
showForm(vi1);
{ if vi1.readOnlyContact then
vi1.displayBox.setFocus
else
vi1.nickBox.setFocus; }
ForceForegroundWindow(vi1.Handle);
end;
end;
end
end;
clear;
end;
// auto-away (isHooked is needed for keyboard handling)
if IsHooked and Account.AccProto.IsOnline then
begin
// SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, @isSSActive, 0);
SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, @isSSRuning, 0);
Inc(autoaway.time, 5); // we are in delay-block then 0.5s
if IsMoved and not (autoaway.ss and (IsSSRuning or IsLocked)) and not (autoaway.boss and BossMode.isBossKeyOn) then
begin
autoaway.time := 0;
if (autoaway.autoexit) and (autoaway.triggered <> TR_NONE) then
ExitFromAutoaway;
end else if (autoaway.triggered = TR_NONE) and not (Account.AccProto.GetStatus in [Byte(SC_AWAY), Byte(SC_NA)]) or
(autoaway.triggered <> TR_NONE) then
begin
if autoaway.away and (autoaway.time >= autoaway.awayTime) and (autoaway.triggered = TR_NONE) then
begin
if autoaway.setxstatus then
begin
autoaway.bakxstatus := Account.AccProto.GetXStatus;
Account.AccProto.CurXStatus := autoaway.xstatus;
end;
autoaway.bakstatus := Account.AccProto.SetStatus(Byte(SC_AWAY), True);
autoaway.triggered := TR_AWAY; // has to be set AFTER setstatus
end;
if (autoaway.na and (autoaway.time >= autoaway.naTime) and (autoaway.triggered <> TR_NA)) or
(autoaway.ss and (isSSRuning or isLocked)) or (autoaway.boss and BossMode.isBossKeyOn) then
begin
if autoaway.triggered = TR_NONE then
begin
if autoaway.setxstatus then
begin
autoaway.bakxstatus := Account.AccProto.GetXStatus;
Account.AccProto.CurXStatus := autoaway.xstatus;
end;
autoaway.bakstatus := Account.AccProto.SetStatus(Byte(SC_NA), True);
end else
Account.AccProto.SetStatus(Byte(SC_NA));
autoaway.triggered := TR_NA; // has to be set AFTER setstatus
end;
end;
end;
if appBarResizeDelayed then
begin
appBarResizeDelayed := False;
if docking.appBar then
utilLib.setAppBarSize;
end;
Self.doAutosize;
if rosterRebuildDelayed and not roasterLib.building then
begin
rosterRepaintDelayed := False;
rosterRebuildDelayed := False;
roasterLib.rebuild;
end;
if rosterRepaintDelayed then
begin
rosterRepaintDelayed := False;
roster.repaint;
end;
if dbUpdateDelayed then
begin
dbUpdateDelayed := False;
incDBTimer;
if Assigned(RnQdbFrm) AND (RnQdbFrm.Handle <> 0) then
RnQdbFrm.updateList;
end;
end; // short delay
// update noincomingcounter
if NoIncomingCounter > 0 then
Dec(NoIncomingCounter);
chatFrm.chats.CheckTypingTimeAll;
// apply alwaysOnTop
if formVisible(Self) and (alwaysOnTop <> isTopMost(Self)) then
setTopMost(Self, alwaysOnTop);
if formVisible(chatFrm) and (chatAlwaysOnTop <> isTopMost(chatFrm)) then
setTopMost(chatFrm, chatAlwaysOnTop);
TipsShowTop;
if MustQuit then
quit;
end; // OnTimer
procedure TRnQmain.Ignorelist1Click(Sender: TObject);
var
c: TICQContact;
begin
c := clickedContact;
if c = nil then
Exit;
if ignorelist.exists(c) then
removeFromIgnorelist(c)
else
begin
addToIgnorelist(c);
if messageDlg(getTranslation('Do you want to remove %s from your contact list?', [c.displayed]), mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
removeFromRoster(c);
end;
end;
procedure TRnQmain.Openchatwith1Click(Sender: TObject);
var
uid: TUID;
begin
if enterUinDlg(Account.AccProto, uid, getTranslation('Open chat with...')) then
chatFrm.OpenOn(Account.AccProto.GetContact(uid));
end;
procedure TRnQmain.RQhomepage1Click(Sender: TObject);
begin
utilLib.openURL(rnqSite)
end;
procedure TRnQmain.RQHelp1Click(Sender: TObject);
begin
utilLib.openURL('http://help.rnq.ru')
end;
{ procedure TRnQmain.RQforum1Click(Sender: TObject);
begin openURL('http://rnq.ru/forum') end;
procedure TRnQmain.RQwhatsnew1Click(Sender: TObject);
begin openURL('http://RnQ.ru/whatsnew.html') end; }
procedure TRnQmain.rosterKeyPress(Sender: TObject; var Key: Char);
var
k: Char;
begin
k := upcase(Key);
// k :=AnsiUpperCase(key)[1];
Key := #0; // avoid beep
case k of
#8, #27:
searching := '';
#13:
if roasterLib.focused <> NIL then
if roasterLib.focused.kind = NODE_DIV then
toggleOnlyOnline
else
chatFrm.openOn(roasterLib.focusedContact);
'A' .. 'Z', '0' .. '9', '_', '@', '-', '=', '[', ']', 'а' .. 'я', 'А' .. 'Я':
begin
searching := searching + k;
doSearch;
lastSearchTime := now;
Exit;
end;
end;
FormKeyPress(Sender, k);
end;
procedure TRnQmain.rosterMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
focused: Tnode;
begin
focused := roasterLib.focused;
if (Button = mbLeft) and (clickedNode <> nil) then
case clickedNode.kind of
NODE_CONTACT:
if (focused <> nil) and into(Types.Point(X, Y - focused.rect.Top), focused.outboxRect) then
begin
if not Assigned(outboxFrm) then
begin
outboxFrm := ToutboxFrm.Create(Application);
translateWindow(outboxFrm);
end;
outboxFrm.open(focused.contact);
end;
NODE_GROUP:
if (focused <> nil) and into(Types.Point(X, Y - focused.rect.Top), focused.outboxRect) then
begin
roster.ToggleNode(focused.treenode);
// roaster.Expanded[focused.treenode] := not roaster.Expanded[focused.treenode];
end;
end;
with roster.clientToScreen(Types.Point(X, Y)) do
if Button = mbRight then
roasterLib.Popup;
end;
procedure TRnQmain.rosterMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
var Handled: Boolean);
begin
KillHint;
end;
procedure TRnQmain.rosterDblClick(Sender: TObject);
var
ev: Thevent;
begin
if clickedNode = nil then
Exit;
case clickedNode.kind of
NODE_DIV:
toggleOnlyOnline;
NODE_CONTACT:
begin
ev := eventQ.firstEventFor(clickedContact);
if ev = nil then
begin
chatFrm.OpenOn(clickedContact);
if chatFrm.Visible then
chatFrm.SetFocus;
ForceForegroundWindow(chatFrm.Handle);
end
else
begin
// eventQ.removeEvent(ev.kind, clickedContact);
eventQ.remove(ev);
realizeEvent(ev);
// realizeEvents(ev.kind, clickedContact);
end;
end;
end;
end;
procedure TRnQmain.rosterKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
clickedContact := roasterLib.focusedContact;
if Shift = [] then
case Key of
VK_HOME, VK_END, VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN, VK_RIGHT, VK_LEFT:
searching := '';
VK_DELETE:
Delete1Click(Self);
VK_F2:
if not (roasterLib.focused = nil) and (roasterLib.focused.kind = NODE_GROUP) then
begin
if not groups.Get(roasterLib.focused.groupId).IsLocal and not Account.AccProto.IsOnline then
begin
msgDlg('Group is not local and must be modified while online', True, mtInformation);
Exit;
end;
roasterLib.Edit(roasterLib.focused, GA_Rename)
end else
roasterLib.Edit(roasterLib.focused);
VK_F3:
chatFrm.flash();
VK_APPS:
roasterLib.Popup();
end;
if Shift = [ssShift] then
case Key of
VK_F10:
roasterLib.Popup();
end;
end;
procedure TRnQmain.roasterStopEditing(Sender: TObject);
begin
inplace.edit.Hide
end;
procedure TRnQmain.roasterKeyEditing(Sender: TObject; var Key: Char);
var
tmp: String;
begin
case Key of
#27:
begin
Key := #0;
with inplace do
if (what = NODE_GROUP) and (groupAction = GA_Add) then
RemoveGroup(groupId);
inplace.edit.Hide;
roster.setFocus;
end;
#13:
begin
Key := #0;
inplace.edit.Text := Trim(inplace.edit.Text);
with inplace do
if not (edit.Text = '') then
case what of
NODE_GROUP:
begin
if groups.Name2ID(edit.Text) > 0 then
begin
msgDlg(getTranslation('The name %s already exists.', [edit.Text]), False, mtWarning);
Exit;
end;
if Account.AccProto.IsOnline then
begin
tmp := groups.RenameLocal(groupId, edit.Text).Key;
groups.Get(groupId).ServerUpdate(groupAction, tmp);
end else if groups.Get(groupId).IsLocal then
groups.RenameLocal(groupId, edit.Text)
else
begin
msgDlg('Group is not local and must be modified while online', True, mtInformation);
inplace.edit.Hide;
Exit;
end;
SaveGroupsDelayed := True;
end;
NODE_CONTACT:
begin
if not (edit.Text = contact.displayed) then
contact.SetDisplay(edit.Text);
// roasterLib.updateHiddenNodes;
// chatFrm.userChanged(contact);
redraw(contact);
dbUpdateDelayed := True;
updateViewInfo(contact);
end;
end else if (what = NODE_GROUP) and (groupAction = GA_Add) then
RemoveGroup(groupId);
roasterLib.Sort(inplace.Node);
inplace.edit.Hide;
roster.SetFocus;
Exit;
end;
end;
end;
procedure TRnQmain.rosterCompareNodes(Sender: TBaseVirtualTree; Node1, Node2: PVirtualNode; Column: TColumnIndex;
var Result: Integer);
begin
Result := compareNodes(getNode(Node1), getNode(Node2))
end;
procedure TRnQmain.rosterMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
const
SC_DragMove = $F012;
begin
roasterLib.focus(roasterLib.nodeAt(X, Y));
{ //anfmaker 29.03.2005
Перемещение формы за DIVISOR
BEGIN }
if clickedNode = NIL then
Exit;
if Self.Floating then
case clickedNode.kind of
NODE_DIV:
begin
ReleaseCapture;
Perform(WM_SYSCOMMAND, SC_DragMove, 0);
end;
end
{ END
//anfmaker }
end;
procedure TRnQmain.rosterClick(Sender: TObject);
begin
KillHint;
end;
procedure TRnQmain.rosterCollapsed(Sender: TBaseVirtualTree; Node: PVirtualNode);
var
n: TNode;
ex: Boolean;
begin
if roasterLib.building then
Exit;
autosizeDelayed := TRUE;
n := getNode(Node);
if n.kind = NODE_GROUP then
begin
ex := groups.Get(n.groupId).Expanded[n.divisor];
if ex <> (vsExpanded in node.states) then
begin
groups.SetExpanded(n.groupId, n.divisor, vsExpanded in node.states);
saveGroupsDelayed := True;
end;
end;
end;
procedure TRnQmain.rosterCollapsing(Sender: TBaseVirtualTree; Node: PVirtualNode; var Allowed: Boolean);
var
n: Tnode;
begin
n := getNode(Node);
if not Assigned(n) then
Exit;
Allowed := n.kind <> NODE_DIV;
end;
procedure TRnQmain.rosterDragOver(Sender: TBaseVirtualTree; Source: TObject; Shift: TShiftState; State: TDragState; Pt: TPoint;
Mode: TDropMode; var Effect: Integer; var Accept: Boolean);
var
dest, destGrp, destDiv, clickedGrp, clickedDiv: Tnode;
begin
Accept := False;
if not Sender.equals(Source) then
Exit;
dest := roasterLib.nodeAt(Pt.X, Pt.Y);
if dest = nil then
Exit;
case dest.kind of
NODE_CONTACT:
begin
destGrp := dest.parent;
if destGrp.kind = NODE_GROUP then // it's not sure that contact is under a group
destDiv := destGrp.parent
else
begin
destDiv := destGrp;
destGrp := nil;
end;
end;
NODE_GROUP:
begin
destGrp := dest;
destDiv := destGrp.parent;
end;
NODE_DIV:
begin
destGrp := nil;
destDiv := dest;
end;
else
begin // should never reach this
msgDlg('error: drag over: unknown kind', TRUE, mtError);
Exit;
end;
end;
if Assigned(clickedContact) then
begin
clickedGrp := Tnode(TCE(clickedContact.data^).Node).parent;
if clickedGrp.kind = NODE_DIV then
begin
clickedDiv := clickedGrp;
clickedGrp := nil;
end
else
clickedDiv := clickedGrp.parent;
Accept := (clickedDiv = destDiv) and Assigned(clickedContact) and (clickedGrp <> destGrp);
if Accept then
if not clickedContact.CntIsLocal and (Account.AccProto.IsOffline or not Assigned(destGrp) or not groups.Exists(destGrp.groupId)) then
Accept := False;
end else if clickedGroup > 0 then
begin
if Assigned(clickedNode) and not (clickedNode.parent = nil) and (clickedNode.parent.kind = NODE_DIV) then
clickedDiv := clickedNode.parent
else
clickedDiv := nil;
Accept := ((dest.kind = NODE_GROUP) and (clickedGroup <> destGrp.groupId)) or ((dest.kind = NODE_DIV) and (clickedDiv = destDiv))
end
end;
procedure TRnQmain.rosterDragDrop(Sender: TBaseVirtualTree; Source: TObject; DataObject: IDataObject; Formats: TFormatArray;
Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode);
var
grpOrDiv, n: Tnode;
o: Integer;
begin
if not Sender.equals(Source) then
Exit;
roasterLib.dragging := False;
grpOrDiv := roasterLib.nodeAt(Pt.X, Pt.Y);
while grpOrDiv.kind = NODE_CONTACT do
grpOrDiv := grpOrDiv.parent;
if Assigned(clickedContact) then
SetNewGroupFor(clickedContact, RDUtils.ifThen(grpOrDiv.kind = NODE_GROUP, grpOrDiv.groupId));
if clickedGroup > 0 then
begin
n := grpOrDiv;
if n.kind = NODE_DIV then // we want the group to be the first
begin
// n = first group on this div
n := n.firstChild;
repeat
n := n.next;
if n = nil then
Exit;
until n.kind = NODE_GROUP;
groups.SetOrder(clickedGroup, n.order - 1);
end
else
begin
// is this the last group?
repeat
n := n.next
until (n = nil) or (n.kind = NODE_GROUP);
if n = nil then
// we want the group to be the last
groups.SetOrder(clickedGroup, grpOrDiv.order + 1)
else
begin
n := grpOrDiv;
o := n.order - 1;
groups.SetOrder(clickedGroup, o);
repeat
if n.groupID <> clickedGroup then
begin
dec(o);
groups.SetOrder(n.groupId, o);
end;
n := n.prev;
until (n = nil) or (n.kind <> NODE_GROUP);
end;
end;
rosterRebuildDelayed := True;
end;
end;
procedure TRnQmain.rosterFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
begin
roasterLib.focus(Node);
end;
procedure TRnQmain.menushowonlyimvisibleto1Click(Sender: TObject);
begin
toggleOnlyImVisibleto
end;
procedure TRnQmain.rosterDrawNode(Sender: TBaseVirtualTree; const PaintInfo: TVTPaintInfo);
begin
RstrDrawNode(Sender, PaintInfo);
end;
procedure TRnQmain.rosterFocusChanging(Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode;
OldColumn, NewColumn: TColumnIndex; var Allowed: Boolean);
begin
roster.ClearSelection;
// if NewNode <> OldNode then
// Sender.NodeHeight[OldNode] := TVirtualDrawTree(Sender).DefaultNodeHeight;
end;
procedure TRnQmain.mainmenureloadtheme1Click(Sender: TObject);
begin
reloadCurrentTheme()
end;
procedure TRnQmain.mainmenureloadlang1Click(Sender: TObject);
begin
reloadCurrentLang()
end;
procedure TRnQmain.FormCreate(Sender: TObject);
begin
HintWindowClass := THintWindowNoShadow;
Self.CreateMenus;
PntBar := TRnQPntBox.Create(bar);
// PntBar.ControlStyle := [csOpaque];
PntBar.parent := bar;
// PntBar.Align := alRight;
PntBar.align := alClient;
// PntBar.
PntBar.OnMouseDown := sbarMouseDown;
PntBar.OnMouseUp := sbarMouseUp;
PntBar.OnDblClick := sbarDblClick;
PntBar.OnPaint := PntBarPaint;
uninstallHook;
installHook(Self.Handle);
Width := 120;
// contactsPnl:=sbar.panels[0];
Application.OnActivate := AppActivate;
Application.OnDeactivate := AppActivate;
{ Let Windows know we accept dropped files }
DragAcceptFiles(Self.Handle, TRUE);
// Application.OnMessage := AppMessage;
oldHandle := 0;
mainfrmHandleUpdate;
FToggling := False;
// Self.GlassFrame.SheetOfGlass := CheckWin32Version(6);
// if StyleServices.Enabled and DwmCompositionEnabled then
// begin
// bar.BevelEdges := [];
bar.BevelKind := bkNone;
roster.DoubleBuffered := True;
roster.OnMouseLeave := RosterMouseLeave;
// end;
// Self.DoubleBuffered := GlassFrame.SheetOfGlass;
// roster.DoubleBuffered := Self.GlassFrame.SheetOfGlass;
// StsBox.DoubleBuffered := True;
// FilterEdit.DoubleBuffered := Self.GlassFrame.SheetOfGlass;
// MlPnl.DoubleBuffered := True;
// MlCntLbl.do
// bar.DoubleBuffered := True;
// PntBar.do
// bar
LastMonCnt := GetActiveMonitorCount;
SaveFormPositionForCurrentMonitorCount;
end;
procedure TRnQmain.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #27 then
toggleVisible;
end;
procedure TRnQmain.rosterKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
FormKeyDown(Sender, Key, Shift)
end;
procedure TRnQmain.rosterMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if (ssLeft in Shift) and ((clickedContact <> NIL) or (clickedGroup > 0)) then
begin
roasterLib.dragging := TRUE;
roster.BeginDrag(False);
end;
end;
procedure TRnQmain.rosterGetHintSize(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var R: TRect);
var
n: Tnode;
begin
n := getNode(Node);
if n = nil then
Exit;
R := rect(0, 0, 1, 1);
end;
procedure TRnQmain.rosterDrawHint(Sender: TBaseVirtualTree; HintCanvas: TCanvas; Node: PVirtualNode; R: TRect;
Column: TColumnIndex);
var
bmp: TBitmap32;
n: Tnode;
Rt: TRect;
X, Y: Integer;
begin
{ pre-paint is made on another canvas, the font is different, and i don't know
{ how to get the system tooltip font size. To get the same font size in paint
{ and pre-paint i set the font to the standard window font }
// hintcanvas.font := font;
n := getNode(Node);
if n = nil then
Exit;
// drawNodeHint(hintcanvas, node, r);
// drawHint(HintCanvas, n.kind, n.groupId, n.contact, R);
KillHint;
X := Mouse.CursorPos.X + 10;
Y := Mouse.CursorPos.Y + 10;
// вычислим размеры хинта - результат вернется в Rt
bmp := TBitmap32.Create;
bmp.SetSize(1, 1);
bmp.Canvas.Font := Screen.HintFont;
drawHint(bmp.Canvas, n.kind, n.groupId, n.contact, Rt, TRUE);
if (Rt.Width = 0) or (Rt.Height = 0) then
begin
bmp.Free;
Exit;
end;
bmp.SetSize(Rt.Width, Rt.Height);
bmp.Canvas.Font := Screen.HintFont;
drawHint(bmp.Canvas, n.kind, n.groupId, n.contact, Rt);
dec(Rt.Bottom, 4);
Rt.Left := Rt.Left + X;
Rt.Top := Rt.Top + Y;
Rt.Right := Rt.Right + X;
Rt.Bottom := Rt.Bottom + Y;
hintwnd := THintWindowEx.Create(mainDlg.RnQmain);
hintwnd.bmp := TBitmap32.Create;
hintwnd.bmp.Assign(bmp);
hintwnd.ActivateHintWithFade(Rt, '');
bmp.Free;
Exit;
end;
procedure TRnQmain.minBtnClick(Sender: TObject);
begin
toggleVisible
end;
procedure TRnQmain.MMGenErrorClick(Sender: TObject);
begin
// Exception.Create('Error');
Exception.RaiseOuterException(Exception.Create('Just for info'));
end;
procedure TRnQmain.pwdBoxKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
i: Integer;
s, sub: string;
begin
if Key = VK_RETURN then
begin
sub := '';
if Shift = [ssCtrl] then
sub := CRLF;
if Shift = [ssShift] then
sub := #13;
if Shift = [ssAlt] then
sub := #10;
with Sender as TEdit do
begin
i := selstart;
s := Text;
insert(sub, s, i + 1);
Text := s;
selstart := i + length(sub);
end;
end;
end; // pwdboxKeyDown
procedure TRnQmain.menuDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState);
begin
GPdrawmenuitemR7(ACanvas, TMenuItem(Sender), ARect, False, odSelected in State);
end;
procedure TRnQmain.menuMeasureItem(Sender: TObject; ACanvas: TCanvas; var Width, Height: Integer);
var
p: TPoint;
begin
p := GPdrawmenuitemR7(ACanvas, TMenuItem(Sender), Rect(0, 0, Width, Height), True);
Width := p.X;
Height := p.Y;
end;
procedure TRnQmain.CreateMenus;
begin
InitMenu;
createMenusExt;
// InitProtoMenus();
end;
procedure TRnQmain.AUIN1Update(Sender: TObject);
begin
if clickedContact <> nil then
TAction(Sender).caption := getTranslation('%s (copy UIN)', [clickedContact.uin2Show]);
end;
procedure TRnQmain.ASendemail1Update(Sender: TObject);
var
i: Integer;
begin
if Assigned(clickedContact) then
TAction(Sender).Visible := not (TICQContact(clickedContact).Email = '') and not TryStrToInt(TICQContact(clickedContact).Email, i)
else
TAction(Sender).Visible := False;
end;
procedure TRnQmain.ASendSMSExecute(Sender: TObject);
begin
// Send SMS
end;
procedure TRnQmain.ASendSMSUpdate(Sender: TObject);
begin
TAction(Sender).Visible := False{clickedContact.CanSMS};
end;
procedure TRnQmain.cmAmovetogroupUpdate(Sender: TObject);
begin
TAction(Sender).Enabled := Assigned(clickedContact) and (clickedContact.CntIsLocal or (Assigned(Account.AccProto) and Account.AccProto.IsOnline))
end;
procedure TRnQmain.ARename1Update(Sender: TObject);
begin
TAction(Sender).Visible := Assigned(clickedContact) and not (clickedContact.UID2Cmp = spamsFilename);
TAction(Sender).Enabled := Assigned(clickedContact);
end;
procedure TRnQmain.ARequestAvtUpdate(Sender: TObject);
begin
{$IFDEF RNQ_AVATARS}
if Assigned(clickedContact) and Assigned(Account.AccProto) then
TAction(Sender).Visible := Account.AccProto.AvatarsSupport and Assigned(clickedContact) and not (clickedContact.UID2Cmp = spamsFilename);
{$ELSE RNQ_AVATARS}
TAction(Sender).Visible := False;
{$ENDIF RNQ_AVATARS}
end;
procedure TRnQmain.SelectTheme(Sender: TObject);
var
i: NativeInt;
begin
if not(Sender is TRQMenuItem) then
Exit;
i := TRQMenuItem(Sender).Tag;
if (i >= Low(theme.themelist2)) and (i <= High(theme.themelist2)) then
begin
// theme.fn:=themelist2[TRQMenuItem(Sender).tag].fn;
with theme.themelist2[i] do
theme.load(fn, subFile);
with RQSmilesPath do
theme.load(fn, subfn, False, tsc_smiles);
with RQSoundsPath do
theme.load(fn, subfn, False, tsc_sounds);
theme.loadThemeScript(userthemeFilename, AccPath);
applyTheme;
// saveCFG;
saveCfgDelayed := TRUE;
// reloadCurrentTheme;
end
else
msgDlg('Not found this theme''s description. Make Refresh-List.', TRUE, mtError);
{ for i := 3 to mainmenuthemes1.Count - 1 do
if mainmenuthemes1.items[i] is TRQMenuItem then
TRQMenuItem(mainmenuthemes1.items[i]).ImageName := PIC_UNCHECKED;
TRQMenuItem(Sender).ImageName := PIC_CHECKED; }
end;
procedure TRnQmain.SelectSmiles(Sender: TObject);
var
i: NativeInt;
begin
if not(Sender is TRQMenuItem) then
Exit;
i := TRQMenuItem(Sender).Tag;
if (i >= Low(theme.smileList)) and (i <= High(theme.smileList)) then
begin
// theme.fn:=themelist2[TRQMenuItem(Sender).tag].fn;
with theme.smileList[i] do
begin
RQSmilesPath.pathType := pt_path;
RQSmilesPath.fn := fn;
RQSmilesPath.subfn := subFile;
if fn > '' then
begin
theme.load(fn, subFile, False, tsc_smiles);
theme.loadThemeScript(userthemeFilename, AccPath);
if Assigned(chatFrm) then
chatFrm.ResetHistory;
mainmenugetthemes1Click(nil);
end else
reloadCurrentTheme();
end;
// applyTheme;
// mainmenugetthemes1Click(nil);
// chatDlg.chatFrm.pagectrl.Refresh;
// chatDlg.chatFrm.pagectrl.ActivePage.Invalidate;
// chatFrm.InValidate;
// saveCFG;
saveCfgDelayed := True;
// reloadCurrentTheme;
if Assigned(chatFrm) then
chatFrm.UpdateChatSettings;
end else
msgDlg('Not found this theme''s description. Make Refresh-List.', TRUE, mtError);
{ for i := 3 to mainmenuthemes1.Count - 1 do
if mainmenuthemes1.items[i] is TRQMenuItem then
TRQMenuItem(mainmenuthemes1.items[i]).ImageName := PIC_UNCHECKED;
TRQMenuItem(Sender).ImageName := PIC_CHECKED; }
end;
procedure TRnQmain.SelectSounds(Sender: TObject);
var
i: NativeInt;
begin
if not(Sender is TRQMenuItem) then
Exit;
i := TRQMenuItem(Sender).Tag;
if (i >= Low(theme.soundList)) and (i <= High(theme.soundList)) then
begin
// theme.fn:=themelist2[TRQMenuItem(Sender).tag].fn;
with theme.soundList[i] do
begin
RQSoundsPath.pathType := pt_path;
RQSoundsPath.fn := fn;
RQSoundsPath.subfn := subFile;
if fn > '' then
begin
theme.load(fn, subFile, False, tsc_sounds);
theme.loadThemeScript(userthemeFilename, AccPath);
mainmenugetthemes1Click(nil);
end
else
reloadCurrentTheme();
end;
// applyTheme;
// mainmenugetthemes1Click(nil);
// chatDlg.chatFrm.pagectrl.Refresh;
// chatDlg.chatFrm.pagectrl.ActivePage.Invalidate;
// chatFrm.thisChat.repaint;
// saveCFG;
saveCfgDelayed := TRUE;
// reloadCurrentTheme;
end
else
msgDlg('Not found this theme''s description. Make Refresh-List.', TRUE, mtError);
end;
procedure TRnQmain.mainmenugetthemes1Click(Sender: TObject);
begin
theme.refreshThemelist;
refreshMenuThemelist(mainmenuthemes1, 6, SelectTheme);
refreshMenuSmileslist(SmilesMenu, 0, SelectSmiles);
refreshMenuSoundslist(SoundsMenu, 0, SelectSounds);
end;
procedure TRnQmain.AShowEmptyGroups1Execute(Sender: TObject);
begin
ToggleShowEmptyGroups
end;
procedure TRnQmain.AShowEmptyGroups1Update(Sender: TObject);
begin
TAction(Sender).Enabled := ShowGroups;
if ShowEmptyGroups then
TAction(Sender).HelpKeyword := PIC_RIGHT
else
TAction(Sender).HelpKeyword := '';
end;
procedure TRnQmain.AShowgroups1Execute(Sender: TObject);
begin
ToggleShowGroups
end;
procedure TRnQmain.AShowgroups1Update(Sender: TObject);
begin
if showGroups then
TAction(Sender).HelpKeyword := PIC_RIGHT
else
TAction(Sender).HelpKeyword := '';
end;
procedure TRnQmain.AShowonlyonlinecontacts1Update(Sender: TObject);
begin
if showOnlyOnline then
TAction(Sender).HelpKeyword := PIC_RIGHT
else
TAction(Sender).HelpKeyword := '';
end;
procedure TRnQmain.Amenushowonlyimvisibleto1Update(Sender: TObject);
begin
if showOnlyImVisibleTo then
TAction(Sender).HelpKeyword := PIC_RIGHT
else
TAction(Sender).HelpKeyword := '';
end;
procedure TRnQmain.AMuteUnmuteExecute(Sender: TObject);
begin
if Assigned(Account.AccProto) and Assigned(clickedContact) then
Account.AccProto.SetMuted(clickedContact, not clickedContact.IsMuted);
end;
procedure TRnQmain.AMuteUnmuteUpdate(Sender: TObject);
begin
TAction(Sender).Visible := False; Exit; // Unused
if not Assigned(clickedContact) then
Exit;
TAction(Sender).Visible := not (clickedContact.UID2Cmp = spamsFilename);
TAction(Sender).Enabled := Account.AccProto.IsOnline;
if clickedContact.IsMuted then
begin
TAction(Sender).HelpKeyword := 'unmuted';
TAction(Sender).Caption := GetTranslation('Unmute');
end
else
begin
TAction(Sender).HelpKeyword := 'muted';
TAction(Sender).Caption := GetTranslation('Mute');
end;
end;
procedure TRnQmain.ANothingExecute(Sender: TObject);
begin
//
end;
procedure TRnQmain.AViewinfo1Update(Sender: TObject);
begin
TAction(Sender).Visible := Assigned(clickedContact) and not (clickedContact.UID2Cmp = spamsFilename)
end;
procedure TRnQmain.ADelete1Update(Sender: TObject);
begin
TAction(Sender).Visible := getShiftState() and (1 + 2) = 0;
TAction(Sender).Enabled := Assigned(clickedContact) and (clickedContact.CntIsLocal or Account.AccProto.IsOnline);
end;
procedure TRnQmain.AIgnorelist1Update(Sender: TObject);
begin // tag = 3007
if ignorelist.exists(clickedContact) then
TAction(Sender).HelpKeyword := PIC_RIGHT
else
TAction(Sender).HelpKeyword := '';
end;
procedure TRnQmain.mAThmCntEdtExecute(Sender: TObject);
var
s: String;
begin
if fantomWork then
Exit;
s := AccPath + contactsthemeFilename;
if not FileExists(s) then
appendFile(s, '');
exec(s);
// ShellExecute()
end;
procedure TRnQmain.mAvisibilityUpdate(Sender: TObject);
var
b: Boolean;
visArr: TStatusArray;
begin // tag = 3005
// TAction(Sender).HelpKeyword := visibilityImgName;
b := True;
if Assigned(Account.AccProto) then
begin
visArr := Account.AccProto.GetVisibilities;
if Assigned(visArr) then
begin
b := False;
TAction(Sender).HelpKeyword := visArr[Account.AccProto.getVisibility].ImageName;
end;
end;
if b then
TAction(Sender).HelpKeyword := status2imgName(byte(SC_UNK), False);
end;
procedure TRnQmain.mAStatusUpdate(Sender: TObject);
begin // tag = 3004
if Assigned(Account.AccProto) then
begin
if Account.AccProto.IsOnline then
TAction(Sender).HelpKeyword := Account.AccProto.getStatuses[Account.AccProto.getStatus].ImageName
else
TAction(Sender).HelpKeyword := status2imgName(byte(SC_OFFLINE), False);
end
else
TAction(Sender).HelpKeyword := status2imgName(byte(SC_UNK), False);
end;
procedure TRnQmain.mAHelpExecute(Sender: TObject);
begin
utilLib.openURL(myPath + docsPath + getTranslation(helpFilename));
end;
procedure TRnQmain.mAHelpUpdate(Sender: TObject);
begin
if Sender is TRQMenuItem then
TRQMenuItem(Sender).visible := helpExists;
end;
procedure TRnQmain.mARequestCLExecute(Sender: TObject);
begin
if OnlFeature(Account.AccProto) then
TICQSession(Account.AccProto).GetCL;
end;
procedure TRnQmain.mARequestCLUpdate(Sender: TObject);
begin
TAction(Sender).Visible := True;
end;
procedure TRnQmain.cARemFrHisCLExecute(Sender: TObject);
begin
if OnlFeature(Account.AccProto) then
Account.AccProto.RemoveMeFromHisCL(clickedContact.uid)
end;
procedure TRnQmain.cAAdd2ServerExecute(Sender: TObject);
begin
if Assigned(clickedContact) then
Account.AccProto.AddContact(TICQContact(clickedContact));
end;
procedure TRnQmain.cAAdd2ServerUpdate(Sender: TObject);
begin
if Sender is TAction then
with Sender as TAction do
begin
Visible := Assigned(clickedContact) and not (clickedContact.UID2Cmp = spamsFilename) and
clickedContact.CntIsLocal and (Assigned(Account.AccProto) and Account.AccProto.IsOnline);
if Visible then
Enabled := not (clickedContact.group = 0) and not groups.Get(clickedContact.group).IsLocal;
end;
end;
procedure TRnQmain.cAAuthGrantExecute(Sender: TObject);
begin
if Assigned(clickedContact) and OnlFeature(Account.AccProto) then
Account.AccProto.Authorize(TICQContact(clickedContact))
end;
procedure TRnQmain.cAAuthGrantUpdate(Sender: TObject);
begin
TAction(Sender).Enabled := Assigned(Account.AccProto) and Account.AccProto.IsOnline;
TAction(Sender).Visible := (getShiftState() and (1 + 2) > 0) and Assigned(clickedContact) and not (clickedContact.UID2Cmp = spamsFilename); // shift OR control
end;
procedure TRnQmain.cAAuthReqstUpdate(Sender: TObject);
begin
TAction(Sender).Enabled := Assigned(Account.AccProto) and Account.AccProto.IsOnline;
TAction(Sender).Visible := Assigned(clickedContact) and not (clickedContact.UID2Cmp = spamsFilename) and (Boolean(getShiftState() and (1 + 2)) or (clickedContact.CntIsLocal and not clickedContact.Authorized and clickedContact.IsInRoster));
end;
procedure TRnQmain.cADeleteOHExecute(Sender: TObject);
begin
if Assigned(clickedContact) then
DelHistWith(clickedContact.UID2cmp);
end;
procedure TRnQmain.cADeleteOHUpdate(Sender: TObject);
begin
TAction(Sender).visible := Boolean(getShiftState() and (1 + 2)); // shift OR control
end;
procedure TRnQmain.cADeleteWHExecute(Sender: TObject);
begin
if Assigned(clickedContact) then
if messageDlg(getTranslation('Are you sure you want to delete %s from your list with his history?', [clickedContact.displayed]
), mtConfirmation, [mbYes, mbNo], 0) = mrYes then
removeFromRoster(clickedContact, TRUE);
end;
procedure TRnQmain.cADeleteWHUpdate(Sender: TObject);
begin
TAction(Sender).visible := Boolean(getShiftState() and (1 + 2)); // shift OR control
TAction(Sender).Enabled := (Assigned(clickedContact) and (clickedContact.CntIsLocal or (Assigned(Account.AccProto) and Account.AccProto.IsOnline)))
end;
procedure TRnQmain.cAMakeLocalExecute(Sender: TObject);
begin
if Assigned(clickedContact) and Account.AccProto.IsOnline then
clickedContact.DelCntFromSrv;
end;
procedure TRnQmain.cAMakeLocalUpdate(Sender: TObject);
begin
if Sender is TAction then
with Sender as TAction do
Visible := Assigned(clickedContact) and (Assigned(Account.AccProto) and Account.AccProto.IsOnline) and not clickedContact.CntIsLocal and clickedContact.isInRoster;
end;
{ //anfmaker 29.03.2005
Перемещение формы за sbar }
procedure TRnQmain.sbarMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
const
SC_DragMove = $F012;
begin
if Self.Floating then
begin
ReleaseCapture;
Perform(WM_SYSCOMMAND, SC_DragMove, 0);
end;
end;
procedure TRnQmain.statusBtnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
// x1, y1 : Integer;
R: TRect;
begin
if Button = mbRight then
// with mousePos do xstatusMenu.Popup(x,y)
begin
if Self.Floating then
R := Self.boundsrect
else
begin
// R := chatFrm.BoundsRect
R.TopLeft := Self.clientToScreen(Self.boundsrect.TopLeft);
R.BottomRight := Self.clientToScreen(Self.boundsrect.BottomRight);
end;;
with Self.clientToScreen(Types.Point(X, Y)) do
TxStatusForm.ShowNear2(Self, Account.AccProto, R, X, Y)
end;
// with boundsrect do xstatusMenu.Popup(x,y)
end;
procedure TRnQmain.mASearchInHistExecute(Sender: TObject);
begin
showForm(WF_SEARCH, '', vmShort, nil);
end;
procedure TRnQmain.mASinchrCLUpdate(Sender: TObject);
begin
(Sender as TAction).visible := False;
end;
{$IFDEF RNQ_PLAYER}
procedure TRnQmain.mARnQPlayerExecute(Sender: TObject);
begin
if not Assigned(RnQPlayer) then
begin
RnQPlayer := TRnQPlayer.Create(Application);
// frmPlayer.Parent :=
translateWindow(RnQPlayer);
applyCommonsettings(RnQPlayer);
end;
showForm(RnQPlayer);
end;
{$ENDIF RNQ_PLAYER}
procedure TRnQmain.mAXStatusExecute(Sender: TObject);
var
X, Y: Integer;
R: TRect;
begin
// with mousePos do xstatusMenu.Popup(x,y);
if Self.Floating then
begin
X := Self.Left;
Y := Self.Top + Self.Height;
R := Self.boundsrect
end
else
begin
// x := chatFrm.Left + chatFrm.Width;
// y := chatFrm.Top + chatFrm.Height;
// R := chatFrm.BoundsRect;
R.TopLeft := Self.clientToScreen(Self.boundsrect.TopLeft);
R.BottomRight := Self.clientToScreen(Self.boundsrect.BottomRight);
X := R.Left;
Y := R.Top + Self.Height;
end;
// with Self.ClientToScreen(Point(x,y)) do
TxStatusForm.ShowNear2(Self, Account.AccProto, R, X, Y)
end;
procedure TRnQmain.mAXStatusUpdate(Sender: TObject);
begin
if Sender is TAction then
begin
TAction(Sender).visible := showXStatusMnu;
if TAction(Sender).visible then
try
TAction(Sender).HelpKeyword := Protocols_All.GetXStsPic(nil, True);
except
end;
end
else if Sender is TRQMenuItem then
begin
TRQMenuItem(Sender).visible := showXStatusMnu;
if TRQMenuItem(Sender).visible then
try
TRQMenuItem(Sender).ImageName := Protocols_All.GetXStsPic(nil, True);
except
end;
end;
end;
procedure TRnQmain.mAhideUpdateEx(Sender: TObject);
begin // tag = 3002
if formVisible(Self) then
begin
TRQMenuItem(Sender).ImageName := PIC_MINIMIZE;
TRQMenuItem(Sender).caption := getTranslation('Hide');
end
else
begin
TRQMenuItem(Sender).ImageName := PIC_RESTORE;
TRQMenuItem(Sender).caption := getTranslation('Show');
end;
end;
procedure TRnQmain.menuPopup(Sender: TObject);
var
ev: TaMenuItemUpd;
begin
for ev in aMainMenuUpd do
if Assigned(ev.amiuMenu) then
ev.amiuEv(ev.amiuMenu);
for ev in aMainMenuUpd2 do
if Assigned(ev.amiuMenu) then
ev.amiuEv(ev.amiuMenu);
end;
procedure TRnQmain.StatusMenuPopup(Sender: TObject);
var
ev: TaMenuItemUpd;
begin
for ev in aStatusMenuUpd do
if Assigned(ev.amiuMenu) then
ev.amiuEv(ev.amiuMenu);
end;
procedure TRnQmain.CMMouseEnter(var Msg: TMessage);
begin
inherited;
if Pointer(Msg.LParam) = Pointer(roster) then
if (transparency.chgOnMouse) and not FMouseInControl then
begin
if AlphaBlend then
AlphaBlendValue := transparency.active;
FMouseInControl := True;
end;
end;
procedure TRnQmain.CMMouseLeave(var Msg: TMessage);
begin
inherited;
if Pointer(Msg.LParam) = Pointer(roster) then
if (transparency.chgOnMouse) and FMouseInControl then
begin
if AlphaBlend then
if Handle <> getForegroundWindow then
AlphaBlendValue := transparency.inactive;
FMouseInControl := False;
end;
end;
procedure TRnQmain.WMNCActivate(var Msg: TWMNCActivate);
begin
inherited;
applyTransparency;
end;
procedure TRnQmain.Showallcontactsinone1Click(Sender: TObject);
begin
OnlOfflInOne := not OnlOfflInOne;
// design_fr.prefToggleShowGroups;
rosterRebuildDelayed := TRUE;
end;
procedure TRnQmain.AContInOneUpdate(Sender: TObject);
begin
if OnlOfflInOne then
TAction(Sender).HelpKeyword := PIC_RIGHT
else
TAction(Sender).HelpKeyword := '';
end;
{ procedure TRnQmain.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do
begin
// Style := Style and (not WS_CAPTION);
// Style := Style and not WS_OVERLAPPEDWINDOW or WS_BORDER and (not WS_CAPTION);
Style := (Style or WS_POPUP) and (not WS_DLGFRAME);
// Style := Style or WS_SYSMENU;
// ExStyle := ExStyle or WS_EX_APPWINDOW or WS_EX_NOPARENTNOTIFY;
end;
end;
}
procedure TRnQmain.wmNCHitTest(var Msg: TWMNCHitTest);
begin
Inherited;
with Msg do
begin
if TopLbl.visible then
begin
IF YPos - Top <= TopLbl.Height THEN
if (XPos - Left < 10) or (XPos - Left - Width > -10) then
Result := HTSYSMENU
else
Result := HTCAPTION;
if within(0, YPos - Top, 5) then
if within(-5, XPos - Left - Width, 0) then
Result := HTTOPRIGHT
else if within(0, XPos - Left, 5) then
Result := HTTOPLEFT;
end;
if (within(-5, YPos - ClientRect.Bottom, 0) and within(-5, XPos - ClientRect.Right, 0)) then
Result := HTBOTTOMRIGHT;
end;
end;
procedure TRnQmain.onCloseSomeWindows(Sender: TObject; var Action: TCloseAction);
begin
Inherited;
Action := caFree;
end;
procedure TRnQmain.previewFormKeyPress(Sender: TObject; var Key: Char);
begin
case Key of
#27:
begin
(Sender as TForm).Close;
Key := #0;
end;
end;
end;
procedure TRnQmain.imgMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
StartX := X;
StartY := Y;
end;
procedure TRnQmain.imgMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
ShfX, ShfY: Integer;
ks: TKeyBoardState;
vertScroll, horizScroll: TControlScrollBar;
img: TImage;
begin
img := Sender as TImage;
vertScroll := (img.parent as TScrollBox).VertScrollBar;
horizScroll := (img.parent as TScrollBox).HorzScrollBar;
if (vertScroll.IsScrollBarVisible) or (horizScroll.IsScrollBarVisible) then
begin
img.Cursor := crSizeAll;
img.DragCursor := crSizeAll;
end
else
begin
img.Cursor := crDefault;
img.DragCursor := crDefault;
end;
GetKeyBoardState(ks);
if ks[VK_LBUTTON] >= 128 then
begin
ShfY := StartY - Y;
ShfX := StartX - X;
vertScroll.Position := vertScroll.Position + ShfY;
horizScroll.Position := horizScroll.Position + ShfX;
end;
end;
procedure TRnQmain.MemoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Sender is TMemo) then
begin
if (Key = $41) and (ssCtrl in Shift) then
TMemo(Sender).SelectAll
end
else
Inherited;
end;
procedure TRnQmain.ReStart(Sender: TObject);
begin
try
quitUser;
if Assigned(StatusIcon) then
begin
if Assigned(StatusIcon.TrayIcon) then
StatusIcon.TrayIcon.Hide;
StatusIcon.Empty;
end;
except
end;
RQUtil.restartApp;
end;
// function TRnQmain.AddMainMenuItem(wPar: WPARAM; lPar: LPARAM): Integer; cdecl;
function TRnQmain.AddContactMenuItem(pMI: PCLISTMENUITEM): Integer; // cdecl;
{ function TRnQmain.AddContactMenuItem(pPluginProc : Pointer; menuIcon: hIcon; menuCaption:String;
menuHint:string; //procIdx : Integer;
position : Integer;
PopupName : String; popupPosition : Integer;
hotKey : DWORD; PicName : String = ''):integer; }
var
// clMI : TCLISTMENUITEM;
str, Str1: String;
i: Integer;
MI: TRQMenuItem;
PM: TRQMenuItem;
MM: TMenuItem;
// Ic : TIcon;
// bmp : TBitmap;
begin
// Str :=String(wPar);
// clMI := PCLISTMENUITEM(lPar)^;
if pMI.cbSize <> sizeof(TCLISTMENUITEM) then
begin
Result := 0;
Exit;
end;
// Str := pMI.pszName;
MI := TRQMenuItem.Create(Self);
MI.caption := UnUTF(pMI.pszName);
MI.Hint := UnUTF(pMI.pszHint);
if (pMI.hIcon <> 0) then
begin
ico2bmp2(pMI.hIcon, MI.Bitmap);
end;
// MI.ServiceName := clMI.pszService;
MI.PluginProc := pMI.Proc;
// MI.Plugin := pPlugin;
// MI.ProcIdx := procIdx;
if pMI.Proc = NIL then
MI.OnClick := NIL
else
MI.OnClick := OnPluginMenuClick;
MI.ImageName := pMI.pszPic;
MI.Enabled := (pMI.flags and RQFM_DISABLED) = 0;
MI.visible := (pMI.flags and RQFM_HIDDEN) = 0;
MM := contactMenu.Items;
str := UnUTF(pMI.pszPopupName);
if str <> '' then
begin
Str1 := str;
while str > '' do
begin
i := pos('\', str);
if i = 0 then
i := length(str) + 1;
Str1 := copy(str, 1, i - 1);
delete(str, 1, i + length('\') - 1);
if Assigned(MM.Find(Str1)) then
MM := TMenuItem(MM.Find(Str1))
else
begin
PM := TRQMenuItem.Create(contactMenu);
PM.caption := Str1;
MM.add(PM);
MM := PM;
// PM.Add(MI);
end;
end;
end;
// else
// contactMenu.Items.Insert(12, MI);
MM.add(MI);
Result := MI.Handle;
end;
// function TRnQmain.UpdateContactMenuItem(menuHandle: hmenu; pMI : PCLISTMENUITEM ): Integer;// cdecl;
Procedure TRnQmain.UpdateContactMenuItem(menuHandle: hmenu; pMI: PCLISTMENUITEM); // cdecl;
function findItem(item: TMenuItem): TMenuItem;
var
i: Integer;
begin
Result := NIL;
if item.Handle = menuHandle then
Result := item
else if item.Count > 0 then
for i := 0 to item.Count - 1 do
begin
// if item.Items[i].Count > 0 then
Result := findItem(item.Items[i]);
if Result <> NIL then
break;
end;
end;
var
MI: TMenuItem;
begin
MI := findItem(contactMenu.Items);
if MI <> NIL then
begin
if (pMI.flags and RQFM_UPD_CAPTION) > 0 then
MI.caption := UnUTF(pMI.pszName);
if (pMI.flags and RQFM_UPD_HINT) > 0 then
MI.Hint := UnUTF(pMI.pszHint);
if (pMI.flags and RQFM_UPD_ENABLE) > 0 then
MI.Enabled := (pMI.flags and RQFM_DISABLED) = 0;
if (pMI.flags and RQFM_UPD_VISIBLE) > 0 then
MI.visible := (pMI.flags and RQFM_HIDDEN) = 0;
if (pMI.flags and RQFM_UPD_ICON) > 0 then
if (pMI.hIcon <> 0) then
ico2bmp2(pMI.hIcon, MI.Bitmap)
else
begin
MI.Bitmap := NIL; // .Empty := True;
end;
end;
// Result := mi
end;
procedure TRnQmain.DelContactMenuItem(menuHandle: hmenu);
function findItem(item: TMenuItem): TMenuItem;
var
i: Integer;
begin
Result := NIL;
if item.Handle = menuHandle then
Result := item
else if item.Count > 0 then
for i := 0 to item.Count - 1 do
begin
// if item.Items[i].Count > 0 then
Result := findItem(item.Items[i]);
if Result <> NIL then
break;
end;
end;
var
item, parItem: TMenuItem;
begin
item := findItem(contactMenu.Items);
if item <> NIL then
begin
parItem := item.parent;
parItem.remove(item);
item.free;
while (parItem <> contactMenu.Items) and (parItem.Count = 0) do
begin
item := parItem;
parItem := item.parent;
parItem.remove(item);
item.free;
end;
end;
end;
procedure TRnQmain.OnPluginMenuClick(Sender: TObject);
var
// pr : procedure(uid:String);
pr: procedure(uid: RawByteString);
begin
if Sender is TRQMenuItem then
begin
if TRQMenuItem(Sender).PluginProc <> NIL then
// if (TRQMenuItem(Sender).Plugin^) is Tplugin then
begin
pr := TRQMenuItem(Sender).PluginProc;
pr(clickedContact.UID2cmp);
// Tplugin(TRQMenuItem(Sender).Plugin).cast(
// char(PM_EVENT)+char(PE_CONTACTMENUCLICK)+_int(TRQMenuItem(Sender).ProcIdx)+_int(StrToIntDef(clickedContact.UID, 0))
// )
end;
end;
end;
procedure TRnQmain.OnTrayEvent(Sender: TObject; ev: TTrayEvent);
begin
if not locked and running then
case ev of
TE_CLICK:
begin
if (not useSingleClickTray)
// or (useSingleClickTray and RnQmain.Visible and not alwaysOnTop and not (RnQmain.handle=getForegroundWindow))
then
SetForegroundWindow(self.Handle)
else
begin
// mainfrm.toggleVisible
// if not mainFrm.Visible then
// mainFrm.toggleVisible;
trayAction;
end;
end;
TE_2CLICK: if (not useSingleClickTray) then trayAction;
TE_RCLICK:
if GetAsyncKeyState(VK_CONTROL) shr 7 <> 0 then
eventQ.clear
else
begin
ForceForegroundWindow(self.handle);
with mousePos do
menu.Popup(x, y);
end;
end;
end;
procedure TRnQmain.WMRestoreApp(var Msg: TMessage);
begin
if IsIconic(Application.Handle) then
Application.RESTORE
else
Application.BringToFront;
end;
procedure TRnQmain.DefaultHandler(var Message);
var
Len: Integer;
Data: String;
DataArr: TArray;
begin
with TMessage(Message) do
if Msg = WM_FINDINSTANCE then
begin
Result := 1337;
end else if Msg = WM_HANDLEICQLINK then
begin
SetLength(Data, MAX_PATH);
Len := GlobalGetAtomName(WPARAM, PChar(Data), MAX_PATH);
GlobalDeleteAtom(WPARAM);
SetLength(Data, Len);
ProcessICQLink(Data);
end else inherited DefaultHandler(message);
end;
initialization
WM_FINDINSTANCE := RegisterWindowMessage('Unique R&Q message');
MonPositions := TDictionary.Create;
finalization
FreeAndNil(MonPositions);
end.