Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to manage image position after changing screen resolution?

How to manage image position after changing screen resolution?

Scheduled Pinned Locked Moved C / C++ / MFC
game-devtutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Supra2
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • S Supra2

      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

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      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++

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups