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. Picture Control

Picture Control

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicslearning
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.
  • L Offline
    L Offline
    Leyu
    wrote on last edited by
    #1

    I was using the picture box control and i loaded a bitmap to it from the resource using the properties dialog box, i wanted to manipulate the image from the code and i wanted to create a member variable so i changed the ID from IDC_STATIC to another and the only member variable for control and value is CString nothing as i Assumed of CBitmap or another. Well my ? is can i use this control to modify the contents of the bitmap at run time if so how do i do it? isn't there any class in which my picture box can map in to like HBITMAP,CBitmap or another ? Thanks :)

    V 1 Reply Last reply
    0
    • L Leyu

      I was using the picture box control and i loaded a bitmap to it from the resource using the properties dialog box, i wanted to manipulate the image from the code and i wanted to create a member variable so i changed the ID from IDC_STATIC to another and the only member variable for control and value is CString nothing as i Assumed of CBitmap or another. Well my ? is can i use this control to modify the contents of the bitmap at run time if so how do i do it? isn't there any class in which my picture box can map in to like HBITMAP,CBitmap or another ? Thanks :)

      V Offline
      V Offline
      Vikram Kashyap
      wrote on last edited by
      #2

      Hi,;) Yes, Certainly you can change the bitmap at run time during the MOUSEMOVE or on LBUTTONDOWN. Let's take the example of MOUSEMOVE void CMouseDlg::OnMouseMove(UINT nFlags, CPoint point) { m_Image.GetWindowRect(&rect); ClientToScreen(&point); if(rect.PtInRect(point)) { m_Image.SetBitmap(m_Bitmap1); } else { m_Image.SetBitmap(m_Bitmap2); } CDialog::OnMouseMove(nFlags, point); } Here m_Image is the control type variable of Image control created using Class Wizard and rect is CRect object. // m_Image.GetWindowRect(&rect); Extract the image control co-ordinates in a rect object. // ClientToScreen(&point); ClientToScreen is used to convert the client coordinates of a given point or rectangle on the display to screen coordinates. Next step is to check whether these points fall under the area where our image is place on the screen using PtInRect. If yes, then change the bitmap to whatever. m_Bitmap1 and m_Bitmap2 are twom CBitmap type objects defined in the header file. That's it...you r on ur way to change the bitmaps at runtime Vikram Kashyap "You will never fail until you stop trying"

      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