1
CFrameWnd::m_bAutoMenuEnable
说明:
当此成员是可用的(缺省),用户下拉一个菜单时,没有ON_COMMAND或ON_UPDATE_COMMAND_UI处理程序的菜单项目将被自动设置为无效。
具有ON_COMMAND处理程序而无ON_UPDATE_COMMAND_UI处理程序的菜单项目将被自动设置为可用。
当数据成员被设置时,菜单条与工具条按钮一样的方式被可用。
此数据成员简化了基于当前选择的最优命令的实现,并减少为可用与无效菜单项目编写ON_UPDATE_COMMAND_UI处理程序的应用需求。
2
static LPCSTR s_pszClassName = NULL;
if(s_pszClassName == NULL)
{
WNDCLASS wndcls;
::GetClassInfo(AfxGetInstanceHandle(),cs.lpszClass,&wndcls);
wndcls.style = CS_HREDRAW|CS_VREDRAW;
wndcls.cbWndExtra = 0;
wndcls.cbClsExtra = 0;
wndcls.lpszMenuName = 0;
wndcls.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
wndcls.hCursor = LoadCursor(NULL,IDC_ARROW);
wndcls.hIcon = 0;
wndcls.lpszClassName = ND_PANEL_CLASS_NAME;
VERIFY(AfxRegisterClass(&wndcls));
s_pszClassName = ND_PANEL_CLASS_NAME;
}
cs.lpszClass = s_pszClassName;
3
BOOL SetThreadDesktopMFC(HDESK hDesk)
{
_AFX_THREAD_STATE* pState = AfxGetThreadState();
BOOL bReHook = UnhookWindowsHookEx(pState->m_hHookOldMsgFilter);
pState->m_hHookOldMsgFilter = NULL;
BOOL bRet = ::SetThreadDesktop(hDesk);
if(!bRet)
{
TRACE("SetThreadDesktopMFC fail:%u",GetLastError());
}
if(bReHook)
{
pState->m_hHookOldMsgFilter = SetWindowsHookEx(WH_MSGFILTER,MsgFilter,0,GetCurrentThreadId());
}
return bRet;
}
static LRESULT CALLBACK MsgFilter(int code,WPARAM wParam,LPARAM lParam)
{
CWinThread* pThread;
if(afxContextIsDLL || (code<0 && code!=MSGF_DDEMGR) || ((pThread = AfxGetThread())==NULL))
{
return ::CallNextHookEx(_afxThreadState->m_hHookOldMsgFilter,code,wParam,lParam);
}
ASSERT(pThread != NULL);
return (LRESULT)pThread->ProcessMessageFilter(code,(LPMSG)lParam);
}