"Changing Editbox color"
-
Hi, When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.. but i want the editbox color to be white only.. Is there anyway to do? Is there any function like in the case of listcontrol(SetBkColor()) to get the color of Editbox to the color i want to. Harsha
-
Hi, When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.. but i want the editbox color to be white only.. Is there anyway to do? Is there any function like in the case of listcontrol(SetBkColor()) to get the color of Editbox to the color i want to. Harsha
harsh_2961 wrote:
When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.
How you have done this ?
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Hi, When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.. but i want the editbox color to be white only.. Is there anyway to do? Is there any function like in the case of listcontrol(SetBkColor()) to get the color of Editbox to the color i want to. Harsha
harsh_2961 wrote:
When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing..
:confused: can u show the code...
Do your Duty and Don't expect the Result
-
Hi, When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.. but i want the editbox color to be white only.. Is there anyway to do? Is there any function like in the case of listcontrol(SetBkColor()) to get the color of Editbox to the color i want to. Harsha
Default color of editbox is white but if you want to change color of editbox use of
WM_CTLCOLOREDIT
WhiteSky
-
harsh_2961 wrote:
When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing..
:confused: can u show the code...
Do your Duty and Don't expect the Result
I used following function HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { return m_brush; } along with the line m_List.SetBkColor(RGB(255, 255, 255)); in oninitdialog(). harsha
-
harsh_2961 wrote:
When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.
How you have done this ?
Prasad Notifier using ATL | Operator new[],delete[][^]
I put the code in my reply just now.. please see the code.. Harsha
-
I put the code in my reply just now.. please see the code.. Harsha
harsh_2961 wrote:
please see the code
Where ? I cannot see it .
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Hi, When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.. but i want the editbox color to be white only.. Is there anyway to do? Is there any function like in the case of listcontrol(SetBkColor()) to get the color of Editbox to the color i want to. Harsha
Over ride WM_ERASEBKGND and put this code over there. CPen myPen; int i =100; CRect rect ; myPen.CreatePen(PS_SOLID, 1, RGB ((i * 4),0,0)); CPen *oldPen = pDC->SelectObject(&myPen) ; GetClientRect(&rect); for(i = 0 ; i <= rect.bottom;) { pDC->MoveTo(0, i); pDC->LineTo(rect.right, i); pDC->SelectObject (&myPen); } pDC->SelectObject(oldPen) ; return TRUE ; The edit box would not be painted to match the dialog back color and would show as white. See if this helps _AnShUmAn_ -- modified at 4:55 Wednesday 14th March, 2007
-
harsh_2961 wrote:
please see the code
Where ? I cannot see it .
Prasad Notifier using ATL | Operator new[],delete[][^]
I used following function HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { return m_brush; } along with the line m_List.SetBkColor(RGB(255, 255, 255)); in oninitdialog(). Harsha
-
I used following function HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { return m_brush; } along with the line m_List.SetBkColor(RGB(255, 255, 255)); in oninitdialog(). harsha
harsh_2961 wrote:
along with the line m_List.SetBkColor(RGB(255, 255, 255)); in oninitdialog().
Hope the m_List is your CEdit control.
harsh_2961 wrote:
HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { return m_brush; }
Instead of simply returning m_brush(hope this the brush to paint the dialog background). Try this,
CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (CTLCOLOR_EDIT != nCtlColor)
return m_brush;
return hbr;
}The above change the background color for all the controls in the dialog except for the CEdit controls. If you want to change the color only to the dialog then change the 'if' condition as below
if (CTLCOLOR_DLG == nCtlColor)
Do your Duty and Don't expect the Result
-
harsh_2961 wrote:
along with the line m_List.SetBkColor(RGB(255, 255, 255)); in oninitdialog().
Hope the m_List is your CEdit control.
harsh_2961 wrote:
HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { return m_brush; }
Instead of simply returning m_brush(hope this the brush to paint the dialog background). Try this,
CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (CTLCOLOR_EDIT != nCtlColor)
return m_brush;
return hbr;
}The above change the background color for all the controls in the dialog except for the CEdit controls. If you want to change the color only to the dialog then change the 'if' condition as below
if (CTLCOLOR_DLG == nCtlColor)
Do your Duty and Don't expect the Result
Thanks a lot ... its perfectly working :) Harsha
-
I used following function HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { return m_brush; } along with the line m_List.SetBkColor(RGB(255, 255, 255)); in oninitdialog(). Harsha
I'm not sure, how you have done it, but modify your code to,
CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
return m_brush;
}To skip edit control painting do this,
HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
m_brush= CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_EDIT)
{
return brush
}
else
{
//do your customized painting
}return m_brush;
}Prasad Notifier using ATL | Operator new[],delete[][^]
-
Hi, When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.. but i want the editbox color to be white only.. Is there anyway to do? Is there any function like in the case of listcontrol(SetBkColor()) to get the color of Editbox to the color i want to. Harsha
harsh_2961 wrote:
When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.. but i want the editbox color to be white only..
HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH OrgBrush=CreateSolidBrush(RGB(255,255,255)); // make it white if(pWnd->GetSafeHwnd() == GetDlgItem(IDC_EDIT1)->GetSafeHwnd()) { return OrgBrush; } return m_brush; }
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta Global Interface Table: An Easy Way to Marshal an Interface Pointer[new] VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
harsh_2961 wrote:
When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.. but i want the editbox color to be white only..
HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH OrgBrush=CreateSolidBrush(RGB(255,255,255)); // make it white if(pWnd->GetSafeHwnd() == GetDlgItem(IDC_EDIT1)->GetSafeHwnd()) { return OrgBrush; } return m_brush; }
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta Global Interface Table: An Easy Way to Marshal an Interface Pointer[new] VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
ThatsAlok wrote:
if(pWnd->GetSafeHwnd() == GetDlgItem(IDC_EDIT1)->GetSafeHwnd())
if (pWnd->GetDlgCtrlID() == IDC_EDIT1)
would be better.Prasad Notifier using ATL | Operator new[],delete[][^]