ApplicationEx.Idle ?

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

I'm using OpenNETCF's ApplicationEx in my code.
there is no Idle event .... (which I plan to use)

looking in winuser.h I found
WM_ENTERIDLE 289

but, looking on VS.NET help file it didn't seem to be defined on WindowsCE

How could I know when my appli is Idle ?
(typically I want to take the opportunity to do some additional & small
consolidation work when the user is not using the app...)
 
Simply look for message 289 in your switch. We didn't define every WIndows
message, just some common ones for an example.
 
I detect misunderstanding here. WM_ENTERIDLE is not a sign of application
not being used. It is sent periodically, while the application is displaying
a drop-down or a popup menu or inside a modal dialog.

For you purpose you will need to modifyApplicationEx message loop.
The Pump method needs to be modified like this

private static bool Pump()
{
// there are, so get the top one
if(PeekMessage(out msg, IntPtr.Zero, 0, 0))
{
if ( msg.message == WM_QUIT )
return false;
process = true;

// iterate any filters
foreach(IMessageFilter mf in messageFilters)
{
#if !NDOC && !DESIGN
Message m = Message.Create(msg.hwnd, msg.message, msg.wParam,
msg.lParam);

// if *any* filter says not to process, we won't
process = process ? !(mf.PreFilterMessage(ref m)) : false;
#endif
}

// if we're supposed to process the message, do so
if(process)
{
TranslateMessage(out msg);
DispatchMessage(ref msg);
}
}
else
{
// DO your background processing here or better yet, fire an event
}
return true;
}
 
Back
Top