problem with dialog background color
-
i have a dialog with background color when i minimize the dialog and maximize again i am loosing the color of the dialog if i switch to another window and come back to same dialog the color will appear on the dialog again whats the problem i should not loos the color of the dialod when i minni mize and maximize any message handlr i have to handle ?
-
i have a dialog with background color when i minimize the dialog and maximize again i am loosing the color of the dialog if i switch to another window and come back to same dialog the color will appear on the dialog again whats the problem i should not loos the color of the dialod when i minni mize and maximize any message handlr i have to handle ?
How did you change the background color??
nave [OpenedFileFinder]
-
i have a dialog with background color when i minimize the dialog and maximize again i am loosing the color of the dialog if i switch to another window and come back to same dialog the color will appear on the dialog again whats the problem i should not loos the color of the dialod when i minni mize and maximize any message handlr i have to handle ?
Seems like a paint issue. Try overriding the OnEraseBkgnd() function.Write the code to put color on the screen there. Hope this works out for you.(never tried this though...) cheers! PS:do comment or call the CDialog::OnEraseBkgnd( pDC ) first before putting in your paint code
modified on Tuesday, May 13, 2008 12:39 AM
-
Seems like a paint issue. Try overriding the OnEraseBkgnd() function.Write the code to put color on the screen there. Hope this works out for you.(never tried this though...) cheers! PS:do comment or call the CDialog::OnEraseBkgnd( pDC ) first before putting in your paint code
modified on Tuesday, May 13, 2008 12:39 AM
do comment or call the CDialog::OnEraseBkgnd( pDC ) first, before putting in your paint code
-
i have a dialog with background color when i minimize the dialog and maximize again i am loosing the color of the dialog if i switch to another window and come back to same dialog the color will appear on the dialog again whats the problem i should not loos the color of the dialod when i minni mize and maximize any message handlr i have to handle ?
CAn you show your code?
-
i have a dialog with background color when i minimize the dialog and maximize again i am loosing the color of the dialog if i switch to another window and come back to same dialog the color will appear on the dialog again whats the problem i should not loos the color of the dialod when i minni mize and maximize any message handlr i have to handle ?
Hi Handle the WM_CTLCOLORDLG and place your painting code inside the handler.
HBRUSH CBkColorDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if(nCtlColor == CTLCOLOR_DLG) { hbr = CreateSolidBrush(RGB(2,22,222)); } else if(nCtlColor == CTLCOLOR_STATIC) { pDC->SetBkMode(TRANSPARENT); hbr = CreateSolidBrush(RGB(2,22,222)); } // TODO: Return a different brush if the default is not desired return hbr; }
that's it Regargs Nitheesh -
Hi Handle the WM_CTLCOLORDLG and place your painting code inside the handler.
HBRUSH CBkColorDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if(nCtlColor == CTLCOLOR_DLG) { hbr = CreateSolidBrush(RGB(2,22,222)); } else if(nCtlColor == CTLCOLOR_STATIC) { pDC->SetBkMode(TRANSPARENT); hbr = CreateSolidBrush(RGB(2,22,222)); } // TODO: Return a different brush if the default is not desired return hbr; }
that's it Regargs NitheeshSerious resource leak there :) Those brushes should be created and destroyed outside of the WM_CTLCOLOR handler! Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: