engllf
asked on
Bring application to topmost
VC5
I have several MFC Applications opened and overlapping one another (all have SW_NORMAL state). Every App does a little bit of data calculation and passes the results to the next App when the calculation is done.
How do i programmatically moves an Application(that is being hidden by others) to the toppest application when this particular Application has the control ?
I have tried AfxGetMainWnd()->BringWind owToTop(), SetFocus,
::SetForegroundWindow, SetActiveWindow... but they don't seem to work.
Sample code would be appreciated.
Thanx
Leow
I have several MFC Applications opened and overlapping one another (all have SW_NORMAL state). Every App does a little bit of data calculation and passes the results to the next App when the calculation is done.
How do i programmatically moves an Application(that is being hidden by others) to the toppest application when this particular Application has the control ?
I have tried AfxGetMainWnd()->BringWind
::SetForegroundWindow, SetActiveWindow... but they don't seem to work.
Sample code would be appreciated.
Thanx
Leow
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here a snipped peece of code afxwin.h:
static AFX_DATA const CWnd wndTop; // SetWindowPos's pWndInsertAfter
static AFX_DATA const CWnd wndBottom; // SetWindowPos's pWndInsertAfter
static AFX_DATA const CWnd wndTopMost; // SetWindowPos pWndInsertAfter
static AFX_DATA const CWnd wndNoTopMost; // SetWindowPos pWndInsertAfter
BOOL SetWindowPos(const CWnd* pWndInsertAfter, int x, int y,
int cx, int cy, UINT nFlags);
it is not inside the private scope it is public
and because it is a static member all CWnd derived classes will have the same
so you can use each CWnd to access wndTopMost.
if your BringWindowToTop function belongs not to a CWnd class simple try
void BringWindowToTop( )
{
CWnd* MainWnd= AfxGetMainWnd();
MainWnd->SetWindowPos (&MainWnd->wndTopMost ,0,0,0,0, SWP_NOMOVE| SWP_NOSIZE| SWP_SHOWWINDOW);
}
that should do the work
static AFX_DATA const CWnd wndTop; // SetWindowPos's pWndInsertAfter
static AFX_DATA const CWnd wndBottom; // SetWindowPos's pWndInsertAfter
static AFX_DATA const CWnd wndTopMost; // SetWindowPos pWndInsertAfter
static AFX_DATA const CWnd wndNoTopMost; // SetWindowPos pWndInsertAfter
BOOL SetWindowPos(const CWnd* pWndInsertAfter, int x, int y,
int cx, int cy, UINT nFlags);
it is not inside the private scope it is public
and because it is a static member all CWnd derived classes will have the same
so you can use each CWnd to access wndTopMost.
if your BringWindowToTop function belongs not to a CWnd class simple try
void BringWindowToTop( )
{
CWnd* MainWnd= AfxGetMainWnd();
MainWnd->SetWindowPos (&MainWnd->wndTopMost ,0,0,0,0, SWP_NOMOVE| SWP_NOSIZE| SWP_SHOWWINDOW);
}
that should do the work
I would have expected CWnd::BringWindowToTop() to have worked.
Is it being called?
Are other windows set as TOPMOST?
Is the processing locking out the Windows redraw? - Try CWnd::Redraw()
It may also be that all the apps are trying to bring themselves to the front rather than just the one you think is processing.
I have an app that fires off sub-apps. It uses BringWindowToTop to force itself to the front without any major problems.
Is it being called?
Are other windows set as TOPMOST?
Is the processing locking out the Windows redraw? - Try CWnd::Redraw()
It may also be that all the apps are trying to bring themselves to the front rather than just the one you think is processing.
I have an app that fires off sub-apps. It uses BringWindowToTop to force itself to the front without any major problems.
ASKER
void BringWindowToTop( )
{
AfxGetMainWnd()->SetWindow
}