| 303 | } |
| 304 | |
| 305 | void ContextMenu::invokeCommand(LPCONTEXTMENU pContextMenu, UINT idCommand) |
| 306 | { |
| 307 | CMINVOKECOMMANDINFO cmi = {0}; |
| 308 | HRESULT hr; |
| 309 | if (idCommand < DISPLAY_SCREEN_RESOLUTION_ID) |
| 310 | { |
| 311 | // Set it all up |
| 312 | cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); |
| 313 | cmi.lpVerb =(LPSTR) MAKEINTRESOURCE(idCommand); |
| 314 | cmi.nShow = SW_SHOWNORMAL; |
| 315 | |
| 316 | // See how many shortcuts are currently on the desktop |
| 317 | int numShortcutsBeforeInvokeCommand = scnManager->getFileSystemActors(DeadLink, false).size(); |
| 318 | |
| 319 | // Invoke the specific command |
| 320 | hr = pContextMenu->InvokeCommand(&cmi); |
| 321 | |
| 322 | // Update the file system watcher to see if any new files were created |
| 323 | fsManager->update(); |
| 324 | |
| 325 | // Check if a new shortcut has been added to the desktop |
| 326 | vector<FileSystemActor *> shortcutsAfterInvokingCommand = scnManager->getFileSystemActors(DeadLink, false); |
| 327 | |
| 328 | // If a new shortcut was added launch "New Shortcut" prompt dialog |
| 329 | if (winOS->IsWindowsVersionGreaterThanOrEqualTo(WindowsVista) && |
| 330 | shortcutsAfterInvokingCommand.size() > numShortcutsBeforeInvokeCommand) |
| 331 | { |
| 332 | // Use the last item added to the list of getFileSystemActors |
| 333 | int index = shortcutsAfterInvokingCommand.size() - 1; |
| 334 | QString filePath = shortcutsAfterInvokingCommand[index]->getFullPath(); |
| 335 | |
| 336 | // Create a path without spaces |
| 337 | // The new shortcut prompt requires a path to the new shortcut file, and the path |
| 338 | // cannot contain spaces. Enclosing the path in ""'s doesn't work either |
| 339 | // So instead we will call GetShortPathName to get a short path name |
| 340 | // that we can pass to rundll32.exe |
| 341 | QString shortFilePathQS(""); |
| 342 | winOS->GetShortPathName(filePath, shortFilePathQS); |
| 343 | |
| 344 | // Launch rundll32.exe to bring up the new shortcut prompt |
| 345 | fsManager->launchFile("rundll32.exe", "appwiz.cpl,NewLinkHere " + native(shortFilePathQS), "", false, false); |
| 346 | } |
| 347 | }else{ |
| 348 | // Handle the display properties |
| 349 | if (native(scnManager->getWorkingDirectory()) == winOS->GetSystemPath(DesktopDirectory) && |
| 350 | idCommand == DISPLAY_PROPERTIES_ID) |
| 351 | { |
| 352 | if (winOS->IsWindowsVersion(WindowsXP)) |
| 353 | { |
| 354 | // Launch the display properties |
| 355 | fsManager->launchFileAsync("Rundll32.exe", "shell32.dll,Control_RunDLL Desk.cpl", "", false, false); |
| 356 | } |
| 357 | else if (winOS->IsWindowsVersionGreaterThanOrEqualTo(WindowsVista)) |
| 358 | { |
| 359 | // Launch the personalization applet |
| 360 | // http://msdn.microsoft.com/en-us/library/cc144191(VS.85).aspx |
| 361 | fsManager->launchFileAsync("control.exe", "/name Microsoft.Personalization", "", false, false); |
| 362 | } |
nothing calls this directly
no test coverage detected