I did a lot of search and research and didn't find a answer for my probleam, so.. I made a custom Menu using WinForm C++, where we override the Renderer and OnPaint methods. Our application can move to one monitor to another and when we do that, the texts of the options on my Menu get corrupted. I don't have any idea or know if this has a solution. I'll be very thankfull if somebody can help me.
MyRenderer.h
ref class MyRenderer: ToolStripProfessionalRenderer
{
protected:
virtual void OnRenderToolStripBorder(System::Windows::Forms::ToolStripRenderEventArgs ^e) override
{
System::Drawing::SolidBrush^ brush = gcnew System::Drawing::SolidBrush(Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(60)),static_cast<System::Int32>(static_cast<System::Byte>(107))));
e->Graphics->FillRectangle(brush, e->ConnectedArea);
Drawing::Rectangle rectBorder = Drawing::Rectangle(0, 1, e->AffectedBounds.Width-1, e->AffectedBounds.Height-2);
Pen^ pen = gcnew Pen(brush, 2);
e->Graphics->DrawRectangle(pen, rectBorder);
}
};
MenuHover.h
public ref class MenuHover: ToolStripMenuItem
{
protected:
virtual void OnPaint(PaintEventArgs ^e) override
{
if (this->Visible)
{
System::Drawing::SolidBrush^ brush = gcnew System::Drawing::SolidBrush(Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(60)),
static_cast<System::Int32>(static_cast<System::Byte>(107))));
e->Graphics->FillRectangle(brush, e->ClipRectangle.X, e->ClipRectangle.Y, e->ClipRectangle.Width, e->ClipRectangle.Height+34);
Drawing::Rectangle rect = Drawing::Rectangle(e->ClipRectangle.X, e->ClipRectangle.Y+5, e->ClipRectangle.Width, e->ClipRectangle.Height+34);
StringFormat^ sf = gcnew StringFormat();
sf->Alignment = StringAlignment::Center;
e->Graphics->DrawString(this->Text, this->Font, Brushes::White, rect, sf);
}
if (this->Selected || this->Pressed)
{
System::Drawing::SolidBrush^ brush = gcnew System::Drawing::SolidBrush(Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(42)),
static_cast<System::Int32>(static_cast<System::Byte>(82))));
e->Graphics->FillRectangle(brush, e->ClipRectangle.X, e->ClipRectangle.Y, e->ClipRectangle.Width, e->ClipRectangle.Height);
Drawing::Rectangle rect = Drawing::Rectangle(e->ClipRectangle.X, e->ClipRectangle.Y+5, e->ClipRectangle.Width, e->ClipRectangle.Height);
StringFormat^ sf = gcnew StringFormat();
sf->Alignment = StringAlignment::Center;
e->Graphics->DrawString(this->Text, this->Font, Brushes::White, rect, sf);
}
}
};
MenuHoverItem.h
ref class MenuHoverItem: ToolStripMenuItem
{
protected:
virtual void OnPaint(PaintEventArgs ^e) override
{
if (this->Visible)
{
System::Drawing::SolidBrush^ brush = gcnew System::Drawing::SolidBrush(Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(42)),
static_cast<System::Int32>(static_cast<System::Byte>(82))));
e->Graphics->FillRectangle(brush, e->ClipRectangle.X, e->ClipRectangle.Y, e->ClipRectangle.Width, e->ClipRectangle.Height);
Drawing::Rectangle rect = Drawing::Rectangle(e->ClipRectangle.X+14, e->ClipRectangle.Y+1, e->ClipRectangle.Width, e->ClipRectangle.Height);
StringFormat^ sf = gcnew StringFormat();
sf->LineAlignment = StringAlignment::Center;
e->Graphics->DrawString(this->Text, this->Font, Brushes::White, rect, sf);
}
if (this->Selected || this->Pressed)
{
System::Drawing::SolidBrush^ brush = gcnew System::Drawing::SolidBrush(Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(60)),
static_cast<System::Int32>(static_cast<System::Byte>(107))));
e->Graphics->FillRectangle(brush, e->ClipRectangle.X, e->ClipRectangle.Y, e->ClipRectangle.Width, e->ClipRectangle.Height-1);
Drawing::Rectangle rect = Drawing::Rectangle(e->ClipRectangle.X+14, e->ClipRectangle.Y+1, e->ClipRectangle.Width, e->ClipRectangle.Height);
StringFormat^ sf = gcnew StringFormat();
sf->LineAlignment = StringAlignment::Center;
e->Graphics->DrawString(this->Text, this->Font, Brushes::White, rect, sf);
}
}
};
If theres a question like that, please send me a link and my I'm sorry if theres anything wrong, thanks for the help