📄 myicqdlg.cpp
字号:
void CIcqDlg::OnFindContact()
{
IcqWindow *win = findWindow(WIN_SEARCH_WIZARD);
if (!win) {
CSearchWizard *dlg = new CSearchWizard;
dlg->Create();
}
}
void CIcqDlg::OnTimer(UINT nIDEvent)
{
if (nIDEvent == IDT_RESEND)
checkSendQueue();
else if (nIDEvent == IDT_KEEPALIVE)
serverSession()->sendKeepAlive();
else if (nIDEvent == IDT_STATUS) {
static int frame = 0;
HICON hIcon = statusImgList.ExtractIcon(frame);
m_btnStatus.SetIcon(hIcon);
modifyNotifyIcon(hIcon);
if (++frame >= 3)
frame = 0;
} else if (nIDEvent == IDT_BLINK) {
static int frame = 0;
frame ^= 1;
IcqMsg *msg = (IcqMsg *) msgList.front();
HICON icon = NULL;
if (msg->isSysMsg()) {
icon = (frame ? iconSysMsg : iconBlank);
m_btnSysMsg.SetIcon(icon);
} else {
IcqContact *c = findContact(msg->uin);
if (c)
icon = (frame ? getApp()->smallImageList.ExtractIcon(c->face) : iconBlank);
}
modifyNotifyIcon(icon);
} else if (nIDEvent == IDT_DBLCLK) {
KillTimer(nIDEvent);
CPoint pt;
GetCursorPos(&pt);
SetForegroundWindow();
popupStatusMenu(TPM_BOTTOMALIGN | TPM_RIGHTALIGN, pt);
} else if (nIDEvent == IDT_HOVER) {
CPoint pt;
GetCursorPos(&pt);
CRect rc;
GetWindowRect(rc);
rc.InflateRect(10, 10);
if (!rc.PtInRect(pt)) {
KillTimer(nIDEvent);
hideWindow();
}
} else if (nIDEvent == IDT_AUTO_SWITCH_STATUS) {
KillTimer(nIDEvent);
if (options.flags.test(UF_AUTO_SWITCH_STATUS)) {
switch (options.autoStatus) {
case STATUS_AWAY:
onStatusAway();
break;
case STATUS_INVIS:
OnStatusInvis();
break;
case STATUS_OFFLINE:
OnStatusOffline();
break;
}
}
} else
CCaptionBtnDlg::OnTimer(nIDEvent);
}
void CIcqDlg::OnSysMessage()
{
IcqMsg *msg = fetchMsg(0);
IcqWindow *win;
if (!msg) {
CSysHistoryDlg *pDlg;
win = findWindow(WIN_SYS_HISTORY);
if (!win) {
pDlg = new CSysHistoryDlg;
pDlg->Create(IDD_SYS_HISTORY);
} else {
pDlg = (CSysHistoryDlg *) win;
pDlg->ShowWindow(SW_NORMAL);
pDlg->BringWindowToTop();
}
} else {
CSysMsgDlg *win = new CSysMsgDlg(msg);
win->Create(IDD_SYS_MESSAGE);
}
}
void CIcqDlg::OnMainMenu()
{
CGfxPopupMenu menu;
CMenu tmp;
tmp.LoadMenu(IDR_MAIN);
menu.Attach(*tmp.GetSubMenu(0));
menu.modifyMenu(ID_CHANGE_USER, IDB_CHANGE_USER);
menu.modifyMenu(ID_REG_WIZARD, IDB_REG_WIZARD);
menu.modifyMenu(ID_MODIFY_INFO, IDB_VIEW_DETAIL);
menu.modifyMenu(ID_SYS_OPTION, IDB_SYS_OPTION);
menu.modifyMenu(ID_APP_EXIT, IDB_EXIT);
CRect rc;
m_btnMain.GetWindowRect(rc);
popupMainMenu(TPM_BOTTOMALIGN, rc.TopLeft());
}
void CIcqDlg::OnGfxSmallIcon()
{
outbarCtrl.setIconView(FALSE);
saveGroupInfo();
}
void CIcqDlg::OnUpdateGfxSmallIcon(CCmdUI* pCmdUI)
{
pCmdUI->Enable(outbarCtrl.isLargeIconView());
}
void CIcqDlg::OnGfxLargeIcon()
{
outbarCtrl.setIconView(TRUE);
saveGroupInfo();
}
void CIcqDlg::OnUpdateGfxLargeIcon(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!outbarCtrl.isLargeIconView());
}
void CIcqDlg::OnGfxFontColor()
{
CColorDialog dlg;
if (dlg.DoModal() == IDOK) {
outbarCtrl.setFontColor(dlg.GetColor());
saveGroupInfo();
}
}
void CIcqDlg::OnGfxBackground()
{
CColorDialog dlg;
if (dlg.DoModal() == IDOK) {
outbarCtrl.setBgColor(dlg.GetColor());
saveGroupInfo();
}
}
void CIcqDlg::OnGfxAddGroup()
{
outbarCtrl.addFolderUI();
saveGroupInfo();
}
void CIcqDlg::OnGfxRename()
{
outbarCtrl.renameUI();
}
void CIcqDlg::OnUpdateGfxAddGroup(CCmdUI* pCmdUI)
{
pCmdUI->Enable(outbarCtrl.getSelFolder() < outbarCtrl.getFolderCount() - 2);
}
void CIcqDlg::OnGfxRemove()
{
int obj = outbarCtrl.hitObj();
int index = outbarCtrl.hitIndex();
if (obj == OutBarCtrl::HT_FOLDER) {
if (outbarCtrl.getItemCount(index) > 0)
AfxMessageBox(IDS_GROUP_NOT_EMPTY);
else {
outbarCtrl.removeFolder(index);
saveGroupInfo();
}
} else if (obj == OutBarCtrl::HT_ITEM) {
IcqContact *c = outbarCtrl.contact(index);
int n = outbarCtrl.getFolderCount();
if (outbarCtrl.getSelFolder() < n - 2)
delFriend(c);
else {
outbarCtrl.removeItem(index);
contactList.remove(c);
IcqDB::delContact(c->uin);
saveGroupInfo();
delete c;
}
}
}
void CIcqDlg::OnModifyInfo()
{
CModifyDetailDlg *win = new CModifyDetailDlg;
win->Create();
}
void CIcqDlg::OnGfxShowOnline()
{
bool b = !outbarCtrl.showOnlineOnly();
outbarCtrl.setShowOnlineOnly(b);
options.flags.set(UF_SHOW_ONLINE, b);
IcqDB::saveOptions(options);
}
void CIcqDlg::OnStatus()
{
CRect rc;
m_btnStatus.GetWindowRect(rc);
popupStatusMenu(TPM_BOTTOMALIGN, rc.TopLeft());
}
void CIcqDlg::OnStatusOnline()
{
if (myInfo.status == STATUS_OFFLINE)
login();
else {
if (myInfo.status != STATUS_ONLINE) {
myInfo.status = STATUS_ONLINE;
serverSession()->changeStatus(myInfo.status);
}
updateStatusIcon();
}
}
void CIcqDlg::OnStatusOffline()
{
if (myInfo.status != STATUS_OFFLINE)
logout();
updateStatusIcon();
}
void CIcqDlg::OnStatusInvis()
{
if (myInfo.status == STATUS_OFFLINE)
login(STATUS_INVIS);
else {
if (myInfo.status != STATUS_INVIS) {
myInfo.status = STATUS_INVIS;
serverSession()->changeStatus(myInfo.status);
}
destroySession();
updateStatusIcon();
}
}
void CIcqDlg::OnStatusAwayNoReply()
{
options.flags.set(UF_AUTO_REPLY, false);
IcqDB::saveOptions(options);
onStatusAway();
}
void CIcqDlg::OnSysOption()
{
showOptions();
}
void CIcqDlg::OnStatusAwayCustom()
{
showOptions(1);
}
void CIcqDlg::OnStatusAway(UINT nID)
{
int pos = nID - ID_STATUS_AWAY;
StrList l;
IcqDB::loadAutoReply(l);
StrList::iterator it;
for (it = l.begin(); it != l.end(); ++it) {
if (pos-- <= 0)
break;
}
if (pos < 0) {
options.flags.set(UF_AUTO_REPLY);
options.autoReplyText = *it;
IcqDB::saveOptions(options);
onStatusAway();
}
}
void CIcqDlg::OnPlugin(UINT nID)
{
int pos = nID - ID_PLUGIN;
PtrList &l = PluginFactory::getPluginList();
PtrList::iterator it;
IcqPlugin *p = NULL;
int i = 0;
for (it = l.begin(); it != l.end(); ++it) {
p = (IcqPlugin *) *it;
if (p->type == ICQ_PLUGIN_NET || p->type == ICQ_PLUGIN_EXE) {
if (++i > pos)
break;
}
}
if (it != l.end()) {
p = (IcqPlugin *) *it;
CSendRequestDlg *dlg = new CSendRequestDlg(p->name.c_str(), curContact);
dlg->Create(IDD_SEND_REQUEST);
}
}
LRESULT CIcqDlg::OnHostFound(WPARAM wParam, LPARAM lParam)
{
WORD error = WSAGETASYNCERROR(lParam);
struct in_addr addr;
addr.s_addr = INADDR_NONE;
if (error == 0) {
struct hostent *hent = (struct hostent *) hostBuf;
addr = *(struct in_addr *) hent->h_addr;
}
IcqWindow *win = findWindow(WIN_REG_WIZARD);
if (win)
((CRegWizard *) win)->onHostFound(addr);
else
onHostFound(addr);
return TRUE;
}
LRESULT CIcqDlg::OnHotKey(WPARAM wParam, LPARAM lParam)
{
if (wParam == ID_HOTKEY)
onNotifyDblClk();
return 1;
}
LRESULT CIcqDlg::OnNotifyIcon(WPARAM wParam, LPARAM lParam)
{
if (wParam != ID_NOTIFYICON || !myInfo.uin)
return 0;
if (lParam == WM_LBUTTONDOWN)
SetTimer(IDT_DBLCLK, GetDoubleClickTime(), NULL);
else if (lParam == WM_RBUTTONUP) {
CPoint pt;
GetCursorPos(&pt);
SetForegroundWindow();
popupMainMenu(TPM_BOTTOMALIGN | TPM_RIGHTALIGN, pt);
} else if (lParam == WM_LBUTTONDBLCLK) {
KillTimer(IDT_DBLCLK);
onNotifyDblClk();
}
return 1;
}
BOOL CIcqDlg::OnToolTipText(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *) pNMHDR;
if (pNMHDR->idFrom == ID_TOOLTIP) {
if (serverSession()->sessionCount) {
CString str;
str.Format(IDS_NR_ONLINES, serverSession()->sessionCount);
strcpy(pTTT->szText, str);
} else {
pTTT->lpszText = (LPSTR) (LPCTSTR) AfxGetAppName();
pTTT->hinst = NULL;
}
}
return TRUE;
}
void CIcqDlg::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
if (lpMeasureItemStruct->CtlType == ODT_MENU && currentMenu)
currentMenu->MeasureItem(lpMeasureItemStruct);
else
CCaptionBtnDlg::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
}
void CIcqDlg::OnRegWizard()
{
if (!doRegWizard())
EndDialog(IDCANCEL);
}
void CIcqDlg::OnChangeUser()
{
doLogin();
outbarCtrl.Invalidate();
}
void CIcqDlg::OnAbout()
{
CAboutDlg dlg;
dlg.DoModal();
}
void CIcqDlg::OnDestroy()
{
destroyUser();
removeNotifyIcon();
CCaptionBtnDlg::OnDestroy();
}
void CIcqDlg::OnMoving(UINT fwSide, LPRECT pRect)
{
if (!options.flags.test(UF_TASKBAR_STYLE)) {
CCaptionBtnDlg::OnMoving(fwSide, pRect);
return;
}
CRect rcOld, rcWorkArea;
CPoint pt;
GetWindowRect(rcOld);
SystemParametersInfo(SPI_GETWORKAREA, 0, rcWorkArea, 0);
GetCursorPos(&pt);
int cxScreen = GetSystemMetrics(SM_CXSCREEN);
if (alignType == ALIGN_NONE) {
if (pt.y - rcWorkArea.top < 20) {
alignType = ALIGN_TOP;
pRect->top = 0;
} else if (pt.x - rcWorkArea.left < 20) {
alignType = ALIGN_LEFT;
pRect->left = 0;
winNormalSize = rcOld.Size();
} else if (rcWorkArea.right - pt.x < 20) {
alignType = ALIGN_RIGHT;
pRect->right = cxScreen;
winNormalSize = rcOld.Size();
}
if (alignType != ALIGN_NONE)
SetTimer(IDT_HOVER, 50, NULL);
}
if (alignType == ALIGN_TOP) {
if (pRect->top > 0)
alignType = ALIGN_NONE;
else {
pRect->top = 0;
pRect->bottom = rcOld.Height();
}
} else if (alignType == ALIGN_LEFT) {
if (pRect->left > 0) {
pRect->right = pRect->left + winNormalSize.cx;
pRect->bottom = pRect->top + winNormalSize.cy;
alignType = ALIGN_NONE;
} else {
pRect->left = 0;
pRect->right = rcOld.Width();
pRect->top = 0;
pRect->bottom = rcWorkArea.bottom;
}
} else if (alignType == ALIGN_RIGHT) {
if (pRect->right < cxScreen) {
pRect->left = pRect->right - winNormalSize.cx;
pRect->bottom = pRect->top + winNormalSize.cy;
alignType = ALIGN_NONE;
} else {
pRect->right = cxScreen;
pRect->left = pRect->right - rcOld.Width();
pRect->top = 0;
pRect->bottom = rcWorkArea.bottom;
}
}
if (alignType == ALIGN_NONE)
KillTimer(IDT_HOVER);
CCaptionBtnDlg::OnMoving(fwSide, pRect);
}
void CIcqDlg::OnSendEmail()
{
CString url = "mailto:";
url += curContact->email.c_str();
ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOW);
}
void CIcqDlg::OnHomePage()
{
ShellExecute(NULL, _T("open"), curContact->homepage.c_str(), NULL, NULL, SW_SHOW);
}
void CIcqDlg::OnAddAsFriend()
{
addFriend(curContact, 0);
}
void CIcqDlg::OnMsgHistory()
{
CMsgMgrWnd *pWnd = new CMsgMgrWnd;
if (pWnd->LoadFrame(IDR_MSGMGR))
pWnd->ActivateFrame(curContact->uin);
}
void CIcqDlg::OnMessageMgr()
{
CMsgMgrWnd *pWnd = new CMsgMgrWnd;
if (pWnd->LoadFrame(IDR_MSGMGR))
pWnd->ActivateFrame();
}
void CIcqDlg::OnBroadcastMsg()
{
CBroadcastDlg *win = new CBroadcastDlg;
win->Create(IDD_BROADCAST);
}
void CIcqDlg::OnOK()
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -