Changeset 21590 for trunk/src


Ignore:
Timestamp:
Mar 15, 2011, 4:34:07 PM (14 years ago)
Author:
dmik
Message:

shell32: Shell_NotifyIcon(): Create a copy of the supplied icon because the caller may DestroyIcon() on it at any time (which would cause systray to display an empty rectangle). This matches Windows behavior.

Location:
trunk/src/shell32
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shell32/systray.c

    r10604 r21590  
    7878  SYSTRAY_ItemSetTip    (*ptrayItem, (pnid->uFlags&NIF_TIP)    ?pnid->szTip           :"", FALSE);
    7979
    80   TRACE("SYSTRAY_Add %p: 0x%08x 0x%08x 0x%08x %s\n",  (*ptrayItem), (*ptrayItem)->notifyIcon.hWnd,
     80  TRACE("SYSTRAY_Add %p: 0x%08x 0x%08x 0x%08x 0x%08x %s\n",  (*ptrayItem),
     81        (*ptrayItem)->notifyIcon.hWnd, (*ptrayItem)->notifyIcon.hIcon,
    8182        pnid->uCallbackMessage, (*ptrayItem)->notifyIcon.uCallbackMessage,
    8283        pnid->szTip );
  • trunk/src/shell32/systray_os2.c

    r10604 r21590  
    154154void SYSTRAY_ItemTerm(SystrayItem *ptrayItem)
    155155{
     156    HPOINTER hIcon = (HPOINTER)WinSendMsg(ptrayItem->hWndFrame, WM_QUERYICON, NULL, NULL);
     157    if (hIcon != NULLHANDLE)
     158        WinDestroyPointer(hIcon);
     159
    156160    WinDestroyWindow(ptrayItem->hWndFrame);
    157161}
     
    166170void SYSTRAY_ItemSetIcon(SystrayItem *ptrayItem, HPOINTER hIcon)
    167171{
     172    // Windows seems to make a copy of icons displayed in the tray area. At
     173    // least, calling DestroyIcon() after passing the icon handle to
     174    // Shell_NotifyIcon() doesn't harm the icon displayed in the tray. Behave
     175    // similarly on OS/2 (some applications do call DestroyIcon()). The copy is
     176    // deleted in SYSTRAY_ItemTerm().
     177
     178    POINTERINFO Info;
     179    HPOINTER hIcon2 = NULLHANDLE;
     180    APIRET arc;
     181    arc = WinQueryPointerInfo(hIcon, &Info);
     182    if (!arc)
     183        return;
     184    hIcon2 = WinCreatePointerIndirect(HWND_DESKTOP, &Info);
     185    if (hIcon2 == NULLHANDLE)
     186        return;
     187    hIcon = hIcon2;
     188
    168189    WinSendMsg( ptrayItem->hWndFrame, WM_SETICON, MPFROMLONG( hIcon ), MPVOID );
    169190    if (hwndTrayServer)
Note: See TracChangeset for help on using the changeset viewer.