From: Dampy on
Hi
I have a little problem when I am using "HOLLOW_BRUSH" as a background (?)
I create a editbox and sets the readonly-flag, but the background goes
grey and I want it white.
To prevent that I use this in WM_CTLCOLORSTATIC:

Code:
case IDC_INFOBOX: {
HDC hdc = (HDC)wParam;
SetBkColor(hdc, 0xFFFFFF);
SetTextColor(hdc, 0);
return (LRESULT)GetStockObject(WHITE_BRUSH);
}

Its working fine, but now I want to make the editbox background
transparent, to do that I use this:

Code:
case IDC_INFOBOX: {
HDC hdc = (HDC)wParam;
//SetBkColor(hdc, 0xFFFFFF);
SetTextColor(hdc, 0);
SetBkMode(hdc, TRANSPARENT);
return (LRESULT)GetStockObject(HOLLOW_BRUSH);
}

I have heard that this is the wrong way to do it, but it works, almost =P.
The transparent background is there, but if I mark some text, the
marking stays in the background.
Picture link: http://dampy.xeroxer.com/?file_id=89

Is there some way to prevent that? Or maybe to prevent marking overall
in the textbox?
If I minimize and maximize the window the editbox is normal again, why?
Can I use the same principle?

I want the transparent background because I want to display a bitmap
behind, it�s working fine as long I don�t mark the text =P

Edit:
Is it possible to make the blue "select-color" transparent?
I have tried to find some way to do that on msdn, but I am bad searcher...
From: Norman Bullen on
Dampy wrote:
> Hi
> I have a little problem when I am using "HOLLOW_BRUSH" as a background (?)
> I create a editbox and sets the readonly-flag, but the background goes
> grey and I want it white.
> To prevent that I use this in WM_CTLCOLORSTATIC:
>
> Code:
> case IDC_INFOBOX: {
> HDC hdc = (HDC)wParam;
> SetBkColor(hdc, 0xFFFFFF);
> SetTextColor(hdc, 0);
> return (LRESULT)GetStockObject(WHITE_BRUSH);
> }
>
> Its working fine, but now I want to make the editbox background
> transparent, to do that I use this:
>
> Code:
> case IDC_INFOBOX: {
> HDC hdc = (HDC)wParam;
> //SetBkColor(hdc, 0xFFFFFF);
> SetTextColor(hdc, 0);
> SetBkMode(hdc, TRANSPARENT);
> return (LRESULT)GetStockObject(HOLLOW_BRUSH);
> }
>
> I have heard that this is the wrong way to do it, but it works, almost =P.
> The transparent background is there, but if I mark some text, the
> marking stays in the background.
> Picture link: http://dampy.xeroxer.com/?file_id=89
>
> Is there some way to prevent that? Or maybe to prevent marking overall
> in the textbox?
> If I minimize and maximize the window the editbox is normal again, why?
> Can I use the same principle?
>
> I want the transparent background because I want to display a bitmap
> behind, it�s working fine as long I don�t mark the text =P
>
> Edit:
> Is it possible to make the blue "select-color" transparent?
> I have tried to find some way to do that on msdn, but I am bad searcher...
You need to make sure the underlying window repaints itself before you
allow the EDIT control to repaint. Perhaps
ShowWindow(hwndEdit, SW_HIDE);
UpdateWindow(hwndParent);
ShowWindow(hwndEdit, SW_NORMAL);
would do it.

--
Norm

To reply, change domain to an adult feline.

From: Christian ASTOR on
Dampy wrote:

> Its working fine, but now I want to make the editbox background
> transparent, to do that I use this:

The simplest way is to use a transparent RichEdit control (v.>= 2.0 :
"RichEd20.Dll", RICHEDIT_CLASS)
(WM_ERASEBKGND + WM_CHAR for InvalidateRect())