I´ve been messing around with edit controls like mad, but I can´t get it to work.
Only Problem, I don´t like the plain white background Windows gives an edit by default, so I´ve created a graphical one.
Now I have a main Window containing some child windows, where one of these is a single line edit control:
MyEdit = CreateWindow(
"edit",0,
WS_CHILD|ES_AUTOHSCROLL,
325,180,170,20,
hWnd,0,hinstance,0
);
Then I do:
case WM_CTLCOLOREDIT:
{
SetBkMode((HDC) wParam, TRANSPARENT);
SetTextColor((HDC) wParam, RGB(64,61,61));
return (LONG) BitmapBrush;
}
break;
where BitmapBrush contains an image in size 170x20px.
There is no further subclass or anything, besides the background I leave the entire handling of the edit to Windows default, including the text content.
The main window as well as all the childs have fixed positions and sizes, there is no WM_SIZE in the whole program, so on first view no problem, it even looks nice when it opens up ....... until I type some text into the control.
Without the graphical background Windows will align the text in the control quite nice, but as soon as the background is present, text gets aligned to the very top left of the control, with no margin at all, leaving plenty of space underneath, but I can´t find a way to get the text aligned properly, as it is without the background.
I don´t even understand, why the presence of a background should effect the alignment of the text.
I´ve found quite a few articles about subclassing entire controls to get things right, but they are all for VC++ or .net, where I´m using MinGW/GCC++, also I´m not really in for rewriting the whole control, just to get the text better aligned.
Does anyone here have an explanation for that, or maybe a solution?