Changeset 34025 in vbox
- Timestamp:
- Nov 12, 2010 10:03:41 AM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxTray
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
r33966 r34025 688 688 } 689 689 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED) 690 VBoxServiceReloadCursor();690 hlpReloadCursor(); 691 691 } else 692 692 { -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHelpers.cpp
r33966 r34025 26 26 #include "resource.h" 27 27 28 29 30 /** 31 * Attempt to force Windows to reload the cursor image by attaching to the 32 * thread of the window currently under the mouse, hiding the cursor and 33 * showing it again. This could fail to work in any number of ways (no 34 * window under the cursor, the cursor has moved to a different window while 35 * we are processing), but we just accept this, as the cursor will be reloaded 36 * at some point anyway. 37 */ 38 void hlpReloadCursor(void) 39 { 40 POINT mousePos; 41 HWND hWin; 42 DWORD hThread, hCurrentThread; 43 44 GetCursorPos(&mousePos); 45 hWin = WindowFromPoint(mousePos); 46 if (hWin) 47 { 48 hThread = GetWindowThreadProcessId(hWin, NULL); 49 hCurrentThread = GetCurrentThreadId(); 50 if (hCurrentThread != hThread) 51 AttachThreadInput(hCurrentThread, hThread, TRUE); 52 } 53 ShowCursor(false); 54 ShowCursor(true); 55 if (hWin && (hCurrentThread != hThread)) 56 AttachThreadInput(hCurrentThread, hThread, FALSE); 57 } 58 28 59 static unsigned hlpNextAdjacentRectXP(RECTL *paRects, unsigned nRects, unsigned uRect) 29 60 { … … 208 239 { 209 240 NOTIFYICONDATA niData; 241 ZeroMemory(&niData, sizeof(NOTIFYICONDATA)); 210 242 niData.cbSize = sizeof(NOTIFYICONDATA); 211 niData.uFlags = NIF_INFO; 243 niData.uFlags = NIF_INFO; /* Display a balloon notification. */ 212 244 niData.hWnd = hWnd; 213 245 niData.uID = uID; 246 /* If not timeout set, set it to 5sec. */ 247 if (uTimeout == 0) 248 uTimeout = 5000; 214 249 niData.uTimeout = uTimeout; 250 /* If no info flag (info, warning, error) set, 251 * set it to info by default. */ 215 252 if (dwInfoFlags == 0) 216 253 dwInfoFlags = NIIF_INFO; 217 254 niData.dwInfoFlags = dwInfoFlags; 218 255 219 OSVERSIONINFO info; 220 DWORD dwMajorVersion = 5; /* default XP */ 221 222 info.dwOSVersionInfoSize = sizeof(info); 223 if (FALSE == GetVersionEx(&info)) 224 return FALSE; 225 226 if (info.dwMajorVersion >= 5) 227 { 228 niData.uFlags |= NIF_ICON; 229 if ( info.dwMajorVersion == 5 230 && info.dwMinorVersion == 1) /* WinXP */ 231 { 232 //niData.dwInfoFlags = NIIF_USER; /* Use an own icon instead of the default one */ 233 niData.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_VIRTUALBOX)); 234 } 235 #ifdef BALLOON_WITH_VISTA_TOOLTIP_ICON 236 else if (info.dwMajorVersion == 6) /* Vista and up */ 237 { 238 niData.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON; /* Use an own icon instead of the default one */ 239 niData.hBalloonIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_VIRTUALBOX)); 240 } 241 #endif 242 } 243 244 strcpy(niData.szInfo, pszMsg ? pszMsg : ""); 245 strcpy(niData.szInfoTitle, pszTitle ? pszTitle : ""); 256 /* Do we want to have */ 257 258 /* Get running OS version. */ 259 OSVERSIONINFO osInfo; 260 osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 261 if (FALSE == GetVersionEx(&osInfo)) 262 return RTErrConvertFromWin32(GetLastError()); 263 264 /* Is the current OS supported (at least WinXP) for displaying 265 * our own icon and do we actually *want* to display our own stuff? */ 266 if ( osInfo.dwMajorVersion >= 5 267 && (dwInfoFlags & NIIF_INFO)) 268 { 269 /* Load (or retrieve handle of) the app's icon. */ 270 HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_VIRTUALBOX)); 271 if (hIcon) 272 niData.dwInfoFlags = NIIF_USER; /* Use an own notification icon. */ 273 274 if ( osInfo.dwMajorVersion == 5 275 && osInfo.dwMinorVersion == 1) /* WinXP. */ 276 { 277 /* Use an own icon instead of the default one. */ 278 niData.hIcon = hIcon; 279 } 280 else if (osInfo.dwMajorVersion == 6) /* Vista and up. */ 281 { 282 /* Use an own icon instead of the default one. */ 283 niData.dwInfoFlags |= NIIF_LARGE_ICON; /* Use a large icon if available! */ 284 niData.hIcon = hIcon; 285 niData.hBalloonIcon = hIcon; 286 } 287 } 288 else 289 { 290 /* This might be a warning, error message or a to old OS. Use the 291 * standard icons provided by Windows (if any). */ 292 } 293 294 strcpy(niData.szInfo, pszMsg ? pszMsg : "-"); 295 strcpy(niData.szInfoTitle, pszTitle ? pszTitle : "Information"); 246 296 247 297 if (!Shell_NotifyIcon(NIM_MODIFY, &niData)) 248 return GetLastError(); 249 return 0; 250 } 251 298 { 299 DWORD dwErr = GetLastError(); 300 return RTErrConvertFromWin32(dwErr); 301 } 302 return VINF_SUCCESS; 303 } 304 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHelpers.h
r33966 r34025 27 27 #endif /* !DEBUG_DISPLAY_CHANGE */ 28 28 29 extern void hlpReloadCursor(void); 29 30 extern void hlpResizeRect(RECTL *paRects, unsigned nRects, unsigned uPrimary, unsigned uResized, int iNewWidth, int iNewHeight); 30 31 extern int hlpShowBalloonTip(HINSTANCE hInst, HWND hWnd, UINT uID, const char *pszMsg, const char *pszTitle, UINT uTimeout, DWORD dwInfoFlags); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHostVersion.cpp
r33966 r34025 49 49 _snprintf(szMsg, sizeof(szMsg), "Your guest is currently running the Guest Additions version %s. " 50 50 "We recommend updating to the latest version (%s) by choosing the " 51 "install option from the Devices menu.", pszGuestVersion, pszHostVersion);51 "install option from the Devices menu.", "1", "2"); 52 52 53 rc = hlpShowBalloonTip(gInstance, gToolWindow, ID_TRAYICON, szMsg, szTitle, 5000, 0); 53 rc = hlpShowBalloonTip(gInstance, gToolWindow, ID_TRAYICON, 54 szMsg, szTitle, 55 5000 /* Time to display in msec */, NIIF_INFO); 54 56 if (RT_FAILURE(rc)) 55 57 Log(("VBoxTray: Guest Additions update found; however: could not show version notifier balloon tooltip! rc = %d\n", rc)); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
r33966 r34025 51 51 DWORD gMajorVersion; 52 52 53 /* Global message handler prototypes. */ 54 int vboxTrayGlMsgTaskbarCreated(LPARAM lParam, WPARAM wParam); 55 int vboxTrayGlMsgShowBalloonMsg(LPARAM lParam, WPARAM wParam); 56 53 57 /* Prototypes */ 58 int vboxTrayCreateTrayIcon(void); 54 59 VOID DisplayChangeThread(void *dummy); 55 60 LRESULT CALLBACK VBoxToolWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 61 56 62 57 63 /* The service table. */ … … 62 68 VBoxDisplayInit, 63 69 VBoxDisplayThread, 64 VBoxDisplayDestroy ,70 VBoxDisplayDestroy 65 71 }, 66 72 { … … 81 87 VBoxRestoreInit, 82 88 VBoxRestoreThread, 83 VBoxRestoreDestroy ,89 VBoxRestoreDestroy 84 90 }, 85 91 #endif … … 88 94 VBoxVRDPInit, 89 95 VBoxVRDPThread, 90 VBoxVRDPDestroy ,96 VBoxVRDPDestroy 91 97 }, 92 98 { … … 95 101 }; 96 102 97 static BOOL vboxTrayIconAdd() 103 /* The global message table. */ 104 static VBOXGLOBALMESSAGE s_vboxGlobalMessageTable[] = 105 { 106 /* Windows specific stuff. */ 107 { 108 "TaskbarCreated", 109 vboxTrayGlMsgTaskbarCreated 110 }, 111 112 /* VBoxTray specific stuff. */ 113 { 114 "VBoxTrayShowBalloonMsg", 115 vboxTrayGlMsgShowBalloonMsg 116 }, 117 118 { 119 NULL 120 } 121 }; 122 123 /** 124 * Gets called whenever the Windows main taskbar 125 * get (re-)created. Nice to install our tray icon. 126 * 127 * @return IPRT status code. 128 * @param wParam 129 * @param lParam 130 */ 131 static int vboxTrayGlMsgTaskbarCreated(LPARAM lParam, WPARAM wParam) 132 { 133 return vboxTrayCreateTrayIcon(); 134 } 135 136 /** 137 * Shows a balloon tooltip message in VBoxTray's 138 * message area in the Windows main taskbar. 139 * 140 * @return IPRT status code. 141 * @param wParam 142 * @param lParam 143 */ 144 static int vboxTrayGlMsgShowBalloonMsg(LPARAM wParam, WPARAM lParam) 145 { 146 int rc = hlpShowBalloonTip(gInstance, gToolWindow, ID_TRAYICON, 147 (char*)wParam /* Ugly hack! */, "Foo", 148 5000 /* Time to display in msec */, NIIF_INFO); 149 /* 150 * If something went wrong while displaying, log the message into the 151 * the release log so that the user still is being informed, at least somehow. 152 */ 153 if (RT_FAILURE(rc)) 154 LogRel(("VBoxTray Information: %s\n", "Foo")); 155 return rc; 156 } 157 158 static int vboxTrayCreateTrayIcon(void) 98 159 { 99 160 HICON hIcon = LoadIcon(gInstance, MAKEINTRESOURCE(IDI_VIRTUALBOX)); 100 161 if (hIcon == NULL) 101 162 { 102 Log(("VBoxTray: Could not load tray icon, err %08X\n", GetLastError())); 103 return FALSE; 163 DWORD dwErr = GetLastError(); 164 Log(("VBoxTray: Could not load tray icon, error %08X\n", dwErr)); 165 return RTErrConvertFromWin32(dwErr); 104 166 } 105 167 … … 116 178 VBOX_PRODUCT, VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV); 117 179 118 BOOL fCreated = Shell_NotifyIcon(NIM_ADD, &gNotifyIconData); 119 if (!fCreated) 120 { 121 Log(("VBoxTray: Could not create tray icon, err %08X\n", GetLastError())); 180 int rc = VINF_SUCCESS; 181 if (!Shell_NotifyIcon(NIM_ADD, &gNotifyIconData)) 182 { 183 DWORD dwErr = GetLastError(); 184 Log(("VBoxTray: Could not create tray icon, error = %08X\n", dwErr)); 185 rc = RTErrConvertFromWin32(dwErr); 122 186 RT_ZERO(gNotifyIconData); 123 187 } … … 125 189 if (hIcon) 126 190 DestroyIcon(hIcon); 127 return fCreated;128 } 129 130 static void vboxTray IconRemove()191 return rc; 192 } 193 194 static void vboxTrayRemoveTrayIcon() 131 195 { 132 196 if (gNotifyIconData.cbSize > 0) … … 145 209 } 146 210 147 static int vbox StartServices(VBOXSERVICEENV *pEnv, VBOXSERVICEINFO *pTable)211 static int vboxTrayStartServices(VBOXSERVICEENV *pEnv, VBOXSERVICEINFO *pTable) 148 212 { 149 213 Log(("VBoxTray: Starting services ...\n")); … … 209 273 } 210 274 211 static void vbox StopServices(VBOXSERVICEENV *pEnv, VBOXSERVICEINFO *pTable)275 static void vboxTrayStopServices(VBOXSERVICEENV *pEnv, VBOXSERVICEINFO *pTable) 212 276 { 213 277 if (!pEnv->hStopEvent) … … 242 306 } 243 307 244 245 /** 246 * Attempt to force Windows to reload the cursor image by attaching to the 247 * thread of the window currently under the mouse, hiding the cursor and 248 * showing it again. This could fail to work in any number of ways (no 249 * window under the cursor, the cursor has moved to a different window while 250 * we are processing), but we just accept this, as the cursor will be reloaded 251 * at some point anyway. 252 */ 253 void VBoxServiceReloadCursor(void) 254 { 255 LogFlowFunc(("\n")); 256 POINT mousePos; 257 HWND hWin; 258 DWORD hThread, hCurrentThread; 259 260 GetCursorPos(&mousePos); 261 hWin = WindowFromPoint(mousePos); 262 if (hWin) 263 { 264 hThread = GetWindowThreadProcessId(hWin, NULL); 265 hCurrentThread = GetCurrentThreadId(); 266 if (hCurrentThread != hThread) 267 AttachThreadInput(hCurrentThread, hThread, TRUE); 268 } 269 ShowCursor(false); 270 ShowCursor(true); 271 if (hWin && (hCurrentThread != hThread)) 272 AttachThreadInput(hCurrentThread, hThread, FALSE); 273 LogFlowFunc(("exiting\n")); 274 } 275 308 int vboxTrayRegisterGlobalMessages(PVBOXGLOBALMESSAGE pTable) 309 { 310 int rc = VINF_SUCCESS; 311 if (pTable == NULL) /* No table to register? Skip. */ 312 return rc; 313 while ( pTable->pszName 314 && RT_SUCCESS(rc)) 315 { 316 /* Register global accessible window messages. */ 317 pTable->uMsgID = RegisterWindowMessage(TEXT(pTable->pszName)); 318 if (!pTable->uMsgID) 319 { 320 DWORD dwErr = GetLastError(); 321 Log(("VBoxTray: Registering global message \"%s\" failed, error = %08X\n", dwErr)); 322 rc = RTErrConvertFromWin32(dwErr); 323 } 324 325 /* Advance to next table element. */ 326 pTable++; 327 } 328 return rc; 329 } 330 331 bool vboxTrayHandleGlobalMessages(PVBOXGLOBALMESSAGE pTable, UINT uMsg, 332 WPARAM wParam, LPARAM lParam) 333 { 334 if (pTable == NULL) 335 return false; 336 while (pTable->pszName) 337 { 338 if (pTable->uMsgID == uMsg) 339 { 340 if (pTable->pfnHandler) 341 pTable->pfnHandler(wParam, lParam); 342 return true; 343 } 344 345 /* Advance to next table element. */ 346 pTable++; 347 } 348 return false; 349 } 276 350 277 351 void WINAPI VBoxServiceStart(void) … … 280 354 281 355 VBOXSERVICEENV svcEnv; 282 283 DWORD status = NO_ERROR; 356 DWORD dwErr = NO_ERROR; 284 357 285 358 /* Open VBox guest driver. */ … … 293 366 if (gVBoxDriver == INVALID_HANDLE_VALUE) 294 367 { 295 LogRel(("VBoxTray: Could not open VirtualBox Guest Additions driver! Please install / start it first! rc = %d\n", GetLastError())); 296 status = ERROR_GEN_FAILURE; 297 } 298 299 Log(("VBoxTray: Driver Handle = %p, Status = %p\n", gVBoxDriver, status)); 300 301 if (status == NO_ERROR) 368 dwErr = GetLastError(); 369 LogRel(("VBoxTray: Could not open VirtualBox Guest Additions driver! Please install / start it first! Error = %08X\n", dwErr)); 370 } 371 372 if (dwErr == NO_ERROR) 302 373 { 303 374 /* Create a custom window class. */ … … 307 378 windowClass.hInstance = gInstance; 308 379 windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); 309 windowClass.lpszClassName = "V irtualBoxTool";380 windowClass.lpszClassName = "VBoxTrayToolWndClass"; 310 381 if (!RegisterClass(&windowClass)) 311 status = GetLastError(); 312 } 313 314 Log(("VBoxTray: Class st %p\n", status)); 315 316 if (status == NO_ERROR) 382 { 383 dwErr = GetLastError(); 384 Log(("VBoxTray: Registering invisible tool window failed, error = %08X\n", dwErr)); 385 } 386 } 387 388 if (dwErr == NO_ERROR) 317 389 { 318 390 /* Create our (invisible) tool window. */ 391 /* Note: The window name ("VBoxTrayToolWnd") and class ("VBoxTrayToolWndClass") is 392 * needed for posting globally registered messages to VBoxTray and must not be 393 * changed! Otherwise things get broken! */ 319 394 gToolWindow = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_TOPMOST, 320 "V irtualBoxTool", "VirtualBoxTool",395 "VBoxTrayToolWndClass", "VBoxTrayToolWnd", 321 396 WS_POPUPWINDOW, 322 397 -200, -200, 100, 100, NULL, NULL, gInstance, NULL); 323 398 if (!gToolWindow) 324 status = GetLastError(); 399 { 400 dwErr = GetLastError(); 401 Log(("VBoxTray: Creating invisible tool window failed, error = %08X\n", dwErr)); 402 } 325 403 else 326 VBoxServiceReloadCursor(); 327 } 328 329 Log(("VBoxTray: Window Handle = %p, Status = %p\n", gToolWindow, status)); 404 { 405 hlpReloadCursor(); 406 } 407 } 408 409 Log(("VBoxTray: Window Handle = %p, Status = %p\n", gToolWindow, dwErr)); 330 410 331 411 OSVERSIONINFO info; … … 334 414 if (GetVersionEx(&info)) 335 415 { 336 Log(("VBoxTray: Windows version major %d minor %d\n", info.dwMajorVersion, info.dwMinorVersion));416 Log(("VBoxTray: Windows version %ld.%ld\n", info.dwMajorVersion, info.dwMinorVersion)); 337 417 gMajorVersion = info.dwMajorVersion; 338 418 } 339 419 340 if ( status== NO_ERROR)420 if (dwErr == NO_ERROR) 341 421 { 342 422 gStopSem = CreateEvent(NULL, TRUE, FALSE, NULL); 343 423 if (gStopSem == NULL) 344 424 { 345 Log(("VBoxTray: CreateEvent for Stopping failed: rc = %d\n", GetLastError()));425 Log(("VBoxTray: CreateEvent for stopping VBoxTray failed, error = %08X\n", GetLastError())); 346 426 return; 347 427 } … … 358 438 ret = SetSecurityDescriptorDacl(SecAttr.lpSecurityDescriptor, TRUE, 0, FALSE); 359 439 if (!ret) 360 Log(("VBoxTray: SetSecurityDescriptorDacl failed with %d\n", GetLastError()));440 Log(("VBoxTray: SetSecurityDescriptorDacl failed with error = %08X\n", GetLastError())); 361 441 362 442 /* For Vista and up we need to change the integrity of the security descriptor too */ … … 383 463 SDDL_REVISION_1, &pSD, NULL); 384 464 if (!ret) 385 Log(("VBoxTray: ConvertStringSecurityDescriptorToSecurityDescriptorA failed with %d\n", GetLastError()));465 Log(("VBoxTray: ConvertStringSecurityDescriptorToSecurityDescriptorA failed with error = %08X\n", GetLastError())); 386 466 387 467 ret = GetSecurityDescriptorSacl(pSD, &fSaclPresent, &pSacl, &fSaclDefaulted); 388 468 if (!ret) 389 Log(("VBoxTray: GetSecurityDescriptorSacl failed with %d\n", GetLastError()));469 Log(("VBoxTray: GetSecurityDescriptorSacl failed with error = %08X\n", GetLastError())); 390 470 391 471 ret = SetSecurityDescriptorSacl(SecAttr.lpSecurityDescriptor, TRUE, pSacl, FALSE); 392 472 if (!ret) 393 Log(("VBoxTray: SetSecurityDescriptorSacl failed with %d\n", GetLastError()));473 Log(("VBoxTray: SetSecurityDescriptorSacl failed with error = %08X\n", GetLastError())); 394 474 } 395 475 } … … 401 481 if (ghSeamlessNotifyEvent == NULL) 402 482 { 403 Log(("VBoxTray: CreateEvent for Seamless failed : rc = %d\n", GetLastError()));483 Log(("VBoxTray: CreateEvent for Seamless failed, error = %08X\n", GetLastError())); 404 484 return; 405 485 } … … 414 494 415 495 /* initializes disp-if to default (XPDM) mode */ 416 status= VBoxDispIfInit(&svcEnv.dispIf);496 dwErr = VBoxDispIfInit(&svcEnv.dispIf); 417 497 #ifdef VBOX_WITH_WDDM 418 498 /* … … 422 502 #endif 423 503 424 if (status == NO_ERROR) 425 { 426 int rc = vboxStartServices(&svcEnv, vboxServiceTable); 427 504 if (dwErr == NO_ERROR) 505 { 506 int rc = vboxTrayStartServices(&svcEnv, vboxServiceTable); 428 507 if (RT_FAILURE (rc)) 429 508 { 430 status= ERROR_GEN_FAILURE;509 dwErr = ERROR_GEN_FAILURE; 431 510 } 432 511 } 433 512 434 513 /* terminate service if something went wrong */ 435 if ( status!= NO_ERROR)436 { 437 vbox StopServices(&svcEnv, vboxServiceTable);514 if (dwErr != NO_ERROR) 515 { 516 vboxTrayStopServices(&svcEnv, vboxServiceTable); 438 517 return; 439 518 } 440 519 441 if ( vboxTrayIconAdd() 520 int rc = vboxTrayCreateTrayIcon(); 521 if ( RT_SUCCESS(rc) 442 522 && gMajorVersion >= 5) /* Only for W2K and up ... */ 443 523 { … … 450 530 } 451 531 532 /* Do the Shared Folders auto-mounting stuff. */ 452 533 VBoxSharedFoldersAutoMount(); 453 534 … … 510 591 Log(("VBoxTray: Returned from main loop, exiting ...\n")); 511 592 512 vboxTray IconRemove();593 vboxTrayRemoveTrayIcon(); 513 594 514 595 Log(("VBoxTray: Waiting for display change thread ...\n")); 515 596 516 vbox StopServices(&svcEnv, vboxServiceTable);597 vboxTrayStopServices(&svcEnv, vboxServiceTable); 517 598 518 599 Log(("VBoxTray: Destroying tool window ...\n")); … … 521 602 DestroyWindow(gToolWindow); 522 603 523 UnregisterClass("V irtualBoxTool", gInstance);604 UnregisterClass("VBoxTrayToolWndClass", gInstance); 524 605 525 606 CloseHandle(gVBoxDriver); … … 540 621 /* Do not use a global namespace ("Global\\") for mutex name here, will blow up NT4 compatibility! */ 541 622 HANDLE hMutexAppRunning = CreateMutex(NULL, FALSE, "VBoxTray"); 542 if ( (hMutexAppRunning != NULL)543 && (GetLastError() == ERROR_ALREADY_EXISTS))544 { 545 /* Close the mutex for this application instance. */546 CloseHandle (hMutexAppRunning);547 hMutexAppRunning = NULL;548 return 0;623 if ( hMutexAppRunning != NULL 624 && GetLastError() == ERROR_ALREADY_EXISTS) 625 { 626 /* Close the mutex for this application instance. */ 627 CloseHandle (hMutexAppRunning); 628 hMutexAppRunning = NULL; 629 return 0; 549 630 } 550 631 … … 565 646 566 647 /* Release instance mutex. */ 567 if (hMutexAppRunning != NULL) { 648 if (hMutexAppRunning != NULL) 649 { 568 650 CloseHandle(hMutexAppRunning); 569 651 hMutexAppRunning = NULL; … … 577 659 * Window procedure for our tool window 578 660 */ 579 LRESULT CALLBACK VBoxToolWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 580 { 581 static UINT s_uTaskbarCreated = 0; 582 583 switch (msg) 661 LRESULT CALLBACK VBoxToolWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 662 { 663 switch (uMsg) 584 664 { 585 665 case WM_CREATE: 666 { 586 667 Log(("VBoxTray: Tool window created\n")); 587 s_uTaskbarCreated = RegisterWindowMessage(TEXT("TaskbarCreated")); 588 if (!s_uTaskbarCreated) 589 Log(("VBoxTray: Cannot register message \"TaskbarCreated\"! Error = %ld\n", GetLastError())); 590 break; 668 669 int rc = vboxTrayRegisterGlobalMessages(&s_vboxGlobalMessageTable[0]); 670 if (RT_FAILURE(rc)) 671 Log(("VBoxTray: Error registering global window messages, rc=%Rrc\n", rc)); 672 return 0; 673 } 591 674 592 675 case WM_CLOSE: 593 break;676 return 0; 594 677 595 678 case WM_DESTROY: 596 679 Log(("VBoxTray: Tool window destroyed\n")); 597 680 KillTimer(gToolWindow, TIMERID_VBOXTRAY_CHECK_HOSTVERSION); 598 break;681 return 0; 599 682 600 683 case WM_TIMER: 601 684 switch (wParam) 602 685 { 603 case WM_VBOXTRAY_CHECK_HOSTVERSION:686 case TIMERID_VBOXTRAY_CHECK_HOSTVERSION: 604 687 if (RT_SUCCESS(VBoxCheckHostVersion())) 605 688 { … … 612 695 break; 613 696 } 614 615 break; 697 break; /* Make sure other timers get processed the usual way! */ 616 698 617 699 case WM_VBOXTRAY_TRAY_ICON: … … 624 706 break; 625 707 } 626 break;708 return 0; 627 709 628 710 case WM_VBOX_INSTALL_SEAMLESS_HOOK: 629 711 VBoxSeamlessInstallHook(); 630 break;712 return 0; 631 713 632 714 case WM_VBOX_REMOVE_SEAMLESS_HOOK: 633 715 VBoxSeamlessRemoveHook(); 634 break;716 return 0; 635 717 636 718 case WM_VBOX_SEAMLESS_UPDATE: 637 719 VBoxSeamlessCheckWindows(); 638 break;720 return 0; 639 721 640 722 case WM_VBOXTRAY_VM_RESTORED: 641 723 VBoxRestoreSession(); 642 break;724 return 0; 643 725 644 726 case WM_VBOXTRAY_VRDP_CHECK: 645 727 VBoxRestoreCheckVRDP(); 646 break;728 return 0; 647 729 648 730 default: 649 731 650 if(msg == s_uTaskbarCreated) 651 { 652 Log(("VBoxTray: Taskbar (re-)created, installing tray icon ...\n")); 653 vboxTrayIconAdd(); 654 } 655 break; 656 } 657 return DefWindowProc(hwnd, msg, wParam, lParam); 658 } 732 /* Handle all globally registered window messages. */ 733 if (vboxTrayHandleGlobalMessages(&s_vboxGlobalMessageTable[0], uMsg, 734 wParam, lParam)) 735 { 736 return 0; /* We handled the message. @todo Add return value!*/ 737 } 738 break; /* We did not handle the message, dispatch to DefWndProc. */ 739 } 740 741 /* Only if message was *not* handled by our switch above, dispatch 742 * to DefWindowProc. */ 743 return DefWindowProc(hWnd, uMsg, wParam, lParam); 744 } -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.h
r33966 r34025 44 44 */ 45 45 #define WM_VBOXTRAY_TRAY_ICON WM_APP + 40 46 #define WM_VBOXTRAY_TRAY_DISPLAY_BALLOON WM_APP + 4147 46 /** 48 47 * VM/VMMDev related messsages. … … 53 52 */ 54 53 #define WM_VBOXTRAY_VRDP_CHECK WM_APP + 301 55 /**56 * Misc. utility functions.57 */58 #define WM_VBOXTRAY_CHECK_HOSTVERSION WM_APP + 100059 54 60 55 61 56 /* The tray icon's ID. */ 62 #define ID_TRAYICON 200057 #define ID_TRAYICON 2000 63 58 64 59 … … 87 82 88 83 /* Variables. */ 89 HANDLE hThread; 90 void *pInstance; 91 bool fStarted; 92 84 HANDLE hThread; 85 void *pInstance; 86 bool fStarted; 93 87 } VBOXSERVICEINFO; 94 88 89 /* Globally unique (system wide) message registration. */ 90 typedef struct _VBOXGLOBALMESSAGE 91 { 92 /** Message name. */ 93 char *pszName; 94 /** Function pointer for handling the message. */ 95 int (* pfnHandler) (LPARAM lParam, WPARAM wParam); 96 97 /* Variables. */ 98 99 /** Message ID; 100 * to be filled in when registering the actual message. */ 101 UINT uMsgID; 102 } VBOXGLOBALMESSAGE, *PVBOXGLOBALMESSAGE; 95 103 96 104 extern HWND gToolWindow; 97 105 extern HINSTANCE gInstance; 98 106 99 extern void VBoxServiceReloadCursor(void);100 101 107 #endif /* !___VBOXTRAY_H */ 102 108
Note:
See TracChangeset
for help on using the changeset viewer.