color
-
hi all plz help me i want to change color of a particular control on which text is displayed but problem is that when i try folloeing code it will change color only of the text's background but not of all control plz tel me code for this HBRUSH CAfterone::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here pDC->SetBkColor(RGB(0, 0, 0)); // TODO: Return a different brush if the default is not desired return hbr; } Please mail me
-
hi all plz help me i want to change color of a particular control on which text is displayed but problem is that when i try folloeing code it will change color only of the text's background but not of all control plz tel me code for this HBRUSH CAfterone::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here pDC->SetBkColor(RGB(0, 0, 0)); // TODO: Return a different brush if the default is not desired return hbr; } Please mail me
u should return a brush of required color to do that
**CBrush bkBrush( RGB(0,0,0));** HBRUSH CAfterone::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here pDC->SetBkColor(RGB(0, 0, 0)); // TODO: Return a different brush if the default is not desired return **bkBrush**; }
nave -
hi all plz help me i want to change color of a particular control on which text is displayed but problem is that when i try folloeing code it will change color only of the text's background but not of all control plz tel me code for this HBRUSH CAfterone::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here pDC->SetBkColor(RGB(0, 0, 0)); // TODO: Return a different brush if the default is not desired return hbr; } Please mail me
-
hi all plz help me i want to change color of a particular control on which text is displayed but problem is that when i try folloeing code it will change color only of the text's background but not of all control plz tel me code for this HBRUSH CAfterone::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here pDC->SetBkColor(RGB(0, 0, 0)); // TODO: Return a different brush if the default is not desired return hbr; } Please mail me
HBRUSH CAfterone::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if(pWnd->GetDlgCtrlID()==/*Put your control id Here ex IDC_EDIT1*/) // return your color brush here // TODO: Return a different brush if the default is not desired return hbr; } Somethings seem HARD to do, until we know how to do them. ;-) _AnShUmAn_
-
hi all plz help me i want to change color of a particular control on which text is displayed but problem is that when i try folloeing code it will change color only of the text's background but not of all control plz tel me code for this HBRUSH CAfterone::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here pDC->SetBkColor(RGB(0, 0, 0)); // TODO: Return a different brush if the default is not desired return hbr; } Please mail me
-
HBRUSH CAfterone::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if(pWnd->GetDlgCtrlID()==/*Put your control id Here ex IDC_EDIT1*/) // return your color brush here // TODO: Return a different brush if the default is not desired return hbr; } Somethings seem HARD to do, until we know how to do them. ;-) _AnShUmAn_
i want only to change edit box color not text color this will change all dialog box coloto black i want to change only edit control color but not its text color plz tel me how this possible Please mail me
-
i want only to change edit box color not text color this will change all dialog box coloto black i want to change only edit control color but not its text color plz tel me how this possible Please mail me
Here's the code snippet : To change only the background color
HBRUSH CTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here HBRUSH hBr=CreateSolidBrush (RGB(255,0,0)); if(pWnd->GetDlgCtrlID ()== IDC_EDIT1) { pDC->SetBkColor (RGB(255,0,0)); hbr=hBr; } // TODO: Return a different brush if the default is not desired return hbr; }
Is it OK! Somethings seem HARD to do, until we know how to do them. ;-) _AnShUmAn_
-
i want only to change edit box color not text color this will change all dialog box coloto black i want to change only edit control color but not its text color plz tel me how this possible Please mail me
yogendra kaushik wrote:
i want only to change edit box color not text color this will change all dialog box coloto black i want to change only edit control color but not its text color plz tel me how this possible
The following code changes the color of the all the EDIT controls of the dialog CtestMFCDlg.
HBRUSH CtestMFCDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if(nCtlColor== CTLCOLOR_EDIT ) hbr=CreateSolidBrush(RGB(0,100,0)); return hbr; }
:) Knock out 't' from can't, You can if you think you can :cool: -
i want only to change edit box color not text color this will change all dialog box coloto black i want to change only edit control color but not its text color plz tel me how this possible Please mail me
you need to WM_CTLCOLOREDIT message_**
**_
whitesky
-
yogendra kaushik wrote:
i want only to change edit box color not text color this will change all dialog box coloto black i want to change only edit control color but not its text color plz tel me how this possible
The following code changes the color of the all the EDIT controls of the dialog CtestMFCDlg.
HBRUSH CtestMFCDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if(nCtlColor== CTLCOLOR_EDIT ) hbr=CreateSolidBrush(RGB(0,100,0)); return hbr; }
:) Knock out 't' from can't, You can if you think you can :cool: -
hi all plz help me i want to change color of a particular control on which text is displayed but problem is that when i try folloeing code it will change color only of the text's background but not of all control plz tel me code for this HBRUSH CAfterone::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here pDC->SetBkColor(RGB(0, 0, 0)); // TODO: Return a different brush if the default is not desired return hbr; } Please mail me
yogendra kaushik wrote:
i want to change color of a particular control
I think following code will solve ur problem
if(pWnd->GetDlgCtrlID()==IDC_EDIT1) { CRect rect; pWnd->GetClientRect(&rect); pDC->FillSolidRect(&rect,RGB(255,0,0)); pWnd->ReleaseDC(pDC); }
put this code in OnCtlColor (). This wil give you desired output. The secret of life is not enjoyment but education through experience. - Swami Vivekananda. -
yogendra kaushik wrote:
i want to change color of a particular control
I think following code will solve ur problem
if(pWnd->GetDlgCtrlID()==IDC_EDIT1) { CRect rect; pWnd->GetClientRect(&rect); pDC->FillSolidRect(&rect,RGB(255,0,0)); pWnd->ReleaseDC(pDC); }
put this code in OnCtlColor (). This wil give you desired output. The secret of life is not enjoyment but education through experience. - Swami Vivekananda.thanks a lot mut if i want to change color of many edit boxes then i had to use if statement for each or there is some other techniqe to sole it plz send me code Please mail me