Re: Loading A Graphic Using CxImage From User Input
- Posted by ghaberek (admin) Jun 23, 2009
- 1391 views
Andy, you need to separate your onClick handler from your onPaint handler. The only thing you should be doing during a paint event, is painting. You should never interact with the user during a paint event, as doing so will halt the event and possibly cause a repainting, resulting in an infinite loop.
The method should be:
- React to a click event and prompt the user to select a file
- Load the image and store it in a top-level variable
- Trigger a repaint with repaintWindow()
- Blit the image to the screen during the paint event
Mic, the CXI_LoadImage() routine works two ways: You can either feed it a filename or a buffer of a file in memory (in which case the third parameter should be the buffer size). The latter is useful for loading images from a database and such. But it seems Andy only needs to use the filename version, as his user is selecting a file via getOpenFileName().
-Greg