0

I have a TPaintBox control and have assigned the TPaintBox->Canvas->Brush->Bitmap to a prepared TBitmap with a grid pattern. The TPaintBox is client aligned inside it's parent (Form).

When I manually call TPaintBox->Invalidate() to redraw the control the brush is aligned perfectly at top,left (0,0 - left picture), but as soon I resize the window, the brush offset change to (20,7 - right picture) until I manually call TPaintBox->Invalidate() again.

enter image description here

I have tried to use one of the standard brush patterns such as bsBDiagonal and bsCross, but they all behave the same (different alignment between an Invalidate() call and form resize).

I tried to use the Win32 API SetBrushOrgEx() to manually set the brush alignment, but it has no effect on a window resize update. It does work perfectly well if I manually call Invalidate().

If I set a breakpoint in my onPaint handler and check what the brush origo is, it always answer (0,0) even when it is misaligned.

I use Canvas->RectFill() to fill the background.

Canvas->Brush->Style = bsBDiagonal;
Canvas->FillRect(Client);

Any ideas?

Max Kielland
  • 5,627
  • 9
  • 60
  • 95

0 Answers0