Windows controls

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Taftheman
    New Member
    • Nov 2006
    • 93

    Windows controls

    Hi i have been searching on the internet on how to disable the X button at run time, i have got it working, but i don't realy understand what is going on can some please help?
    Code:
    Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
    
    Private Const MF_BYPOSITION = &H400&
    What does this mean, i am OK on the function as i understand it but what is Lib and user 32. I presume that
    Code:
    hMenu = GetSystemMenu(h Wnd, False)
    is stored in the byVal for its declaration
    DeleteMenu hMenu, 6, MF_BYPOSITION
    and same with this

    I hope this makes sense cheers
    Last edited by Killer42; May 3 '07, 02:57 AM. Reason: Addec [CODE] tag
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by Taftheman
    ...What does this mean, i am OK on the function as i understand it but what is Lib and user 32. I presume that
    Code:
    hMenu = GetSystemMenu(h Wnd, False)
    is stored in the byVal for its declaration
    DeleteMenu hMenu, 6, MF_BYPOSITION
    and same with this

    I hope this makes sense cheers
    Didn't really understand the second part of your question. But these declarations are required so you can call functions that are in shared code libraries called DLLs (Dynamic Link Libraries). In this case you are calling a couple of functions in the "User32.DLL " library, which contains a lot of Windows user interface routines.

    You need to be careful when playing with DLL functions, but they allow you to do just about anything Windows is capable of, going beyond what VB can do.

    Comment

    • Taftheman
      New Member
      • Nov 2006
      • 93

      #3
      Hi ok, is there some one out there that can explain to me how to disable the X button on a form. I have the code, but i need to understand it

      Thanks

      Comment

      • Taftheman
        New Member
        • Nov 2006
        • 93

        #4
        Originally posted by Taftheman
        Hi ok, is there some one out there that can explain to me how to disable the X button on a form. I have the code, but i need to understand it

        Thanks
        Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
        Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long

        Private Const MF_BYPOSITION = &H400&

        Private Sub Form_Load()
        '// remove the close menu (which then disables the close button)
        RemoveMenus
        End Sub

        Private Sub RemoveMenus()
        Dim hMenu As Long
        ' Get the form's system menu handle.
        hMenu = GetSystemMenu(h Wnd, False)
        DeleteMenu hMenu, 6, MF_BYPOSITION
        End Sub

        Can some one explain this to me thanks

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by Taftheman
          Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
          Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long

          Private Const MF_BYPOSITION = &H400&

          Private Sub Form_Load()
          '// remove the close menu (which then disables the close button)
          RemoveMenus
          End Sub

          Private Sub RemoveMenus()
          Dim hMenu As Long
          ' Get the form's system menu handle.
          hMenu = GetSystemMenu(h Wnd, False)
          DeleteMenu hMenu, 6, MF_BYPOSITION
          End Sub

          Can some one explain this to me thanks
          When the form is loaded (and triggers the Form_Load event procedure), you are calling the RemoveMenus routine. This calls the Windows system routine that deletes menus, and tells it to delete the 6th item from the window's system menu.

          If you go to pretty much any window and pull down its system menu, you'll see that the sixth option is "close".

          Comment

          • Taftheman
            New Member
            • Nov 2006
            • 93

            #6
            Originally posted by Killer42
            When the form is loaded (and triggers the Form_Load event procedure), you are calling the RemoveMenus routine. This calls the Windows system routine that deletes menus, and tells it to delete the 6th item from the window's system menu.

            If you go to pretty much any window and pull down its system menu, you'll see that the sixth option is "close".
            so how do you find out the DLL enrty point and what they are used for

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by Taftheman
              so how do you find out the DLL enrty point and what they are used for
              Buy a book on Windows programming? Do a course?

              Actually, I think you'll find tons of tutorials online. Also, if you ask in the Windows forum I imagine they could point you to one. Or just try a search for something like "WINDOWS DLL TUTORIAL".

              Comment

              Working...