Thank you,
Holger Ostermann (please also respond via email to 02372...@T-Online.de)
I divert the standard WinProc for the created "EDIT" window, to my own
WinProc, which will allow for more local handling of events, as the
WM_CTLCOLOREDIT message is supposed to be handled by the parent,
where as, in my opinion, it's an attribute of the editbox, not of the
parent.
(object-orientented programming is how you work, not just using c++)
this is accomplished by doing the following after the succesfull
CreateWindow call:
//global defs
WNDPROC pOldEditWndProc = 0;
...
//proto's
LRESULT CALLBACK EditWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM
lParam);
...
// inside a creation function for the editbox
...
hwndEdit = CreateWindowEx(WS_EX_TRANSPARENT, (LPSTR) "EDIT", NULL, ...
...
if (hwndEdit)
{
if (!pOldEditWndProc)
pOldEditWndProc = (WNDPROC) GetWindowLong(pItem->hwnd, GWL_WNDPROC);
SetWindowLong(hwndEdit, GWL_WNDPROC, (long)(WNDPROC)EditWndProc);
// You can do some other things here too, like setting the font,
// background brush etc.
}
...
//end editbox creation function
now you can redirect the the message from the parent WindowProc to this
new EditWndProc like:
case WM_CTLCOLOREDIT:
if (lParam)
return SendMessage((HWND) lParam, msg, wParam,
lParam);
break;
And proces it in EditWndProc as:
LRESULT CALLBACK EditWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM
lParam)
{
...
case WM_CTLCOLOREDIT:
{
HDC hdc = (HDC) wParam;
HDC hdc2 = GetDC( hwnd);
COLORREF color = RGB(255,0,0); // or what ever u like,
// e.g get it from a structure
SetTextColor(hdc2, color );
SetBkMode( hdc2, TRANSPARENT);
ReleaseDC(hwnd, hdc2);
// for some reason i had to double it,
// ask MicroSof for the reason
SetTextColor(hdc, color );
SetBkMode( hdc, TRANSPARENT);
}
return (LRESULT ) ghbrBackEdit ;
// ghbrBackEdit is a global HOLLOW brush, as i have bitmaps
// in the editbox background
/* creation of ghbrBackEdit only once in program
LOGBRUSH mBrush;
mBrush.lbStyle = BS_HOLLOW;
ghbrBackEdit = CreateBrushIndirect(&mBrush);
*/
...
//processing of not (completely) processed messages:
if (pOldEditWndProc )
return CallWindowProc(pOldEditWndProc, hwnd, msg, wParam, lParam);
return 0; // this should never happen anyhow
}
By processing WM_COMMAND, the EN_CHANGE and EN_UPDATE notifications,
you should be able to draw bitmaps as backgrounds too.
The same goes for all other controls.
If i was of any help please let me know!
René Hoevenberg
Electronic Multimedia Productions, Emmen, Nederland
fact:
Object-Oriented is a way of life, not of tools.
(most people forget it and foul up every OO language
to below the level of basic version 1.0)
tip:
If everybody just stuck to C, programs would improve by 100+%
(and your programs would be very small and fast indeed!)
(but you do must know how to program it)
Ostermann <0237212...@t-online.de> schreef in artikel
<71o08p$k6q$1...@news00.btx.dtag.de>...