wxPaintDC dc(this); // create a device context dc.DrawText("Hello World", 50, 50); // draw the text at position (50, 50)
wxPaintDC dc(this); // create a device context wxFont font(20, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false); // create a custom font dc.SetFont(font); // set the font dc.SetTextForeground(wxColour(255, 0, 0)); // set the text color to red dc.DrawText("Custom Font & Color", 50, 50); // draw the text with custom font and colorThis example creates a custom font using the wxFont class and sets it as the font for the device context using the SetFont method. The SetTextForeground method is used to set the text color to red. Finally, the DrawText method is used to draw the text "Custom Font & Color" with the custom font and color. Package/Library: wxWidgets (formerly known as wxWindows) wxWidgets is a C++ GUI framework that provides a platform-independent set of widgets and tools for developing graphical user interfaces. The wxDC class is part of the wxWidgets library and provides a device context that can be used to draw graphics and text on a window or canvas in a platform-independent way.