代码:
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ?996-2001 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You are free to use this code within your own applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Public Const MF_BYPOSITION = &H400
Public Const MF_REMOVE = &H1000Public Declare Function DrawMenuBar Lib "user32" _
      (ByVal hwnd As Long) As Long
      
Public Declare Function GetMenuItemCount Lib "user32" _
      (ByVal hMenu As Long) As Long
      
Public Declare Function GetSystemMenu Lib "user32" _
      (ByVal hwnd As Long, _
       ByVal bRevert As Long) As Long
       
Public Declare Function RemoveMenu Lib "user32" _
      (ByVal hMenu As Long, _
       ByVal nPosition As Long, _
       ByVal wFlags As Long) As Long
'--end block--'Option ExplicitPrivate Sub Form_Load()   Dim hMenu As Long
   Dim menuItemCount As Long  'Obtain the handle to the form's system menu
   hMenu = GetSystemMenu(Me.hwnd, 0)
  
   If hMenu Then
      
     'Obtain the number of items in the menu
      menuItemCount = GetMenuItemCount(hMenu)
    
     'Remove the system menu Close menu item.
     'The menu item is 0-based, so the last
     'item on the menu is menuItemCount - 1
      Call RemoveMenu(hMenu, menuItemCount - 1, _
                      MF_REMOVE Or MF_BYPOSITION)
   
     'Remove the system menu separator line
      Call RemoveMenu(hMenu, menuItemCount - 2, _
                      MF_REMOVE Or MF_BYPOSITION)
    
     'Force a redraw of the menu. This
     'refreshes the titlebar, dimming the X
      Call DrawMenuBar(Me.hwnd)   End If
   
End Sub   

解决方案 »

  1.   

    只需将form的ControlBox设为False.
      

  2.   

    **************************************
    Author:Krudy
    Date:2001.04.27
    Source Code:'去掉窗体的關閉按鈕
    Option ExplicitPrivate Declare Function GetSystemMenu Lib "User32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
    Private Declare Function RemoveMenu Lib "User32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    Private Declare Function DrawMenuBar Lib "User32" (ByVal hWnd As Long) As Long
    Private Declare Function GetMenuItemCount Lib "User32" (ByVal hMenu As Long) As Long
    Private Const MF_BYPOSITION = &H400&
    Private Const MF_DISABLED = &H2&Sub Form_load()
    '去掉關閉按鈕
    Call DisableX(Me)
    End SubPrivate Sub DisableX(Frm As Form)
    Dim hMenu As Long, nCount As Long
    hMenu = GetSystemMenu(Frm.hWnd, 0)
    nCount = GetMenuItemCount(hMenu)
    Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION)
    DrawMenuBar Frm.hWnd
    End Sub
      

  3.   

    先把窗体设置为none,再在上面画,就看你的了。
      

  4.   

    'API函数的声明。
    Private Declare Function GetSystemMenu Lib "User32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
    Private Declare Function DeleteMenu Lib "User32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    Const MF_BYCOMMAND = &H0&
    Const SC_CLOSE = &HF060
    '变量的声明
    Private hMenu As Long
    '以上为窗口中的声明,在vb6.0中无错。有新发现联系[email protected]
    '以下内容复制到Form_Load()中    '*****************************************************
        '******           窗 口 去 处 × 功 能         *******
        '*****************************************************
        '取得系统菜单的句柄。
        hMenu = GetSystemMenu(mdifrmMain.hWnd, 0)
        DoEvents
        '调用函数。
        Call DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)
        DoEvents