bugfix to correctly display notification icons of some applications

svn path=/trunk/; revision=7850
This commit is contained in:
Martin Fuchs 2004-01-23 20:52:18 +00:00
parent ceb721e557
commit afcb6d4fb1
4 changed files with 38 additions and 13 deletions

View file

@ -291,7 +291,7 @@ DesktopShellView::DesktopShellView(HWND hwnd, IShellView* pShellView)
// subclass background window // subclass background window
new BackgroundWindow(_hwndListView); new BackgroundWindow(_hwndListView);
_icon_algo = 0; _icon_algo = 1; // default icon arrangement
PositionIcons(); PositionIcons();
InitDragDrop(); InitDragDrop();

View file

@ -495,6 +495,10 @@ SOURCE=.\res\folder.ico
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\res\icoali10.bmp
# End Source File
# Begin Source File
SOURCE=.\res\icoalig0.bmp SOURCE=.\res\icoalig0.bmp
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -527,6 +531,14 @@ SOURCE=.\res\icoalig7.bmp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\res\icoalig8.bmp
# End Source File
# Begin Source File
SOURCE=.\res\icoalig9.bmp
# End Source File
# Begin Source File
SOURCE=.\res\images.bmp SOURCE=.\res\images.bmp
# End Source File # End Source File
# Begin Source File # Begin Source File

View file

@ -272,5 +272,5 @@ LRESULT DesktopBar::ProcessCopyData(COPYDATASTRUCT* pcd)
return notify_area->ProcessTrayNotification(ptr->notify_code, &ptr->nicon_data); return notify_area->ProcessTrayNotification(ptr->notify_code, &ptr->nicon_data);
} }
return 0; return FALSE;
} }

View file

@ -59,6 +59,7 @@ NotifyInfo::NotifyInfo()
_uCallbackMessage = 0; _uCallbackMessage = 0;
} }
NotifyInfo& NotifyInfo::operator=(NOTIFYICONDATA* pnid) NotifyInfo& NotifyInfo::operator=(NOTIFYICONDATA* pnid)
{ {
_hWnd = pnid->hWnd; _hWnd = pnid->hWnd;
@ -68,7 +69,9 @@ NotifyInfo& NotifyInfo::operator=(NOTIFYICONDATA* pnid)
_uCallbackMessage = pnid->uCallbackMessage; _uCallbackMessage = pnid->uCallbackMessage;
if (pnid->uFlags & NIF_ICON) if (pnid->uFlags & NIF_ICON)
_hIcon = pnid->hIcon; // Some applications destroy the icon immediatelly after completing the,
// NIM_ADD/MODIFY message, so we have to make a copy if it.
_hIcon = (HICON) CopyImage(pnid->hIcon, IMAGE_ICON, 16, 16, 0);
#ifdef NIF_STATE // currently (as of 21.08.2003) missing in MinGW headers #ifdef NIF_STATE // currently (as of 21.08.2003) missing in MinGW headers
if (pnid->uFlags & NIF_STATE) if (pnid->uFlags & NIF_STATE)
@ -119,15 +122,16 @@ NotifyArea::~NotifyArea()
HWND NotifyArea::Create(HWND hwndParent) HWND NotifyArea::Create(HWND hwndParent)
{ {
ClientRect clnt(hwndParent); ClientRect clnt(hwndParent);
#ifndef _ROS_
#ifndef _ROS_
return Window::Create(WINDOW_CREATOR(NotifyArea), WS_EX_STATICEDGE, return Window::Create(WINDOW_CREATOR(NotifyArea), WS_EX_STATICEDGE,
BtnWindowClass(CLASSNAME_TRAYNOTIFY,CS_DBLCLKS), TITLE_TRAYNOTIFY, WS_CHILD|WS_VISIBLE, BtnWindowClass(CLASSNAME_TRAYNOTIFY,CS_DBLCLKS), TITLE_TRAYNOTIFY, WS_CHILD|WS_VISIBLE,
clnt.right-(NOTIFYAREA_WIDTH_DEF+1), 1, NOTIFYAREA_WIDTH_DEF, clnt.bottom-2, hwndParent); clnt.right-(NOTIFYAREA_WIDTH_DEF+1), 1, NOTIFYAREA_WIDTH_DEF, clnt.bottom-2, hwndParent);
#else #else
return Window::Create(WINDOW_CREATOR(NotifyArea), 0, return Window::Create(WINDOW_CREATOR(NotifyArea), 0,
BtnWindowClass(CLASSNAME_TRAYNOTIFY,CS_DBLCLKS), TITLE_TRAYNOTIFY, WS_CHILD|WS_VISIBLE, BtnWindowClass(CLASSNAME_TRAYNOTIFY,CS_DBLCLKS), TITLE_TRAYNOTIFY, WS_CHILD|WS_VISIBLE,
clnt.right-(NOTIFYAREA_WIDTH_DEF+1), 1, NOTIFYAREA_WIDTH_DEF, clnt.bottom-2, hwndParent); clnt.right-(NOTIFYAREA_WIDTH_DEF+1), 1, NOTIFYAREA_WIDTH_DEF, clnt.bottom-2, hwndParent);
#endif #endif
} }
LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
@ -179,7 +183,7 @@ LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
DWORD processId; DWORD processId;
GetWindowThreadProcessId(entry._hWnd, &processId); GetWindowThreadProcessId(entry._hWnd, &processId);
// bind dynamicaly to AllowSetForegroundWindow() to be compatible to WIN98 // bind dynamically to AllowSetForegroundWindow() to be compatible to WIN98
static DynamicFct<BOOL(WINAPI*)(DWORD dwProcessId)> AllowSetForegroundWindow(TEXT("USER32"), "AllowSetForegroundWindow"); static DynamicFct<BOOL(WINAPI*)(DWORD dwProcessId)> AllowSetForegroundWindow(TEXT("USER32"), "AllowSetForegroundWindow");
if (AllowSetForegroundWindow) if (AllowSetForegroundWindow)
@ -219,24 +223,33 @@ LRESULT NotifyArea::ProcessTrayNotification(int notify_code, NOTIFYICONDATA* pni
entry._idx = ++_next_idx; entry._idx = ++_next_idx;
Refresh(); ///@todo call only if really changes occurred Refresh(); ///@todo call only if really changes occurred
return TRUE;
} }
break; break;
case NIM_DELETE: case NIM_DELETE: {
if (_icon_map.erase(pnid)) NotifyIconMap::iterator found = _icon_map.find(pnid);
if (found != _icon_map.end()) {
if (found->second._hIcon)
DestroyIcon(found->second._hIcon);
_icon_map.erase(found);
Refresh(); Refresh();
break; return TRUE;
}
break;}
#if NOTIFYICON_VERSION>=3 // currently (as of 21.08.2003) missing in MinGW headers #if NOTIFYICON_VERSION>=3 // currently (as of 21.08.2003) missing in MinGW headers
case NIM_SETFOCUS: case NIM_SETFOCUS:
break; return TRUE;
case NIM_SETVERSION: case NIM_SETVERSION:
break; return FALSE; ///@todo
#endif #endif
} }
return 0; return FALSE;
} }
void NotifyArea::Refresh() void NotifyArea::Refresh()