Re: Loading A Graphic Using CxImage From User Input

new topic     » goto parent     » topic index » view thread      » older message » newer message

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:

  1. React to a click event and prompt the user to select a file
  2. Load the image and store it in a top-level variable
  3. Trigger a repaint with repaintWindow()
  4. 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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu