why is this code causing an unmapped memory exception?

why is this code causing an unmapped memory exception?

Post by Christian Jo » Tue, 10 Sep 1996 04:00:00



Hi everybody,

I try to change the text in an LCaption object, but the command
SetDescriptor doesn't do what I want it to do. Any idea?

      LStr255 theString;
      LCaption* theCaption = (LCaption*)mWindow->FindPaneByID(
growth_Rate_interval );
      theString.Assign( 4.5,FLOATDECIMAL,8);
      theCaption->SetDescriptor((ConstStringPtr ) theString);

mWindow is the global window variable, growth_Rate_interval is a constant
with the LCaption ID. Everytime the de* tries to digest this line it
says there is an unmapped memory expception and stops.
Actually I tried to adapt the example from the PP book about Controls
(chapter 8), where in the lower right corner an LCaption displays the last
message.

Thanks a lot, Christian.

--
Christian Jost, Universit Paris-Sud XI, Orsay, France

 
 
 

why is this code causing an unmapped memory exception?

Post by Doug Rosenbe » Wed, 11 Sep 1996 04:00:00




> Hi everybody,

> I try to change the text in an LCaption object, but the command
> SetDescriptor doesn't do what I want it to do. Any idea?

>       LStr255 theString;
>       LCaption* theCaption = (LCaption*)mWindow->FindPaneByID(
> growth_Rate_interval );
>       theString.Assign( 4.5,FLOATDECIMAL,8);
>       theCaption->SetDescriptor((ConstStringPtr ) theString);

> mWindow is the global window variable, growth_Rate_interval is a constant
> with the LCaption ID. Everytime the de* tries to digest this line it
> says there is an unmapped memory expception and stops.
> Actually I tried to adapt the example from the PP book about Controls
> (chapter 8), where in the lower right corner an LCaption displays the last
> message.

> Thanks a lot, Christian.

> --
> Christian Jost, Universit Paris-Sud XI, Orsay, France


I think that cast (ConstStringPtr ) theString is invalid.
I believe you really need to use the operator "ConstStringPtr" or
"StringPtr" instead of a cast. Look in the LString.h file for details

Here is some code that works for me
   LStr255 viewName( mName);
   viewName+= "\p of ";
   viewName+= superClass->GetModelNamePtr();
    mWindow->SetDescriptor(StringPtr(viewName) );