Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

bin huwairib. only

Posted on 1998-06-04
6
Medium Priority
?
160 Views
Last Modified: 2010-05-03
from josmic may 9 98 question to disable right mouse click
I owe you points, here they are. but I cant get it to work, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
how does this work, where does it go within vb5, this
line and the next 3 wont compile. thank you.
0
Comment
Question by:josmic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
bin_huwairib earned 300 total points
ID: 1462586
Josmic,

Sorry because of my delayed answer, I was busy with other matters recently.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer is a registry location and you can't use it directly within VB, so you have to write a sub/function to update this location with the specific value, anyway don't bother your self about the function here it is.

1- Add form1 to project1.
2- Add command1, command2, command3 and command4 to form1.
3- Paste the following code:

Private Const HKEY_CURRENT_USER = &H80000001
Private Const REG_DWORD = 4&
Private Const KEY_ALL_ACCESS = &H3F

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" _
(ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _
ByVal samDesired As Long, phkResult As Long) As Long

Private Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, _
ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long

Function SetValueEx(KeyName, ValueName As String, Value As Variant) As Long
 Dim hKey As Long
 Dim lValue As Long
   
 lValue = Value
 Call RegOpenKeyEx(HKEY_CURRENT_USER, KeyName, 0, KEY_ALL_ACCESS, hKey)
 SetValueEx = RegSetValueExLong(hKey, ValueName, 0, REG_DWORD, lValue, 4)
End Function

Private Sub Command1_Click()
 'To Enable the Desktop/Explorer's context menu
 Call SetValueEx("Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoViewContextMenu", 1)
End Sub

Private Sub Command2_Click()
 'To Disable the Desktop/Explorer's context menu
 Call SetValueEx("Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoViewContextMenu", 0)
End Sub

Private Sub Command3_Click()
 'To Enable the Start/Tray's context menu
 Call SetValueEx("Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoTrayContextMenu", 1)
End Sub

Private Sub Command4_Click()
 'To Disable the Start/Tray's context menu
 Call SetValueEx("Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoTrayContextMenu", 0)
End Sub

NOTE: Disabling the context menu will be effected immediately but to enable it you must restart windows to take the effect.


Best regards
Bin Huwairib
0
 

Author Comment

by:josmic
ID: 1462587
this did not work, any suggestions. to clarify, is this to
enable/disable the right/mouse click, and the start button
in the taskbar?
0
 
LVL 5

Expert Comment

by:bin_huwairib
ID: 1462588
josmic,

The code above is doing the following:
1- Enable/Disable right-mouse click on the Desktop window.
2- Enable/Disable right-mouse click on the Explorer window.
3- Enable/Disable right-mouse click on the Taskbar.
4- Enable/Disable right-mouse click on the Start button.

If you face any kind of error please post it, and don't hesitate to ask if you need more clarification.

Bin Huwairib
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:josmic
ID: 1462589
bin. O.K.,if only I could get this to work.
Ive done exactly as you said, and again on a new project.
I get no errors, but the right mouse click still works
in all 4 places. Im using Vb5 and win98.? thank you.
0
 
LVL 5

Expert Comment

by:bin_huwairib
ID: 1462590
I'm sorry josmic, I didn't test it on Windows98 yet.

It is working fine with Windows95 and WindowsNT.

Bin Huwairib
0
 

Author Comment

by:josmic
ID: 1462591
bin, thanks for the help. I will repost this question. I
am going to give you these points anyway.
1) Since your online now perhaps you know how to disable the start button (bottom left on the taskbar)  -without-  disabling the taskbar or hidding the taskbar. I dont care if the start button is visible or not.
2) or im having problems with a webbrowser control. my back and forw buttons dont remember more than the verylast or the verynext
Im using webbrowser.GoBack and frw, I've seen somewhere in here
a refference to code with history list box  etc instead of
back and forw and I think you answered it.?

Ive been picking up code here and have not run into a win98
problem yet. Again thanks.





0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question