|
12 | 12 | #include "throw_helpers.h" |
13 | 13 | #include "drawing.h" |
14 | 14 |
|
| 15 | +#pragma comment(linker,"\"/manifestdependency:type='win32' \ |
| 16 | +name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \ |
| 17 | +processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") |
| 18 | + |
15 | 19 | using namespace Microsoft::WRL; |
16 | 20 | using namespace std; |
17 | 21 | using namespace std::experimental; |
@@ -239,6 +243,12 @@ ATOM MyRegisterClass(HINSTANCE hInstance) { |
239 | 243 | // |
240 | 244 | BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, HWND& hWnd) { |
241 | 245 | //HWND hWnd; |
| 246 | + INITCOMMONCONTROLSEX initCommonControlsEx{ }; |
| 247 | + initCommonControlsEx.dwSize = sizeof(initCommonControlsEx); |
| 248 | + initCommonControlsEx.dwICC = ICC_LINK_CLASS; |
| 249 | + if (InitCommonControlsEx(&initCommonControlsEx) == FALSE) { |
| 250 | + throw runtime_error("Failed call to InitCommonControlsEx."); |
| 251 | + } |
242 | 252 |
|
243 | 253 | hInst = hInstance; // Store instance handle in our global variable |
244 | 254 |
|
@@ -366,7 +376,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
366 | 376 | // Parse the menu selections: |
367 | 377 | switch (wmId) { |
368 | 378 | case IDM_ABOUT: |
369 | | - DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); |
| 379 | + { |
| 380 | + auto aboutResult = DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); |
| 381 | + if (aboutResult <= 0) { |
| 382 | + throw_get_last_error<logic_error>("Failed call to DialogBox."); |
| 383 | + } |
| 384 | + } |
370 | 385 | break; |
371 | 386 | case ID_EDIT_SCREENCAPTURE: |
372 | 387 | ShowSaveAsPNGDialog(); |
@@ -403,6 +418,28 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { |
403 | 418 | return (INT_PTR)TRUE; |
404 | 419 | } |
405 | 420 | break; |
| 421 | + case WM_NOTIFY: |
| 422 | + { |
| 423 | + PNMLINK pnmLink = reinterpret_cast<PNMLINK>(lParam); |
| 424 | + if ((pnmLink->hdr.idFrom == IDC_SYSLINK1) || (pnmLink->hdr.idFrom == IDC_SYSLINK2)) { |
| 425 | + switch (pnmLink->hdr.code) |
| 426 | + { |
| 427 | + case NM_CLICK: |
| 428 | + // Intentional fall-through. |
| 429 | + case NM_RETURN: |
| 430 | + { |
| 431 | + auto shExecResult = reinterpret_cast<int>(ShellExecute(nullptr, L"open", pnmLink->item.szUrl, nullptr, nullptr, SW_SHOW)); |
| 432 | + if (shExecResult <= 32) { |
| 433 | + wstringstream err; |
| 434 | + err << L"Error calling ShellExecute while trying to open the link. Return code: " << to_wstring(shExecResult) << "." << endl; |
| 435 | + MessageBox(hDlg, err.str().c_str(), L"Error opening link", MB_OK | MB_ICONEXCLAMATION); |
| 436 | + } |
| 437 | + } |
| 438 | + return (INT_PTR)TRUE; |
| 439 | + } |
| 440 | + } |
| 441 | + } |
| 442 | + break; |
406 | 443 | } |
407 | 444 | return (INT_PTR)FALSE; |
408 | 445 | } |
0 commit comments