VerySource

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1114|回复: 0

让窗口变成 Windows 新版白色窗口(仅适用 Windows 10 及以上的版本)

[复制链接]

1

主题

1

帖子

8.00

积分

新手上路

Rank: 1

积分
8.00
发表于 2023-7-1 09:02:53 | 显示全部楼层 |阅读模式
让窗口变成 Windows 新版白色窗口(仅适用 Windows 10 及以上的版本)
代码:
Option Explicit
Private Const MF_BYCOMMAND As Long = &H0&
Private Const SC_SIZE As Long = &HF000&
Private Const SC_MAXIMIZE As Long = &HF030&


Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long

Private Type margins
    cxLeftWidth As Long
    cxRightWidth As Long
    cyTopHeight As Long
    cyBottomHeight As Long
End Type

Private Declare Function DwmExtendFrameIntoClientArea Lib "dwmapi.dll" (ByVal hwnd As Long, ByRef pMarInset As margins) As Long

Private Sub Form_Load()
    Me.Icon = LoadPicture("")
    '设置窗口样式为无边框
    Me.BorderStyle = vbBSNone
    '创建一个Margins结构体来指定窗口边框宽度,这里设为5像素
    Dim margins As margins
    margins.cxLeftWidth = 5
    margins.cxRightWidth = 5
    margins.cyTopHeight = 5
    margins.cyBottomHeight = 5
    '调用DwmExtendFrameIntoClientArea函数来扩展窗口边框,并将颜色设为红色
    Call DwmExtendFrameIntoClientArea(Me.hwnd, margins)
    Me.Refresh '强制重绘窗口
    ' 去掉系统菜单栏的大小选项
    Dim hMenu As Long
    hMenu = GetSystemMenu(Me.hwnd, False)
    Call RemoveMenu(hMenu, SC_SIZE, MF_BYCOMMAND)
    Call RemoveMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)

    ' 设置窗口BorderStyle属性为2
    Me.BorderStyle = 2
    Me.BackColor = &H8000000E
    Me.Height = 7791 ' reset the height if user tries to resize the form
    Me.Width = 11235 ' reset the width if user tries to resize the form
End Sub

Private Sub Form_Resize()
If Me.WindowState = 0 Then
    Me.Height = 7791 ' reset the height if user tries to resize the form
    Me.Width = 11235 ' reset the width if user tries to resize the form
End If
If Me.WindowState = 2 Then
    Me.Height = 7791 ' reset the height if user tries to resize the form
    Me.Width = 11235 ' reset the width if user tries to resize the form
End If
End Sub


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

快速回复 返回顶部 返回列表