First off, let me congratulate you. Getting an interactive multimedia Today plugin is really impressive! Second, posting your experiences for everyone to share is wonderful. Hopefully this will be indexed by Google and help others trying to do the same thing.
ppcStudios wrote:Basically, the Today Screen parent absorbs many of the notification events you would expect your child plugin to receive.
I want to be explicit here (again, for posterity) - in Windows programming, many messages are sent only to top-level windows and there is no contract that these messages are propagated to child windows. System messages like WM_SYSCOLORCHANGE and WM_SETTINGCHANGE, for example, have this contract.
On the other hand, some messages like WM_DISPLAYCHANGE is sent/posted to all windows. Again, though, the contract is not that the top-level window is sent the message and must delegate to child windows. Instead, the system explicitly sends it to all windows.
So saying that the parent
absorbs messages is misleading, and could be confusing to beginning Windows developers. The Today screen parent is behaving like a perfectly well behaved top-level window and honoring contracts to the letter.
There are absolutely NO notifications that your plugin has been covered by another window.
If you are writing a normal Windows application, this statement is true for all child windows. Generally, child windows don't do processing other than painting and handling input events, so it's not a problem. Most controls defer their paint actions by invalidating themselves and waiting for the system to tell them to redraw, rather than explicitly painting as soon as their state updates. Controls like progress bars are an exception - they are typically shown while heavy processing is going on so there is no idle time to redraw, so they redraw immediately - but only on an explicit state change.
The API GetForegroundWindow() ALWAYS returns an HWND different from your plugin (probably the HWND of the parent in most cases, but not verified that is the always the case), so thats not an option either.
This might be worth investigating - the Today screen should be the parent window (or an ancestor window) of your plugin, so this would be pretty reliable.
Thus far I've determined there are NO WM_ACTIVATE messages passed to the plugin (this may not be the case on Phone Edition devices or Smartphone - those have yet to be examined).
It would actually be quite strange if this were to change, given that this contract has existed since Windows 3.1.
(As an aside, suddenly sending a window a message it isn't expecting is often a cause of compatibility issues. The window might handle it incorrectly and return a bogus value - which makes it meaningless - or it could simply crash. This is one of the reasons the Windows API is so complicated - dealing with millions of legacy applications that are each fragile in their own little way.)
So, as you can see the Today Screen world is quite a bit different from standard windows development.
Again, only if you're expecting a Today plugin to work like a top-level window. If you start thinking of them as a child window, then it's exactly the same as standard Windows development. Except that, in this case, you don't own the top-level window too, so it's like programming with one arm tied behind your back!
(But that's true of device programming in general. I think we're masochists or something.)
In the desktop world, there are COM interfaces for defining contracts between client (container) windows and server (embedded) windows to handle things like activation notifications. It is really a shame that the Today API is not rich enough to do this, and requires hacks. If you're planning on doing further development in the mobile device arena taking advantage of this, I'd encourage you to send feedback to Microsoft with your requests. You've shipped a product and run into platform limitations, and this is exactly the sort of thing they want to hear.
I'm looking forward to having it tried on a WM2003SE device with a rotated screen.
Be sure to look on MSDN for what message is sent when the display orientation changes, and if it is sent to all windows or just to top-level windows. This might be another area of pain, where the platform expects apps will delegate this internally if necessary but the Today API isn't that deep. However, since this is something apps need to be informed about, there is almost certainly some message sent. I'd keep my eye on WM_DISPLAYCHANGE but it could be something else. Again, only trust MSDN.