📄 seconddllwnd.cpp
字号:
// SecondDLLWnd.cpp: implementation of the CSecondDLLWnd class.
#include "stdafx.h"
#include "SecondDLLWnd.h"
#include "Resource.h"
#include "tlhelp32.h"
int CSecondDLLWnd::m_nDllCount = 0;
CToolBar CSecondDLLWnd::m_QueryBar;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CSecondDLLWnd,CWndForDLL)
CSecondDLLWnd::CSecondDLLWnd()
{
m_nDllCount++;
m_viewChange = FALSE;
m_bHaveMouseRight = FALSE;
m_bDown = FALSE;
}
CSecondDLLWnd::~CSecondDLLWnd()
{
m_nDllCount--;
if(m_nDllCount <= 0)
{
DelMenu();
m_nDllCount = 0;
}
}
BEGIN_MESSAGE_MAP(CSecondDLLWnd, CWndForDLL)
//{{AFX_MSG_MAP(CSecondDLLWnd)
ON_WM_LBUTTONDOWN()
ON_COMMAND(IDM_MAPPING_CREATE_MAP, OnQueryDemPoint)
ON_UPDATE_COMMAND_UI(IDM_MAPPING_CREATE_MAP, OnUpdateQueryDemPoint)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CSecondDLLWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
if(!m_bHaveMouseRight) return;
m_bDown = TRUE;
CallFirstDLL();
CWndForDLL::OnLButtonDown(nFlags, point);
}
BOOL CSecondDLLWnd::AddMenu()
{
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,11112,"第二模块的操作");
// pSubMenu->EnableMenuItem(11111,MF_ENABLED);
pSubMenu->DeleteMenu(1,MF_BYPOSITION);
//pSubMenu->DeleteMenu(1,MF_BYPOSITION);
break;
}
}
if(m_nDllCount == 1)
{
CWndForDLL::AddMenu();
return TRUE;
}
else
return TRUE;
}
void CSecondDLLWnd::OnLostMouseRight()
{
//当其他模块(包括本身)抢得鼠标控制权时,由框架调用此函数
}
void CSecondDLLWnd::OnMyDraw(CMyView* pView)//动态库临时维护
{
if(m_pView == NULL)
return;
if(m_bHaveMouseRight==0)
return;
CDC* pDC=pView->GetDC();
pDC->TextOut(100,100,"模块22");
}
void CSecondDLLWnd::OnQueryDemPoint()
{
GetMouseRight();
m_pView->MyInvalidate();
}
void CSecondDLLWnd::OnUpdateQueryDemPoint(CCmdUI* pCmdUI)
{
}
void CSecondDLLWnd::CallFirstDLL()
{
HINSTANCE hinstLib;
FARPROC ProcAdd;
HANDLE hSnapshot;
// PROCESSENTRY32 pe;
MODULEENTRY32 me;
BOOL hasInfo;
hSnapshot =CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,0);
me.dwSize =sizeof(MODULEENTRY32);
hasInfo =Module32First(hSnapshot,&me);
while(hasInfo==TRUE)
{
hasInfo =Module32Next(hSnapshot,&me);
if(strcmp(me.szModule,"FirstDLL.dll")==0)
{
hinstLib=(HINSTANCE)me.hModule;
if (hinstLib != NULL)
{
ProcAdd =GetProcAddress(hinstLib,"CallTest");
if(ProcAdd == NULL)
return;
(*ProcAdd)();
}
break;
}
}
CloseHandle(hSnapshot);
}
/*
FARPROC ProcAdd;
CWndForDLL* pWndDll;
CTestInterfaceDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
hinstLib = LoadLibrary("F:\\界面框架\\MyInterface\\Debug\\FirstDLL.dll");
if (hinstLib != NULL)
{
ProcAdd =GetProcAddress(hinstLib,"InitMyDLL");
if(ProcAdd == NULL)
return;
pWndDll = (CWndForDLL *)(*ProcAdd)();
if(pWndDll == NULL)
return;
pWndDll->ConnectWithDocument(pDoc);
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -