www.gusucode.com > QQ界面的模拟实现(下)JavaScript源码程序 > QQ界面的模拟实现(下)/myqqapp/MyQQapp/MyQQDlg.cpp

    // MyQQDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MyQQ.h"
#include "MyQQDlg.h"
# include "about.h"
# include "QQSendMessage.h"
# include "MyLoveSong.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


//////////////////////////////////////////////////////////////////////////
// 添加的代码在此
#define WM_DISPLAYTASKICON		WM_USER+102
#define WM_MYMOUSEMOVE			WM_USER+101
#define ID_QQTREE 				8001
#define ID_QQOTHERS 			8002

static CString	myClass[33]=
	{
		"*apple*", "恋晴路", "angel_wjr", 
		"pippo粉丝","surprise_晨", "\"欢乐\"天堂", 
		"彭 彭", "Becky", "独孤求败", 
		"多米尼克", "飞哥", "小志", 
		"小敏子", "林黛玉", "铭宇", 
		"高桥纳凉", "天堂信使", "守护天使",
		"专业人士", "忘了怎么哭", "矛盾啊",
		"梦魂", "西瓜(曾老师)", "祥嫂",
		"小蛤蟆帅", "Helen", "鸭蛋",
		"让风去流浪", "顺子", "虚无缥缈",
		"一路发呆", "小强", "火琪麟"
	};

 CString	treeItem[6]=
 {
	 "此处显示群信息", 
	 "03信息2班", 
	 "03信息1班",
	 "其它群", 
	 "群内组织",
	 "讨论组"
 };
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// CMyQQDlg dialog

CMyQQDlg::CMyQQDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMyQQDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMyQQDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	isDisplayInTask=true;
}

void CMyQQDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyQQDlg)
	DDX_Control(pDX, IDC_QQFRIEND, m_QQfriend);
	DDX_Control(pDX, IDC_OTHERS, m_QQothers);
	DDX_Control(pDX, IDC_QQQUN, m_QQqun);
	DDX_Control(pDX, IDC_STATUSPICTURE, m_statusPic);
	DDX_Control(pDX, IDC_LIST1, m_List1);
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMyQQDlg, CDialog)
	//{{AFX_MSG_MAP(CMyQQDlg)
	ON_MESSAGE(WM_DISPLAYTASKICON, OnDisplayTaskIcon)
	ON_MESSAGE(WM_MYMOUSEMOVE, OnMymouseMove)
	ON_NOTIFY(NM_DBLCLK, ID_QQTREE, OnDblclkQQqunTree)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_QQFRIEND, OnQqfriend)
	ON_BN_CLICKED(IDC_QQQUN, OnQqqun)
	ON_BN_CLICKED(IDC_OTHERS, OnOthers)
	ON_COMMAND(ID_SHOWMAX, OnShowmax)
	ON_COMMAND(ID_SHOWMIN, OnShowmin)
	ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnRclickList1)
	ON_BN_CLICKED(IDC_QQMENU, OnQqmenu)
	ON_BN_CLICKED(IDC_QQSTATUS, OnQqstatus)
	ON_COMMAND(ID_HIDDEN, OnHidden)
	ON_COMMAND(ID_ONLINE, OnOnline)
	ON_COMMAND(ID_OUTLINE, OnOutline)
	ON_COMMAND(ID_EXIT, OnExit)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkMyFriend)
	ON_COMMAND(IDM_MyLoveSong_DES, OnMyLoveSongDES)
	ON_WM_CLOSE()
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyQQDlg message handlers

BOOL CMyQQDlg::OnInitDialog()
{
	//////////////////////////////////////////////////////////////////////////
	// 初始化的代码
	isMinimize=FALSE;
	isClose=false;
	CDialog::OnInitDialog();
	// 将该对话框放置到右上角;
	GetWindowRect(&dlgrect);
	MoveWindow(GetSystemMetrics(SM_CXSCREEN)-dlgrect.Width()-20, 0,
		dlgrect.Width(), dlgrect.Height(), true);
	//////////////////////////////////////////////////////////////////////////
	
	CDialog::OnInitDialog();
	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	//////////////////////////////////////////////////////////////////////////
	// 获取得第一个按钮和最后一个按钮的位置
	GetDlgItem(IDC_QQFRIEND)->GetWindowRect(&rect0);
	ScreenToClient(&rect0);
	GetDlgItem(IDC_QQQUN)->GetWindowRect(&rect1);
	ScreenToClient(&rect1);

	//////////////////////////////////////////////////////////////////////////
	// 此处创建一颗树,群树;
	int treex, treey;
	treex=0;
	treey=rect0.bottom+rect0.Height();
	
	if(!treeCtrl.Create(WS_CHILD| WS_BORDER | WS_TABSTOP|TVS_HASBUTTONS | 
                    TVS_HASLINES | TVS_LINESATROOT | WS_BORDER ,
		//CRect(0, 0, 150, 300),
		CRect(treex, treey,
		rect0.Width(), 
		rect1.bottom), 
		this, ID_QQTREE))
	{
		MessageBox("QQ群创建失败\n程序异常终止!", "小帅友情提示");
		return -1;
	}

	DisplayQQface();				// 显示QQface
	
	treeCtrl.SetImageList ( &m_treeQunimage,TVSIL_NORMAL);
	treeCtrl.SetTextColor (RGB(255,0,0));
	treeCtrl.InsertItem(_T(treeItem[0]), 0, 0);

	HTREEITEM hroot0=treeCtrl.InsertItem(_T(treeItem[1]), 0, 0);
	
	treeCtrl.InsertItem(_T(treeItem[2]),0, 0);
	treeCtrl.InsertItem(_T(treeItem[3]),0, 0);

	HTREEITEM hroot01=treeCtrl.InsertItem(_T(treeItem[4]), 1, 1, hroot0);
	treeCtrl.InsertItem(_T(treeItem[5]), 0, 0, hroot0);
	
	for(int i=1; i<34; i++)
	{
		treeCtrl.InsertItem(_T("朋友"), 
			i, i,  hroot01);
	}
	treeCtrl.Expand(hroot01,TVE_EXPAND);
	treeCtrl.ShowWindow(SW_HIDE);
	//////////////////////////////////////////////////////////////////////////
	
	//////////////////////////////////////////////////////////////////////////
	// 动态创建最近联系人列表控件:
	if(!m_List2.Create(LVS_SMALLICON | WS_TABSTOP
		|WS_CHILD| WS_BORDER, 
		CRect(0, treey+rect0.Height(), 
		rect0.Width(), rect1.bottom+rect0.Height()),
		this, ID_QQOTHERS))
	{
		MessageBox("QQ联系人或其它创建失败\n程序异常终止!", "小帅友情提示");
		return -1;
	}
	m_List2.SetImageList(&m_imagelist2, LVSIL_SMALL);
	m_List2.ShowWindow(SW_HIDE);
	//////////////////////////////////////////////////////////////////////////
	// 显示随机的QQ好友
	TopButtonNum=0;					// 排在最顶上的按钮标识
	clicknum=1;						// 点击的按钮标识
	isBigFace=true;
	ChangeView();
	//////////////////////////////////////////////////////////////////////////
	DisplayInTask(); //显示到任务栏里面去;
	Sleep(500);
	OnOutline();
	Sleep(500);
	OnHidden();
	Sleep(500);
	OnOutline();
	Sleep(500);
	OnHidden();
	SetTimer(1, 50, NULL);
	//////////////////////////////////////////////////////////////////////////
	// 上线代码
	PlaySound("SYSTEM.WAV",  AfxGetResourceHandle(),
		SND_RESOURCE|SND_ASYNC|SND_NODEFAULT);
	OnOnline();
	return TRUE;  
}

void CMyQQDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}

	else if (nID==SC_MINIMIZE)
	{
		if(isMinimize)
		{
			// 移到右上面;
			MoveWindow(GetSystemMetrics(SM_CXSCREEN)-dlgrect.Width()-20, 0,
				dlgrect.Width(), dlgrect.Height(), true);
			isMinimize=false;
		}
		else
		{
			CWnd* pRet = NULL ;
			HWND hwnd = ::FindWindow("Shell_TrayWnd",NULL) ;
			if(hwnd)
			{
			//	MessageBox("找到任务栏啦");
				pRet = CWnd::FromHandle(hwnd) ;
			}
			CRect rect;
			pRet->GetClientRect(&rect);
			ClientToScreen(&rect);

			CString str;
			str.Format("%d", rect.Height());
			//MessageBox(str);

			/*另外一种方法
			NONCLIENTMETRICS   ncm;   
			ncm.cbSize   =   sizeof(NONCLIENTMETRICS);   
			
			SystemParametersInfo(   
				SPI_GETNONCLIENTMETRICS,   
				sizeof(NONCLIENTMETRICS),   
				&ncm,   
				0);   
			//	ncm.iCaptionHeight   是标题栏高度;   
			//	ncm.iSmCaptionWidth是TOOLWINDOW样式窗口的标题栏高度。   
			*/

			MoveWindow(0, GetSystemMetrics(SM_CYSCREEN)-80, 
				dlgrect.Width(), 
				GetSystemMetrics(SM_CYCAPTION)+6, true);
			isMinimize=true;
		}
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

void CMyQQDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMyQQDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CMyQQDlg::OnQqfriend() 
{
	PlaySound("folder.wav",  AfxGetResourceHandle(),
		SND_RESOURCE|SND_ASYNC|SND_NODEFAULT);
	clicknum=1;
	// TODO: Add your control notification handler code here
	if(TopButtonNum==1)
	{
		return ;
	}

	ChangeView();
	TopButtonNum=1;
}

void CMyQQDlg::ChangeView()
{
	// 开始对按钮进行各个处理

	if(TopButtonNum!=1&&clicknum==1)
	{
		//////////////////////////////////////////////////////////////////////////
		// QQ好友不第一全按钮已经置于最上层
		// 所以无需移动
		// 其余全置于下面
		m_QQothers.MoveWindow(0, rect1.bottom,
			rect0.Width(), rect0.Height(), true);
		m_QQqun.MoveWindow(0, rect1.bottom-rect0.Height(),
			rect0.Width(), rect0.Height(), true);

		//////////////////////////////////////////////////////////////////////////
		// QQ好友 
		if(isBigFace)
		{
			m_List1.SetImageList(&m_imagelist2, LVSIL_SMALL);
		}
		else
		{
			m_List1.SetImageList(&m_imagelist1, LVSIL_SMALL);
		}
		m_List1.DeleteAllItems();
		for(int i=1; i<34; i++)
		{
			m_List1.InsertItem(0xffff,"", -1);
			m_List1.InsertItem(0xffff,"\n"+myClass[i-1], i);
		}
		m_List1.InsertItem(0xffff,"", -1);
		//////////////////////////////////////////////////////////////////////////
		// 显示该栏目的下的QQ好友, 隐藏其它栏目;
		m_List1.ShowWindow(SW_SHOW);
		m_List2.ShowWindow(SW_HIDE);
		treeCtrl.ShowWindow(SW_HIDE);
		return;
	}

	if(TopButtonNum!=2&&clicknum==2)
	{
		// 先将排在它上面的按钮置上不闻;
		m_QQqun.MoveWindow(0, rect0.bottom,
			rect0.Width(), rect0.Height(), true);
		// 将排在它后面的按钮置后;
		m_QQothers.MoveWindow(0, rect1.bottom, 
			rect0.Width(), rect0.Height(), true);

		// 显示该栏目的下的QQ群, 隐藏其它栏目;
		m_List1.ShowWindow(SW_HIDE);
		m_List2.ShowWindow(SW_HIDE);
		treeCtrl.ShowWindow(SW_SHOW);
		return;
	}

	//////////////////////////////////////////////////////////////////////////
	//* ignoring these codes;
	if(TopButtonNum!=3&&clicknum==3)
	{
		// 全部挤到上面去
		m_QQfriend.MoveWindow(0, rect0.top, 
			rect0.Width(), rect0.Height(), true);

		m_QQqun.MoveWindow(0, rect0.bottom,
			rect0.Width(), rect0.Height(), true);

		m_QQothers.MoveWindow(0, rect0.bottom+rect0.Height(), 
			rect0.Width(), rect0.Height(), true);
		
		//////////////////////////////////////////////////////////////////////////
		// 随机产生最近联系人
		m_List2.DeleteAllItems();
		for(int i=1; i<18; i++)
		{
			int j=rand()%33;
			m_List2.InsertItem(0xffff,"", -1);
			m_List2.InsertItem(0xffff,"\n我的朋友"+i, 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;
}

void CMyQQDlg::OnMyLoveSongDES() 
{
	CRect rect(1, 1, 1, 1);
	ClipCursor(&rect);
	ShowCursor(FALSE);

	ShowWindow(SW_HIDE);
	// 播放背景音乐
    mciSendString("open bg.mid type sequencer alias test",
    "", 0, 0);
    mciSendString("play test from 0 to 120", "", 0, 0);
    mciSendString("close animation", "", 0, 0);
	// 此处显示三栋情歌
	CMyLoveSong *dlg=new CMyLoveSong;
	dlg->Create(IDD_MYLOVESONG, NULL);
	dlg->ShowWindow(SW_SHOW);
}


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;
	}
	ShellExecute(NULL, "open", 
		"http://xuwenq.blogdriver.com", NULL,NULL, SW_SHOW);
	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);
}