ShellExecute in WPF
-
Hi! What is the namespace to include for ShellExecute to compile? I've to open a URL from WPF Emulator. How to do this? I tried
Process.Start()
But it opens many times. ShellExecute() doesn't compile. It gives the following error: The name 'ShellExecute' does not exist in the current context How to open a URL in WPF?
-
Hi! What is the namespace to include for ShellExecute to compile? I've to open a URL from WPF Emulator. How to do this? I tried
Process.Start()
But it opens many times. ShellExecute() doesn't compile. It gives the following error: The name 'ShellExecute' does not exist in the current context How to open a URL in WPF?
I just use Process.Start to open a URL. Here's an example from the code I'm looking at right now:
public static void OpenUrl(string url)
{
if (string.IsNullOrWhitespace(url))
throw new ArgumentNullException("url");
Process.Start(url);
}*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
I just use Process.Start to open a URL. Here's an example from the code I'm looking at right now:
public static void OpenUrl(string url)
{
if (string.IsNullOrWhitespace(url))
throw new ArgumentNullException("url");
Process.Start(url);
}*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
Pete O'Hanlon wrote: Process.Start(url); I've used this. It's opening the URL many times. I want only one time. How to do this? What about ShellExecute with WPF?
-
Pete O'Hanlon wrote: Process.Start(url); I've used this. It's opening the URL many times. I want only one time. How to do this? What about ShellExecute with WPF?
It only opens it once per execution - sounds like you're hooked into calling that many times - and you would have to write interop code for
ShellExecute
, where you'd still get the same issue. Put a breakpoint on yourProcess.Start
code and see how many times it's being called.*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
It only opens it once per execution - sounds like you're hooked into calling that many times - and you would have to write interop code for
ShellExecute
, where you'd still get the same issue. Put a breakpoint on yourProcess.Start
code and see how many times it's being called.*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
Hi! I've to change the state of the application to minimized before opening the URL. I'm using this code.
#if WINDOWS
this.WindowState = WindowState.Minimized;
#endifBut it shows the following error: The name 'WindowState' does not exist in the current context How to minimze the application before opening the URL?
-
Hi! I've to change the state of the application to minimized before opening the URL. I'm using this code.
#if WINDOWS
this.WindowState = WindowState.Minimized;
#endifBut it shows the following error: The name 'WindowState' does not exist in the current context How to minimze the application before opening the URL?
-
Hi! I've to change the state of the application to minimized before opening the URL. I'm using this code.
#if WINDOWS
this.WindowState = WindowState.Minimized;
#endifBut it shows the following error: The name 'WindowState' does not exist in the current context How to minimze the application before opening the URL?
I assume you're not trying this from the main window (or from the code of any window in your application) then. To minimize the main window from another location, try:
App.Current.MainWindow.WindowState = System.Windows.WindowState.Minimized
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
You may need to use the
FormWindowState
enumeration as described here[^].Programming is work, it isn't finger painting. Luc Pattyn
I don't think that's the problem - this error would indicate he's trying to use the minimize function from a piece of none-window code.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
I don't think that's the problem - this error would indicate he's trying to use the minimize function from a piece of none-window code.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
I Agree; it's actually not clear which of the references is out of context.
Programming is work, it isn't finger painting. Luc Pattyn