Skip to content

Commit a7ea59d

Browse files
committed
Fixed issue #11. The About dialog now shows and I made it so that the link buttons in it actually do something.
1 parent 81283c9 commit a7ea59d

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

win32/N3888_RefImpl/N3888_RefImpl.vcxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<Link>
9292
<SubSystem>Windows</SubSystem>
9393
<GenerateDebugInformation>true</GenerateDebugInformation>
94-
<AdditionalDependencies>"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\cairo.lib";"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\zlib.lib";comctl32.lib;user32.lib;kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib</AdditionalDependencies>
94+
<AdditionalDependencies>"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\cairo.lib";"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\zlib.lib";comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
9595
</Link>
9696
<PostBuildEvent>
9797
<Command>cmd /c copy "$(ProjectDir)DLLs\$(PlatformTarget)\$(Configuration)\cairo.dll" "$(OutputPath)"
@@ -113,7 +113,7 @@ cmd /c copy "$(ProjectDir)DLLs\$(PlatformTarget)\$(Configuration)\zlib1.pdb" "$(
113113
<Link>
114114
<SubSystem>Windows</SubSystem>
115115
<GenerateDebugInformation>true</GenerateDebugInformation>
116-
<AdditionalDependencies>"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\cairo.lib";"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\zlib.lib";comctl32.lib;user32.lib;kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib</AdditionalDependencies>
116+
<AdditionalDependencies>"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\cairo.lib";"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\zlib.lib";comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
117117
</Link>
118118
<PostBuildEvent>
119119
<Command>cmd /c copy "$(ProjectDir)DLLs\$(PlatformTarget)\$(Configuration)\cairo.dll" "$(OutputPath)"
@@ -140,7 +140,7 @@ cmd /c copy "$(ProjectDir)DLLs\$(PlatformTarget)\$(Configuration)\zlib1.pdb" "$(
140140
<GenerateDebugInformation>true</GenerateDebugInformation>
141141
<EnableCOMDATFolding>true</EnableCOMDATFolding>
142142
<OptimizeReferences>true</OptimizeReferences>
143-
<AdditionalDependencies>"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\cairo.lib";"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\zlib.lib";comctl32.lib;user32.lib;kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib</AdditionalDependencies>
143+
<AdditionalDependencies>"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\cairo.lib";"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\zlib.lib";comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
144144
</Link>
145145
<PostBuildEvent>
146146
<Command>cmd /c copy "$(ProjectDir)DLLs\$(PlatformTarget)\$(Configuration)\cairo.dll" "$(OutputPath)"
@@ -165,7 +165,7 @@ cmd /c copy "$(ProjectDir)DLLs\$(PlatformTarget)\$(Configuration)\zlib1.dll" "$(
165165
<GenerateDebugInformation>true</GenerateDebugInformation>
166166
<EnableCOMDATFolding>true</EnableCOMDATFolding>
167167
<OptimizeReferences>true</OptimizeReferences>
168-
<AdditionalDependencies>"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\cairo.lib";"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\zlib.lib";comctl32.lib;user32.lib;kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib</AdditionalDependencies>
168+
<AdditionalDependencies>"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\cairo.lib";"$(ProjectDir)\lib\$(PlatformTarget)\$(Configuration)\zlib.lib";comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
169169
</Link>
170170
<PostBuildEvent>
171171
<Command>cmd /c copy "$(ProjectDir)DLLs\$(PlatformTarget)\$(Configuration)\cairo.dll" "$(OutputPath)"

win32/N3888_RefImpl/entrypoint-win32.cpp

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#include "throw_helpers.h"
1313
#include "drawing.h"
1414

15+
#pragma comment(linker,"\"/manifestdependency:type='win32' \
16+
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
17+
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
18+
1519
using namespace Microsoft::WRL;
1620
using namespace std;
1721
using namespace std::experimental;
@@ -239,6 +243,12 @@ ATOM MyRegisterClass(HINSTANCE hInstance) {
239243
//
240244
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, HWND& hWnd) {
241245
//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+
}
242252

243253
hInst = hInstance; // Store instance handle in our global variable
244254

@@ -366,7 +376,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
366376
// Parse the menu selections:
367377
switch (wmId) {
368378
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+
}
370385
break;
371386
case ID_EDIT_SCREENCAPTURE:
372387
ShowSaveAsPNGDialog();
@@ -403,6 +418,28 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
403418
return (INT_PTR)TRUE;
404419
}
405420
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;
406443
}
407444
return (INT_PTR)FALSE;
408445
}

win32/N3888_RefImpl/entrypoint-win32.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <Unknwn.h>
1010
#include <ShObjIdl.h>
1111
#include <KnownFolders.h>
12+
#include <shellapi.h>
1213

1314
// Forward declarations of functions included in this code module:
1415
ATOM MyRegisterClass(HINSTANCE hInstance);

0 commit comments

Comments
 (0)