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. color change

color change

Scheduled Pinned Locked Moved C / C++ / MFC
c++comquestion
3 Posts 3 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
    sidkraft
    wrote on last edited by
    #1

    I am trying to change colors using variables in the initialization of a RGB command. The following are the commands used in MFC/Visual C++ 6.0: int a = 200; int b = 180; int c = 125; CMainFrame::CMainFrame() { //Set color frame colorbar.CreateSolidBrush(RGB (a, b, c)); } void CMainFrame::OnPaint() { CPaintDC dc(this); CRect rc(100,150,150,200); a = 140; dc.FillSolidRect(&rc,RGB(a,b,c)); } No matter what I set a to, it always displays with the original value for color. Is there a way to change the RGB colors after initialization? Please let me know at sid_kraft@msn.com. Thanks in advance, Sid Kraft Sid

    S H 2 Replies Last reply
    0
    • S sidkraft

      I am trying to change colors using variables in the initialization of a RGB command. The following are the commands used in MFC/Visual C++ 6.0: int a = 200; int b = 180; int c = 125; CMainFrame::CMainFrame() { //Set color frame colorbar.CreateSolidBrush(RGB (a, b, c)); } void CMainFrame::OnPaint() { CPaintDC dc(this); CRect rc(100,150,150,200); a = 140; dc.FillSolidRect(&rc,RGB(a,b,c)); } No matter what I set a to, it always displays with the original value for color. Is there a way to change the RGB colors after initialization? Please let me know at sid_kraft@msn.com. Thanks in advance, Sid Kraft Sid

      S Offline
      S Offline
      Sarath C
      wrote on last edited by
      #2

      Seems this will work properly. check for local definitions of variable 'a' You always filling a rectangle with a value 140,180,125 the how you could track the difference? When filling a solid rectangle, you don't need to create teh solid brush. the brush you have created is not selected by any dc. so if you are not using that, remove the same. SaRath.
      "Don't Do Different things... Do Things Differently..." Understanding State Pattern in C++

      1 Reply Last reply
      0
      • S sidkraft

        I am trying to change colors using variables in the initialization of a RGB command. The following are the commands used in MFC/Visual C++ 6.0: int a = 200; int b = 180; int c = 125; CMainFrame::CMainFrame() { //Set color frame colorbar.CreateSolidBrush(RGB (a, b, c)); } void CMainFrame::OnPaint() { CPaintDC dc(this); CRect rc(100,150,150,200); a = 140; dc.FillSolidRect(&rc,RGB(a,b,c)); } No matter what I set a to, it always displays with the original value for color. Is there a way to change the RGB colors after initialization? Please let me know at sid_kraft@msn.com. Thanks in advance, Sid Kraft Sid

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        a rectangle with green color(almost) of course OnPaint in CSDIView::OnPaint()_**


        **_

        whitesky


        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