473,748 Members | 2,471 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 2282
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,Ope nAs_RunDLL "C:\test.tx t"

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%3Dop enwith%2520dial og%2520%25
22c%2523%2522%2 6hl%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_MACH INE\SOFTWARE\Mi crosoft\Windows \CurrentVersion \Explorer]
"InternetOpenWi th"="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 "contextmen u" 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******** ********@TK2MSF TNGP12.phx.gbl. ..
lgbjr,

Drag from the toolbox a "contextmen u" 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_R OOT) 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_RO OT) 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\picture boxname.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.n ospam> wrote in message
news:OR******** ******@tk2msftn gp13.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_RO OT, we may also try to query the keys below to get the
OpenWith dialog.
1. HKEY_CLASSES_RO OT\.jpeg\OpenWi thList
2. HKEY_CURRENT_US ER\Software\Mic rosoft\Windows\ CurrentVersion\
Explorer\FileEx ts\.extension\O penWithList

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
3073
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 up, the window does not closes until I click on the window. Below is the code. Hopefully, you can help me out.
0
1366
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 for? At the moment I am saving the control in a member variable when it is clicked and referencing this from the context menu click but I thought there would be an easier way. TIA JB
5
5493
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
0
1312
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; _count<=(something.Count); _count++) { PictureBox pictureBox1 = new PictureBox(); pictureBox1.Location = new Point(x,y);
8
10099
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 a text box has 6 items, undo, cut, copy, paste, delete and select all. I would like to add one additional paste menu that opens a new sub menu with several optional text items that could be pasted. The items would be populated by my program but...
0
1571
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 the context menu. However, I have stumbled across one problem. Which is that how does one go about enhancing the event handler for the context menu to invoke individual actions for each of the menu items. I have included a snippet of my code....
7
8118
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 mousedown to handle mybase.mousedown but it doesn't detect the mousedown event until I move out of the pictureboxes I have created (only works on the part of the form where I don't have any pictureboxes). I also cannot set the mousedown event to...
1
6340
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 etc'). is there a way making this without writing my own context menu (meaning, popup form or something) ? Please don't post commercial products to this topic thanks.
2
5907
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 commands to the control's context menu? I'm envisioning a case where the control has a set of context menu items, and the parent form also has a set of context menu items. Thanks.
0
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8237
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3300
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 we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.