wxPaintDC dc(this); wxColour blue = wxColour(0, 0, 255); // blue color dc.SetTextBackground(blue); // set background color to blue dc.DrawText("Some text", 10, 10); // draw text with blue background color
void MyFrame::OnButtonClick(wxCommandEvent& event) { wxColour red = wxColour(255, 0, 0); // red color deviceContext->SetTextBackground(red); // set background color to red deviceContext->DrawText("New background color.", 10, 50); // draw text with red background color }This example demonstrates how SetTextBackground method can be used inside an event handler method. In this case, a button click event changes the background color of the text to red and displays the new text on the device context. Package library: wxWidgets.