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