|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
delu qiu
|
May 25, 2006 - 1:17 PM
|
Hi,
I have a CMDIFrameWnd derived frame, I want to set the frame window to top most when it receive a user-defined WM_ message which send from frame’s child window. and the SetWindowPos function can set the position but can not put the window to top. MoveWindow take same effect;
here is my code: -------------------------------------------------------------------------------------------- class CMainFrame : public CExtNCW < CMDIFrameWnd > {
protected: //{{AFX_MSG(CMainFrame) ........... //}}AFX_MSG ......... afx_msg LRESULT OnTMClose(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnTMOpen(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP() };
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMainFrame) ON_WM_CREATE() ON_WM_TIMER() //}}AFX_MSG_MAP ................. ON_MESSAGE(WM_DISABLEMAIN ,OnTMClose) ON_MESSAGE(WM_ENABLEMAIN,OnTMOpen) .......... END_MESSAGE_MAP()
LRESULT CMainFrame::OnTMOpen(WPARAM wParam, LPARAM lParam) { bClosed=FALSE; m_wndSplitter.SetColumnInfo(0,GetSystemMetrics (SM_CXSCREEN)-DEF_RIGHTVIEWWIDTH,500); m_wndSplitter.SetColumnInfo(1,DEF_RIGHTVIEWWIDTH,20); m_wndSplitter.RecalcLayout(); m_wndStatusBar.ShowWindow(SW_SHOW); EnableWindow(TRUE); CWnd * pParent=::AfxGetMainWnd(); BOOL bOpen; bOpen=::SetWindowPos(pParent->m_hWnd, HWND_TOPMOST ,//wndBottom wndNoTopMost wndTop 0,0,GetSystemMetrics (SM_CXSCREEN ), GetSystemMetrics (SM_CYSCREEN ),SWP_SHOWWINDOW); if (!bOpen) { CString Err; Err.Format("LastError %d",GetLastError()); AfxMessageBox(Err); } /* ShowWindow(SW_SHOWMAXIMIZED); CRect cRect; cRect.top = 0; cRect.left = 0; cRect.right = GetSystemMetrics (SM_CXSCREEN); cRect.bottom = GetSystemMetrics (SM_CYSCREEN); MoveWindow (&cRect); ::SetForegroundWindow (this->m_hWnd); ::BringWindowToTop(this->m_hWnd); ::SetActiveWindow(this->m_hWnd); */
return 0; }
|
|
Technical Support
|
May 26, 2006 - 2:25 AM
|
We guess the problem hides somewhere outside the source code provided in your message. We have been using the CFrameWnd::BringToTop() method in our projects and never had any problems.
|
|