【问题标题】:How to change the Backcolor of TitleBar on DockWindow?如何更改 DockWindow 上 TitleBar 的背景色?
【发布时间】:2012-08-09 10:52:45
【问题描述】:

我必须为 DockWindow 的 TitleBar 着色。我可以为正常的winform Titlebar color..着色,但我不知道如何更改dockwindow titlebar 的颜色,如果它停靠在右、左、上、下。

    [DllImport("User32.dll", CharSet = CharSet.Auto)]
    public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);

    [DllImport("User32.dll")]
    private static extern IntPtr GetWindowDC(IntPtr hWnd);

    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);
        const int WM_NCPAINT = 0x85;
        if (m.Msg == WM_NCPAINT)
        {
            IntPtr hdc = GetWindowDC(m.HWnd);
            if ((int)hdc != 0)
            {
                Graphics g = Graphics.FromHdc(hdc);
                g.FillRectangle(Brushes.Green, new Rectangle(0, 0, 4800, 23));
                    //(0, 0, 400, 252));
                g.Flush();
                ReleaseDC(m.HWnd, hdc);
            }
        }
    }

通过使用它,我可以绘制普通 winform 的标题栏..但我不能为 Dockwindow 做同样的事情

【问题讨论】:

  • 你从哪里得到的 DockWindow 类?它不是 .NET Framework 的一部分。

标签: c# winforms docking dockpanel


【解决方案1】:

使用来自 codeplexDrawing Custom Borders in Windows Forms 项目。这个项目是一个小型库,它扩展了 Windows 窗体,能够自定义窗口的非客户区

【讨论】:

  • 你可以学习如何自定义windows的非客户区如TitleBar
  • @ Ria 只是在上面看到 pls ..我为普通 winform 制作了一个代码,这样我就可以更改 Winform 的标题栏 ..但是如果我为 dockwindow 做了同样的事情,它就不起作用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-01-17
  • 2011-05-12
  • 1970-01-01
  • 1970-01-01
  • 2011-11-11
  • 1970-01-01
  • 2017-05-05
相关资源
最近更新 更多