vb,边框样式为0时如何用菜单编辑器
高手指导一下啊,我做个无边框样式的窗体,但我同时需要用到菜单,可是VB总无法实现,因为有菜单就会有标题栏出现,尽管我的BorderStyle为0...
高手指导一下啊,我做个无边框样式的窗体,但我同时需要用到菜单,可是VB总无法实现,因为有菜单就会有标题栏出现,尽管我的BorderStyle为0
展开
2个回答
展开全部
用SetWindowRgn和CreatePolygonRgn函数设置窗体显示区域
把外面的边框隐藏掉
Private Declare Function SetWindowRgn Lib "user32.dll" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Sub form_load()
Dim point(3) As POINTAPI
point(0).x = 3
point(0).y = 30
point(1).x = 596
point(1).y = 30
point(2).x = 596
point(2).y = 397
point(3).x = 3
point(3).y = 397
SetWindowRgn Me.hWnd, CreatePolygonRgn(point(0), 4, 1), True
End Sub
这里几个点的坐标根据你窗体的大小调节,所有点坐标围成的多边型就是窗体的外形。
坐标的值是相对于原窗体左上角开始计算的。
把外面的边框隐藏掉
Private Declare Function SetWindowRgn Lib "user32.dll" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Sub form_load()
Dim point(3) As POINTAPI
point(0).x = 3
point(0).y = 30
point(1).x = 596
point(1).y = 30
point(2).x = 596
point(2).y = 397
point(3).x = 3
point(3).y = 397
SetWindowRgn Me.hWnd, CreatePolygonRgn(point(0), 4, 1), True
End Sub
这里几个点的坐标根据你窗体的大小调节,所有点坐标围成的多边型就是窗体的外形。
坐标的值是相对于原窗体左上角开始计算的。
参考资料: vb-api函数手册
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是从VB吧里的版主cbm666贴子中学到的..那儿是个学习的好地方:
'全屏下无边框的窗体菜单制作
'建立菜单menu1 子项 menuexit
'Me.ControlBox = False 在属性窗口设置,不能在运行期设置
Private Sub Form_Load()
Me.BorderStyle = 0
Me.Caption = ""
Me.Move 0, 0, Screen.Width, Screen.Height
menu1.Enabled = False
menu1.Visible = False
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then PopupMenu menu1
End Sub
Sub menuexit_click() '菜单退出
Unload Me
End Sub
'全屏下无边框的窗体菜单制作
'建立菜单menu1 子项 menuexit
'Me.ControlBox = False 在属性窗口设置,不能在运行期设置
Private Sub Form_Load()
Me.BorderStyle = 0
Me.Caption = ""
Me.Move 0, 0, Screen.Width, Screen.Height
menu1.Enabled = False
menu1.Visible = False
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then PopupMenu menu1
End Sub
Sub menuexit_click() '菜单退出
Unload Me
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询