I'm creating a custom shell for Windows 7 / 8. How do I create a custom tray for my shell ? I'm aware that the tray window has the class name "Shell_TrayWnd". I tried creating it on my own and posted "TaskbarCreated" message using PostMessage but I'm not getting "WM_COPYDATA" message in my Tray WndProc. I'm missing out on something? Need help.
The code is as follows:
static LRESULT CALLBACK tray_proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_COPYDATA)
{
COPYDATASTRUCT *cpdata = (COPYDATASTRUCT*)lParam;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
int init_tray(void)
{
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
wc.lpfnWndProc = tray_proc;
wc.hInstance = GetModuleHandle(NULL);
wc.lpszClassName = TEXT("Shell_TrayWnd");
if (!RegisterClass(&wc))
{
return 0;
}
tray_window = CreateWindowEx(
WS_EX_TOOLWINDOW,
wc.lpszClassName,
NULL,
WS_POPUP,
0, 0, 0, 0,
NULL, NULL,
wc.hInstance,
NULL);
if (!tray_window)
return 0;
/* let running apps know that a new tray is around */
PostMessage(HWND_BROADCAST, RegisterWindowMessage(TEXT("TaskbarCreated")), 0, 0);
return 1;
}
Got it working!
SendNotifyMessage(HWND_BROADCAST, RegisterWindowMessage("TaskbarCreated"), 0, 0);
This message is the key. Without this, the Tray WndProc will not get data.