Try using MSG_VIS_OPEN instead. I can't say I've ever intercepted that
message but I'm repeatedly told that is the solution to this problem. The
reason the ObjDerefGen doesn't work before the object receives a message is
that the Gen portion of the instance data hasn't been built out yet. The optr
only points to the Meta instance. Then when the object receives a message it
will build itself out and then you can use ObjDerefGen.
> Next, I want to calculate the size of the view based on some instance
> data and font sizes. To get the font size, I have to have a gstate. To
> get a gstate, I have to have a windowhandle. Is there any way I can do
> that stuff before MSG_META_EXPOSED ? Because if I try to set the bounds
> from in there it doesn't resize the view.
Here's how I did it in Character Map:
@method blah, blah {
WindowHandle win;
GStateHandle gstate;
win = @call pself->VCNI_view::MSG_GEN_VIEW_GET_WINDOW();
gstate = GrCreateState( win );
GrInvalRect( gstate, CHARM_MAP_LEFT, CHARM_MAP_TOP,
CHARM_MAP_RIGHT, CHARM_MAP_BOTTOM );
GrDestroyState( gstate );
}
The neat part about using a VisContent (as I am here) is that one of the
instance data is the optr of the view. You may not need to utilize a
VisContent is the view you are using is statically defined. In any case, send
the MSG_GEN_VIEW_GET_WINDOW message to the view and it will return the window
handle associated with the view. Then use that window handle to create a
gstate. Here I'm using the gstate to invalidate the content and thus refresh
the view.
Nathan