CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2001
    Posts
    23

    how to hide close option in form

    how to hide close option in form I dont want end user to use x button


  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: how to hide close option in form

    refer http://vblib.virtualave.net, there is a function called DisableXButton in vbSystem of the activeX DLL which might help

    HTH


  3. #3
    Join Date
    May 2001
    Location
    Sri Lanka
    Posts
    2

    Re: how to hide close option in form

    ok all you got to do is there is a property in the properties window you should be able to fine aproperty called controllbox set it to false then those button will not be displayed play with the things in the properties window to find out more like minbutton, maxbutton


  4. #4
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: how to hide close option in form

    Set the Controlbox property to False to get rid of the Min,Max,CLose buttons. IF all you want to do is disable the Close button and leave Min and Maximize buttons available, use the following code in the following sample.
    Add a command button to a form. Add a module to the project

    '
    ' This is the Forms Code
    '
    option Explicit

    private Sub Command1_Click()
    Unload me
    End Sub

    private 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
    '--end block--'
    '
    ' This is the Modules code
    option Explicit

    public Const MF_BYPOSITION = &H400
    public Const MF_REMOVE = &H1000

    public 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--'




    John G

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured