473,236 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 software developers and data experts.

Context Menu for PictureBoxes

Hello All,

I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I
would like to use a context menu to allow the user to open the picture in
their default picture viewer or editor. I'd like to use the same default
viewer/editor and open with... choices that are present on the users
computer.

Does anyone know how I can find this information programatically, so my
picturebox context menu uses the same settings as the system context menu
for pictures?

Thanks!!

Lee
Nov 21 '05 #1
5 2216
Hi

The System Context Menu is worked with Shell(Explorer.exe), so we need to
save the picture to a disk file first, or the Explorer.exe and even the
following picture viewer program will not know where to load the file.

And then we can use the syntax below to spawn a process to do the job.
rundll32.exe shell32.dll,OpenAs_RunDLL "C:\test.txt"

You may try to take a look at the link below.
http://groups.google.co.jp/groups?hl...42NHpEHA.1992%
40TK2MSFTNGP09.phx.gbl&rnum=1&prev=/groups%3Fq%3Dopenwith%2520dialog%2520%25
22c%2523%2522%26hl%3Dzh-CN%26lr%3D%26sa%3DN%26tab%3Dwg

Also in windows xp, there will be additional dialog asked for if you want
to search the programs on the internet, if you do not want it, you may try
to use the registry below to disable it.

This can be disabled in the registry:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Explorer]
"InternetOpenWith"="FALSE"

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2
lgbjr,

Drag from the toolbox a "contextmenu" on your form,
Than fill that as a normal menu by clicking on it (It appears in top of your
form).
Than set in the properties of your picturebox in the property contextmenu
(that will be added because you draged that contextmenu on your form) the
name of that contextmenu.

Than it works in my opinion.

I hope this helps?

Cor
Nov 21 '05 #3
Cor,

Thanks for the reply. Adding the context menu for a particular control and
adding items to the control is not the question. That is easy. Depending on
how the user has their system setup, when they right click on a picture (in
Explorer), and select the Open command, there is a default program that the
system uses, or if they select Open with... there is a list of recommended
programs, plus an entry for Choose program.

I want the context menu that I use for the pictures in my app to have the
same default open program and the same list of programs for Open With. I'm
assuming this information is in the registry somewhere, but I don't know
where. Once I know where to look, I can set the actions for my context menu
at runtime.

Regards,
Lee

"Cor Ligthert" <no************@planet.nl> wrote in message
news:eS****************@TK2MSFTNGP12.phx.gbl...
lgbjr,

Drag from the toolbox a "contextmenu" on your form,
Than fill that as a normal menu by clicking on it (It appears in top of
your form).
Than set in the properties of your picturebox in the property contextmenu
(that will be added because you draged that contextmenu on your form) the
name of that contextmenu.

Than it works in my opinion.

I hope this helps?

Cor

Nov 21 '05 #4
Hi All,

OK, before I start coding, I want to make sure the process I need to use is
correct. I want the context menu in my app to look/act the same as the
system context menu for any given object. So, as an example, I want to setup
a context menu for a picturebox.

Let's say that I limit the contents of the picturebox to JPG files. So, when
the user right clicks on the picturebox, I need to look at the registry
(HKEY_ClASSES_ROOT) entry for .jpg (Default Value). If the user has not
added any Graphics packages to his system, the Default Value will be
jpegfile. I then go to the jpegfile registry entry (still in
HKEY_CLASSES_ROOT) and look at the shell subkey. The shell subkey may have
some subkeys like Open, Edit, Preview. I add these menu items to my context
menu. Whatever the command values are for these subkeys will be what I need
to use for each item in my context menu.

If the user has added some programs to the system, the default value for the
..jpg key may not be jpegfile. For instance, if the user has added ACDSee,
the default value might be ACDSee.jpg. In this case, I would go to that
registry entry and look at the shell subkeys.

In all cases I'll need to create a temporary copy of the image (maybe
something like C:\Temp\pictureboxname.jpg), then use the temp jpg file for
whatever action the user requested.

Now, I want to delete this temp jpg file when the user finishes doing
whatever they wanted to do (open, edit, preview, etc). So, I'll need to
create a thread for whatever command is executed, and when the thread
terminates I can delete the temp file. If the user selected the edit item,
when the thread terminates, I'll need to load the temp jpg file back to the
picturebox first, then delete the temp file.

Keeping in mind that I want the context menu in my app to provide the same
functions as the system context menu, does this process make sense, or am I
missing a much simpler way to accomplish the same thing?

Regards and TIA,
Lee

"lgbjr" <lg***@online.nospam> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
Hello All,

I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I
would like to use a context menu to allow the user to open the picture in
their default picture viewer or editor. I'd like to use the same default
viewer/editor and open with... choices that are present on the users
computer.

Does anyone know how I can find this information programatically, so my
picturebox context menu uses the same settings as the system context menu
for pictures?

Thanks!!

Lee

Nov 21 '05 #5
Hi,

I think it is hard to make the identity context menu with system one,
because many of whose implement is depent on the Shell(Explorer.exe).
e.g. the winrar is a shell extension, it is registered in the register as a
shell extension which is only used by the explorer.exe.

Anyway I think we can try to make it as similar with the system one as
possible.
From the KB,
How to Remove Programs from the "Open With" List
http://support.microsoft.com/?id=258860

In addition to what you mention about the .jpg and jpeg key in the
HKEY_CLASSES_ROOT, we may also try to query the keys below to get the
OpenWith dialog.
1. HKEY_CLASSES_ROOT\.jpeg\OpenWithList
2. HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\
Explorer\FileExts\.extension\OpenWithList

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
0
by: John Baro | last post by:
I have a number of pictureboxes that I create dynamically and add a context menu for (One context menu for all of them). Is there any way to determine which control the context menu was invoked...
5
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
0
by: hector | last post by:
Hi guys. I'm writting an aplication that in one module creates multiple PictureBox controls, something like that(i'm trying to just post the relevant code): for(int _count=0;...
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
0
by: VP | last post by:
G'day folks, well i am attempting to get an understanding on how to create the menuitems in a context menu on the fly. So far I have managed to actually achieve the menu items being created for...
7
by: Scott Mackay | last post by:
Hi, I'm using visual studio dotnet 2002 programming in vb can anyone tell me how I can handle the mousedown event for pictureboxes I create dynamically at runtime? I've tried setting the...
1
by: goRide | last post by:
Hi, I'm looking of a way (preferred - a ready class or dll) to customize the context menu. many application has more controls inside the context menu (like textbox, sliders, checkbox, panel...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.