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

📄 mainfrm.cpp

📁 qq聊天的一些基本功能,要的太飞 飞师大~
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "ChatClient.h"
#include "MyTreeView.h"
#include "MyEditView.h"
#include "ClientFormView.h"

#include "MainFrm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_WM_GETMINMAXINFO()
	ON_WM_SHOWWINDOW()
	ON_WM_SIZE()
	ON_WM_CLOSE()
	ON_COMMAND(ID_ROOM_QUIT, OnRoomQuit)
	ON_COMMAND(IDR_QUIT_SYSABOUT, OnQuitSysabout)
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_TASKICON,OnTaskIcon)
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	
}

CMainFrame::~CMainFrame()
{

	
}
extern CChatClientApp theApp;
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	CRect rect;
	//应该首先得到屏幕的分辨率
	int iCxWidth = GetSystemMetrics(SM_CXFULLSCREEN);
	int iCyWidth = GetSystemMetrics(SM_CYFULLSCREEN);
	rect.SetRect(iCxWidth - 150,iCyWidth - 420,iCxWidth,iCyWidth);
	MoveWindow(&rect);
	SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE);
//	CenterWindow();
	NOTIFYICONDATA &TaskIcon = theApp.TaskIcon;
	TaskIcon.cbSize = sizeof(TaskIcon);
	TaskIcon.hIcon = AfxGetApp()->LoadIcon(IDI_TASKICON);
	TaskIcon.hWnd = this->GetSafeHwnd();
	TaskIcon.uFlags = 0x7;
	lstrcpy(TaskIcon.szTip,_T("未登陆"));
	TaskIcon.uCallbackMessage = WM_TASKICON;
	Shell_NotifyIcon(NIM_ADD,&TaskIcon);



	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers


BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class
	CSize size;
	size.cx = 100;
	size.cy = 80;
//	m_wndSplitter.Create(this,2,1,size,pContext);
	if(!m_wndSplitter.CreateStatic(this,2,1))
	{
		return FALSE;
	}
	if(!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CClientFormView),size,pContext))
		return FALSE;
	if(!m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CMyTreeView),size,pContext))
		return FALSE;
	

	return TRUE;
}
CMyTreeView * CMainFrame::GetTreeView()
{
	return (CMyTreeView *)m_wndSplitter.GetPane(1,0);
}
CWnd * CMainFrame::GetFormView()
{
	return m_wndSplitter.GetPane(0,0);
}



BOOL CMainFrame::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CFrameWnd::DestroyWindow();
}

void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
{
	// TODO: Add your message handler code here and/or call default
	
	CFrameWnd::OnGetMinMaxInfo(lpMMI);
}
void CMainFrame::OnTaskIcon(WPARAM wParam,LPARAM lParam)
{
	POINT point;
	GetCursorPos(&point);
//	CTreeView::OnLButtonDown(0,point);
//	ScreenToClient(&point);
	
	CMenu * pContextMenu ;	

	if(lParam == WM_LBUTTONDBLCLK)
		ShowWindow(SW_SHOWNORMAL);
	else if(lParam == WM_RBUTTONDOWN)
	{
		CMenu menu;
		menu.LoadMenu(IDR_QUIT);
		pContextMenu = menu.GetSubMenu(0);
		pContextMenu->TrackPopupMenu(TPM_LEFTBUTTON,point.x,point.y,this);
		
		
	}

	return;
}

void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CFrameWnd::OnShowWindow(bShow, nStatus);
	
	// TODO: Add your message handler code here
	
	
}

void CMainFrame::OnSize(UINT nType, int cx, int cy) 
{
	
	CFrameWnd::OnSize(nType, cx, cy);
	if(nType == SW_SHOWNORMAL)
		ShowWindow(SW_HIDE);
	//if(nType == SC_MINIMIZE) ShowWindow(SW_HIDE);
	
	// TODO: Add your message handler code here
	
}



BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	// TODO: Add your specialized code here and/or call the base class

	return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

void CMainFrame::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	ShowWindow(SW_HIDE);

}

void CMainFrame::OnRoomQuit() 
{
	// TODO: Add your command handler code here
	PostMessage(WM_QUIT);
}

void CMainFrame::OnQuitSysabout() 
{
	// TODO: Add your command handler code here
	theApp.OnAppAbout();
}

⌨️ 快捷键说明

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