forked from ladislav-zezula/FileTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDlgSimple.cpp
120 lines (99 loc) · 3.93 KB
/
DlgSimple.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*****************************************************************************/
/* DlgSimple.cpp Copyright (c) Ladislav Zezula 2014 */
/*---------------------------------------------------------------------------*/
/* Description: Common module for a few simple dialogs */
/*---------------------------------------------------------------------------*/
/* Date Ver Who Comment */
/* -------- ---- --- ------- */
/* 18.03.14 1.00 Lad The first version of DlgSimple.cpp */
/*****************************************************************************/
#include "FileTest.h"
#include "resource.h"
//-----------------------------------------------------------------------------
// Local functions
static void SetWindowModuleVersion(HWND hWndChild, LPCTSTR szModuleName)
{
ULARGE_INTEGER Version;
TCHAR szFormat[255];
TCHAR szText[255];
// Is such window really there ?
if(hWndChild != NULL)
{
GetWindowText(hWndChild, szFormat, _countof(szFormat));
GetModuleVersion(szModuleName, &Version);
StringCchPrintf(szText, _countof(szText), szFormat,
HIWORD(Version.HighPart),
LOWORD(Version.HighPart),
HIWORD(Version.LowPart),
LOWORD(Version.LowPart));
SetWindowText(hWndChild, szText);
}
}
//-----------------------------------------------------------------------------
// Event handlers
static int OnInitDialog(HWND hDlg, LPARAM /* lParam */)
{
TCHAR szMyName[MAX_PATH + 1];
HWND hWndChild;
// Set the dialog icon
SetDialogIcon(hDlg, IDI_FILE_TEST);
// Parse all child windows
// If there is IDC_VERSION static text, supply the 4-digit version from resources
hWndChild = GetDlgItem(hDlg, IDC_FILETEST_WEB);
if(hWndChild != NULL)
InitURLButton(hDlg, IDC_FILETEST_WEB, FALSE);
// If there is IDC_VERSION static text, supply the 4-digit version from resources
hWndChild = GetDlgItem(hDlg, IDC_VERSION);
if(hWndChild != NULL)
{
GetModuleFileName(NULL, szMyName, MAX_PATH);
SetWindowModuleVersion(hWndChild, szMyName);
}
return TRUE;
}
static BOOL OnCommand(HWND hDlg, HWND hWndFrom, UINT nNotifyCode, UINT nCtrlID)
{
if(nNotifyCode == BN_CLICKED)
{
// An URL button leads to opening its WWW page
if(IsURLButton(hWndFrom))
{
ClickURLButton(hWndFrom);
return TRUE;
}
// Any other button closes the dialog
EndDialog(hDlg, nCtrlID);
return TRUE;
}
return FALSE;
}
//-----------------------------------------------------------------------------
// Message handler
static INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
return OnInitDialog(hDlg, lParam);
case WM_DRAWITEM:
DrawURLButton(hDlg, (LPDRAWITEMSTRUCT)lParam);
return FALSE;
case WM_COMMAND:
return OnCommand(hDlg, (HWND)lParam, HIWORD(wParam), LOWORD(wParam));
}
return FALSE;
}
//-----------------------------------------------------------------------------
// Dialog functions
INT_PTR HelpAboutDialog(HWND hParent)
{
return DialogBox(g_hInst, MAKEINTRESOURCE(IDD_HELP_ABOUT), hParent, DialogProc);
}
INT_PTR ObjectIDActionDialog(HWND hParent)
{
return DialogBox(g_hInst, MAKEINTRESOURCE(IDD_OBJECT_ID_MORE), hParent, DialogProc);
}
INT_PTR ObjectGuidHelpDialog(HWND hParent)
{
return DialogBox(g_hInst, MAKEINTRESOURCE(IDD_OBJECT_GUID_HELP), hParent, DialogProc);
}