扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
private: System::Void picText_Paint(System::Object * sender, System::Windows::Forms::PaintEventArgs * e) { ... Graphics* g = e->Graphics; |
using namespace System::Drawing; ... Font* font = new Font(S"Times new Roman", 20, FontStyle::Regular); |
SizeF textSize = g->MeasureString(S"My Sample Text", font); |
// HatchBrush example Brush* brush = new HatchBrush(HatchStyle::Cross, Color::Black, Color::Blue); // LinearGradientBrush example RectangleF* rect = __nogc new RectangleF(PointF(0, 0), textSize); brush= new LinearGradientBrush(*rect, Color::Black, Color::Blue, LinearGradientMode::ForwardDiagonal); |
// Use the Windows-defined color for controls // and explicitly state the rectangle coordinates g->FillRectangle(SystemBrushes::Control, picText->Left, picText->Top, picText->Right - picText->Left, picText->Bottom - picText->Top); // Color the entire drawing surface using White g->Clear(Color::White); |
// Center the text on the drawing surface g->DrawString(txtToDisplay->Text, font, brush, (picText->Width - textSize.Width) / 2, (picText->Height - textSize.Height) / 2); |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者