Private Const GWL_STYLE = (-16) '窗口样式
'窗口风格
Private Const WS_CAPTION = &HC00000 '带标题栏的窗口
Private Const WS_MAXIMIZEBOX = &H10000 '带最大化按钮的窗口
Private Const WS_MINIMIZEBOX = &H20000 '带最小化按钮的窗口
Private Const WS_SYSMENU = &H80000 '带系统菜单的窗口
Private Const WS_CLIPSIBLINGS = &H4000000 '不重绘层叠子窗口
Private Const WS_CLIPCHILDREN = &H2000000 '绘图时排子窗口区域
Private Const WS_OVERLAPPED = &H0& '具有标题栏和边框的层叠窗口
Private Const WS_THICKFRAME = &H40000 '具有可调边框
'WS_OVERLAPPEDWINDOW具有标题栏、窗口菜单、可调边框和最大化、最小化按钮的窗口
Private Const WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX)
Private Const WS_GROUP = &H20000 '指定一组控制的第一个控制
Private Const WS_POPUP = &H80000000 '弹出式窗口
Private Const WS_BORDER = &H800000 '单边框窗口
Private Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU) '具有单边框、标题栏菜单的弹出式窗口
Private Const WS_MINIMIZE = &H20000000 '窗口最小化
Private Const WS_VISIBLE = &H10000000 '窗口可见
Private Const WS_DISABLED = &H8000000 '窗口被禁用
Private Const WS_MAXIMIZE = &H1000000 '窗口最大化
Private Const WS_DLGFRAME = &H400000 '对话框边框风格
Private Const WS_VSCROLL = &H200000 '具有垂直滚动条
Private Const WS_HSCROLL = &H100000 '具有水平滚动条
Private Const WS_TABSTOP = &H10000 '具有TAB键控制
Private Const WS_CHILD = &H40000000
Private Const WS_CHILDWINDOW = (WS_CHILD) '具有子窗口
'扩展风格
Private Const WS_EX_WINDOWEDGE = &H100& '窗口具有凸起的3D边框
Private Const WS_EX_CLIENTEDGE = &H200& '窗口具有阴影边界
Private Const WS_EX_TOOLWINDOW = &H80& '小标题工具窗口
Private Const WS_EX_TOPMOST = &H8& '窗口总在顶层
Private Const WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE Or WS_EX_CLIENTEDGE) 'WS_EX-CLIENTEDGE和WS_EX_WINDOWEDGE的组合
Private Const WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE Or WS_EX_TOOLWINDOW Or WS_EX_TOPMOST) 'WS_EX_WINDOWEDGE和WS_EX_TOOLWINDOW和WS_EX_TOPMOST的组合
Private Const WS_EX_DLGMODALFRAME = &H1& '带双边的窗口
Private Const WS_EX_NOPARENTNOTIFY = &H4& '窗口在创建和销毁时不向父窗口发送WM_PARENTNOTIFY消息
Private Const WS_EX_TRANSPARENT = &H20& '窗口透眀
Private Const WS_EX_MDICHILD = &H40& 'MDI子窗口
Private Const WS_EX_CONTEXTHELP = &H400& '标题栏包含问号联机帮助按钮
Private Const WS_EX_RIGHT = &H1000& '窗口具有右对齐属性
Private Const WS_EX_RTLREADING = &H2000& '窗口文本自右向左显示
Private Const WS_EX_LEFTSCROLLBAR = &H4000& '标题栏在客户区的左边
Private Const WS_EX_CONTROLPARENT = &H10000 '允许用户使用Tab键在窗口的子窗口间搜索
Private Const WS_EX_STATICEDGE = &H20000 '为不接受用户输入的项创建一个三维边界风格
Private Const WS_EX_APPWINDOW = &H40000 '在任务栏上显示顶层窗口的标题按钮
Private Const WS_EX_LAYERED = &H80000 '窗口具有透眀属性(Win2000)以上
Private Const WS_EX_NOINHERITLAYOUT = &H100000 '窗口布局不传递给子窗口(Win2000)以上
Private Const WS_EX_LAYOUTRTL = &H400000 '水平起点在右边的窗口
Private Const WS_EX_NOACTIVATE = &H8000000 '窗口不会变成前台窗口(Win2000)以上
Private Const WS_EX_LEFT = &H0& '窗口具有左对齐属性
Private Const WS_EX_LTRREADING = &H0& '窗口文本自左向右显示
Private Const WS_EX_RIGHTSCROLLBAR = &H0& '垂直滚动条在窗口的右边界
Private Const WS_EX_ACCEPTFILES = &H10& '接受文件拖曳
Private Const WS_EX_COMPOSITED = &H2000000 '窗体所有子窗口使用双缓冲从低到高绘制(XP)
Private Sub Command1_Click()
OrStyle
End Sub
Private Sub OrStyle()
Dim lStyle As Long
lStyle = GetWindowLong(Me.hwnd, GWL_STYLE) '获取原风格
'lStyle = lStyle And Not WS_OVERLAPPEDWINDOW
' lStyle = lStyle And Not WS_OVERLAPPED '去除不用的风格
' lStyle = lStyle And Not WS_THICKFRAME
' lStyle = lStyle And Not WS_MAXIMIZEBOX
lStyle = lStyle Or WS_SYSMENU '加上自定义风格
lStyle = lStyle Or WS_GROUP
lStyle = lStyle Or WS_MINIMIZEBOX
SetWindowLong p.hwnd, GWL_STYLE, lStyle '设置新的风格
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
p.Refresh
End Sub