- ::DrawText(hdc, label, label.length(), &rc, DT_SINGLELINE | DT_VCENTER);
+
+ // first we need to correctly paint the background of the label
+ // as Windows ignores the brush offset when doing it
+ RECT rc = { x, 0, GetSize().x, y };
+ ::DrawText(hdc, label, label.length(), &rc,
+ DT_SINGLELINE | DT_VCENTER | DT_CALCRECT);
+
+ // need to adjust the rectangle to cover all the label background
+ rc.left -= 2;
+ rc.right += 2;
+ rc.bottom += 2;
+ PaintBackground(dc, rc);
+
+ // now draw the text
+ RECT rc2 = { x, 0, GetSize().x, y };
+ ::DrawText(hdc, label, label.length(), &rc2,
+ DT_SINGLELINE | DT_VCENTER);