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. MFC background color

MFC background color

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

    Hello, i'm a newbie in MFC programming and I'm writing a simple and silly program that change the background color of the window by selecting the color in the Menù. I've created a menù with 5 color and each color has its own ID message. I put the handler of these messages in the Document class of the program: i don't know if this is correct. How can I change the color of background? I'm a bit confused because I would like to invalidate the client area and set the new color in OnDraw Method but I can't invalidate the area because if i put Invalidate() in the handler of the menù i get error. These questions could be silly and obvious for an expert user but I don't know how to proceed. Can anyone suggest me the way to do? Best regards.

    Richard Andrew x64R 1 Reply Last reply
    0
    • L lor75

      Hello, i'm a newbie in MFC programming and I'm writing a simple and silly program that change the background color of the window by selecting the color in the Menù. I've created a menù with 5 color and each color has its own ID message. I put the handler of these messages in the Document class of the program: i don't know if this is correct. How can I change the color of background? I'm a bit confused because I would like to invalidate the client area and set the new color in OnDraw Method but I can't invalidate the area because if i put Invalidate() in the handler of the menù i get error. These questions could be silly and obvious for an expert user but I don't know how to proceed. Can anyone suggest me the way to do? Best regards.

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      What type of view are you using? What error do you get when you call Invalidate()?

      The difficult we do right away... ...the impossible takes slightly longer.

      L 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        What type of view are you using? What error do you get when you call Invalidate()?

        The difficult we do right away... ...the impossible takes slightly longer.

        L Offline
        L Offline
        lor75
        wrote on last edited by
        #3

        If i put Invalidate(); in the handler I get the message: "error C3861: 'Invalidate': identifier not found I have a doubt: Invalidate is a method of Cview class and I call this function inside a method of CDocument class. Is this calling correct? How can I call a method of a class inside a method of another class?

        L 1 Reply Last reply
        0
        • L lor75

          If i put Invalidate(); in the handler I get the message: "error C3861: 'Invalidate': identifier not found I have a doubt: Invalidate is a method of Cview class and I call this function inside a method of CDocument class. Is this calling correct? How can I call a method of a class inside a method of another class?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You should use the UpdateAllViews[^] function of your CDocument derived class. That will then call the correct method for each CView derived object to update itself.

          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