Note that there are some explanatory texts on larger screens.

plurals
  1. POMissing WM_Messages on WPF
    primarykey
    data
    text
    <p>I'm having problems to minimize/restore my wpf app by clicking on windows taskbar. Sometimes it works, sometimes it does not. So, <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6b97a6de-0480-4339-8ed0-cb7cdb27bd83/" rel="nofollow">I added a hook</a> to app main window to try to see if events were coming or not. Sometimes they do, sometimes they do not. Then I use <a href="http://msdn.microsoft.com/en-us/library/aa264396%28v=vs.60%29.aspx" rel="nofollow">Spy++</a> to see if events were at least launched... Yes! They are. So why am I receiving just some of them?</p> <pre><code>public MyMainWindow() { InitializeComponent(); this.SourceInitialized += new EventHandler(OnSourceInitialized); } void OnSourceInitialized(object sender, EventArgs e) { HwndSource source = (HwndSource)PresentationSource.FromVisual(this); source.AddHook(new HwndSourceHook(HandleMessages)); } private IntPtr HandleMessages(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { switch (msg) { case 0x0112://WM_SYSCOMMAND: switch ((int)wParam &amp; 0xFFF0) { case 0xF020://SC_MINIMIZE: break; case 0xF120://SC_RESTORE: break; } break; } } </code></pre> <p>I have <a href="http://sudhirdotnet.wordpress.com/2011/09/27/wpf-adding-a-custom-main-method-in-wpf-application-2/" rel="nofollow">a custom main</a> and I'm using <a href="http://caliburnmicro.codeplex.com/wikipage?title=Customizing%20The%20Bootstrapper&amp;referringTitle=Documentation" rel="nofollow">Caliburn Micro with customized Bootstrapper</a>.</p> <hr> <p>I think I made a simplified case where this problem can be seen (not sure about this been same source of my problem). I used a Timer to emulate been waiting for async socket/activeX response. As is possible to see, clicking over taskbar, sometimes window will not be maximized/minimized.</p> <p>Still don't know how to solve it.</p> <pre><code>using System; using System.Threading; using System.Windows; using System.Windows.Threading; using Timer = System.Timers.Timer; namespace Garbage { /// &lt;summary&gt; /// Interaction logic for MainWindow.xaml /// &lt;/summary&gt; public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); var dispatcherTimer = new DispatcherTimer { Interval = new TimeSpan(0,0,0,0,10) }; dispatcherTimer.Tick += (o, e) =&gt; { var waintingForSocketAsyncRenponseEmulation = new Timer(10); waintingForSocketAsyncRenponseEmulation.Elapsed += delegate { lock (this) { Monitor.Pulse(this); } }; waintingForSocketAsyncRenponseEmulation.Start(); lock (this) { Monitor.Wait(this); } }; dispatcherTimer.Start(); } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload