VB如何用CreateWindowEx 创建无标题栏无边框窗体?

仅建立窗体,无需移动、最大化、最小化...请赐予完整代码,我找了好多,总是运行不正确,谢谢!... 仅建立窗体,无需移动、最大化、最小化...
请赐予完整代码,我找了好多,总是运行不正确,谢谢!
展开
 我来答
jmeycn
2012-08-28 · TA获得超过373个赞
知道小有建树答主
回答量:331
采纳率:50%
帮助的人:121万
展开全部
编号 窗口样式 对应值 说明

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
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
36000天
2012-08-27 · TA获得超过527个赞
知道小有建树答主
回答量:658
采纳率:77%
帮助的人:270万
展开全部
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
复制进去看看
追问
谢谢!但我需要的是建立新的无标题栏无边框窗体,再请赐教!
追答
VB本来自己就可以做你想要点窗体为什么还要API去做,我就不知道了。
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式