Results 1 to 11 of 11

Thread: the "X"

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Location
    Michigan
    Posts
    15

    Post

    I have two forms which I would like to keep loaded. I switch between each form by hiding one of the forms. The problem is when the user clicks on the "X" which unloads the form. I need to keep both forms loaded at all times.

    It is possible to disable the "X", but is there a way to make it disappear? Is there a way to make all three disappear from a form?

    Thanks
    deDogs

  2. #2
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Post

    Hi,

    On the form properties change the ControlBox option to False. That will make all the buttons invisible.


  3. #3
    Lively Member
    Join Date
    Jan 1999
    Location
    California
    Posts
    115

    Post

    Try the tip: http://www.vb-world.net/tips/tip117.html



    ------------------
    Ryan French
    Niresoft Incorporated
    http://www.niresoft.com
    support@niresoft.com

  4. #4
    Lively Member
    Join Date
    Jun 1999
    Location
    Ireland
    Posts
    96

    Post

    Try this,

    Private Sub Form_UnLoad()
    Cancel = True
    Me.Hide
    End Sub

    This will make the form impossible to close, and changes the "X" to act as a hide button.

    Add a little extra code, in the form of a boolean, to allow the form to unload when you are exiting the program.

    Something like

    Private Sub Form_UnLoad()
    If Not booExiting then Cancel = True
    Me.Hide
    End Sub

    Where booExiting is set True by the Main form exit location.

    Hope this helps,

    Steve.

  5. #5
    Lively Member
    Join Date
    Nov 1999
    Posts
    98

    Post

    here is a response i think you are looking for:

    in a .bas module:

    Code:
    Public Const MF_INSERT = &H0&
    Public Const MF_REMOVE = &H1000&
    Public Const SC_CLOSE = &HF060
    
    Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    Declare Function InsertMenu Lib "user32" Alias "InsertMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
    Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    then in the form_load proeedure:
    Code:
    RemoveMenu GetSystemMenu(hwnd, 0), SC_CLOSE, MF_REMOVE
    if you want to put it back later, i have added the MF_INSERT constant for you in the public declarations section. just replace MF_REMOVE with it. happy programming!!

    --michael

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Location
    Michigan
    Posts
    15

    Post

    Thanks for all the information.

    Thanks,
    deDogs

  7. #7
    Junior Member
    Join Date
    Jan 2004
    Location
    chennai
    Posts
    22
    Hi

    It doesn't work. the Removemenu makes the "X" button disable but not remove it.
    viji

  8. #8
    Frenzied Member dis1411's Avatar
    Join Date
    Mar 2001
    Posts
    1,048
    what's the difference?

  9. #9
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Yes, why do you NEED to make it disappear?
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  10. #10

  11. #11
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    cant you use the vbCode Tags?

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