By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,816 Members | 2,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,816 IT Pros & Developers. It's quick & easy.

Windows controls

P: 93
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?
Expand|Select|Wrap|Line Numbers
  1. Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
  2. Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
  3.  
  4. 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(hWnd, False)
is stored in the byVal for its declaration
DeleteMenu hMenu, 6, MF_BYPOSITION
and same with this

I hope this makes sense cheers
May 2 '07 #1
Share this Question
Share on Google+
6 Replies


Expert 5K+
P: 8,434
...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(hWnd, 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.
May 3 '07 #2

P: 93
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
May 3 '07 #3

P: 93
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(hWnd, False)
DeleteMenu hMenu, 6, MF_BYPOSITION
End Sub

Can some one explain this to me thanks
May 3 '07 #4

Expert 5K+
P: 8,434
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(hWnd, 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".
May 3 '07 #5

P: 93
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
May 3 '07 #6

Expert 5K+
P: 8,434
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".
May 3 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.