Click here to Skip to main content
15,917,862 members
Home / Discussions / WPF
   

WPF

 
QuestionSendMessage in C# WPF Pin
dominioYP28-Sep-12 6:11
dominioYP28-Sep-12 6:11 
hello
I say first that this code works with windowsFormApplication, but no work with wpf, help me please

C#
namespace WpfApplication22
{
public partial class App : Application
{


[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

private const int APPCOMMAND_XXX = 0x80000;

private void MetodoMute(object sender, EventArgs e)
// Mute
        {
            SendMessageW(this.Handle, WM_APPCOMMAND, this.Handle,
                (IntPtr)APPCOMMAND_xxx);

        }
}
}


when I use:
C#
private void button4_Click(object sender, RoutedEventArgs e)
{
    App x = new App();
    x.MetodoMute(new WindowInteropHelper(this).Handle);

}


not works, It's launch exception:
"Eccezione non gestita di tipo 'System.InvalidOperationException' in PresentationFramework.dll

Informazioni aggiuntive: Impossibile creare più di un'istanza System.Windows.Application nello stesso AppDomain."



how do I call a method written in App.xaml.cs from another window?
AnswerRe: SendMessage in C# WPF Pin
Pete O'Hanlon29-Sep-12 10:30
mvePete O'Hanlon29-Sep-12 10:30 
GeneralRe: SendMessage in C# WPF Pin
dominioYP29-Sep-12 12:08
dominioYP29-Sep-12 12:08 
GeneralRe: SendMessage in C# WPF Pin
Pete O'Hanlon29-Sep-12 20:45
mvePete O'Hanlon29-Sep-12 20:45 
QuestionNew to .net/ previous programming background Pin
goawayxxxx27-Sep-12 8:29
goawayxxxx27-Sep-12 8:29 
AnswerRe: New to .net/ previous programming background Pin
Richard MacCutchan27-Sep-12 9:47
mveRichard MacCutchan27-Sep-12 9:47 
GeneralRe: New to .net/ previous programming background Pin
goawayxxxx27-Sep-12 10:00
goawayxxxx27-Sep-12 10:00 
GeneralRe: New to .net/ previous programming background Pin
Richard MacCutchan27-Sep-12 21:16
mveRichard MacCutchan27-Sep-12 21:16 
GeneralRe: New to .net/ previous programming background Pin
goawayxxxx28-Sep-12 8:14
goawayxxxx28-Sep-12 8:14 
GeneralRe: New to .net/ previous programming background Pin
Richard MacCutchan28-Sep-12 21:57
mveRichard MacCutchan28-Sep-12 21:57 
GeneralRe: New to .net/ previous programming background Pin
goawayxxxx29-Sep-12 7:29
goawayxxxx29-Sep-12 7:29 
GeneralRe: New to .net/ previous programming background Pin
Richard MacCutchan29-Sep-12 7:34
mveRichard MacCutchan29-Sep-12 7:34 
GeneralRe: New to .net/ previous programming background Pin
goawayxxxx29-Sep-12 16:46
goawayxxxx29-Sep-12 16:46 
GeneralRe: New to .net/ previous programming background Pin
Richard MacCutchan29-Sep-12 21:38
mveRichard MacCutchan29-Sep-12 21:38 
GeneralRe: New to .net/ previous programming background Pin
goawayxxxx30-Sep-12 6:23
goawayxxxx30-Sep-12 6:23 
GeneralRe: New to .net/ previous programming background Pin
Richard MacCutchan30-Sep-12 6:59
mveRichard MacCutchan30-Sep-12 6:59 
GeneralRe: New to .net/ previous programming background Pin
goawayxxxx30-Sep-12 7:51
goawayxxxx30-Sep-12 7:51 
GeneralRe: New to .net/ previous programming background Pin
Richard MacCutchan30-Sep-12 21:57
mveRichard MacCutchan30-Sep-12 21:57 
AnswerRe: New to .net/ previous programming background Pin
Pete O'Hanlon30-Sep-12 7:48
mvePete O'Hanlon30-Sep-12 7:48 
AnswerRe: New to .net/ previous programming background Pin
Blikkies2-Oct-12 5:04
professionalBlikkies2-Oct-12 5:04 
GeneralRe: New to .net/ previous programming background Pin
Alisaunder3-Oct-12 17:10
Alisaunder3-Oct-12 17:10 
AnswerRe: New to .net/ previous programming background Pin
_Maxxx_7-Oct-12 17:17
professional_Maxxx_7-Oct-12 17:17 
QuestionJesús Alvarez Manrique Pin
Member 901299827-Sep-12 6:47
Member 901299827-Sep-12 6:47 
AnswerRe: Jesús Alvarez Manrique Pin
Yayozama27-Sep-12 7:37
Yayozama27-Sep-12 7:37 
GeneralRe: Jesús Alvarez Manrique Pin
Member 901299827-Sep-12 7:57
Member 901299827-Sep-12 7:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.