Solved

Bring application to topmost

Posted on 1998-07-06
4
500 Views
Last Modified: 2013-11-19
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()->BringWindowToTop(), SetFocus,
::SetForegroundWindow, SetActiveWindow... but they don't seem to work.

Sample code would be appreciated.
Thanx
Leow
0
Comment
Question by:engllf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
Norbert earned 50 total points
ID: 1318797
Did you try AfxGetMainWnd()->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
0
 

Author Comment

by:engllf
ID: 1318798
How can i get a reference to the wndTopMost (which is a private member) in a global function ?

void BringWindowToTop( )
{  
  AfxGetMainWnd()->SetWindowPos (&wndTopMost??? ,0,0,0,0, SWP_NOMOVE| SWP_NOSIZE| SWP_SHOWWINDOW);

}





0
 
LVL 3

Expert Comment

by:Norbert
ID: 1318799
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
0
 

Expert Comment

by:Magrat
ID: 1318800
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.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question