How to add a popup menu on a VB 6.0 borderless form?
Every time I add a menu, the border reappears, even when BorderStyle
is set to vbBSNone
and the menu is hidden.
It's doable, but somewhat unsatisfying (to me). By having any menu properties in a form, the border will default back to visible. There are, however, a few workarounds:
1) The method I think you'll prefer involves making a second form that you'll never really "use" or see. Put the menu on that second form, and then call that menu from the form you actually want to use. Assuming you're using Form_MouseDown
to call this, here's the code:
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
You will have to remember to unload this second form from memory, however.
2) Another way, only using the first form, would be to set the form's ControlBox
to False
and to leave the Caption
property blank. This "removes" the border when BorderStyle
is set to 0... I put removes in quotes because it will unfortunately leave behind a 1-pixel black line. It doesn't look bad, but it might not be a viable solution for you.
3) The final way, which I read about but haven't done anything with myself, would be to use the CreatePopupMenu
API, found at http://allapi.mentalis.org/apilist/CreatePopupMenu.shtml
Hope this helps!