Click to See Complete Forum and Search --> : Static control with Background Image


Vintik
July 27th, 2006, 04:28 AM
Hello people,
I have a problem with creating static control with Background Image.
1. When I process WM_ERASEBKGND and set the Background Image, I can see only the text of the control, but that image is under the text.
2. When I use SS_BITMAP style for the control and than use STM_SETIMAGE to the control to set the image, I can't output the text. So I can't see the text on the control.

SendMessage(hStatic, STM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hBmpStatic);
........
RECT r;
HDC sdc = GetDC(hStatic);
GetClientRect(hStatic, &r);
SetBkMode(sdc, OPAQUE);
BeginPath(sdc);
TextOut(sdc, r.left, r.top, "Some text", 6);
EndPath(sdc);
DeleteDC(sdc);

Can any guru help me? Help plz

Ali Imran
July 27th, 2006, 07:17 AM
Probably you have sub-classed the control, did you ? or you are tracking message WM_ERASEBKGND of parent window ? If not then sub-class the control set background by tracking message WM_PAINT.

2.As far I know when you use SS_BITMAP, the static becomes a simple image box and no more displays default text over it.

Another option may be create a static over it, turn it to transparent and display text over it.
see WM_CTLCOLORSTATIC details.

regards