PDA

View Full Version : Background Colours (again)


Richard
11-02-2006, 01:50 PM
First of all, many thanks for the ability to set a background colour (in 1.06), it has saved me a great deal of work!

But I should now like to ask for some advice.

I would like to set the background of a (label) control at run time. But obviously there is a great deal of difference in using the SetBackColor call before the form dispalys and after.

So, is there any way to force a re-paint of the control, so that windows knows to redraw it? Or is this being a bit too simplistic?

Should I be looking at the GetDc, SetBkColor, ReleaseDc route? If so, is there some sample code somewhere?

Thanks in advance,

Richard.

Richard
11-02-2006, 03:33 PM
Ok, panic over...

Have used a picture and painted on it with this..

struct (Sq$, RECT);
Sq.Left$ = 20;
Sq.Right$ = 50;
Sq.Top$ = 20;
Sq.Bottom$ = 70;
Dc$ = GetDc(Picture$);
Br$ = CreateSolidBrush(RGB(255,0,0));
Rc$ = FillRect(Dc$, Sq$, Br$);
Rc$ = ReleaseDC(Picture$, Dc$);
Rc$ = DeleteObject(Br$);

Thanks.

kornalius
11-02-2006, 03:42 PM
Easiest thing to do,

SetBackColor(LabelHandle$, RGB(100, 100, 100));
Repaint(LabelHandle$);

Repaint() function is located in the Windows.ppl library.