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. Change the color of static control

Change the color of static control

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

    I want to change the color of static control to white.As well as in the static controls the text also should be visible.

    CStatic temp = new CStatic();
    temp->Create(text ,style |SS_LEFT ,pos ,this ,m_iAutoControlID);

    bhw

    H 1 Reply Last reply
    0
    • T TobetheWinner

      I want to change the color of static control to white.As well as in the static controls the text also should be visible.

      CStatic temp = new CStatic();
      temp->Create(text ,style |SS_LEFT ,pos ,this ,m_iAutoControlID);

      bhw

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

      See WM_CTLCOLORSTATIC and on the this message use of SetTextColor() for text color and SetBKColor() for background color.


      WhiteSky


      T 1 Reply Last reply
      0
      • H Hamid Taebi

        See WM_CTLCOLORSTATIC and on the this message use of SetTextColor() for text color and SetBKColor() for background color.


        WhiteSky


        T Offline
        T Offline
        TobetheWinner
        wrote on last edited by
        #3

        This is a dynamically created control.is there any style or method to do that. bhw

        H M 2 Replies Last reply
        0
        • T TobetheWinner

          This is a dynamically created control.is there any style or method to do that. bhw

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

          I dont understand what you said can you more explain.


          WhiteSky


          D 1 Reply Last reply
          0
          • H Hamid Taebi

            I dont understand what you said can you more explain.


            WhiteSky


            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            WhiteSky wrote:

            I dont understand what you said can you more explain.

            The control is created at runtime rather than design time.


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            H 1 Reply Last reply
            0
            • D David Crow

              WhiteSky wrote:

              I dont understand what you said can you more explain.

              The control is created at runtime rather than design time.


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

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

              No I want to know his question was about control or color.


              WhiteSky


              1 Reply Last reply
              0
              • T TobetheWinner

                This is a dynamically created control.is there any style or method to do that. bhw

                M Offline
                M Offline
                Max Santos
                wrote on last edited by
                #7

                Hello Use WinProc or PreTranslateMessage to catch the message WM_CTLCOLORSTATIC and compare the control id with the id that you give to your static. And then is just the same as if you use the designer. Something like this: BOOL CYourDialog::PreTranslateMessage(MSG* pMsg) { if(pMsg->message == WM_KEYDOWN && pMsg->wParam==VK_RETURN) { if(IsWindow(m_YourStatic.m_hWnd)) { if(pMsg->hwnd==m_YourStatic.m_hWnd) { DoSomething(); } } } }

                http://xwega.com

                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