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

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


How to add a new view in a SDI application

Juan Carlos Cobas -- qocarlos@usc.es
Monday, January 20, 1997

Environment: VC++ 4.0, Win 95

I'm developing a SDI application. I use the initial view succesfully. I want
to add a new view in response to a specific menu option. I want this view
become attached to the document and frame in order to use the UpdateAllViews
and related functions which keep the views coordinated.
I don't know how to create the new view. The following function handles the
above mentioned menu option. What I've tried without success was to declare
a derived class from CFormView (with the corresponding dialog ID),
constructed it, used the member function Create of the parent class of any
view (CWnd). Then I called ShowWindow() which failed. Finally when exiting
OnTempo, the program crashed.

void CKkDoc::OnTempo() 
{
	UINT nID=33333;//I have added this ID but I don't know if this is right.
	vchap p;
	p.Create("AfxFrameOrView","aaa",WS_CHILD,CRect(0,0,300,300),pMF,nID,NULL);
	AddView(&p);
	p.ShowWindow(SW_SHOWNORMAL); //This function fails (returns FALSE), but
shows the window.
	pMF->SetActiveView(&p); //pMF is a global pointer to the MainFrame window,
correctly initialized.
	Sleep(10000); //Just to see if the title bar of the newly created child
window is highlighted 
                      //but it did not become highlighted
	
}

Any help would gratefully appreciated.
==================================

Juan Carlos Cobas Gomez        

Departamento de Quimica Organica

Universidade de Santiago de Compostela

Fax number: +34-81-595012 

Telephone number: +34-81-591085
email: qocarlos@uscmail.usc.es

Spain

==================================




Juan Carlos Cobas -- qocarlos@usc.es
Monday, January 20, 1997

Environment: VC++ 4.0, Win 95

I'm developing a SDI application. I use the initial view succesfully. I want
to add a new view in response to a specific menu option. I want this view
become attached to the document and frame in order to use the UpdateAllViews
and related functions which keep the views coordinated.
I don't know how to create the new view. The following function handles the
above mentioned menu option. What I've tried without success was to declare
a derived class from CFormView (with the corresponding dialog ID),
constructed it, used the member function Create of the parent class of any
view (CWnd). Then I called ShowWindow() which failed. Finally when exiting
OnTempo, the program crashed.

void CKkDoc::OnTempo() 
{
	UINT nID=33333;//I have added this ID but I don't know if this is right.
	vchap p;
	p.Create("AfxFrameOrView","aaa",WS_CHILD,CRect(0,0,300,300),pMF,nID,NULL);
	AddView(&p);
	p.ShowWindow(SW_SHOWNORMAL); //This function fails (returns FALSE), but
shows the window.
	pMF->SetActiveView(&p); //pMF is a global pointer to the MainFrame window,
correctly initialized.
	Sleep(10000); //Just to see if the title bar of the newly created child
window is highlighted 
                      //but it did not become highlighted
	
}

Any help would gratefully appreciated.
==================================

Juan Carlos Cobas Gomez        

Departamento de Quimica Organica

Universidade de Santiago de Compostela

Fax number: +34-81-595012 

Telephone number: +34-81-591085
email: qocarlos@uscmail.usc.es

Spain

==================================




Ray Barley -- barley@rdaconsultants.com
Wednesday, January 22, 1997

[Mini-digest: 5 responses]

Take a look at the sample VSWAP32 on the knowledge base for C and Visual
C++ in the MSDN library.  Also available at ftp.microsoft.com in
directory Softlib\Mslfiles - VSWAP32.EXE (self-extracting archive).

>----------
>From: 	Juan Carlos Cobas[SMTP:qocarlos@usc.es]
>Sent: 	Monday, January 20, 1997 3:58 PM
>To: 	mfc-l@netcom.com
>Subject: 	How to add a new view in a SDI application
>
>Environment: VC++ 4.0, Win 95
>
>I'm developing a SDI application. I use the initial view succesfully. I want
>to add a new view in response to a specific menu option. I want this view
>become attached to the document and frame in order to use the UpdateAllViews
>and related functions which keep the views coordinated.
>I don't know how to create the new view. The following function handles the
>above mentioned menu option. What I've tried without success was to declare
>a derived class from CFormView (with the corresponding dialog ID),
>constructed it, used the member function Create of the parent class of any
>view (CWnd). Then I called ShowWindow() which failed. Finally when exiting
>OnTempo, the program crashed.
>
>void CKkDoc::OnTempo() 
>{
>	UINT nID=33333;//I have added this ID but I don't know if this is right.
>	vchap p;
>	p.Create("AfxFrameOrView","aaa",WS_CHILD,CRect(0,0,300,300),pMF,nID,NULL);
>	AddView(&p);
>	p.ShowWindow(SW_SHOWNORMAL); //This function fails (returns FALSE), but
>shows the window.
>	pMF->SetActiveView(&p); //pMF is a global pointer to the MainFrame window,
>correctly initialized.
>	Sleep(10000); //Just to see if the title bar of the newly created child
>window is highlighted 
>                      //but it did not become highlighted
>	
>}
>
>Any help would gratefully appreciated.
>==================================
>
>Juan Carlos Cobas Gomez        
>
>Departamento de Quimica Organica
>
>Universidade de Santiago de Compostela
>
>Fax number: +34-81-595012 
>
>Telephone number: +34-81-591085
>email: qocarlos@uscmail.usc.es
>
>Spain
>
>==================================
>
>
-----From: Craig Marshall 


Hi,
there is an old article on the MSDN Library CD that explains how to do this.
It can be found under the Technical Articles section.
It is titled "Multiple views for a single document" 
written by Dale Rogerson, Microsoft Developer Network Technology Group
Created: August 2, 1993

The article ends with:
----
Conclusion
The ability to create multiple view classes for a single document class is
only one of the many benefits of using the document/view architecture
promoted by the Microsoft Foundation Class Library version 2.0. The process
is not difficult; it consists of the following steps:
 1.	Creating a new view class.
 2.	Adding the new view class to the document template during the
application's InitInstance function.
 3.	Adding a pointer to the document template.
 4.	Adding the document template string for the new document template.
 5.	Giving the application variable global scope.
 6.	Adding menu commands to change the view.
 7.	Adding handlers to change the view.
 8.	Adding a function such as CMainFrame::CreateOrActivateFrame to open or
create an alternate view for the current document.
 9.	Testing extensively.
  
-------------------




At 21:58 20/01/97 +0100, you wrote:
>Environment: VC++ 4.0, Win 95
>
>I'm developing a SDI application. I use the initial view succesfully. I want
>to add a new view in response to a specific menu option. I want this view
>become attached to the document and frame in order to use the UpdateAllViews
>and related functions which keep the views coordinated.
>I don't know how to create the new view. The following function handles the
>above mentioned menu option. What I've tried without success was to declare
>a derived class from CFormView (with the corresponding dialog ID),
>constructed it, used the member function Create of the parent class of any
>view (CWnd). Then I called ShowWindow() which failed. Finally when exiting
>OnTempo, the program crashed.
>
>void CKkDoc::OnTempo() 
>{
>	UINT nID=33333;//I have added this ID but I don't know if this is right.
>	vchap p;
>	p.Create("AfxFrameOrView","aaa",WS_CHILD,CRect(0,0,300,300),pMF,nID,NULL);
>	AddView(&p);
>	p.ShowWindow(SW_SHOWNORMAL); //This function fails (returns FALSE), but
>shows the window.
>	pMF->SetActiveView(&p); //pMF is a global pointer to the MainFrame window,
>correctly initialized.
>	Sleep(10000); //Just to see if the title bar of the newly created child
>window is highlighted 
>                      //but it did not become highlighted
>	
>}
>
>Any help would gratefully appreciated.
>==================================
>
>Juan Carlos Cobas Gomez        
>
>Departamento de Quimica Organica
>
>Universidade de Santiago de Compostela
>
>Fax number: +34-81-595012 
>
>Telephone number: +34-81-591085
>email: qocarlos@uscmail.usc.es
>
>Spain
>
>==================================
>
>
>

-----From: Santosh Gadre 

Hi Juan,
Pl. see the documentation of CDocument, it has a member function called void AddView( CView* pView );
   The documentation also has a sweet, tiny example.
   Hope it solves ur problem.

Warm regards,

-SanyG


----------
From: 	Juan Carlos Cobas[SMTP:qocarlos@usc.es]
Sent: 	Tuesday, January 21, 1997 2:28 AM
To: 	mfc-l@netcom.com
Subject: 	How to add a new view in a SDI application

Environment: VC++ 4.0, Win 95

I'm developing a SDI application. I use the initial view succesfully. I want
to add a new view in response to a specific menu option. I want this view
become attached to the document and frame in order to use the UpdateAllViews
and related functions which keep the views coordinated.
I don't know how to create the new view. The following function handles the
above mentioned menu option. What I've tried without success was to declare
a derived class from CFormView (with the corresponding dialog ID),
constructed it, used the member function Create of the parent class of any
view (CWnd). Then I called ShowWindow() which failed. Finally when exiting
OnTempo, the program crashed.

void CKkDoc::OnTempo() 
{
	UINT nID=33333;//I have added this ID but I don't know if this is right.
	vchap p;
	p.Create("AfxFrameOrView","aaa",WS_CHILD,CRect(0,0,300,300),pMF,nID,NULL);
	AddView(&p);
	p.ShowWindow(SW_SHOWNORMAL); //This function fails (returns FALSE), but
shows the window.
	pMF->SetActiveView(&p); //pMF is a global pointer to the MainFrame window,
correctly initialized.
	Sleep(10000); //Just to see if the title bar of the newly created child
window is highlighted 
                      //but it did not become highlighted
	
}

Any help would gratefully appreciated.
==================================

Juan Carlos Cobas Gomez        

Departamento de Quimica Organica

Universidade de Santiago de Compostela

Fax number: +34-81-595012 

Telephone number: +34-81-591085
email: qocarlos@uscmail.usc.es

Spain

==================================



-----From: mfc-l@netcom.com

>From mfc-l Mon Jan 20 21:58:58 +0100 1997 remote from netcom.com
Received: from netcom.com by tc4d1.cmc.stph.net; Thu, 23 Jan 1997 14:40 EST
Received: by majordomo.netcom.com (8.7.5/8.7.3/(NETCOM MLS v1.01)) id IAA23565; Wed, 22 Jan 1997 08:19:26 -0800 (PST)
Message-Id: <1.5.4.32.19970120205858.0067baf8@uscmail.usc.es>
X-Sender: qocarlos@uscmail.usc.es
X-Mailer: Windows Eudora Light Version 1.5.4 (32)
Mime-Version: 1.0
Date: Mon, 20 Jan 1997 21:58:58 +0100
To: mfc-l@netcom.com
From: Juan Carlos Cobas 
Subject: How to add a new view in a SDI application
Sender: owner-mfc-l@majordomo.netcom.com
Errors-To: owner-mfc-l@majordomo.netcom.com
Precedence: bulk
Reply-To: mfc-l@netcom.com
Content-Type: text/plain; charset="us-ascii"
Content-Length: 1581

Environment: VC++ 4.0, Win 95

I'm developing a SDI application. I use the initial view succesfully. I want
to add a new view in response to a specific menu option. I want this view
become attached to the document and frame in order to use the UpdateAllViews
and related functions which keep the views coordinated.
I don't know how to create the new view. The following function handles the
above mentioned menu option. What I've tried without success was to declare
a derived class from CFormView (with the corresponding dialog ID),
constructed it, used the member function Create of the parent class of any
view (CWnd). Then I called ShowWindow() which failed. Finally when exiting
OnTempo, the program crashed.

void CKkDoc::OnTempo() 
{
	UINT nID=33333;//I have added this ID but I don't know if this is right.
	vchap p;
	p.Create("AfxFrameOrView","aaa",WS_CHILD,CRect(0,0,300,300),pMF,nID,NULL);
	AddView(&p);
	p.ShowWindow(SW_SHOWNORMAL); //This function fails (returns FALSE), but
shows the window.
	pMF->SetActiveView(&p); //pMF is a global pointer to the MainFrame window,
correctly initialized.
	Sleep(10000); //Just to see if the title bar of the newly created child
window is highlighted 
                      //but it did not become highlighted
	
}

Any help would gratefully appreciated.
==================================

Juan Carlos Cobas Gomez        

Departamento de Quimica Organica

Universidade de Santiago de Compostela

Fax number: +34-81-595012 

Telephone number: +34-81-591085
email: qocarlos@uscmail.usc.es

Spain

==================================

-----From: mfc-l@netcom.com

>From mfc-l Mon Jan 20 21:58:58 +0100 1997 remote from netcom.com
Received: from netcom.com by tc4d1.cmc.stph.net; Thu, 23 Jan 1997 14:42 EST
Received: by majordomo.netcom.com (8.7.5/8.7.3/(NETCOM MLS v1.01)) id IAA23565; Wed, 22 Jan 1997 08:19:26 -0800 (PST)
Message-Id: <1.5.4.32.19970120205858.0067baf8@uscmail.usc.es>
X-Sender: qocarlos@uscmail.usc.es
X-Mailer: Windows Eudora Light Version 1.5.4 (32)
Mime-Version: 1.0
Date: Mon, 20 Jan 1997 21:58:58 +0100
To: mfc-l@netcom.com
From: Juan Carlos Cobas 
Subject: How to add a new view in a SDI application
Sender: owner-mfc-l@majordomo.netcom.com
Errors-To: owner-mfc-l@majordomo.netcom.com
Precedence: bulk
Reply-To: mfc-l@netcom.com
Content-Type: text/plain; charset="us-ascii"
Content-Length: 1581

Environment: VC++ 4.0, Win 95

I'm developing a SDI application. I use the initial view succesfully. I want
to add a new view in response to a specific menu option. I want this view
become attached to the document and frame in order to use the UpdateAllViews
and related functions which keep the views coordinated.
I don't know how to create the new view. The following function handles the
above mentioned menu option. What I've tried without success was to declare
a derived class from CFormView (with the corresponding dialog ID),
constructed it, used the member function Create of the parent class of any
view (CWnd). Then I called ShowWindow() which failed. Finally when exiting
OnTempo, the program crashed.

void CKkDoc::OnTempo() 
{
	UINT nID=33333;//I have added this ID but I don't know if this is right.
	vchap p;
	p.Create("AfxFrameOrView","aaa",WS_CHILD,CRect(0,0,300,300),pMF,nID,NULL);
	AddView(&p);
	p.ShowWindow(SW_SHOWNORMAL); //This function fails (returns FALSE), but
shows the window.
	pMF->SetActiveView(&p); //pMF is a global pointer to the MainFrame window,
correctly initialized.
	Sleep(10000); //Just to see if the title bar of the newly created child
window is highlighted 
                      //but it did not become highlighted
	
}

Any help would gratefully appreciated.
==================================

Juan Carlos Cobas Gomez        

Departamento de Quimica Organica

Universidade de Santiago de Compostela

Fax number: +34-81-595012 

Telephone number: +34-81-591085
email: qocarlos@uscmail.usc.es

Spain

==================================





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