Click here to Skip to main content
15,911,531 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Get started with WPF with XAMLFest Online in June Pin
#realJSOP12-May-09 10:47
professional#realJSOP12-May-09 10:47 
QuestionResource Dictionaries - Confused Pin
#realJSOP12-May-09 6:08
professional#realJSOP12-May-09 6:08 
AnswerRe: Resource Dictionaries - Confused Pin
Mark Salsbery12-May-09 6:51
Mark Salsbery12-May-09 6:51 
GeneralRe: Resource Dictionaries - Confused Pin
#realJSOP12-May-09 8:42
professional#realJSOP12-May-09 8:42 
GeneralRe: Resource Dictionaries - Confused Pin
Pete O'Hanlon12-May-09 8:51
mvePete O'Hanlon12-May-09 8:51 
GeneralRe: Resource Dictionaries - Confused Pin
#realJSOP12-May-09 8:58
professional#realJSOP12-May-09 8:58 
GeneralRe: Resource Dictionaries - Confused Pin
Pete O'Hanlon12-May-09 9:03
mvePete O'Hanlon12-May-09 9:03 
GeneralRe: Resource Dictionaries - Confused Pin
#realJSOP12-May-09 9:23
professional#realJSOP12-May-09 9:23 
GeneralRe: Resource Dictionaries - Confused Pin
Pete O'Hanlon12-May-09 9:26
mvePete O'Hanlon12-May-09 9:26 
GeneralRe: Resource Dictionaries - Confused Pin
#realJSOP12-May-09 11:01
professional#realJSOP12-May-09 11:01 
GeneralRe: Resource Dictionaries - Confused Pin
Pete O'Hanlon12-May-09 11:10
mvePete O'Hanlon12-May-09 11:10 
GeneralRe: Resource Dictionaries - Confused Pin
Mark Salsbery12-May-09 9:46
Mark Salsbery12-May-09 9:46 
GeneralRe: Resource Dictionaries - Confused Pin
#realJSOP12-May-09 10:36
professional#realJSOP12-May-09 10:36 
GeneralRe: Resource Dictionaries - Confused [modified] Pin
#realJSOP12-May-09 9:02
professional#realJSOP12-May-09 9:02 
QuestionWPF SideBar Pin
GomathiR11-May-09 23:01
GomathiR11-May-09 23:01 
AnswerRe: WPF SideBar Pin
Mark Salsbery12-May-09 7:19
Mark Salsbery12-May-09 7:19 
Questionconvert byte[] to BitmabImage Pin
amer shammout11-May-09 21:56
amer shammout11-May-09 21:56 
AnswerRe: convert byte[] to BitmabImage Pin
KarstenK11-May-09 22:10
mveKarstenK11-May-09 22:10 
GeneralRe: convert byte[] to BitmabImage Pin
califax2k12-May-09 0:43
califax2k12-May-09 0:43 
AnswerRe: convert byte[] to BitmabImage Pin
Pete O'Hanlon12-May-09 1:31
mvePete O'Hanlon12-May-09 1:31 
GeneralRe: convert byte[] to BitmabImage Pin
califax2k12-May-09 2:19
califax2k12-May-09 2:19 
GeneralRe: convert byte[] to BitmabImage Pin
Pete O'Hanlon12-May-09 2:35
mvePete O'Hanlon12-May-09 2:35 
AnswerRe: convert byte[] to BitmabImage Pin
morishuz18-Aug-10 6:35
morishuz18-Aug-10 6:35 
QuestionHow can I be notified when Windows XP fades the screen to gray? Pin
CooperWu11-May-09 21:03
CooperWu11-May-09 21:03 
AnswerRe: How can I be notified when Windows XP fades the screen to gray? Pin
Pete O'Hanlon12-May-09 2:19
mvePete O'Hanlon12-May-09 2:19 
Add the following WndProc in:
private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
  const WM_QUERYENDSESSION = 0x0011;
  switch (msg)
  {
    case WM_QUERYENDSESSION:
      // The "screen" is fading here - do what you need to do...
      break;
  }
  return IntPtr.Zero;
}
Alternatively, you could have a thread monitoring System.Environment.HasShutdownStarted;

The advantage of the WndProc approach is that it gets called when the event is fired, and doesn't require a separate thread.

Now, to add the WndProc, you do the following in the Window loaded event:
void MyWindow_Loaded(object sender, RoutedEventArgs e)
{
  HwndSource src = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
  src.AddHook(new HwndSourceHook(WndProc));
}


"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys | Onyx



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.