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. CStatic on CMDIChildWnd

CStatic on CMDIChildWnd

Scheduled Pinned Locked Moved C / C++ / MFC
13 Posts 4 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.
  • P Offline
    P Offline
    prithaa
    wrote on last edited by
    #1

    Hello, I have a CStatic on CMDIChildWnd but I am not able to change its background color. I have tried using CWnd functions CStatic* Static = new CStatic; CDC* pDC = Static->GetDC(); pDC->SetBkMode(OPAQUE); pDC->SetBkColor(RGB(150,150,255)); Pritha

    O _ 2 Replies Last reply
    0
    • P prithaa

      Hello, I have a CStatic on CMDIChildWnd but I am not able to change its background color. I have tried using CWnd functions CStatic* Static = new CStatic; CDC* pDC = Static->GetDC(); pDC->SetBkMode(OPAQUE); pDC->SetBkColor(RGB(150,150,255)); Pritha

      O Offline
      O Offline
      ovidiucucu
      wrote on last edited by
      #2

      First of all, in your piece of code you have instantiated a CStatic object but have not created a static control (see CStatic::Create). And BTW: where/why do you want to put a static control in the MDI child frame window?

      Ovidiu Cucu Microsoft MVP - Visual C++ Cofounder CODEXPERT.RO

      P 1 Reply Last reply
      0
      • P prithaa

        Hello, I have a CStatic on CMDIChildWnd but I am not able to change its background color. I have tried using CWnd functions CStatic* Static = new CStatic; CDC* pDC = Static->GetDC(); pDC->SetBkMode(OPAQUE); pDC->SetBkColor(RGB(150,150,255)); Pritha

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        Handle the WM_CTLCOLORSTATIC notification and return the brush to be used to paint the control.

        «_Superman_» I love work. It gives me something to do between weekends.

        1 Reply Last reply
        0
        • O ovidiucucu

          First of all, in your piece of code you have instantiated a CStatic object but have not created a static control (see CStatic::Create). And BTW: where/why do you want to put a static control in the MDI child frame window?

          Ovidiu Cucu Microsoft MVP - Visual C++ Cofounder CODEXPERT.RO

          P Offline
          P Offline
          prithaa
          wrote on last edited by
          #4

          thanks Yes I do have the Create function. How do I use WM_CTLCOLORSTATIC ? Should I call the OnCtlColor() ? Thanks Pritha

          _ H 2 Replies Last reply
          0
          • P prithaa

            thanks Yes I do have the Create function. How do I use WM_CTLCOLORSTATIC ? Should I call the OnCtlColor() ? Thanks Pritha

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #5

            No. It will be called by the system while initializing the controls. You simply have to return the appropriate brush from the message handler.

            «_Superman_» I love work. It gives me something to do between weekends.

            1 Reply Last reply
            0
            • P prithaa

              thanks Yes I do have the Create function. How do I use WM_CTLCOLORSTATIC ? Should I call the OnCtlColor() ? Thanks Pritha

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

              You need to declare this event.

              Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

              P 1 Reply Last reply
              0
              • H Hamid Taebi

                You need to declare this event.

                Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                P Offline
                P Offline
                prithaa
                wrote on last edited by
                #7

                Thank you It helped me a lot.

                P 1 Reply Last reply
                0
                • P prithaa

                  Thank you It helped me a lot.

                  P Offline
                  P Offline
                  prithaa
                  wrote on last edited by
                  #8

                  Hello, There was a query on the same lines.I am many a times confused which are the fucntions that are called by the system automatically which are not. Now in this case why the creation of CStatic calls OnCtlColor(). Thanks, Pritha

                  H 1 Reply Last reply
                  0
                  • P prithaa

                    Hello, There was a query on the same lines.I am many a times confused which are the fucntions that are called by the system automatically which are not. Now in this case why the creation of CStatic calls OnCtlColor(). Thanks, Pritha

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

                    Again you dont need to call OnCtlColor.

                    Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                    P 1 Reply Last reply
                    0
                    • H Hamid Taebi

                      Again you dont need to call OnCtlColor.

                      Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                      P Offline
                      P Offline
                      prithaa
                      wrote on last edited by
                      #10

                      Hello, I wanted to understand the functions that are directly called by the system and the reason behind it. Prithaa

                      H 1 Reply Last reply
                      0
                      • P prithaa

                        Hello, I wanted to understand the functions that are directly called by the system and the reason behind it. Prithaa

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

                        We suppose you made a program Windows send messges to your program if you need to these messages you can declare events for them like WM_MOUSE* or WM_PAINT and etc.You dont need to call windows events because windows sends them to your program for exmaple you need to change color of a static control so you tell to Windows that I need to this event with declare this event.

                        Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                        P 1 Reply Last reply
                        0
                        • H Hamid Taebi

                          We suppose you made a program Windows send messges to your program if you need to these messages you can declare events for them like WM_MOUSE* or WM_PAINT and etc.You dont need to call windows events because windows sends them to your program for exmaple you need to change color of a static control so you tell to Windows that I need to this event with declare this event.

                          Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                          P Offline
                          P Offline
                          prithaa
                          wrote on last edited by
                          #12

                          Hello, Thanks for the reply. but how do I know exactly which functions are called by the system an which ones I am suppose to call. is there any article which makes this clear. Prithaa

                          H 1 Reply Last reply
                          0
                          • P prithaa

                            Hello, Thanks for the reply. but how do I know exactly which functions are called by the system an which ones I am suppose to call. is there any article which makes this clear. Prithaa

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

                            You can see them on the MSDN for example if you enter WM_COPYDATA on the MSDN you will be see "This message is sent when an application passes data to another application" or WM_INPUT "The WM_INPUT message is sent to the window that is getting raw input."

                            Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                            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