accessing objects in different views 
Author Message
 accessing objects in different views

It would be better to put the handlers in the document or in the view
itself.  You can do the handlers with OnCommandUI handlers and simply set
variables to determine whether or not the windows are enabled.

Tom


Quote:
> I have an SDI with multiple views that are switched in and out.

> My toolbar buttons are handled in MainFrame, but i cant change any of the
> objects in the current view from mainframe.

> All the objects are declaired as public.. Help:

> in mainframe:
> CHexView HexView;

> if(GetActiveView()->GetRuntimeClass() == RUNTIME_CLASS(CHexView))

> {

> HexView.c_SendDataButton.EnableWindow( TRUE );

> HexView.c_ClearDataButton.EnableWindow( FALSE );

> }

> both seem to cause an assertion error even though CHevView is the
currently
> displayed view!

> joe

> #



Mon, 18 Apr 2005 01:53:40 GMT  
 accessing objects in different views
I have an SDI with multiple views that are switched in and out.

My toolbar buttons are handled in MainFrame, but i cant change any of the
objects in the current view from mainframe.

All the objects are declaired as public.. Help:

in mainframe:
CHexView HexView;

if(GetActiveView()->GetRuntimeClass() == RUNTIME_CLASS(CHexView))

{

HexView.c_SendDataButton.EnableWindow( TRUE );

HexView.c_ClearDataButton.EnableWindow( FALSE );

Quote:
}

both seem to cause an assertion error even though CHevView is the currently
displayed view!

joe

#



Mon, 18 Apr 2005 01:09:36 GMT  
 accessing objects in different views
I know, but i have several menu options that only relate to that view (when
displayed), they are greyed out when not displayed, but when the view is
shown, they need to be handled. Its too late to do it that way (Bad
planning..!) so i have had to use postmessage(...) all over the place with a
check to see if it is in view!

Really bad practice, im gonna learn from this mistake!

Cheers,

joe

#


Quote:
> It would be better to put the handlers in the document or in the view
> itself.  You can do the handlers with OnCommandUI handlers and simply set
> variables to determine whether or not the windows are enabled.

> Tom



> > I have an SDI with multiple views that are switched in and out.

> > My toolbar buttons are handled in MainFrame, but i cant change any of
the
> > objects in the current view from mainframe.

> > All the objects are declaired as public.. Help:

> > in mainframe:
> > CHexView HexView;

> > if(GetActiveView()->GetRuntimeClass() == RUNTIME_CLASS(CHexView))

> > {

> > HexView.c_SendDataButton.EnableWindow( TRUE );

> > HexView.c_ClearDataButton.EnableWindow( FALSE );

> > }

> > both seem to cause an assertion error even though CHevView is the
> currently
> > displayed view!

> > joe

> > #



Mon, 18 Apr 2005 03:36:22 GMT  
 accessing objects in different views

Quote:

> I have an SDI with multiple views that are switched in and out.

> My toolbar buttons are handled in MainFrame, but i cant change any of the
> objects in the current view from mainframe.

> All the objects are declaired as public.. Help:

> in mainframe:
> CHexView HexView;

> if(GetActiveView()->GetRuntimeClass() == RUNTIME_CLASS(CHexView))

> {

> HexView.c_SendDataButton.EnableWindow( TRUE );

> HexView.c_ClearDataButton.EnableWindow( FALSE );

> }

> both seem to cause an assertion error even though CHevView is the currently
> displayed view!

> joe

> #

Your first line:  CHexView HexView;
creates a new CHexView object, then you are calling this new
(uninitialized) object.  It is not the same object as the active view.
GetActiveView() can be used to obtain a pointer to the actual active
object that you need to call.

Your if statement is also dangerous or maybe invalid.  Doing it like
this would be legal:
if (GetActiveView()->IsKindOf(RUNTIME_CLASS(CHexView)))

--
Scott McPhillips [VC++ MVP]



Mon, 18 Apr 2005 03:46:37 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. how to access objects in different views

2. User Controls: Accessing Properties (a slightly different point of view)

3. Problem accessing function in different view....

4. Accessing objects from different threads

5. Accessing View from App Object

6. Accessing View and Doc From Application object

7. Accessing View & Doc from Application object

8. Create mutiple views of one document using different view classes

9. Create mutiple views of one document using different view classes

10. How to Access View methods from Document in MFC DOC/VIEW

11. access to a views member variables from another view

12. Get access to a view's member var from another view using multiple templates

 

 
Powered by phpBB® Forum Software