I would like to let the user to select a particular area in a graph screen
(The graph screen is now exists). Now I have made a feature that enables the
user to "drag" a dotted rectangle using WinDrawGrayRectangleFrame(),
like the one in windows for selecting icons.

I tried to use WinSaveBits() when penDownEvent occurs to save the whole
screen and draw the screen back when penMoveEvent occur by WinRestoreBits().
However, when I run it in my Palm m515, It complains with a fatal alert:

MemoryMgr.c, Line:4475
Invalid chunk ptr

and require me to reset. It merely makes my PC hang when I run it in POSE. :(
I tried to use WinEraseRectangleFrame() when penMoveEvent occur to erase
the previous rectangle. It seems works but the graph is spoiled.

The WinRestoreBits() only works when penUpEvent occur. As a result, when user
is selecting the graph, the graph will be  spoiled. Fortunately, it can be
restored back to the original one when the stylus take off from the screen.
But I hope to make it looks like the Windows one, that means the dotted
rectangle won't spoil the background graph. Could anybody teach me how to
achieve that?

Sorry for my poor English.

Here is what I have written:

switch (eventP->eType) {
  case penDownEvent:
    if (RctPtInRectangle(eventP->screenX,eventP->screenY,&gDrawRect)){
      SavedRegion = WinSaveBits(&wholeScreenRect, &rectErr);
      gX =eventP->screenX;
      gY =eventP->screenY;
      gPenDown =true;
      handled =true;
    }
  break;
  case penMoveEvent:

    if (RctPtInRectangle(eventP->screenX,eventP->screenY,&gDrawRect)&&gPenDown){
      WinEraseRectangleFrame(rectangleFrame, &dottedRect);
      WinRestoreBits(SavedRegion, 0, 0);  //fatal alert occurs when this line exists
      newX =eventP->screenX;
      newY =eventP->screenY;
      dottedRect.topLeft.x = gX;
      dottedRect.topLeft.y = gY;
      dottedRect.extent.x = newX - gX;
      dottedRect.extent.y = newY - gY;
      WinDrawGrayRectangleFrame(rectangleFrame, &dottedRect);

      handled =true;
    }
  break;
  case penUpEvent:
    if (RctPtInRectangle(eventP->screenX,eventP->screenY,&gDrawRect)&&gPenDown){
      newX =eventP->screenX;
      newY =eventP->screenY;
      gX =gDrawRect.topLeft.x;
      gY =gDrawRect.topLeft.y;
      gPenDown =false;
      handled =true;
    }
  break;
}


-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to