tags:

views:

91

answers:

1

I need to activate Windows start menu on mouse location.

I know I can send CTRL + ESC or Win keys to the specific window, and move the window afterwards, but it still shows menu on original location for a short period of time (unless I install hook, and that is overkill for the task).

I recall there is some way to do this, using some dll call or sending some message to the shell or something.

Ty

+1  A: 

Do you get the same behaviour if you "press" the button more programmatically?

  // Find the Start button
  HANDLE hScreenDC = GetDC(0);
  DWORD height = GetDeviceCaps(hScreenDC, VERTRES);
  ReleaseDC(0, hScreenDC);
  hTaskBarWnd = FindWindow("Shell_TrayWnd", 0);
  hStartButtonWnd = GetWindow(hTaskBarWnd, GW_CHILD);

  // Now simulate a press on the Start button
  SendMessage(hButtonWnd, WM_LBUTTONDOWN,
        MK_LBUTTON, LOWORD(5) + HIWORD(height - 20));

Otherwise you might explore the "Shell_TrayWnd" window using WinSpy++ or by using a similar utility, perhaps the Start menu is a child window of the tray window.

Gabriella
Your code works only when i pass 0 (or some small value, probably must be in client region of button) as Lparam of WM_LBUTTODOWN. It seems its not a child window but recreated each time....
majkinetor
It certainly can be done, there are apps around doing it (for instance DesktopX by Stardock)
majkinetor
Ok, then you might use Dependency Walker to examine the imports used by the DesktopX utility, it might reveal the API function you are looking for.
Gabriella
Ok, I was wrong. Window is not recreated but simply hidden. To show it on any position simply get its Hwnd and show it. The problem that may be experienced is that shadow may stay after the window is gone, and that window looses its transparency. Shadow must be killed (SysShadow) and transparency can be set, however.
majkinetor