我通过override WndProc对非客户区进行重绘,自己在最小化按钮的旁边画了一个按钮,但位置是用的this.Width - 95,不知道怎么取到最小化按钮的Location,望高手指点!ps:用SystemInfomation.CaptionButtonSize.Width * 3 + SystemInfomation.Border3DSize.Width需要在win2000的界面模式,连Xp都不支持,而且取出来的偏移量也是有误差的。

解决方案 »

  1.   

    http://topic.csdn.net/u/20101213/10/ff171d02-1e8d-42a0-aa5d-baad122b77ac.html?17567
    相似例子自己看
      

  2.   


    4页的回复我全看了,没有获取minimizeButton位置的啊,非客户区绘图我也可以了,我是想紧挨着最小化按钮,如果估计一个位置,不同的操作系统下岂不是会乱?谢谢了!
      

  3.   

    WndProc窗体换肤的,看看有没帮助
      

  4.   

    给你个思路:
    public partial class Form1 : Form
        {
            const int WM_NCCALCSIZE = 0x83;
            const int WM_NCPAINT = 0x0085;
            const int WM_NCACTIVATE = 0x0086;
            const int WM_NCMOUSEMOVE = 0x00A0;
            const int WM_NCLBUTTONDOWN = 0x00A1;
            const int WM_NCLBUTTONDBLCLK = 0x00A3;
            const int WM_SIZE = 0x0005;
            const int WM_PAINT = 0x000F;
            const int WM_WINDOWPOSCHANGING = 0x0046;        Brush b;
            public Form1()
            {
                InitializeComponent();
                b = Brushes.Red;
            }        [DllImport("user32")]
            public static extern IntPtr GetWindowDC(IntPtr hWnd);
            [DllImport("user32")]
            public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
            protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);
                switch (m.Msg)
                {
                    case WM_NCPAINT:
                    case WM_NCACTIVATE:
                        IntPtr hdc = GetWindowDC(this.Handle);
                        Graphics g = Graphics.FromHdc(hdc);                    
                        g.FillRectangle(b, 60, 5, 80, 16);
                        g.Dispose();
                        ReleaseDC(this.Handle, hdc);
                        break;
                }
            }
        }
      

  5.   


    首先谢谢 楼上兄弟的回复,我就是这么写的,问题在于,g.FillRectangle(b, 60, 5, 80, 16);这一句,60,5这些数字不都是自己写的么?怎么知道minimizeButton的位置,然后紧挨着它画一个按钮?不要告诉我要所有按钮都自己重画!!我不是要做windows的皮肤,只想加个按钮而已,就这么难么?
      

  6.   


    用SystemInformation.CaptionButtonSize.width * 3就大概差不多了,但这是在未使用主题(或者说使用类似2000的经典主题)的情况下,使用主题后就不对了。相差甚大,很难看
      

  7.   

    发生WM_NCHITTEST消息时可以知道鼠标指针在哪个区域,比如在关闭按钮、或最大化按钮上等,不知道可不可以用Point模拟鼠标指针,然后强制得到WM_NCHITTEST消息呢?
    期待高人出现。。