Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 无边框的可缩放应用程序(FormBorderStyle=可缩放)_Vb.net_Dwm - Fatal编程技术网

Vb.net 无边框的可缩放应用程序(FormBorderStyle=可缩放)

Vb.net 无边框的可缩放应用程序(FormBorderStyle=可缩放),vb.net,dwm,Vb.net,Dwm,如何隐藏默认窗口(窗体)边框(我想使用我的边框),但仍然可以使用捕捉和窗体阴影 在(桌面)Win8上开发,认为它是DWMAPI函数或类似的东西 PS:我是DWM新手。好的,我终于找到了解决问题的方法 最初我使用的是WinForms,但几年后我改用了WPF WPF得到了一个名为WindowChrome的东西,它是一个窗口框架/支架,每次有新的Windows迭代时都会保存窗口内容和更改 我发现有一个函数可以很容易地更改窗口的WindowChrome属性 我创建了自己的函数,可以在其中传递新chrom

如何隐藏默认窗口(窗体)边框(我想使用我的边框),但仍然可以使用捕捉和窗体阴影

在(桌面)Win8上开发,认为它是DWMAPI函数或类似的东西


PS:我是DWM新手。

好的,我终于找到了解决问题的方法

最初我使用的是WinForms,但几年后我改用了WPF

WPF得到了一个名为WindowChrome的东西,它是一个窗口框架/支架,每次有新的Windows迭代时都会保存窗口内容和更改

我发现有一个函数可以很容易地更改窗口的WindowChrome属性

我创建了自己的函数,可以在其中传递新chrome的属性:

/// <summary>
/// Changes the WindowChrome of selected Window (wnd) &amp; adjust its properties
/// </summary>
/// <param name="wnd">Window to affect</param>
/// <param name="glassThickness">Thickness of glass border (0 - no glass = no shadow, lower than 0 - whole window, higher than 0 - real border)</param>
/// <param name="resBorder">Thickness of resize border - where Windows natively supports resizing of the window</param>
/// <param name="topMove">Height of the window header/title - Windows native support for changing position of the window (from top), disables mouse events of controls underneath it</param>
/// <remarks></remarks>
public void NiceChrome(Window wnd, Thickness glassThickness, Thickness resBorder, int topMove)
{
    WindowStyle = WindowStyle.SingleBorderWindow;
    Shell.WindowChrome.SetWindowChrome(wnd, new Shell.WindowChrome
    {
        ResizeBorderThickness = resBorder,
        GlassFrameThickness = glassThickness,
        UseAeroCaptionButtons = false,
        CaptionHeight = topMove,
        CornerRadius = new CornerRadius(0),
        NonClientFrameEdges = Shell.NonClientFrameEdges.None
    });
}
//
///更改所选窗口的WindowChrome(wnd)&;调整其属性
/// 
///影响窗口
///玻璃边框的厚度(0-无玻璃=无阴影,低于0-整个窗口,高于0-真实边框)
///调整边框的厚度-窗口本机支持调整窗口大小
///窗口标题/标题的高度-Windows本机支持更改窗口的位置(从顶部),禁用其下方控件的鼠标事件
/// 
公共空间(窗宽、玻璃厚度、重新边框厚度、内部顶部移动)
{
WindowsStyle=WindowsStyle.SingleBorderWindow;
Shell.WindowChrome.SetWindowChrome(wnd,新Shell.WindowChrome
{
ResizeBorderThickness=resBorder,
玻璃框架厚度=玻璃厚度,
UseAeroCaptionButtons=false,
标题高度=顶部移动,
拐角半径=新拐角半径(0),
NonClientFrameEdges=Shell.NonClientFrameEdges.None
});
}
如果有人想使用该功能,我希望我的评论易于理解。我还发现,在
glassThickness
上使用厚度(-1)可以使整个窗口的玻璃位于其下方,而不会在窗口之外提供任何额外的空间/边框,但仍然保持阴影效果

另一个注意事项是,您必须在最大化窗口的同时更改窗口的填充,因为窗口仍然希望切断不再存在的边框/玻璃


注:英语不是我的母语,如果语法有问题,请在编辑时解决。谢谢&是的,我正在回答我自己将近2年的问题(我的任命)。

不要隐藏边框,而是尝试在默认边框上方绘制边框。截获NC_绘制消息。这样你就可以使用Windows的大小调整功能了。回答得好,但是如果我想隐藏def边框…可能是用WindowStyles…怎么做?!完成,无需更多帮助:)将您的解决方案作为答案发布,以便其他人可以从中受益。