VB如何用CreateWindowEx 创建无标题栏无边框窗体?
2个回答
展开全部
编号 窗口样式 对应值 说明
0 WS_BORDER &H800000 带有一线条边框
1 WS_CAPTION &HC00000 窗口有标题栏
2 WS_CHILD &H40000000 窗口为子窗口
3 WS_SYSMENU &H80000 带有系统菜单,必须有WS_CAPTION
4 WS_CLIPCHILDREN &H2000000
5 WS_CLIPSIBLINGS &H4000000
6 WS_DLGFRAME &H400000 类似对话框的边框,无标题栏
7 WS_GROUP &H20000
8 WS_MAXIMIZEBOX &H10000 最大化
9 WS_MINIMIZEBOX &H20000 最小化
10 WS_OVERLAPPED 0
'Creates an overlapped window. An overlapped window has a title bar and a border.
Same as the WS_TILED style.
11 WS_OVERLAPPEDWINDOW &HCF0000
'Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU,
WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the
WS_TILEDWINDOW style
12 WS_POPUP &H80000000 'Creates a pop-up window. This style cannot be used with the WS_CHILD style.
13 WS_POPUPWINDOW &H80880000
'Creates a pop-up window with WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The
WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu
visible.
14 WS_THICKFRAME &H40000 可调整大小的边框
15 WS_DISABLED &H8000000
代码参考1楼
先CreateWindow,接着 i = GetWindowLong(lHandle, GWL_STYLE)返回窗口样式 i 。
将当前样式 i 修改为你想要的样式
添加新样式 i = i Or newWS
删除某样式 i = i And Not (WS)
如 SetWindowLong Handle, GWL_STYLE, i And Not (WS_OVERLAPPEDWINDOW Or WS_POPUPWINDOW Or WS_THICKFRAME)
最后SetWindowLong(lHandle, GWL_STYLE, i)应用新的样式。
最后要显示或刷新窗口
ShowWindow handle, SW_SHOW
UpdateWindow handle
0 WS_BORDER &H800000 带有一线条边框
1 WS_CAPTION &HC00000 窗口有标题栏
2 WS_CHILD &H40000000 窗口为子窗口
3 WS_SYSMENU &H80000 带有系统菜单,必须有WS_CAPTION
4 WS_CLIPCHILDREN &H2000000
5 WS_CLIPSIBLINGS &H4000000
6 WS_DLGFRAME &H400000 类似对话框的边框,无标题栏
7 WS_GROUP &H20000
8 WS_MAXIMIZEBOX &H10000 最大化
9 WS_MINIMIZEBOX &H20000 最小化
10 WS_OVERLAPPED 0
'Creates an overlapped window. An overlapped window has a title bar and a border.
Same as the WS_TILED style.
11 WS_OVERLAPPEDWINDOW &HCF0000
'Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU,
WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the
WS_TILEDWINDOW style
12 WS_POPUP &H80000000 'Creates a pop-up window. This style cannot be used with the WS_CHILD style.
13 WS_POPUPWINDOW &H80880000
'Creates a pop-up window with WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The
WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu
visible.
14 WS_THICKFRAME &H40000 可调整大小的边框
15 WS_DISABLED &H8000000
代码参考1楼
先CreateWindow,接着 i = GetWindowLong(lHandle, GWL_STYLE)返回窗口样式 i 。
将当前样式 i 修改为你想要的样式
添加新样式 i = i Or newWS
删除某样式 i = i And Not (WS)
如 SetWindowLong Handle, GWL_STYLE, i And Not (WS_OVERLAPPEDWINDOW Or WS_POPUPWINDOW Or WS_THICKFRAME)
最后SetWindowLong(lHandle, GWL_STYLE, i)应用新的样式。
最后要显示或刷新窗口
ShowWindow handle, SW_SHOW
UpdateWindow handle
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Const WS_EX_STATICEDGE = &H20000
Const WS_EX_TRANSPARENT = &H20&
Const WS_CHILD = &H40000000
Const CW_USEDEFAULT = &H80000000
Const SW_NORMAL = 1
Private Type CREATESTRUCT
lpCreateParams As Long
hInstance As Long
hMenu As Long
hWndParent As Long
cy As Long
cx As Long
y As Long
x As Long
style As Long
lpszName As String
lpszClass As String
ExStyle As Long
End Type
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Dim mWnd As Long
Private Sub Form_Load()
Dim CS As CREATESTRUCT
mWnd = CreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, "STATIC", "Hello World !", WS_CHILD, 0, 0, 300, 50, Me.hwnd, 0, App.hInstance, CS)
Me.Caption = mWnd
ShowWindow mWnd, SW_NORMAL
End Sub
Private Sub Form_Unload(Cancel As Integer)
DestroyWindow mWnd
End Sub
复制进去看看
Const WS_EX_TRANSPARENT = &H20&
Const WS_CHILD = &H40000000
Const CW_USEDEFAULT = &H80000000
Const SW_NORMAL = 1
Private Type CREATESTRUCT
lpCreateParams As Long
hInstance As Long
hMenu As Long
hWndParent As Long
cy As Long
cx As Long
y As Long
x As Long
style As Long
lpszName As String
lpszClass As String
ExStyle As Long
End Type
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Dim mWnd As Long
Private Sub Form_Load()
Dim CS As CREATESTRUCT
mWnd = CreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, "STATIC", "Hello World !", WS_CHILD, 0, 0, 300, 50, Me.hwnd, 0, App.hInstance, CS)
Me.Caption = mWnd
ShowWindow mWnd, SW_NORMAL
End Sub
Private Sub Form_Unload(Cancel As Integer)
DestroyWindow mWnd
End Sub
复制进去看看
追问
谢谢!但我需要的是建立新的无标题栏无边框窗体,再请赐教!
追答
VB本来自己就可以做你想要点窗体为什么还要API去做,我就不知道了。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询