PDA

View Full Version : Subclassing the Start Button


moitoius
18th February 2009, 08:49 AM
Hi All,

I cracked open Remote Spy++ and started figuring out how I could go about writing a Honeycomb start menu replacement for WM5-6.1 (seen the XP Start Replacement? Same idea). Having written something similar on desktop Windows I thought it would be easy. The app is in C#/CF.

So the window hierarchy is:
- Desktop
- HHTaskBar
- (nothing !!!)

And messages of interest (in order):
WM_LBUTTONDOWN (0x201)
WM_PAINT (0xF)
WM_INITMENUPOPUP (0x117)

Okay, so forgetting about the fact that the window is opaque (I will delve into this later on), I went ahead and subclassed it to catch the WM_LBUTTONDOWN message (the others didn't stop the original from showing up). That falls over (the debugger doesn't even break into code and the device needs a hard reset). I am investigating this - although my MessageBox shows up just before it dies.

Update: Using BeginInvoke with a worker method fixes the above issue. E.g:

public IntPtr NewWndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
{
if (msg == WM_LBUTTONDOWN)
{
this.BeginInvoke(new Action(DoWork));
return IntPtr.Zero;
}
return CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam);;
}

private void DoWork()
{
Form2 two = new Form2();
two.Show();
}

So my question: the HHTaskBar is opaque, it has no child controls. Obviously, I don't want to subclass the battery/close/etc. buttons, and ideas on how to reliably retrieve the rect for the start button?

Or is the whole thing a hack? I suspect there is a way to do this without all this subclassing hackery. Google and forum search didn't turn up anything.

Thanks guys.

Source code (http://www.mediafire.com/?sharekey=679ef754c1081ebca0f2f20c509059d935654749 aeeafa6e5621d66e282a0ee8)

Usage: (not recommended on real device - use an emulator!) Click on button1 then click anywhere on the taskbar. Now reboot :)

twolf
18th February 2009, 09:26 AM
I'd start with Quickmenu:
http://forum.xda-developers.com/showthread.php?t=471292

This app is the best start menu replacement I ever saw...
I'd only add a mixture of WKTASK's taskbar management and the ability to choose a icon for the start menu.
;)

moitoius
18th February 2009, 09:46 AM
I'd start with Quickmenu:
http://forum.xda-developers.com/showthread.php?t=471292

This app is the best start menu replacement I ever saw...
I'd only add a mixture of WKTASK's taskbar management and the ability to choose a icon for the start menu.
;)

Thanks, it doesn't look like he has any source code available though. Looks like I will have to investigate more... I am not going for the drop down style (but as you said, it is really cool), I am trying to make a Honeycomb (WM 6.5) style menu.

twolf
18th February 2009, 10:32 AM
I tried the wm6.5 honeycomb start menu... was not impressed, but maybe it had some extra something i didnt noticed... :/

moitoius
18th February 2009, 10:37 AM
I still haven't flashed my device with 6.5, but I reckon a FOSS honeycomb menu could be cool...

frepe383
18th February 2009, 10:42 AM
I think you'r on to something here. The start menu as it is in WM6.1 is pretty much useless. I would much rather have the start menu show me a application shortcut page like the one in WM6.5. Although to be honest I don't really like the honeycomb look. What's wrong with a plain old columns and rows type of thing. With the added physics scrolling/swiping stuff of course ;)

moitoius
18th February 2009, 10:45 AM
I think you'r on to something here. The start menu as it is in WM6.1 is pretty much useless. I would much rather have the start menu show me a application shortcut page like the one in WM6.5.

Exactly! I am also hoping to replace that shoddy settings menu.

Although to be honest I don't really like the honeycomb look. What's wrong with a plain old columns and rows type of thing. With the added physics scrolling/swiping stuff of course ;)

I think something with tabs (like Manila 2D) such as 'Programs', 'Running Programs', 'Settings' would be pretty useful. Skinning is a given, and honeycomb would be one (for the fanatics).

moitoius
18th February 2009, 11:56 AM
I decided to call the tool Mead (as in the beer that contains honey :)).

I was having problems with the default message pump and the hook (well, subclassed event). I am not sure which message was crashing my program, but if I use Application.Run() a native exception occurs in mscoree3_5.dll. The workaround is to create the form in the handler for the hook and show that one (it wasn't a UI thread being called from a worker, I am aware of that). So I think it must be a CF message pump bug. In any case, it works great now.

Quitting isn't all the way there yet, still some bugs (the type that will need a soft reset).

On to the UI stuff.

clickety (http://www.mediafire.com/?sharekey=679ef754c1081ebca0f2f20c509059d935654749 aeeafa6e5621d66e282a0ee8)

winwiz
19th February 2009, 02:25 PM
Excellent idea mate, but is it worth doing? the Beta 2 of 6.5 is already out and i am guessing its not long until the final version

laser21
27th March 2009, 03:29 PM
Any news on this?

moitoius
27th March 2009, 03:57 PM
Nothing new. Just haven't had time between my job.

For now I am pinning it as the native call-in issue that the .Net CF suffers from (a documented limitation). Something isn't quite right.

I will continue to experiment, but push comes to shove, I will probably land up creating an interop library for it.

_TB_TB_
27th March 2009, 04:19 PM
Instead of subclassing, you can just create a childwindow of HHTaskbar that is located over the start button.
Alternatively, you could suPerclass the "Explore" window class just to replace the Programs menu. Beware, that superclassing may be a bit dangerous ;)

moitoius
27th March 2009, 04:41 PM
That is an interesting idea. When I get time I will start messing around with it.

That said I do expect some problems: again the interop call-in to .NET CF, but this may prove to work as a work-around :).