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. Changing the look and feel of a MFC dialog box

Changing the look and feel of a MFC dialog box

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++beta-testingtutorialcode-review
5 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.
  • B Offline
    B Offline
    burslem2001
    wrote on last edited by
    #1

    Hi, I want to change the shape and color of a MFC dialog box? Any feedback on this would be appreciated. I know this is probably a very common question, just dont know how to do this. Much appreciated, garyc

    _ 1 Reply Last reply
    0
    • B burslem2001

      Hi, I want to change the shape and color of a MFC dialog box? Any feedback on this would be appreciated. I know this is probably a very common question, just dont know how to do this. Much appreciated, garyc

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

      A window is always rectangular. Any other shape can be created using a region. There are several functions in GDI that help you create regions - Region Functions[^] Here is a simple example with source code to create a region from a bitmap and apply to a window. Fish Region[^] Background color can be set by handling the WM_CTLCOLORDLG[^] message.

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      B 1 Reply Last reply
      0
      • _ _Superman_

        A window is always rectangular. Any other shape can be created using a region. There are several functions in GDI that help you create regions - Region Functions[^] Here is a simple example with source code to create a region from a bitmap and apply to a window. Fish Region[^] Background color can be set by handling the WM_CTLCOLORDLG[^] message.

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        B Offline
        B Offline
        burslem2001
        wrote on last edited by
        #3

        Much appreciated. I never knew how they did this and now I know. Thanks, Garyc

        W 1 Reply Last reply
        0
        • B burslem2001

          Much appreciated. I never knew how they did this and now I know. Thanks, Garyc

          W Offline
          W Offline
          wangningyu
          wrote on last edited by
          #4

          you can add this with ClassWizard,or in the sources code to add it by yourself. just like this: C***Dlg.h

          afx\_msg HBRUSH OnCtlColor(CDC\* pDC, CWnd\* pWnd, UINT nCtlColor);
          

          C***Dlg.cpp

          BEGIN_MESSAGE_MAP
          ......
          ON_WM_CTLCOLOR()
          ......
          END_MESSAGE_MAP()

          HBRUSH C***Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
          {
          HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

          // TODO: Change any attributes of the DC here
          switch (pWnd->GetDlgCtrlID())
          {
          case IDC\_STATIC1:
          case IDC\_STATIC2:
          	pDC->SetTextColor(RGB(255,0,0));
          	break;
          case IDC\_STATIC3:
          case IDC\_STATIC4:
          	pDC->SetTextColor(RGB(0,0,255));
          	break;
          }    
          
          // TODO: Return a different brush if the default is not desired
          return hbr;
          

          }

          Best Reguards ! by Koma http://blog.csdn.net/wangningyu

          B 1 Reply Last reply
          0
          • W wangningyu

            you can add this with ClassWizard,or in the sources code to add it by yourself. just like this: C***Dlg.h

            afx\_msg HBRUSH OnCtlColor(CDC\* pDC, CWnd\* pWnd, UINT nCtlColor);
            

            C***Dlg.cpp

            BEGIN_MESSAGE_MAP
            ......
            ON_WM_CTLCOLOR()
            ......
            END_MESSAGE_MAP()

            HBRUSH C***Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
            {
            HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

            // TODO: Change any attributes of the DC here
            switch (pWnd->GetDlgCtrlID())
            {
            case IDC\_STATIC1:
            case IDC\_STATIC2:
            	pDC->SetTextColor(RGB(255,0,0));
            	break;
            case IDC\_STATIC3:
            case IDC\_STATIC4:
            	pDC->SetTextColor(RGB(0,0,255));
            	break;
            }    
            
            // TODO: Return a different brush if the default is not desired
            return hbr;
            

            }

            Best Reguards ! by Koma http://blog.csdn.net/wangningyu

            B Offline
            B Offline
            burslem2001
            wrote on last edited by
            #5

            Much apreciated guys for your contributions. Thanks, Garyc

            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