Always On Top
DORIE@ris.risinc.com Thursday, April 25, 1996 Environment: VC++ 4.0 Targeting: Win95 and PowerMac I am trying to accomplish the same behavior of the Infoviewer Query Results window when the pushpin button is set. That is, have the window remain visible when not active. I have a CBrowserFrame which is a descendant of CMDIChildWnd. This CBrowserFrame is the parent of a CToolbar which has a button ID_KEEPVISIBLE. The following is the code I wrote for ON_COMMAND. void CBrowserFrame::OnKeepVisible() { if(m_bOnTop == TRUE ) SetWindowPos(&NoTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); else SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); m_bOnTop = !m_bOnTop; } While the SetWindowPos returns TRUE nothing appears to change. My window does not stay active when I switch to another window. As an experiment I tried to SetWindowPos with &wndBottom and then return it to the top with SetWindowPos using &wndTopMost. The window does become the bottom window but does not come back to the top or become the topmost window. Does anyone know of any good examples of this or know why it would not be working? TIA Dorie Hannan Dorie@ris.risinc.com
Frederic Steppe -- FredericS@msn.com Sunday, April 28, 1996 >Environment: VC++ 4.0 Targeting: Win95 and PowerMac > >I am trying to accomplish the same behavior of the Infoviewer Query >Results window when the pushpin button is set. That is, have the >window remain visible when not active. > if(m_bOnTop == TRUE ) > SetWindowPos(&NoTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); > else > SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); Reading the VC++ 4.0 help files, I found this : If neither SWP_NOACTIVATE nor SWP_NOZORDER is specified (that is, when the application requests that a window be simultaneously activated and placed in the specified Z-order), the value specified in pWndInsertAfter is used only in the following circumstances: · Neither &wndTopMost nor &wndNoTopMost is specified in the pWndInsertAfter parameter. · This window is not the active window. As far as I can understand, the pWndInsertAfter is ignored if you don't specify either SWP_NOACTIVATE or SWP_NOZORDER. You should try to include the SWP_NOACTIVATE flag. Another possible solution is to work on the extended window style : long dwExStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE); if(m_bOnTop == TRUE ) dwExStyle &= ~WS_EX_TOPMOST; else dwExStyle |= WS_EX_TOPMOST; ::SetWindowLong(m_hWnd, GWL_EXSTYLE, dwExStyle); Hope it will help. Frederic Steppe (frederics@msn.com)
Veeraraghavan -- veera@hiso.honeywell.soft.net Monday, April 29, 1996 hi, Instead of SetwindowPos Try using SetWindowLong with GWL_EXSTYLE parameter and specify WS_EX_TOPMOST. Tell me if this work. Thanks Veera At 03:56 PM 4/25/96 PST, you wrote: >Environment: VC++ 4.0 >Targeting: Win95 and PowerMac > >I am trying to accomplish the same behavior of the Infoviewer Query >Results window when the pushpin button is set. That is, have the >window remain visible when not active. > >I have a CBrowserFrame which is a descendant of CMDIChildWnd. >This CBrowserFrame is the parent of a CToolbar which has a button >ID_KEEPVISIBLE. The following is the code I wrote for ON_COMMAND. > >void CBrowserFrame::OnKeepVisible() >{ > if(m_bOnTop == TRUE ) > SetWindowPos(&NoTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); > else > SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); > m_bOnTop = !m_bOnTop; >} > >While the SetWindowPos returns TRUE nothing appears to change. My >window does not stay active when I switch to another window. As an >experiment I tried to SetWindowPos with &wndBottom and then return it >to the top with SetWindowPos using &wndTopMost. The window does >become the bottom window but does not come back to the top or become >the topmost window. >Does anyone know of any good examples of this or know why it would >not be working? > >TIA >Dorie Hannan >Dorie@ris.risinc.com > WM_THANKS|WM_REGARDS Veera Sr.Software Engineer ____________________________ | Veeraraghavan . S. | /)| veera@honeywell.soft.net |(\ / )| Ph :011-91-80-8520150 |( \ __( (|____________________________|) )__ ((( \ \ > /_) ( \ < / / ))) (\\\ \ \_/ / \ \_/ / ///) \ / \ / \ _/ \_ / / / \ \ / / \ \
| Вернуться в корень Архива |