how to change the edit background color
Hi
I created a document based application use window programming
I mean not VC++. On the document view i created a edit box
, and try to chang the background color but I don't know How? I Any help and example
Thanks
robin
email to : binluo@bigpond.com
# 1 Re: how to change the edit background color
Actually My code:
RECT rect // this is the Edit box Rect
LRESULT CALLBACK EditClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
case WM_PAINT:
HBRUSH hBrush;
PAINTSTRUCT ps;
hdc = BeginPaint( m_hWnd, &ps );
hBrush = CreateSolidBrush(rgb);
FillRect (hdc, &rect, hBrush);
DeleteObject (hBrush);
EndPaint( m_hWnd, &ps );
.............
..........
}
it changed the Edit background color but in different position, why,
or how to fix this?
robin luo bin
robinluobin@hotmail.com
# 2 Re: how to change the edit background color
you dont need to handle this in WM_PAINT at all.
process the WM_CTLCOLOREDIT message in your parent window's window procedure and it will handle the wm_paint stuff itself.
the WPARAM is the HDC you'll be working with and the LPARAM is a HWND to whatever is processing this...
for example...
case WM_CTLCOLOREDIT:
SetTextColor((HDC)wParam, ftext);
SetBkColor((HDC)wParam, tback);
return (LRESULT)CreateSolidBrush(tback);
where ftext is a COLORREF structure holding the text color and tback is another one w/ith the background color.... *COLORREF ftext = RGB(255, 255, 255); * for example.
hope this helps
# 3 Re: how to change the edit background color
// globals
HBRUSH hbrushEditBox = CreateSolidBrush(RGB(34,94,144)); // making a brush color (API)
//------------------
case WM_CTLCOLOREDIT: // Same as Static, only for EditBoxes
{
HDC hdcEdit = (HDC)wParam; //Get handles
SetTextColor(hdcEdit, RGB(255, 255, 255)); // Text color
SetBkMode(hdcEdit, TRANSPARENT); // EditBox Backround Mode (note: OPAQUE can be used)
SetBkColor(hdcEdit,(LONG)hbrushEditBox); // Backround color for EditBox
return (LONG)hbrushEditBox; // Paint it
}
break;
Bengi at 2007-11-9 13:04:54 >

# 5 Re: how to change the edit background color
hi,
u can use CBitmapButton in MFC, which show all 4 bitmap in Button
regards
thomas