VB 如何让窗体既没有标题栏,又可以在任务栏中显示标题图标等。
将BorderStyle=0后虽然没有了标题栏,但是在任务栏没有任务将Caption设置为空,ControlBox=False后,虽然没有了标题栏,但是任务栏中的任务也只...
将BorderStyle=0后 虽然没有了标题栏,但是在任务栏没有任务
将Caption设置为空,ControlBox=False后,虽然没有了标题栏,但是任务栏中的任务也只剩下图标,没有标题。
怎么才能让窗体没有标题栏,而任务栏中的显示任务的标题和图标?
谢谢
解决了。。原来在把BorderStyle选择为0的时候ShowInTaskbar自动设置成False了。。只要手动改成True就可以达到我的要的效果了。。行了别回答了。不解决了 展开
将Caption设置为空,ControlBox=False后,虽然没有了标题栏,但是任务栏中的任务也只剩下图标,没有标题。
怎么才能让窗体没有标题栏,而任务栏中的显示任务的标题和图标?
谢谢
解决了。。原来在把BorderStyle选择为0的时候ShowInTaskbar自动设置成False了。。只要手动改成True就可以达到我的要的效果了。。行了别回答了。不解决了 展开
展开全部
'怎么不解决呢?虽然显示了,但没有常见的右键菜单以及菜单功能,解决一下
'添加一个模块,加入以下代码
Option Explicit
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const WM_SYSCOMMAND = &H112
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const WM_CLOSE = &H10
Private Const SC_CLOSE = &HF060&
Public lOldproc As Long
'处理一些消息
Public Function WndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case Msg
Case WM_SYSCOMMAND
'使无边框窗体系统菜单的关闭按钮有效
If wParam = SC_CLOSE Then
SendMessage hWnd, WM_CLOSE, ByVal 0&, ByVal 0&
End If
End Select
WndProc = CallWindowProc(lOldproc, hWnd, Msg, wParam, lParam)
End Function
'移动无边框窗体,可用于任意控件的鼠标按下事件里
Public Sub DragForm(Frm As Form)
ReleaseCapture
Call SendMessage(Frm.hWnd, WM_NCLBUTTONDOWN, 2, 0&)
End Sub
'窗体加载事件
'使无边框窗体获得系统菜单
Private Sub Form_Load()
Dim lStyle&
lStyle = GetWindowLong(Me.hWnd, -16)
lStyle = lStyle Or &H80000 Or &H20000
SetWindowLong Me.hWnd, -16, lStyle
lOldproc = SetWindowLong(Me.hWnd, -4, AddressOf WndProc)
End Sub
'添加一个模块,加入以下代码
Option Explicit
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const WM_SYSCOMMAND = &H112
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const WM_CLOSE = &H10
Private Const SC_CLOSE = &HF060&
Public lOldproc As Long
'处理一些消息
Public Function WndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case Msg
Case WM_SYSCOMMAND
'使无边框窗体系统菜单的关闭按钮有效
If wParam = SC_CLOSE Then
SendMessage hWnd, WM_CLOSE, ByVal 0&, ByVal 0&
End If
End Select
WndProc = CallWindowProc(lOldproc, hWnd, Msg, wParam, lParam)
End Function
'移动无边框窗体,可用于任意控件的鼠标按下事件里
Public Sub DragForm(Frm As Form)
ReleaseCapture
Call SendMessage(Frm.hWnd, WM_NCLBUTTONDOWN, 2, 0&)
End Sub
'窗体加载事件
'使无边框窗体获得系统菜单
Private Sub Form_Load()
Dim lStyle&
lStyle = GetWindowLong(Me.hWnd, -16)
lStyle = lStyle Or &H80000 Or &H20000
SetWindowLong Me.hWnd, -16, lStyle
lOldproc = SetWindowLong(Me.hWnd, -4, AddressOf WndProc)
End Sub
追问
用找那么麻烦么 大哥。 我自己都补充说了。。就那么一下 就能解决 我想解决的问题。你这未免兴师动众了吧?
追答
呵呵,那恭喜你了,我只是觉得虽然在任务栏里显示了,但右键点击任务栏的时候没菜单,你无所谓,那就无所谓^_^
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询