CDialog
-
you ca use
WM_CTLCOLOR
orWM_PAINT
_**
**_
whitesky
Though you could do it by these ways, Handling
WM_ERASEBKGND
is the right one for it.
--[:jig:]-- [My Current Status]
-
But the background color is not changing. Here is my code: OnPaint() { ............. CSliderApp* app=(CSliderApp*)AfxGetApp(); app->ChangeDialogColor((COLORREF)m_clr.GetPos()); } void CSliderApp::ChangeDialogColor(COLORREF ref) { SetDialogBkColor(ref); } Is there anything wrong:confused:
-
Though you could do it by these ways, Handling
WM_ERASEBKGND
is the right one for it.
--[:jig:]-- [My Current Status]
but i want to know why he cant show controls its attract for me to find answer for this question (of course i need to see his code that how to use)_**
**_
whitesky
-
ok... i Understood instead of calling the ChangeDialogColor from onPaint call this Function as the first line of OnCtlColor funtion nave
No its not working. Thanks for ur reply.:)
-
No its not working. Thanks for ur reply.:)
ok another way... forgot every thing done before...Now do as below 1. Create a member variable of CBrush say m_BkBrush 2. Write Function like this ChangeColor( COLORREF clr_i ) { if( m_BkBrush.m_hObject ) m_BkBrush.DeleteObject(); m_BkBrush.CreateSolidBrush( clr_i ) Invalidate(); } 3. Call this function in the OnInitDialog and where ever u want to change the color 4. now overide the WM_CTLCOLOR message and inside that write as below HBRUSH MYDialog::OnCtlColor( CDC* pDC_i, CWnd* pWnd_i, UINT uCtlColor_i ) { HBRUSH hDefaultBrush = CDialog::OnCtlColor( pDC_i, pWnd_i, uCtlColor_i ); if( CTLCOLOR_DLG == uCtlColor_i ) { return m_BkBrush; } return hDefaultBrush; } try and tell me the result..;) nave
-
ok another way... forgot every thing done before...Now do as below 1. Create a member variable of CBrush say m_BkBrush 2. Write Function like this ChangeColor( COLORREF clr_i ) { if( m_BkBrush.m_hObject ) m_BkBrush.DeleteObject(); m_BkBrush.CreateSolidBrush( clr_i ) Invalidate(); } 3. Call this function in the OnInitDialog and where ever u want to change the color 4. now overide the WM_CTLCOLOR message and inside that write as below HBRUSH MYDialog::OnCtlColor( CDC* pDC_i, CWnd* pWnd_i, UINT uCtlColor_i ) { HBRUSH hDefaultBrush = CDialog::OnCtlColor( pDC_i, pWnd_i, uCtlColor_i ); if( CTLCOLOR_DLG == uCtlColor_i ) { return m_BkBrush; } return hDefaultBrush; } try and tell me the result..;) nave
Sorry, its not working.:(
-
Sorry, its not working.:(
-
but i want to know why he cant show controls its attract for me to find answer for this question (of course i need to see his code that how to use)_**
**_
whitesky
My code is: BOOL CSliderDlg::OnEraseBkgnd(CDC* pDC) { if(m_clr.GetPos()!=0) { int color=m_clr.GetPos(); COLORREF clr=RGB(color,color,color); CRect rect; GetClientRect(&rect); pDC->FillSolidRect(&rect,clr); } return CDialog::OnEraseBkgnd(pDC); } I am calling this function from WM_HSCROLL handler. m_clr is the slider ctrl. If there is any mistake in my, let me that mistake. Thanx.:)
-
My code is: BOOL CSliderDlg::OnEraseBkgnd(CDC* pDC) { if(m_clr.GetPos()!=0) { int color=m_clr.GetPos(); COLORREF clr=RGB(color,color,color); CRect rect; GetClientRect(&rect); pDC->FillSolidRect(&rect,clr); } return CDialog::OnEraseBkgnd(pDC); } I am calling this function from WM_HSCROLL handler. m_clr is the slider ctrl. If there is any mistake in my, let me that mistake. Thanx.:)
this code it seems not problem i tested this code and it work fine of course without if(m_clr.GetPos()!=0) like this
BOOL CAnswerDlg::OnEraseBkgnd(CDC* pDC) { //int color=m_clr.GetPos(); COLORREF clr=RGB(53,97,200); CRect rect; GetClientRect(&rect); pDC->FillSolidRect(&rect,clr); return TRUE; }
and controls are visible you can use WM_CTLCOLOR with a brush and it work and i think it good for you_**
**_
whitesky
-
this code it seems not problem i tested this code and it work fine of course without if(m_clr.GetPos()!=0) like this
BOOL CAnswerDlg::OnEraseBkgnd(CDC* pDC) { //int color=m_clr.GetPos(); COLORREF clr=RGB(53,97,200); CRect rect; GetClientRect(&rect); pDC->FillSolidRect(&rect,clr); return TRUE; }
and controls are visible you can use WM_CTLCOLOR with a brush and it work and i think it good for you_**
**_
whitesky
I want to change the back ground of dialog when i move the slider ctrl. That's why i used int color=m_clr.GetPos(); Ths background of the dialog was changing but the controls are not visible.