在WIN7 64位运行正常,在Windows server 2008 r2不显示OnPaint里面的内容,网上找了 说把WIN7 64电脑的gdiplus.dll放到程序根目录也没有用,这是什么问题 ?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace VolumeShow
{
public partial class VolumeShow : UserControl
{
private VerticalProgressBar _progressbar = new VerticalProgressBar();
public VolumeShow()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);
InitializeComponent();
OnForeColorChanged(EventArgs.Empty);
OnResize(EventArgs.Empty);
_progressbar.Minimum = 0;
_progressbar.Maximum = 100;
_progressbar.Left = pictureBox1.Left;
_progressbar.Width = 8;
_progressbar.Height = pictureBox1.Top-10;
this.Controls.Add(_progressbar);
}
public int Volume
{
get { return _progressbar.Value; }
set {
if (Math.Abs(_progressbar.Value - value) < 5) return;
_progressbar.Value = value>100 ? 100: value;
}
}
private void VolumeShow_Paint(object sender, PaintEventArgs e)
{
Graphics g = this.CreateGraphics();
g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.CompositingQuality = CompositingQuality.HighQuality;
Point[] ps = new Point[3];
ps[0].X = _progressbar.Location.X + _progressbar.Width;
ps[0].Y = _progressbar.Location.Y;
ps[1].X = _progressbar.Location.X + _progressbar.Width;
ps[1].Y = pictureBox1.Top-10;
ps[2].X = _progressbar.Location.X + _progressbar.Width + 16;
ps[2].Y = _progressbar.Location.Y;
g.FillPolygon(new SolidBrush(Color.LightGray), ps);
Pen pen = new Pen(Color.LightGray,1);
g.DrawLine(pen, new Point(_progressbar.Location.X + _progressbar.Width, _progressbar.Location.Y),
new Point( _progressbar.Location.X + _progressbar.Width + 20, _progressbar.Location.Y));
g.DrawLine(pen, new Point(_progressbar.Location.X + _progressbar.Width, (pictureBox1.Top - 10)/2),
new Point(_progressbar.Location.X + _progressbar.Width + 20, (pictureBox1.Top - 10)/2));
g.DrawLine(pen, new Point(_progressbar.Location.X + _progressbar.Width, pictureBox1.Top - 10),
new Point(_progressbar.Location.X + _progressbar.Width + 20, pictureBox1.Top-10));
g.Dispose();
}
}
}