我正在为应用程序开发一个插件,我需要插入一个菜单,作为扩展。问题是邮件未被处理。我得到了一个指向窗口过程的指针,但是如何使用函数CWnd::WindowProc
却不知道。我试图覆盖函数CWnd::WindowProc
,但它不起作用:
LRESULT Plugin::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
if (HIWORD(wParam) == ID_EXPCATXML)
{
Plugin::OnExportCatalogXML();
return TRUE;
}
}
return CWnd::WindowProc(uMsg, wParam, lParam);
}
欢迎任何想法,谢谢
答案 0 :(得分:0)
通过使用CWnd::SubclassWindow的特殊函数来覆盖应用程序窗口的子类,可以找到解决方案:
bool Plugin::OnAppStartAfter(long CallParamBlock)
{
CoInitialize(NULL);
SessionId = app->StartSessionFromCallParams(&CallParamBlock);
if (SessionId != 0)
{
m_pWnd = CWnd::FindWindow(_T("#32770"), _T("MobiScript"));
HWND hWnd = m_pWnd->m_hWnd;
if (m_pWnd != NULL)
{
m_pMenu = m_pWnd->GetMenu()->GetSubMenu(0)->GetSubMenu(6);
if (m_pMenu != NULL)
{
m_pMenu->InsertMenu(0, MF_BYPOSITION, ID_EXPCATXML, _T("Catalog to XML\tCtrl+E"));
}
m_pMenu = m_pWnd->GetMenu()->GetSubMenu(0)->GetSubMenu(7);
if (m_pMenu != NULL)
{
m_pMenu->InsertMenu(0, MF_BYPOSITION, ID_IMPCATXML, _T("Catalog to XML\tCtrl+I"));
}
}
plugin.SubclassWindow(hWnd);
}
CoUninitialize();
return 1;
}