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

📄 firstdllwnd.cpp

📁 随着计算机信息技术的飞速发展
💻 CPP
字号:
// FirstDLLWnd.cpp: implementation of the CFirstDLLWnd class.
#include "stdafx.h"
#include "FirstDLLWnd.h"
#include "resource.h"

int CFirstDLLWnd::m_nDllCount = 0;
CToolBar CFirstDLLWnd::m_QueryBar;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNAMIC(CFirstDLLWnd,CWndForDLL)

CFirstDLLWnd::CFirstDLLWnd()
{
	m_nDllCount++;
	m_viewChange	  = FALSE;
	m_bHaveMouseRight = FALSE;
	m_bDown			  = FALSE;

}

CFirstDLLWnd::~CFirstDLLWnd()
{
	m_nDllCount--;
	if(m_nDllCount <= 0)
	{
		DelMenu();
		DelToolBar();
		m_nDllCount = 0;
	}

}

BEGIN_MESSAGE_MAP(CFirstDLLWnd, CWndForDLL)
	//{{AFX_MSG_MAP(CFirstDLLWnd)
	ON_WM_LBUTTONDOWN()
	ON_COMMAND(ID_QUERY_CONTENT_WINDOW, OnQueryDemPoint)
	ON_UPDATE_COMMAND_UI(ID_QUERY_CONTENT_WINDOW, OnUpdateQueryDemPoint)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CFirstDLLWnd::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if(!m_bHaveMouseRight) 
		return;
	
	m_bDown = TRUE;
	AfxMessageBox("这是第一个模块!");
//	m_pView->
	
	CWndForDLL::OnLButtonDown(nFlags, point);
}

BOOL CFirstDLLWnd::AddMenu()
{
	//    (CFrameWnd*)GetMainWnd()->EnableDocking(CBRS_ALIGN_ANY);
    CString menuItemName;
	int		menuItemCount;
	int		i;
	CMenu* pTopMenu= AfxGetMainWnd()->GetMenu();
	CMenu* pSubMenu=NULL;
	menuItemCount  = pTopMenu->GetMenuItemCount();
	for(i=0;i<menuItemCount;i++)
		{
		pTopMenu->GetMenuString(i,menuItemName,MF_BYPOSITION);

		//AfxMessageBox(menuItemName);
		if(menuItemName.Compare("标准操作")==0)
			{
			pSubMenu=pTopMenu->GetSubMenu(i);
			pSubMenu->AppendMenu(MF_STRING,11111,"第一模块的操作");
//			pSubMenu->EnableMenuItem(11111,MF_ENABLED);
			pSubMenu->DeleteMenu(1,MF_BYPOSITION);
			//pSubMenu->DeleteMenu(1,MF_BYPOSITION);
			break;
			}

		}


	if(m_nDllCount == 1)
	{
		if(!CreateToolBar())
			return FALSE;
		CWndForDLL::AddMenu();
		return TRUE;
	}
	else
		return TRUE;
}



BOOL CFirstDLLWnd::CreateToolBar()
{	
	CMDIFrameWnd* pMainWnd = (CMDIFrameWnd*)AfxGetMainWnd();
	if ( IsWindow(m_QueryBar.m_hWnd) )
		return TRUE;
	if (!m_QueryBar.Create(pMainWnd, WS_CHILD | WS_VISIBLE | CBRS_TOOLTIPS
		| CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_RIGHT | CBRS_TOOLTIPS, IDR_QUERY_BAR)
		|| !m_QueryBar.LoadToolBar( IDR_QUERY_BAR ) )
	{
		TRACE0("Failed to create toolbar\n");
		return FALSE;       // fail to create
	}
	
	m_QueryBar.SetWindowText(_T("查询工具"));//_T("查询工具"));
//	m_QueryBar.SetBarStyle(CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);  
	m_QueryBar.EnableDocking(CBRS_ALIGN_ANY);
	
	CRect rect;
	pMainWnd->GetWindowRect( rect );
/*	if ( rect.Width() < 700 || rect.Height() < 550 )
		{
		CPoint pt( 10,
		GetSystemMetrics(SM_CYSCREEN) / 5 * 4 );
		pMainWnd->FloatControlBar(&m_QueryBar, pt);
		}
	else*/
	pMainWnd->DockControlBar(&m_QueryBar,AFX_IDW_DOCKBAR_TOP);
	
	pMainWnd->RecalcLayout();

	return TRUE;
}

BOOL CFirstDLLWnd::DelToolBar()
{
	CMDIFrameWnd* pMainWnd = (CMDIFrameWnd*)AfxGetMainWnd();
	if ( IsWindow(m_QueryBar.m_hWnd) )
		return TRUE;

	m_QueryBar.DestroyWindow();
	pMainWnd->DestroyDockBars();
	pMainWnd->RecalcLayout();
	return TRUE;
}

void CFirstDLLWnd::OnLostMouseRight()
{
	
}	




void CFirstDLLWnd::OnMyDraw(CMyView* pView)//动态库临时维护
{
	if(m_pView == NULL)
		return;

//	CRect 
	if(m_bHaveMouseRight==0)
		return;
	
	CDC* pDC=pView->GetDC();
	pDC->TextOut(100,100,"模块11");
}

void CFirstDLLWnd::OnQueryDemPoint() 
{
	GetMouseRight();
	m_pView->MyInvalidate();

}

void CFirstDLLWnd::OnUpdateQueryDemPoint(CCmdUI* pCmdUI) 
{

}

⌨️ 快捷键说明

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