How to manage image position after changing screen resolution?
-
Hi, I have developed one application which loads some jpg images and when I resize window the position of all these images gets changed. I have loaded a small image at bottom of right corner of screen (SDI application). When I restore the screen I am not able to see the same image in window. I am using GetclientRect function to calculate the screen size but after using this I am able to manage the images properly. I want to draw these images as per the screen size(e.g solitaire game). Please suggest how to do it. Thanks
-
Hi, I have developed one application which loads some jpg images and when I resize window the position of all these images gets changed. I have loaded a small image at bottom of right corner of screen (SDI application). When I restore the screen I am not able to see the same image in window. I am using GetclientRect function to calculate the screen size but after using this I am able to manage the images properly. I want to draw these images as per the screen size(e.g solitaire game). Please suggest how to do it. Thanks
You shouldn't draw only the image on screen. Instead what you have to do is remember the data that should be displayed, and redraw the data when needed. If you are using an SDI application, part of the job is already done for you. Let's take the solitaire game as an example: in your document class, you would store your current situation (e.g. what are the visible cards, the current available card in to be draw, ...). You do not store anything which is related to the screen (no images, no card position, ...). This is purely data. Then whenever this data changes (e.g. the user moves some card), then you request the view to repaint itself. Everything is delegated to the view to set the cards to the correct position and so on. When the view is resized, it will also repaint itself in the same way. In your situation, if the images disappear it's probably because your view is repainted and you didn't put any drawing code in the paint handler. A suggest you take a look at the Scribble example[^] on MSDN (it's a MDI application, but it will already give you a lot of feedback on how you have to do it for a SDI app).
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++