Re: Adding an item to R-Click context menu
From: Randy Birch (rgb_removethis_at_mvps.org)
Date: 09/02/04
- Next message: LuckyStrike: "Re: Adding an item to R-Click context menu"
- Previous message: Jezebel: "Re: VB and Word Bookmarks"
- In reply to: LuckyStrike: "Re: Adding an item to R-Click context menu"
- Next in thread: LuckyStrike: "Re: Adding an item to R-Click context menu"
- Reply: LuckyStrike: "Re: Adding an item to R-Click context menu"
- Reply: LuckyStrike: "Re: Adding an item to R-Click context menu"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 1 Sep 2004 21:45:26 -0400
Yea, that first link is pretty well all you need. Start a new VB project,
remove the form, add a bas module, open the bas module in code view, go to
tools > add procedure and add a new sub and name it Main (important), then
past into Sub Main (all on one line)
Shell "rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,1",
vbNormalFocus
That's it. Run the app (Run > start with full compile) and the control
panel should open to the security page (1=security, 0=general, etc). Then
just make an exe (File > make exe), and be sure to set the startup object as
Sub Main, and save the exe wherever (I use a \windows\utils folder for stuff
like this), and create a shortcut to the exe and place it on your desktop.
Done. Double clicking will execute Sub Main, which will launch the control
panel applet. If you want to assign your own icon you could add a resource
file, or a form with the icon assigned to the Icon property and set that
icon in the make exe dialog.
If you want to go further -- place an icon in the systray and on clicking it
show the panel -- the concept is the same but you'd require a form in the
app as well as the bas module (it can remain hidden) in order to receive the
mouse events over the systray icon -- see the subclassing section on my site
for the minimal code to place an icon in the systray
(http://vbnet.mvps.org/code/subclass/shellnotifybasic.htm).
The changes you would make to the app is (and I'm going of the top of my
head here ...):
- in Sub Main call the code to Load Form1, but don't show it (eg no Form1
show)
- move the Shell code to a new procedure in the bas module, Private Sub
ShowPanel
- in the load event of the form call the routine that adds the icon to the
systray
- in the form unload event, call the routine that removes the icon
- in the bas module's WindowProc subclassing routine, where the mouse click
code is use:
Call ShowPanel
... rather than the menu code that's in the site demo
When you make the app keep Sub Main as the startup object - it's only code
would be:
Load Form1
Form1's only code would be:
Private Sub Form_Load()
If ShellTrayAdd = 1 Then
SubClass Form1.hwnd
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
ShellTrayRemove
UnSubClass
End Sub
... plus the ShellTrayAdd and ShellTrayRemove routines.
The code change in WindowProc would be
Call ShowPanel
instead of
Form1.PopupMenu .zmnuDemo
I suggest - if you want to go the systray route - you first construct the
site demo exactly as it is shown, then once you get the hang of what's going
on you can start to make changes. This is a 10 minute app once you've got
the basics down.
The only thing (with the subclassed demo) that you **have** to pay attention
to is:
- in the WindowProc routine ensure all Form1 references are changed to the
name you decide to use for the your form
- **always** use start with full compile to run the app -- this will catch
errors before you run into them executing the app. Subclassed apps die
horrible deaths when an error occurs while the subclassing is active!
-- Randy Birch MVP Visual Basic http://vbnet.mvps.org/ Please respond only to the newsgroups so all can benefit. "LuckyStrike" <LS@smokedamagedfurniture.youcandriveitawaytoday.com> wrote in message news:%23GO1QhIkEHA.2696@TK2MSFTNGP10.phx.gbl... : Hi Randy, : : Well, you make it sound so simple. Of course as simple as it is, it isn't as : simple as I am. <g> The only script I've ever done was in Outlook2002 to : make an AVG antivirus scan button. So, as you can see, my skills - if you : want to call 'em that - are less than adequate to fully understand the : means by which to implement that which you've offered. : : So, if I may ask, would I need to install or use something like this to : accomplish that which I seek to do? : http://www.mvps.org/vb/index2.html?tips/shellcpl.htm : http://www.mvps.org/vb/samples.htm#Shell32 : : Please be so kind as to excuse my ignorance in such matters. : : Thanks again, : -- : : LuckyStrike : LS@smokedamagedfurniture.youcandriveitawaytoday.com : : How to make a good newsgroup post: : http://www.dts-l.org/goodpost.htm : ------------------------------------------------------------ : "Randy Birch" <rgb_removethis@mvps.org> wrote in message : news:%23aIedvHkEHA.2140@TK2MSFTNGP15.phx.gbl... : > How about making a tiny VB exe on your desktop or system tray that simply : > executes: : > : > Shell "rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,1", : > vbNormalFocus : > : > -- : > : > Randy Birch : > MVP Visual Basic : > http://vbnet.mvps.org/ : > Please respond only to the newsgroups so all can benefit. : > : > : > "LuckyStrike" wrote in : > message news:uc%23RIjHkEHA.1040@TK2MSFTNGP10.phx.gbl... : <snipped> : > : : > : OS: W98se/IE6-SP-1 fully patched. : > : : > : Is it possible to add (a pointer to) the *Security Tab* from IE Options : to : > : the R-Click context menu? I am surfing with Active Scripting disabled : 99% : > of : > : the time. It is a hassle when having to enable active scripting even : > though : > : I have made a IE Options shortcut on the Quick Launch Toolbar. It still : > : involves a few motions and clicks too many as far as I am concerned. : > : : <snipped> : > : : > : Thanks, : > : -- : > : LuckyStrike : > : LS@smokedamagedfurniture.youcandriveitawaytoday.com : > : ------------------------------------------------------------ : :
- Next message: LuckyStrike: "Re: Adding an item to R-Click context menu"
- Previous message: Jezebel: "Re: VB and Word Bookmarks"
- In reply to: LuckyStrike: "Re: Adding an item to R-Click context menu"
- Next in thread: LuckyStrike: "Re: Adding an item to R-Click context menu"
- Reply: LuckyStrike: "Re: Adding an item to R-Click context menu"
- Reply: LuckyStrike: "Re: Adding an item to R-Click context menu"
- Messages sorted by: [ date ] [ thread ]