📄 myqqdlg.cpp
字号:
for(int i=1; i<6; i++)
{
int j=rand()%10;
m_List2.InsertItem(0xffff,"", -1);
m_List2.InsertItem(0xffff,myClass[j], j);
}
m_List2.InsertItem(0xffff,"", -1);
// 显示该栏目的下的QQ联系人或其它, 隐藏其它栏目;
m_List1.ShowWindow(SW_HIDE);
treeCtrl.ShowWindow(SW_HIDE);
m_List2.ShowWindow(SW_SHOW);
return;
}
//*/
//////////////////////////////////////////////////////////////////////////
}
void CMyQQDlg::DisplayQQface()
{
//////////////////////////////////////////////////////////////////////////
//此处将显示的图片加入到图像列表里面去
m_imagelist1.Create(16, 16, ILC_COLOR32, 1, 1); // 小头像
m_imagelist2.Create(40, 40, ILC_COLOR32, 1, 1); // 大头像
// 显示群树的图像
m_treeQunimage.Create(20, 20, ILC_COLOR32, 1, 1);
m_treeQunimage.Add(AfxGetApp()->LoadIcon(IDI_QQQUN));
CBitmap *bmp=new CBitmap;
CString str;
for(int i=1; i<109; i++)
{
str.Format("qqface\\%d_m.bmp", i);
bmp->m_hObject=(HBITMAP)LoadImage
(NULL, str, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_imagelist1.Add(bmp, RGB(0, 0, 0));
m_treeQunimage.Add(bmp, RGB(0, 0, 0));
str.Format("qqface\\%d.bmp", i);
bmp->m_hObject=(HBITMAP)LoadImage
(NULL, str, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
m_imagelist2.Add(bmp, RGB(0, 0, 0));
}
delete bmp;
}
void CMyQQDlg::OnQqqun()
{
// TODO: Add your control notification handler code here
PlaySound("folder.wav", AfxGetResourceHandle(),
SND_RESOURCE|SND_ASYNC|SND_NODEFAULT);
clicknum=2;
if(TopButtonNum==2)
{
// QQ群按钮已在上层, 再次点击没反应;
return;
}
ChangeView();
TopButtonNum=2;
}
void CMyQQDlg::OnOthers()
{
// TODO: Add your control notification handler code here
clicknum=3;
PlaySound("folder.wav", AfxGetResourceHandle(),
SND_RESOURCE|SND_ASYNC|SND_NODEFAULT);
if(TopButtonNum==3)
{
// QQ群按钮已在上层, 再次点击没反应;
return;
}
ChangeView();
TopButtonNum=3;
}
void CMyQQDlg::OnShowmax()
{
isBigFace=true;
clicknum=1;
TopButtonNum=!1;
ChangeView();
}
void CMyQQDlg::OnShowmin()
{
isBigFace=false;
clicknum=1;
TopButtonNum=!1;
ChangeView();
}
void CMyQQDlg::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
CMenu menu;
VERIFY(menu.LoadMenu(IDR_CHANGEPIC));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CWnd* pWndPopupOwner = this;
CPoint pt;
GetCursorPos(&pt);
pPopup->TrackPopupMenu(
TPM_LEFTALIGN ,
pt.x,
pt.y,
pWndPopupOwner);
}
void CMyQQDlg::OnQqmenu()
{
CMenu menu;
VERIFY(menu.LoadMenu(IDR_QQMENU));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CWnd* pWndPopupOwner = this;
CPoint pt;
GetCursorPos(&pt);
CRect rect;
GetDlgItem(IDC_QQMENU)->GetClientRect(&rect);
ClientToScreen(&rect);
pPopup->TrackPopupMenu(
TPM_LEFTBUTTON||TPM_RIGHTALIGN ,
rect.left,
pt.y-GetSystemMetrics(SM_CYMENUSIZE)*pPopup->GetMenuItemCount(),
pWndPopupOwner);
}
void CMyQQDlg::OnQqstatus()
{
CMenu menu;
VERIFY(menu.LoadMenu(IDR_QQSTATUS));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CWnd* pWndPopupOwner = this;
CPoint pt;
GetCursorPos(&pt);
pPopup->TrackPopupMenu(TPM_RIGHTALIGN,
pt.x, pt.y, pWndPopupOwner);
}
void CMyQQDlg::OnHidden()
{
m_hIcon=AfxGetApp()->LoadIcon(IDI_HIDDEN);
m_statusPic.SetIcon(m_hIcon);
nid.hIcon = m_hIcon;
Shell_NotifyIcon(NIM_MODIFY,&nid);
}
void CMyQQDlg::OnOnline()
{
m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_statusPic.SetIcon(m_hIcon);
nid.hIcon = m_hIcon;
Shell_NotifyIcon(NIM_MODIFY,&nid);
}
void CMyQQDlg::OnOutline()
{
m_hIcon=AfxGetApp()->LoadIcon(IDI_NOTONLINE);
m_statusPic.SetIcon(m_hIcon);
nid.hIcon = m_hIcon;
Shell_NotifyIcon(NIM_MODIFY,&nid);
}
void CMyQQDlg::OnExit()
{
// TODO: Add your command handler code here
OnSysCommand(IDM_ABOUTBOX, 0);
isClose=true;
SendMessage(WM_CLOSE);
}
void CMyQQDlg::OnDblclkQQqunTree(NMHDR* pNMHDR, LRESULT* pResult)
{
CString str;
//NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
CTreeCtrl *treeCtrl=new CTreeCtrl;
treeCtrl=(CTreeCtrl *)GetDlgItem(ID_QQTREE);
HTREEITEM hSet=treeCtrl->GetSelectedItem();
str=treeCtrl->GetItemText(hSet);
for(int i=0; i<sizeof(treeItem)/sizeof(treeItem[0]); i++)
{
if(str==treeItem[i])
return;
}
CQQSendMessage *dlg=new CQQSendMessage;
dlg->msg=str;
dlg->Create(IDD_QQ_MESSAGE);
dlg->SetWindowText("你正在与群内的"+str+"聊天当中");
dlg->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), false);
dlg->ShowWindow(SW_SHOW);
*pResult = 0;
}
void CMyQQDlg::OnDblclkMyFriend(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
int m_nCurrentSel = pNMListView->iItem;
CString str;
str=m_List1.GetItemText(m_nCurrentSel, NULL);
CQQSendMessage *dlg=new CQQSendMessage;
dlg->msg=str;
dlg->Create(IDD_QQ_MESSAGE);
dlg->SetWindowText("你正在与"+str+"聊天当中");
dlg->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), false);
dlg->ShowWindow(SW_SHOW);
*pResult = 0;
}
BOOL CMyQQDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam==VK_ESCAPE)
{
{
return 1;
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
void CMyQQDlg::DisplayInTask()
{
if(isDisplayInTask)
{
//初始化nid
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd =this->m_hWnd;
nid.uID = IDR_QQMENU;
nid.uFlags = NIF_ICON | NIF_TIP|NIF_MESSAGE ;
nid.hIcon = m_hIcon;
strcpy (nid.szTip, "任务栏图标");
nid.uCallbackMessage=WM_DISPLAYTASKICON;
Shell_NotifyIcon(NIM_ADD,&nid);
isDisplayInTask=FALSE;
}
else
{
Shell_NotifyIcon(NIM_DELETE,&nid);
isDisplayInTask=true;
}
}
LRESULT CMyQQDlg::OnDisplayTaskIcon(WPARAM wParam, LPARAM lParam)
{
if(wParam!=nid.uID)
{
MessageBox("heloo");
return 1;
}
//////////////////////////////////////////////////////////////////////////
// 对事件进行判断
switch(lParam)
{
case WM_RBUTTONUP:
{
LPPOINT point=new tagPOINT;
GetCursorPos(point);
CMenu menu, *pSubMenu=NULL;
menu.LoadMenu(IDR_QQMENU);
if(!(pSubMenu=menu.GetSubMenu(0)))
{
return 0;
}
::TrackPopupMenu(pSubMenu->m_hMenu, 0,
point->x, point->y, 0, this->m_hWnd, NULL);
menu.DestroyMenu();
delete point;
}
break;
case WM_LBUTTONDBLCLK:
MoveWindow(GetSystemMetrics(SM_CXSCREEN)-dlgrect.Width()-20, 3,
dlgrect.Width(), dlgrect.Height(), true);
ShowWindow(SW_SHOWNORMAL);
break;
}
return 0;
}
void CMyQQDlg::OnClose()
{
//////////////////////////////////////////////////////////////////////////
/// 此处设置关闭功能;
if(isClose)
{
isDisplayInTask=false;
DisplayInTask();
CDialog::OnClose();
return;
}
MoveWindow(GetSystemMetrics(SM_CXSCREEN)-dlgrect.Width()-20, 4,
dlgrect.Width(), dlgrect.Height(), true);
ShowWindow(SW_HIDE);
}
LRESULT CMyQQDlg::OnMymouseMove(WPARAM wParam, LPARAM lParam)
{
LPPOINT pt=new CPoint;
GetCursorPos(pt);
CRect rect;
GetWindowRect(&rect);
if(rect.PtInRect(*pt))
{
if(rect.top<=2)
{
MoveWindow(rect.left, rect.top,
dlgrect.Width(), dlgrect.Height(), true);
}
}
else
{
if(rect.top<=2)
{
MoveWindow(rect.left, 0, rect.Width(), 3, true);
}
}
delete pt;
return true;
}
void CMyQQDlg::OnTimer(UINT nIDEvent)
{
if(nIDEvent==1)
{
//////////////////////////////////////////////////////////////////////////
// 获取当前鼠标的坐标,以判断是否可以伸缩对话框;
SendMessage(WM_MYMOUSEMOVE, NULL, NULL);
}
CDialog::OnTimer(nIDEvent);
}
void CMyQQDlg::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnLButtonDblClk(nFlags, point);
}
void CMyQQDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnLButtonDown(nFlags, point);
CMainDlg dlg;
dlg.DoModal();
}
void CMyQQDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnRButtonDown(nFlags, point);
CMainInfo dlg;
dlg.DoModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -