Form1.BorderStyle = None的情况下,
在Form1的窗体上增加了PopupMenu后,Form1的BorderStyle居然自己变为了Fixed Single????而我需要的是BorderStyle = None,因为界面全是按照BorderStyle = None来做的,做了好几天,现在需要加入PopupMenu才发现在这个情况。请问大家怎么解决啊。谢谢!

解决方案 »

  1.   

    ipooy() ??自己做Popup Menu ?? 好麻烦啊,以后可能还要变动,那就麻烦~~
      

  2.   

    试试这个菜单(有源码的):
    http://www.vbaccelerator.com/home/VB/Code/Controls/Menus/Popup_Menu_ActiveX_DLL/artic
    le.asp
      

  3.   

    添加一个模块
    Option Explicit
    Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
    Public Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As LongPublic Const GWL_STYLE = (-16)
    Public Const WS_CAPTION = &HC00000     'WS_BORDER 或 WS_DLGFRAME
    Public Const WS_MAXIMIZEBOX = &H10000
    Public Const WS_MINIMIZEBOX = &H20000
    Public Const WS_SYSMENU = &H80000Public Enum ESetWindowPosStyles
        SWP_SHOWWINDOW = &H40
        SWP_HIDEWINDOW = &H80
        SWP_FRAMECHANGED = &H20 'The frame changed: send WM_NCCALCSIZE
        SWP_NOACTIVATE = &H10
        SWP_NOCOPYBITS = &H100
        SWP_NOMOVE = &H2
        SWP_NOOWNERZORDER = &H200 'Dont do owner Z ordering
        SWP_NOREDRAW = &H8
        SWP_NOREPOSITION = SWP_NOOWNERZORDER
        SWP_NOSIZE = &H1
        SWP_NOZORDER = &H4
        SWP_DRAWFRAME = SWP_FRAMECHANGED
        HWND_NOTOPMOST = -2
    End EnumPublic Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    Public Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End TypePublic Function ShowTitleBar(hWnd As Long, ByVal bState As Boolean)
       Dim lStyle As Long
       Dim tR As RECT
       GetWindowRect hWnd, tR
       lStyle = GetWindowLong(hWnd, GWL_STYLE)
       If bState Then
          lStyle = lStyle Or WS_CAPTION
       Else
          lStyle = lStyle And Not WS_CAPTION
       End If
       SetWindowLong hWnd, GWL_STYLE, lStyle   SetWindowPos hWnd, 0, tR.Left, tR.Top, tR.Right - tR.Left, tR.Bottom - tR.Top, SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED
    End Function在Form_Load事件中写入:
    ShowTitleBar Me.hWnd, False
      

  4.   

    yyz985(yyz985)谢谢!
    这个比较帅,省事~~~~代码我也不用看了,直接用,赶进度了~~结帖