15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


SetActiveDocument

Mats Mеnhav -- manhav@connectum.skurup.se
Saturday, January 20, 1996

-- [ From: Mats Mеnhav * EMC.Ver #2.5.02 ] --

I am using VC40 on WinNT 3.51 with NewShell installed.

I have an application that has several documents defined.
Depending on some user action I want to set which document should be active.

Has anyone come up with a solution for this ?

I tried this code which I thought would work, but it doesn't.

void CMyDoc::BringToTop()
{
   POSITION pos;
   pos = GetFirstViewPosition();
   // this function should not be called if pos == NULL
   ASSERT(pos);
   GetMainWnd()->SetActiveView(GetNextView(pos));
}

Stepping through SetActiveView shows that it will try to change the view
within the document object only. It seems like CFrameWnd::SetActiveView only
works within the document.

Anoyone got another idea.
Mats
--
==========================================================================
Mats Mеnhav (Mats Manhav for 7-bit people)
email:manhav@connectum.skurup.se   WWW: http://connectum.skurup.se/~manhav
FAX:  (int) 46 (0) 414 243 05      Phone: (int) 46 (0) 414 243 05         
==========================================================================




Simon Wilson -- wilsons@roverpte.demon.co.uk
Tuesday, January 23, 1996

[Mini-digest: 2 responses]

>-- [ From: Mats Mnhav * EMC.Ver #2.5.02 ] --
>
>I am using VC40 on WinNT 3.51 with NewShell installed.
>
>I have an application that has several documents defined.
>Depending on some user action I want to set which document should be active.
>
>Has anyone come up with a solution for this ?
>
>I tried this code which I thought would work, but it doesn't.
>
>void CMyDoc::BringToTop()
>{
>   POSITION pos;
>   pos = GetFirstViewPosition();
>   // this function should not be called if pos == NULL
>   ASSERT(pos);
>   GetMainWnd()->SetActiveView(GetNextView(pos));
>}
>
>Stepping through SetActiveView shows that it will try to change the view
>within the document object only. It seems like CFrameWnd::SetActiveView only
>works within the document.
>
>Anoyone got another idea.
>Mats
>--
Mats,

It is possible to iterate through the document template list and then
through the documents in each template. I can't quote code at the moment
because I don't have any handy, but I have used this method before, similar
to the document iteration using the POSITION value.

Cheers,
Simon.
Simon Wilson
wilsons@roverpte.demon.co.uk

-----From: Jim Beveridge 

Our MDI app uses this code to change the active view on
the screen (This code is in the middle of a member function
of the view that *should* be active)

        CMDIChildWnd* pThisChild = (CMDIChildWnd*)GetParentFrame();
        ASSERT_VALID(pThisChild);
        pMainFrame->MDIActivate(pThisChild);
        pThisChild->SetActiveView(this);


-- Jim




| Вернуться в корень Архива |