在对话框属性里的stytle中的[ ]system Menu 选项去掉,则没有X
你试试!

解决方案 »

  1.   


      在SDK下的方法:注册窗口类时,可使CLOSE按键变灰WNDCLASS wc;
      ... ...
      wc.style = CS_HREDRAW ¦ CS_VREDRAW ¦CS_NOCLOSE;
      ... ...
      在MFC下的方法:
    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
      if( !CFrameWnd::PreCreateWindow(cs) )
        return FALSE;
      cs.Style&=~WS_SYSMENU;    //加入本行
        return TRUE;
    }
      

  2.   

    为什么
    wc.style = CS_HREDRAW ¦ CS_VREDRAW ¦CS_NOCLOSE
    变成了
    wc.style = CS_HREDRAW ¦ CS_VREDRAW ¦CS_NOCLOSE??????
      

  3.   

    有一种方法:删除系统菜单的“关闭 ALT+F4”项即可。
      

  4.   

    这是VB的代码,如果看不懂,请给我email: [email protected] :Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
    Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    Const MF_BYPOSITION = &H400&
    Const MF_REMOVE = &H1000&
    Private Sub Form_Load()
        Dim hSysMenu As Long, nCnt As Long
        ' Get handle to our form's system menu
        ' (Restore, Maximize, Move, close etc.)
        hSysMenu = GetSystemMenu(Me.hwnd, False)    If hSysMenu Then
            ' Get System menu's menu count
            nCnt = GetMenuItemCount(hSysMenu)
            If nCnt Then
                ' Menu count is based on 0 (0, 1, 2, 3...)
                RemoveMenu hSysMenu, nCnt - 1, MF_BYPOSITION Or MF_REMOVE
                RemoveMenu hSysMenu, nCnt - 2, MF_BYPOSITION Or MF_REMOVE ' Remove the seperator
                DrawMenuBar Me.hwnd
                ' Force caption bar's refresh. Disabling X button
                Me.Caption = "Try to close me!"
            End If
        End If
    End Sub
      

  5.   

    此方法是删除了系统菜单 “关闭 ALT + F4”项和分割符.
      

  6.   

    dzl 回答的最好,在类的风格里加入 CS_NOCLOSE 即可,以上显示的 ¦ 即为 Shift+\,如果窗口类已经存在,可以试一下 SetClassLong() 这个 API。