Results 1 to 6 of 6

Thread: disable the control "x" in the dialog box

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    Anyone know how to set the property or how to disable the "x" to close in a dialog box. I would just like it disabled and still showing!!!

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089

    No problem just put this code in your form

    Code:
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
    
    Private Const MF_BYCOMMAND = &H0&
    Private Const MF_GRAYED = &H1&
    Private Const MF_ENABLED = &H0&
    Private Const SC_CLOSE = &HF060&
    Private Const FOOLVB = -10
    
    
    Private Sub DisableMenu()
    
    ModifyMenu GetSystemMenu(Me.hwnd, 0), SC_CLOSE, MF_BYCOMMAND Or MF_GRAYED, FOOLVB, "Close"
    
    End Sub
    
    Private Sub EnableMenu()
    
    ModifyMenu GetSystemMenu(Me.hwnd, 0), SC_CLOSE, MF_BYCOMMAND Or MF_ENABLED, SC_CLOSE, "Close"
    
    End Sub
    then type DisableMenu to disable the cross and EnableMenu to enable it again

    I don't know how much experience you have had with the API but make sure you put the Declare statements and constants at the top of the code otherwise it won't work

    Hope this helps

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    You crank thanks that's what iv'e been lookin for ya made me so happy

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    Okay what's the code to disable the maximize; i tried tweeking a little to no avail; thanks in advance!!!

  5. #5
    Guest
    to disable the maximize button, you just set the
    MaxButton property to false. If your next question is
    disabing the Min button, you just set the MinButton
    property to false.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    Right I know about the maximize and minimize property but i wanted to try and do it like the previous example using an api call. How do i change the code in the first answer to get the same result of the close but with the maximize button.

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