You have a popup menu in a borderless form

How to add popup menu in form without fields VB 6.0?

Each time I add a menu, the border reappears, even when BorderStyleset to vbBSNone, and the menu is hidden.

+3
source share
3 answers

This is doable, but somewhat unsatisfactory (for me). Having any properties of the menu on the form, the default border will become visible. However, there are several workarounds:

1) , , , , , "" . , , . , Form_MouseDown :

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button And vbRightButton Then PopupMenu Form2.mnuYourMenu
End sub

.

2) , , - ControlBox False Caption . "" , BorderStyle 0... , , , 1- . , .

3) , , , API CreatePopupMenu, http://allapi.mentalis.org/apilist/CreatePopupMenu.shtml

, !

+5

. BorderStyle None, Caption , ControlBox, MaxButton MinButton - False. , VB6, "mnuPopup" Visible False. , Visible True. PopupMenu menuPopup. :

enter image description here

0

, , API-, :

:

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Const GWL_STYLE = -16, WS_BORDER = &H800000

Form_Load:

SetWindowLong Me.hwnd, GWL_STYLE, GetWindowLong(Me.hwnd, GWL_STYLE) And Not WS_BORDER
0

All Articles