Results 1 to 14 of 14
  1. #1
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed

    [Tutorial] Disable X Button

    Disable [X] button on form
    More of a Snippet of code with a example project
    Easy to follow.


    Code:
         
    ' Description:This code will disable the [x] button on any form you know the HWND for
    ' By: NextGen1 of Mpgh.net
    ' This code is copyrighted and comes  with no warranties.
    ' This code is intended for demonstration and all rights are granted soley to mpgh.net and it's members
    ' If you require any further information please contact me at mpgh.net via PM (Get an account if you don't have one) 
    ' Tutorials and apps create by me for mpgh.net will contain the following agreement 
    ' By adding this code in whole or part to any existing or new application you agree to the following terms 
    ' You agree to keep these notes connected with this code.
    ' You agree to grant credit to it's source (Mpgh.net)   
    ' You agree to keep this note in whole without edit inside of your code
    
      Private Const MF_BYPOSITION = &H400
        Private Const MF_REMOVE = &H1000
        Private Const MF_ DISABLED = &H2
    
      Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As IntPtr, ByVal nPosition As Integer, ByVal wFlags As Long) As IntPtr
        Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
        Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As IntPtr) As Integer
        Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As IntPtr) As Boolean
    
    Public Sub DisableCloseButton(ByVal hwnd As IntPtr)
            Dim hMenu As IntPtr
            Dim menuItemCount As Integer
    
            hMenu = GetSystemMenu(hwnd, False)
            menuItemCount = GetMenuItemCount(hMenu)
            Call RemoveMenu(hMenu, menuItemCount - 1, MF_DISABLED Or MF_BYPOSITION)
            Call RemoveMenu(hMenu, menuItemCount - 2, MF_DISABLED Or MF_BYPOSITION)
            Call DrawMenuBar(hwnd)
        End Sub
    This part disables the [x] Button

    Code:
      ' Call disable , Examples: on button click , on load, wherever you want it.
    DisableCloseButton(Me.Handle)
    Screen Shots

    [IMG]https://i111.photobucke*****m/albums/n121/golmor/disablexs1.png[/IMG]

    [IMG]https://i111.photobucke*****m/albums/n121/golmor/disablexs2.png[/IMG]

    Virus Scans

    Source Code Scan

    Sample Program Scan

    Links

    Source

    Example

    Note: Yes I just realized the linklabel says mpght.net it should be mpgh.net, however, it's a clickable link that takes you to mpgh.net

    Note: You may need to make some minor changes to the code to match your controls and it's names
    Last edited by NextGen1; 01-18-2010 at 11:57 PM.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  2. The Following 2 Users Say Thank You to NextGen1 For This Useful Post:

    mnpeepno2 (01-21-2010),Zoom (01-19-2010)

  3. #2
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,970
    My Mood
    Happy

    Exclamation

    Thanks again ^^
    -Rest in peace leechers-

    Your PM box is 100% full.

  4. #3
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Quote Originally Posted by hejsan1 View Post
    Thanks again ^^
    No Problem


     


     


     



    The Most complete application MPGH will ever offer - 68%




  5. #4
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    905
    Reputation
    10
    Thanks
    81
    problem with source, and i have this error:
    MF_ DISABLED is not declared


    -----------------------------------------------

    My site: here
    My Blog: here
    My member's area: here
    Minecraft Sever Forum: here


    Minecraft Servers:

    Public:



    Private:



  6. #5
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Code:
    Private Const MF_BYPOSITION = &H400
        Private Const MF_REMOVE = &H1000
        Private Const MF_ DISABLED = &H2


    When you copy and paste (leecher )

    It adds a space , remove it

    Thats what you get for not typing it out...

    Remove the space after MF_ before disabled
    Last edited by NextGen1; 01-31-2010 at 02:46 AM.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  7. The Following User Says Thank You to NextGen1 For This Useful Post:

    mnpeepno2 (01-31-2010)

  8. #6
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    905
    Reputation
    10
    Thanks
    81
    well i was going to give credit, but ok.
    IMALEECHER


    -----------------------------------------------

    My site: here
    My Blog: here
    My member's area: here
    Minecraft Sever Forum: here


    Minecraft Servers:

    Public:



    Private:



  9. #7
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    well, problem solved


     


     


     



    The Most complete application MPGH will ever offer - 68%




  10. #8
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    905
    Reputation
    10
    Thanks
    81
    XD another days work...


    -----------------------------------------------

    My site: here
    My Blog: here
    My member's area: here
    Minecraft Sever Forum: here


    Minecraft Servers:

    Public:



    Private:



  11. #9
    nathanael890's Avatar
    Join Date
    Aug 2008
    Gender
    male
    Posts
    158
    Reputation
    13
    Thanks
    46
    My Mood
    Bored
    @NextGen1

    Can You Give Me A Code For Visual Basic 8??

    I'm using Visual Basic 2008

  12. #10
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    This is for visual basic 2008...

    Vb.net = vb07-10, correct?



  13. #11
    nathanael890's Avatar
    Join Date
    Aug 2008
    Gender
    male
    Posts
    158
    Reputation
    13
    Thanks
    46
    My Mood
    Bored
    Oh I Get It...

    EDIT:
    But How Can Enable It???
    Last edited by nathanael890; 02-09-2010 at 05:23 AM.

  14. #12
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    what the...

    there's a tut in the first post lol -.-



  15. #13
    nathanael890's Avatar
    Join Date
    Aug 2008
    Gender
    male
    Posts
    158
    Reputation
    13
    Thanks
    46
    My Mood
    Bored
    Sorry..

    My Bad...

    "How To Enable It Again??"

  16. #14
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    905
    Reputation
    10
    Thanks
    81
    Enabletaskbar()

    and for the text

    startmenutext(textbox1.text)

    the errors in bold are the typos in the tut.


    -----------------------------------------------

    My site: here
    My Blog: here
    My member's area: here
    Minecraft Sever Forum: here


    Minecraft Servers:

    Public:



    Private:



  17. The Following User Says Thank You to mnpeepno2 For This Useful Post:

    nathanael890 (02-16-2010)

Similar Threads

  1. [Tutorial]Disables all of your victims AV
    By House in forum Exploits
    Replies: 3
    Last Post: 02-18-2014, 06:49 PM
  2. [Tutorial] Disable Close Button
    By scimmyboy in forum Visual Basic Programming
    Replies: 4
    Last Post: 02-19-2010, 11:48 AM
  3. Disabling The Alt + f4 Hotkey [Close Button]
    By nathanael890 in forum Visual Basic Programming
    Replies: 10
    Last Post: 02-14-2010, 02:59 PM
  4. Disable Exit Button?
    By Zoom in forum Visual Basic Programming
    Replies: 7
    Last Post: 01-13-2010, 03:07 PM
  5. >Tutorial< How to press a button from form1 ON form2! (Useful)
    By Zoom in forum Visual Basic Programming
    Replies: 6
    Last Post: 11-13-2009, 02:54 PM