Making Window Active Given Pointer to Document

Making Window Active Given Pointer to Document

Post by PeterOu » Sun, 08 Oct 2006 05:49:50


I am using MSVS C++ 7.1.3088.

I have a set of documents, each with a single view. I also have a
pointer to each document and would like to make the window, associated
with that document, the active window (or "in scope" or whatever the
term is) and on top of all the others. I tried the following.

POSITION pos=pDocument->GetFirstViewPosition();
CView pcView=(CView *)(pDocument->GetNextView(pos));
pcIfSARView->SetForegroundWindow();

This sets the erstwhile active window's colors to the inactive colors
but does not do anything to the window that I would like to make
active.

I would be most grateful if someone could put me on the right track.

Many thanks in advance,
Peter.
 
 
 

Making Window Active Given Pointer to Document

Post by PeterOu » Sun, 08 Oct 2006 05:50:44

I am using MSVS C++ 7.1.3088.

I have a set of documents, each with a single view. I also have a
pointer to each document and would like to make the window, associated
with that document, the active window (or "in scope" or whatever the
term is) and on top of all the others. I tried the following.

POSITION pos=pDocument->GetFirstViewPosition();
CView pcView=(CView *)(pDocument->GetNextView(pos));
pcView->SetForegroundWindow();

This sets the erstwhile active window's colors to the inactive colors
but does not do anything to the window that I would like to make
active.

I would be most grateful if someone could put me on the right track.

Many thanks in advance,
Peter.

 
 
 

Making Window Active Given Pointer to Document

Post by Tom Serfac » Sun, 08 Oct 2006 07:07:06

You might try using GetActiveView() and/or BringWindowToTop()

http://www.yqcomputer.com/
http://www.yqcomputer.com/

Tom
 
 
 

Making Window Active Given Pointer to Document

Post by PeterOu » Sun, 08 Oct 2006 07:27:21


It worked!

POSITION pos=pDocument->GetFirstViewPosition();
CView pcView=(CView *)(pDocument->GetNextView(pos));
CFrameView *pcFrameWnd=pcView->GetParentFrame();
pcFrameWnd->BringWindowToTop();

Thanks very much,
Peter.
 
 
 

Making Window Active Given Pointer to Document

Post by Ajay Kalr » Sun, 08 Oct 2006 09:00:13


http://www.yqcomputer.com/




You can call CFrameWnd::ActivateFrame to activate the relevant frame. It
does more than just showing the window and takes care of scenario when
window is minimized and needs restoration etc.

--
Ajay Kalra [MVP - VC++]
XXXX@XXXXX.COM