Question

I'm unable to restore a window after "minimizing" a window to tray, by doing this in wndproc:

case WM_SIZE:
  if (wparam==SIZE_MINIMIZED) {
    ShowWindow(hwnd,SW_HIDE);
  }
  break;

The tray message handler looks like this:

case TRAY_ICON_MESSAGE:
  switch(lparam) {
  case WM_LBUTTONDOWN:
    ShowWindow(hwnd, SW_RESTORE);
    BringWindowToTop(hwnd);
    SetFocus(hwnd);
    break;
  // ...

The window does re-appear, but is always hidden beneath other windows and doesn't come to the top. Neither SetFocus() nor BringWindowToTop() appear to have any effect.

Was it helpful?

Solution

Could you have a look if the functions return any errors?

You could also have a look at SetForegroundWindow

OTHER TIPS

if (::IsIconic(hwnd))  
    ShowWindow(hwnd, SW_RESTORE);  

::SetForegroundWindow(hwnd);  
::BringWindowToTop(hwnd);

Never use SetForeground.

See Msdn remarks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top