Graphics.GetHalftonePalette Method (System.Drawing)
Override and use HalftonePalette can fix some display problem for c# controls under 256 color mode(RDP)
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr SelectPalette(IntPtr hdc, IntPtr htPalette, bool bForceBackground);
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern int RealizePalette(IntPtr hdc);
protected override void OnPaint(PaintEventArgs e)
{
IntPtr hdc = e.Graphics.GetHdc();
// Get handle to halftone palette.
IntPtr htPalette = Graphics.GetHalftonePalette();
// Select and realize new palette.
SelectPalette(hdc, htPalette, true);
RealizePalette(hdc);
e.Graphics.ReleaseHdc(hdc);
base.OnPaint(e);
}
没有评论:
发表评论