if(NULL!=m_lpHtmlView) return false;
CRuntimeClass* pViewClass = RUNTIME_CLASS(CHtmlView); CCreateContext *pContext = NULL;
pContext = new CCreateContext;
pContext->m_pNewViewClass = pViewClass;
pContext->m_pCurrentDoc = NULL;
pContext->m_pNewDocTemplate = NULL;
pContext->m_pLastView = NULL;
pContext->m_pCurrentFrame = NULL;
CWnd* pWnd = NULL; pWnd = DYNAMIC_DOWNCAST(CWnd,pViewClass->CreateObject());
pWnd->Create(NULL,NULL,WS_VISIBLE,CRect(0,0,0,0),m_plParentWnd,0,pContext);
delete pContext; m_lpHtmlView = DYNAMIC_DOWNCAST(CHtmlView,pWnd);
m_lpHtmlView->MoveWindow(__Rect);
::SetWindowPos(m_lpHtmlView->m_hWnd,HWND_TOPMOST,0,0,490,140,SWP_NOSIZE);
m_lpHtmlView->ShowWindow(SW_SHOW);
我用上面的代码创建了一个窗口,可是用spy++却发现没有topmost属性,窗口也根本不在最上端,请问是怎么回事啊,另外请教一下到底把一个窗口设为topmost有多少种方法呢?
CRuntimeClass* pViewClass = RUNTIME_CLASS(CHtmlView); CCreateContext *pContext = NULL;
pContext = new CCreateContext;
pContext->m_pNewViewClass = pViewClass;
pContext->m_pCurrentDoc = NULL;
pContext->m_pNewDocTemplate = NULL;
pContext->m_pLastView = NULL;
pContext->m_pCurrentFrame = NULL;
CWnd* pWnd = NULL; pWnd = DYNAMIC_DOWNCAST(CWnd,pViewClass->CreateObject());
pWnd->Create(NULL,NULL,WS_VISIBLE,CRect(0,0,0,0),m_plParentWnd,0,pContext);
delete pContext; m_lpHtmlView = DYNAMIC_DOWNCAST(CHtmlView,pWnd);
m_lpHtmlView->MoveWindow(__Rect);
::SetWindowPos(m_lpHtmlView->m_hWnd,HWND_TOPMOST,0,0,490,140,SWP_NOSIZE);
m_lpHtmlView->ShowWindow(SW_SHOW);
我用上面的代码创建了一个窗口,可是用spy++却发现没有topmost属性,窗口也根本不在最上端,请问是怎么回事啊,另外请教一下到底把一个窗口设为topmost有多少种方法呢?
两种途径.
BringWindowToTop(Handle);
SetWindowPos函数,指定窗口的最顶风格,用WS_EX_TOPMOST扩展窗口的 风格
Example:
void ToggleTopMost( CWnd *pWnd)
{
ASSERT_VALID(pWnd);
pWnd ->SetWindowPos(pWnd-> GetStyle() &WS_EX_TOPMOST)?
&wndNoTopMOST: &wndTopMost,0,0,0,0,SSP_NOSIZE|WSP_NOMOVE};
}
2,BringWindowToTop等在内部也是调用SetWindowPos.
3,判断SetWindowPos有没有调用成功,看返回值。有多时候,这个函数会调用失败,可以判断并隔一段时间再调用一次。