473,513 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2263
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
3012
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
1346
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
5469
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
0
1293
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
10071
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
1557
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
8096
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
6324
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
5891
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...
0
7264
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7166
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7543
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7106
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5689
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5094
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3236
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3226
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1601
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.