⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nukdlg.cpp

📁 一个界面类似QQ界面的小程序
💻 CPP
📖 第 1 页 / 共 3 页
字号:
					rcW.Width(),
					rcW.Height()+point.y-(m_ptCurPoint.y+m_rcCurRect.top), true);

				m_ptCurPoint.y=point.y-m_rcCurRect.top;
				CRect rc;
				GetWindowRect(rc);
				m_rcCurRect = rc;
			}

			Invalidate();
		}
		break;
	case(9):
		{
			CRect rcW;
			POINT point;
			GetWindowRect(rcW);//

			//实现拖动时窗体跟着右下角拉伸
			::GetCursorPos(&point);	//	

			if(point.y>rcW.top+400&&point.x>rcW.left+170)
			{
				MoveWindow(m_rcCurRect.left ,m_rcCurRect.top, 
					rcW.Width()+point.x-(m_ptCurPoint.x+m_rcCurRect.left),
					rcW.Height()+point.y-(m_ptCurPoint.y+m_rcCurRect.top), true);

				m_ptCurPoint.x=point.x-m_rcCurRect.left;
				m_ptCurPoint.y=point.y-m_rcCurRect.top;
				CRect rc;
				GetWindowRect(rc);
				m_rcCurRect = rc;
			}
			else if(point.y>rcW.top+400&&point.x<rcW.left+170)
			{
				MoveWindow(m_rcCurRect.left ,m_rcCurRect.top, 
					170,
					rcW.Height()+point.y-(m_ptCurPoint.y+m_rcCurRect.top), true);

				m_ptCurPoint.x=170;
				m_ptCurPoint.y=point.y-m_rcCurRect.top;
				CRect rc;
				GetWindowRect(rc);
				m_rcCurRect = rc;
			}
			else if(point.y<rcW.top+400&&point.x>rcW.left+170)
			{
				MoveWindow(m_rcCurRect.left ,m_rcCurRect.top, 
					rcW.Width()+point.x-(m_ptCurPoint.x+m_rcCurRect.left),
					400, true);

				m_ptCurPoint.x=point.x-m_rcCurRect.left;
				m_ptCurPoint.y=400;
				CRect rc;
				GetWindowRect(rc);
				m_rcCurRect = rc;
			}

			Invalidate();
		}
		break;
	default:
		break;
	}
	CDialog::OnTimer(nIDEvent);
}

void CNUKDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	m_bMouseDown=false;
	ReleaseCapture();
	KillTimer(1);		//关闭拖动时记数器 
	KillTimer(2);		//关闭拖动时记数器 
	KillTimer(3);		//关闭拖动时记数器 
	KillTimer(4);		//关闭拖动时记数器 
	KillTimer(5);		//关闭拖动时记数器 
	KillTimer(6);		//关闭右边拉伸时记数器 
	KillTimer(7);		//关闭拖动时记数器 
	KillTimer(8);		//关闭拖动时记数器
	KillTimer(9);		//关闭右下角拉伸时记数器 

	CDialog::OnLButtonUp(nFlags, point);
}

void CNUKDlg::ChangeWindowRgn(CDC *pDC)
{
	COLORREF col = RGB(255,0,255);

	CRect rcClient;
	GetClientRect (rcClient);
	CRgn rgn;
	rgn.CreateRectRgn (0, 0, rcClient.Width(), rcClient.Height());
	int i=6;
	for (int y=0; y<i; y++)
	{
		for (int x=0; x<i; x++)
		{
			// If this pixel is transparent
			if (pDC->GetPixel(x,y)==col)
			{
				CRgn rgnAdd;
				rgnAdd.CreateRectRgn (x,
					y, x+1, y+1);
				rgn.CombineRgn(&rgn, &rgnAdd, RGN_DIFF);
			}
		}
		for (int x=rcClient.Width()-i; x<rcClient.Width(); x++)
		{
			// If this pixel is transparent
			if (pDC->GetPixel(x,y)==col)
			{
				CRgn rgnAdd;
				rgnAdd.CreateRectRgn (x,
					y, x+1, y+1);
				rgn.CombineRgn(&rgn, &rgnAdd, RGN_DIFF);
			}
		}
	}	
	for (int y=rcClient.Height()-i; y<rcClient.Height(); y++)
	{
		for (int x=0; x<i; x++)
		{
			// If this pixel is transparent
			if (pDC->GetPixel(x,y)==col)
			{
				CRgn rgnAdd;
				rgnAdd.CreateRectRgn (x,
					y, x+1, y+1);
				rgn.CombineRgn(&rgn, &rgnAdd, RGN_DIFF);
			}
		}
		for (int x=rcClient.Width()-i; x<rcClient.Width(); x++)
		{
			// If this pixel is transparent
			if (pDC->GetPixel(x,y)==col)
			{
				CRgn rgnAdd;
				rgnAdd.CreateRectRgn (x,
					y, x+1, y+1);
				rgn.CombineRgn(&rgn, &rgnAdd, RGN_DIFF);
			}
		}
	}

	SetWindowRgn (rgn, TRUE);
}
BOOL CNUKDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	switch(m_icur)
	{
	case 1:
	case 9:
		::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENWSE));
		return TRUE;
	case 2:
	case 8:
		::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENS));
		return TRUE;
	case 3:
	case 7:
		::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENESW));
		return TRUE;
	case 4:
	case 6:
		::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEWE));
		return TRUE;
	default:
		::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
		return TRUE;
	}

	return CDialog::OnSetCursor(pWnd, nHitTest, message);
}

void CNUKDlg::OnMouseMove(UINT nFlags, CPoint point)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	CRect rc;
	GetWindowRect(rc);
	m_rcCurRect = rc;//
	CRect rcW(0,0,rc.Width(),rc.Height());

	CRect rcW1(rcW.left+BorderSpace, rcW.top+BorderSpace, rcW.left+PointSpace+BorderSpace, rcW.top+PointSpace+BorderSpace);
	CRect rcW2(rcW.left+BorderSpace, rcW.top, rcW.right-BorderSpace, rcW.top+BorderSpace);
	CRect rcW3(rcW.right-PointSpace-BorderSpace, rcW.top+BorderSpace, rcW.right-BorderSpace, rcW.top+PointSpace+BorderSpace);

	CRect rcW4(rcW.left, rcW.top+BorderSpace, rcW.left+BorderSpace, rcW.bottom-BorderSpace);
	CRect rcW5(rcW.left+BorderSpace, rcW.top+BorderSpace, rcW.right-BorderSpace, rcW.bottom-BorderSpace);
	CRect rcW6(rcW.right-BorderSpace, rcW.top+BorderSpace, rcW.right, rcW.bottom-BorderSpace);

	CRect rcW7(rcW.left+BorderSpace, rcW.bottom-PointSpace-BorderSpace, rcW.left+PointSpace+BorderSpace, rcW.bottom-BorderSpace);
	CRect rcW8(rcW.left+BorderSpace, rcW.bottom-BorderSpace, rcW.right-BorderSpace, rcW.bottom);
	CRect rcW9(rcW.right-PointSpace-BorderSpace, rcW.bottom-PointSpace-BorderSpace, rcW.right-BorderSpace, rcW.bottom-BorderSpace);
	if(rcW2.PtInRect(point))
	{
		m_icur = 2;
	}
	if(rcW4.PtInRect(point))
	{
		m_icur = 4;
	}
	if(rcW5.PtInRect(point))
	{
		if(rcW1.PtInRect(point))
		{
			m_icur = 1;
		}
		else if(rcW3.PtInRect(point))
		{
			m_icur = 3;
		}
		else if(rcW7.PtInRect(point))
		{
			m_icur = 7;
		}
		else if(rcW9.PtInRect(point))
		{
			m_icur = 9;
		}
		else
		{
			m_icur = 5;
		}
	}
	if(rcW6.PtInRect(point))
	{
		m_icur = 6;
	}
	if(rcW8.PtInRect(point))
	{
		m_icur = 8;
	}

	CDialog::OnMouseMove(nFlags, point);
}


void CNUKDlg::OnBnClickedCloseBtn()
{
	// TODO: 在此添加控件通知处理程序代码
	PostQuitMessage(0);
}

void CNUKDlg::OnBnClickedMenuBtn()
{
	// TODO: 在此添加控件通知处理程序代码
	MessageBox(_T("作者:黄锐坤\n毕业学校:韩山师范学院\nQQ:89642685\nE-mail:meet-xp@126.com"));
}

void CNUKDlg::OnBnClickedUserHeardBtn()
{
	// TODO: 在此添加控件通知处理程序代码
}

void CNUKDlg::OnBnClickedSearchBtn()
{
	// TODO: 在此添加控件通知处理程序代码
	if(IDYES==MessageBox(_T("欢迎您加我为QQ好友\n现在就给我QQ留言吧"),NULL,MB_YESNO))
	{
		ShellExecute(m_hWnd, NULL, _T("http://wpa.qq.com/msgrd?V=1&Uin=89642685&Site=NUK程序使用者&Menu=yes"), NULL, NULL, SW_HIDE);
	}
}

void CNUKDlg::OnBnClickedHostingBtn()
{
	// TODO: 在此添加控件通知处理程序代码
	if(IDYES==MessageBox(_T("欢迎您访问VC知识库\n现在就行动吗"),NULL,MB_YESNO))
	{
		ShellExecute(m_hWnd, NULL, _T("http://www.vckbase.com"), NULL, NULL, SW_HIDE);
	}
}

void CNUKDlg::OnBnClickedStatusBtn()
{
	// TODO: 在此添加控件通知处理程序代码
	//CPoint point;
	//GetCursorPos(&point);

	COfficeXPMenu m_popmenu;
	m_popmenu.LoadMenu(IDR_MENU_STATUS);	
	m_popmenu.SetType(TYPE_XP);
	CMenu *psub = (CMenu *)m_popmenu.GetSubMenu(0);
	CRect rect;
	m_statusBtn.GetWindowRect(rect);
	DWORD dwID =psub->TrackPopupMenu((TPM_LEFTALIGN|TPM_RIGHTBUTTON),
		rect.left,rect.top+27, this); 
}

void CNUKDlg::OnDestroy()
{
	CDialog::OnDestroy();

	// TODO: 在此处添加消息处理程序代码
}

void CNUKDlg::ReDrawCrl(CDC* m_MemDC)
{
	CRect rcClient;
	GetClientRect(&rcClient);

	static bool firstGetClientRect = true;
	static int preClientHeight = rcClient.Height();
	static int preClientWidth = rcClient.Width();
	if(firstGetClientRect)
	{
		firstGetClientRect = false;
	}
	if(firstGetClientRect||preClientHeight!=rcClient.Height()||preClientWidth!=rcClient.Width()||m_bMouseDown)
	{
		preClientHeight = rcClient.Height();
		preClientWidth = rcClient.Width();

		CImage *image=NULL;
		CRect rect;
		CRect rcIcon;
		CPoint ptText;
		CString strText;
		CFont font;
		font.CreatePointFont(90,_T("Arial"));
		m_MemDC->SelectObject(&font);

		image=m_closeBtn.GetPaintImage();
		rect = m_closeBtn.GetRectInParent();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
			image->GetWidth(),image->GetHeight(), RGB(255,0,255));

		image=m_userHeadBtn.GetPaintImage();
		rect = m_userHeadBtn.GetRectInParent();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(255,0,255));
		image=m_statusBtn.GetPaintImage();
		rect = m_statusBtn.GetRectInParent();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(255,0,255));
		image=m_mailBtn.GetPaintIcon();
		rect = m_mailBtn.GetRectInParent();
		rcIcon = m_mailBtn.GetIconRect();
		if(!image->IsNull())
		{
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(0,0,0));
			ptText = m_mailBtn.GetTextPos();
			m_mailBtn.GetWindowTextW(strText);
			m_MemDC->TextOutW(rect.left+ptText.x,rect.top+ptText.y,strText);
		}
		image=m_hostingBtn.GetPaintIcon();
		rect = m_hostingBtn.GetRectInParent();
		rcIcon = m_hostingBtn.GetIconRect();
		if(!image->IsNull())
		{
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(0,0,0));
			ptText = m_hostingBtn.GetTextPos();
			m_hostingBtn.GetWindowTextW(strText);
			m_MemDC->TextOutW(rect.left+ptText.x,rect.top+ptText.y,strText);
		}
		image=m_paymentBtn.GetPaintIcon();
		rect = m_paymentBtn.GetRectInParent();
		rcIcon = m_paymentBtn.GetIconRect();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(0,0,0));

		image=m_mobileBtn.GetPaintIcon();
		rect = m_mobileBtn.GetRectInParent();
		rcIcon = m_mobileBtn.GetIconRect();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(0,0,0));
		image=m_gameBtn.GetPaintIcon();
		rect = m_gameBtn.GetRectInParent();
		rcIcon = m_gameBtn.GetIconRect();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(0,0,0));
		image=m_ttBtn.GetPaintIcon();
		rect = m_ttBtn.GetRectInParent();
		rcIcon = m_ttBtn.GetIconRect();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(0,0,0));
		image=m_chatBtn.GetPaintIcon();
		rect = m_chatBtn.GetRectInParent();
		rcIcon = m_chatBtn.GetIconRect();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(0,0,0));
		image=m_petBtn.GetPaintIcon();
		rect = m_petBtn.GetRectInParent();
		rcIcon = m_petBtn.GetIconRect();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(0,0,0));
		image=m_musicBtn.GetPaintIcon();
		rect = m_musicBtn.GetRectInParent();
		rcIcon = m_musicBtn.GetIconRect();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(0,0,0));
		if(m_tvBtn.IsWindowVisible())
		{
			image=m_tvBtn.GetPaintIcon();
			rect = m_tvBtn.GetRectInParent();
			rcIcon = m_tvBtn.GetIconRect();
			if(!image->IsNull())
				image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
					image->GetWidth(),image->GetHeight(), RGB(0,0,0));
		}

		image=m_menuBtn.GetPaintImage();
		rect = m_menuBtn.GetRectInParent();
		rcIcon = m_menuBtn.GetIconRect();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC,rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(255,0,255));
		image=m_msgManagerBtn.GetPaintIcon();
		rect = m_msgManagerBtn.GetRectInParent();
		rcIcon = m_msgManagerBtn.GetIconRect();
		if(!image->IsNull())
			image->TransparentBlt(m_MemDC->m_hDC,rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(0,0,0));
		image=m_searchBtn.GetPaintIcon();
		rect = m_searchBtn.GetRectInParent();
		rcIcon = m_searchBtn.GetIconRect();
		if(!image->IsNull())
		{
			image->TransparentBlt(m_MemDC->m_hDC, rect.left,rect.top, 
				image->GetWidth(),image->GetHeight(), RGB(0,0,0));
			ptText = m_searchBtn.GetTextPos();
			m_searchBtn.GetWindowTextW(strText);
			m_MemDC->SetTextColor(m_searchBtn.GetFGColor());
			m_MemDC->TextOutW(rect.left+ptText.x,rect.top+ptText.y,strText);
		}
		m_MemDC->BitBlt(3,68,27,33*4+4,m_skintab.GetWindowDC(),0,0,SRCCOPY);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -