186 // fix for 6271589: we MUST set the size of the structure to match 187 // the shell version, otherwise some errors may occur (like missing 188 // balloon messages on win2k) 189 DLLVERSIONINFO dllVersionInfo; 190 dllVersionInfo.cbSize = sizeof(DLLVERSIONINFO); 191 int shellVersion = 5; // WIN_2000 192 // MSDN: DllGetVersion should not be implicitly called, but rather 193 // loaded using GetProcAddress 194 HMODULE hShell = JDK_LoadSystemLibrary("Shell32.dll"); 195 if (hShell != NULL) { 196 DLLGETVERSIONPROC proc = (DLLGETVERSIONPROC)GetProcAddress(hShell, "DllGetVersion"); 197 if (proc != NULL) { 198 if (proc(&dllVersionInfo) == NOERROR) { 199 shellVersion = dllVersionInfo.dwMajorVersion; 200 } 201 } 202 } 203 FreeLibrary(hShell); 204 switch (shellVersion) { 205 case 5: // WIN_2000 206 m_nid.cbSize = (BYTE *)(&m_nid.guidItem) - (BYTE *)(&m_nid.cbSize); 207 break; 208 case 6: // WIN_XP 209 m_nid.cbSize = (BYTE *)(&m_nid.hBalloonIcon) - (BYTE *)(&m_nid.cbSize); 210 break; 211 default: // WIN_VISTA 212 m_nid.cbSize = sizeof(m_nid); 213 break; 214 } 215 m_nid.hWnd = AwtTrayIcon::sm_msgWindow; 216 m_nid.uID = uID; 217 m_nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; 218 m_nid.uCallbackMessage = WM_AWT_TRAY_NOTIFY; 219 m_nid.hIcon = AwtToolkit::GetInstance().GetAwtIcon(); 220 m_nid.szTip[0] = '\0'; 221 m_nid.uVersion = NOTIFYICON_VERSION; 222 } 223 224 BOOL AwtTrayIcon::SendTrayMessage(DWORD dwMessage) 225 { 226 return Shell_NotifyIcon(dwMessage, (PNOTIFYICONDATA)&m_nid); 227 } 228 229 static UINT lastMessage = WM_NULL; | 186 // fix for 6271589: we MUST set the size of the structure to match 187 // the shell version, otherwise some errors may occur (like missing 188 // balloon messages on win2k) 189 DLLVERSIONINFO dllVersionInfo; 190 dllVersionInfo.cbSize = sizeof(DLLVERSIONINFO); 191 int shellVersion = 5; // WIN_2000 192 // MSDN: DllGetVersion should not be implicitly called, but rather 193 // loaded using GetProcAddress 194 HMODULE hShell = JDK_LoadSystemLibrary("Shell32.dll"); 195 if (hShell != NULL) { 196 DLLGETVERSIONPROC proc = (DLLGETVERSIONPROC)GetProcAddress(hShell, "DllGetVersion"); 197 if (proc != NULL) { 198 if (proc(&dllVersionInfo) == NOERROR) { 199 shellVersion = dllVersionInfo.dwMajorVersion; 200 } 201 } 202 } 203 FreeLibrary(hShell); 204 switch (shellVersion) { 205 case 5: // WIN_2000 206 m_nid.cbSize = static_cast<DWORD>((BYTE *)(&m_nid.guidItem) - (BYTE *)(&m_nid.cbSize)); 207 break; 208 case 6: // WIN_XP 209 m_nid.cbSize = static_cast<DWORD>((BYTE *)(&m_nid.hBalloonIcon) - (BYTE *)(&m_nid.cbSize)); 210 break; 211 default: // WIN_VISTA 212 m_nid.cbSize = sizeof(m_nid); 213 break; 214 } 215 m_nid.hWnd = AwtTrayIcon::sm_msgWindow; 216 m_nid.uID = uID; 217 m_nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; 218 m_nid.uCallbackMessage = WM_AWT_TRAY_NOTIFY; 219 m_nid.hIcon = AwtToolkit::GetInstance().GetAwtIcon(); 220 m_nid.szTip[0] = '\0'; 221 m_nid.uVersion = NOTIFYICON_VERSION; 222 } 223 224 BOOL AwtTrayIcon::SendTrayMessage(DWORD dwMessage) 225 { 226 return Shell_NotifyIcon(dwMessage, (PNOTIFYICONDATA)&m_nid); 227 } 228 229 static UINT lastMessage = WM_NULL; |