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. "Paint" Separator on Dialog?

"Paint" Separator on Dialog?

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 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
    Lost User
    wrote on last edited by
    #1

    Hello, how can i show a line separator between dialog objects, like in visual basic? I like to put some radio boxes on the left side of my dialog, vertical, and i want to make a litle difference between, not to use "GroupBox", just a simple line like menu separator: ° radio1 ° radio2 ° radio3 ----------------- // <-- my line separator ° radio4 ° radio5 ° radio_n is this posible? thanks in advance break;

    X D 2 Replies Last reply
    0
    • L Lost User

      Hello, how can i show a line separator between dialog objects, like in visual basic? I like to put some radio boxes on the left side of my dialog, vertical, and i want to make a litle difference between, not to use "GroupBox", just a simple line like menu separator: ° radio1 ° radio2 ° radio3 ----------------- // <-- my line separator ° radio4 ° radio5 ° radio_n is this posible? thanks in advance break;

      X Offline
      X Offline
      XtremDev
      wrote on last edited by
      #2

      override the OnPaint() function and add this code : CRect l_rctClient; GetClientRect(&l_rctClient); CDC * l_pDC = GetDC(); CPen l_GrayPen(PS_SOLID, 1, RGB(100, 100, 100)); CPen l_WhitePen(PS_SOLID, 1, RGB(255, 255, 255)); int l_nYLine = l_rctClient.top + l_rctClient.Height()/2; // example for your line y coordinate //could also be //GetDlgItem(IDC_MYITEM)->GetClientRect(l_rctItem); //int l_nYLine = l_rctItem.bottom+10; CPen * l_pOldPen = l_pDC->SelectObject(&l_GrayPen); l_pDC->MoveTo(l_rctClient.left+2, l_nYLine); l_pDC->LineTo(l_rctClient.right-2, l_nYLine); l_pDC->SelectObject(&l_WhitePen); l_pDC->MoveTo(l_rctClient.left+2, l_nYLine+1); l_pDC->LineTo(l_rctClient.right-2, l_nYLine+1); l_pDC->SelectObject(l_pOldPen); ReleaseDC(l_pDC);

      L 2 Replies Last reply
      0
      • X XtremDev

        override the OnPaint() function and add this code : CRect l_rctClient; GetClientRect(&l_rctClient); CDC * l_pDC = GetDC(); CPen l_GrayPen(PS_SOLID, 1, RGB(100, 100, 100)); CPen l_WhitePen(PS_SOLID, 1, RGB(255, 255, 255)); int l_nYLine = l_rctClient.top + l_rctClient.Height()/2; // example for your line y coordinate //could also be //GetDlgItem(IDC_MYITEM)->GetClientRect(l_rctItem); //int l_nYLine = l_rctItem.bottom+10; CPen * l_pOldPen = l_pDC->SelectObject(&l_GrayPen); l_pDC->MoveTo(l_rctClient.left+2, l_nYLine); l_pDC->LineTo(l_rctClient.right-2, l_nYLine); l_pDC->SelectObject(&l_WhitePen); l_pDC->MoveTo(l_rctClient.left+2, l_nYLine+1); l_pDC->LineTo(l_rctClient.right-2, l_nYLine+1); l_pDC->SelectObject(l_pOldPen); ReleaseDC(l_pDC);

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

        Hello, thaks for answer, yes tis is what i mean, only i recive an error in line:

        //GetDlgItem(IDC_MYITEM)->GetClientRect(l_rctItem); // <-- original code 
        CRect l_rctItem;
        GetDlgItem(IDC_RADIO)->GetClientRect(l_rctItem); // errorline, my radio box, i like that the line is under this radio box
        

        i think that the IDC_RADIO dont exists at this time, Error is "Access violation 0x00000005". And the compiler show this:

        _AFXWIN_INLINE void CWnd::GetWindowRect(LPRECT lpRect) const
        	{ ASSERT(::IsWindow(m_hWnd)); ::GetWindowRect(m_hWnd, lpRect); }
        

        How to solve this The rest od your sample works fine, the new line goes through the middle of my dialog :) :-D regards break; -- modified at 9:16 Monday 27th November, 2006

        X 1 Reply Last reply
        0
        • L Lost User

          Hello, thaks for answer, yes tis is what i mean, only i recive an error in line:

          //GetDlgItem(IDC_MYITEM)->GetClientRect(l_rctItem); // <-- original code 
          CRect l_rctItem;
          GetDlgItem(IDC_RADIO)->GetClientRect(l_rctItem); // errorline, my radio box, i like that the line is under this radio box
          

          i think that the IDC_RADIO dont exists at this time, Error is "Access violation 0x00000005". And the compiler show this:

          _AFXWIN_INLINE void CWnd::GetWindowRect(LPRECT lpRect) const
          	{ ASSERT(::IsWindow(m_hWnd)); ::GetWindowRect(m_hWnd, lpRect); }
          

          How to solve this The rest od your sample works fine, the new line goes through the middle of my dialog :) :-D regards break; -- modified at 9:16 Monday 27th November, 2006

          X Offline
          X Offline
          XtremDev
          wrote on last edited by
          #4

          So you can do that : CWnd * l_pRadioWnd = GetDlgItem(IDC_RADIO); if( !l_pRadioWnd ) return; CRect l_rctItem; l_pRadioWnd ->GetClientRect(l_rctItem); int l_nYLine = l_rctItem.bottom+10; CDC * l_pDC = GetDC(); CPen l_GrayPen(PS_SOLID, 1, RGB(100, 100, 100)); CPen l_WhitePen(PS_SOLID, 1, RGB(255, 255, 255)); CPen * l_pOldPen = l_pDC->SelectObject(&l_GrayPen); l_pDC->MoveTo(l_rctClient.left+2, l_nYLine); l_pDC->LineTo(l_rctClient.right-2, l_nYLine); l_pDC->SelectObject(&l_WhitePen); l_pDC->MoveTo(l_rctClient.left+2, l_nYLine+1); l_pDC->LineTo(l_rctClient.right-2, l_nYLine+1); l_pDC->SelectObject(l_pOldPen); ReleaseDC(l_pDC);

          1 Reply Last reply
          0
          • X XtremDev

            override the OnPaint() function and add this code : CRect l_rctClient; GetClientRect(&l_rctClient); CDC * l_pDC = GetDC(); CPen l_GrayPen(PS_SOLID, 1, RGB(100, 100, 100)); CPen l_WhitePen(PS_SOLID, 1, RGB(255, 255, 255)); int l_nYLine = l_rctClient.top + l_rctClient.Height()/2; // example for your line y coordinate //could also be //GetDlgItem(IDC_MYITEM)->GetClientRect(l_rctItem); //int l_nYLine = l_rctItem.bottom+10; CPen * l_pOldPen = l_pDC->SelectObject(&l_GrayPen); l_pDC->MoveTo(l_rctClient.left+2, l_nYLine); l_pDC->LineTo(l_rctClient.right-2, l_nYLine); l_pDC->SelectObject(&l_WhitePen); l_pDC->MoveTo(l_rctClient.left+2, l_nYLine+1); l_pDC->LineTo(l_rctClient.right-2, l_nYLine+1); l_pDC->SelectObject(l_pOldPen); ReleaseDC(l_pDC);

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

            Hello, i solve my problem, thank you! I override the wrong OnPaint() function, because i have more childdialogs!!! :doh: regards break;

            1 Reply Last reply
            0
            • L Lost User

              Hello, how can i show a line separator between dialog objects, like in visual basic? I like to put some radio boxes on the left side of my dialog, vertical, and i want to make a litle difference between, not to use "GroupBox", just a simple line like menu separator: ° radio1 ° radio2 ° radio3 ----------------- // <-- my line separator ° radio4 ° radio5 ° radio_n is this posible? thanks in advance break;

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

              Just insert a static control that is 1 DLU tall, and has the SS_SUNKEN style.


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              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