[rst-commit] r194 - in /redwax-signtext-windows/trunk/Redwax SignText/Redwax SignText (MFC): Redwax SignText (MFC)Dlg.cpp RedwaxSignTextMFC.rc Resource.h

rst-commit at redwax.eu rst-commit at redwax.eu
Sat Jul 27 23:02:34 CEST 2024


Author: minfrin at redwax.eu
Date: Sat Jul 27 23:02:32 2024
New Revision: 194

Log:
Extract the version number in the about box from the application.

Modified:
    redwax-signtext-windows/trunk/Redwax SignText/Redwax SignText (MFC)/Redwax SignText (MFC)Dlg.cpp
    redwax-signtext-windows/trunk/Redwax SignText/Redwax SignText (MFC)/RedwaxSignTextMFC.rc
    redwax-signtext-windows/trunk/Redwax SignText/Redwax SignText (MFC)/Resource.h

Modified: redwax-signtext-windows/trunk/Redwax SignText/Redwax SignText (MFC)/Redwax SignText (MFC)Dlg.cpp
==============================================================================
--- redwax-signtext-windows/trunk/Redwax SignText/Redwax SignText (MFC)/Redwax SignText (MFC)Dlg.cpp	(original)
+++ redwax-signtext-windows/trunk/Redwax SignText/Redwax SignText (MFC)/Redwax SignText (MFC)Dlg.cpp	Sat Jul 27 23:02:32 2024
@@ -23,6 +23,7 @@
 #include <wininet.h>
 
 #pragma comment(lib, "wininet.lib")
+#pragma comment(lib, "version.lib")
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -35,6 +36,8 @@
 {
 public:
 	CAboutDlg();
+
+	CStatic m_Version;
 
 // Dialog Data
 #ifdef AFX_DESIGN_TIME
@@ -46,6 +49,10 @@
 
 // Implementation
 protected:
+	// Generated message map functions
+	//{{AFX_MSG(CAboutPage)
+	virtual BOOL OnInitDialog();
+	//}}AFX_MSG
 	DECLARE_MESSAGE_MAP()
 };
 
@@ -86,17 +93,68 @@
 {
 }
 
+BOOL CAboutDlg::OnInitDialog() {
+	CDialog::OnInitDialog();
+
+	DWORD dwHandle;
+	TCHAR fileName[MAX_PATH];
+
+	HINSTANCE hInst = AfxGetInstanceHandle();
+
+	GetModuleFileName(hInst, fileName, MAX_PATH);
+	DWORD dwSize = GetFileVersionInfoSize(fileName, &dwHandle);
+	HANDLE hMem = GlobalAlloc(GMEM_MOVEABLE, dwSize);
+	LPVOID lpvMem = GlobalLock(hMem);
+
+	VS_FIXEDFILEINFO* pvFileInfo = NULL;
+	UINT fiLen = 0;
+
+	if ((dwSize > 0) && GetFileVersionInfo(fileName, dwHandle, dwSize, lpvMem))
+	{
+		VerQueryValue(lpvMem, L"\\", (LPVOID*)&pvFileInfo, &fiLen);
+	}
+
+	if (fiLen > 0)
+	{
+		wchar_t szResult[MAX_PATH];
+		int len;
+
+		HWND hDlg = GetSafeHwnd();
+
+		WORD major = HIWORD(pvFileInfo->dwFileVersionMS);
+		WORD minor = LOWORD(pvFileInfo->dwFileVersionMS);
+		WORD patch = HIWORD(pvFileInfo->dwFileVersionLS);
+		WORD build = LOWORD(pvFileInfo->dwFileVersionLS);
+
+		if (build) {
+
+			len = swprintf(szResult, MAX_PATH, _T("Version %hu.%hu.%hu (%hu)"),
+				major, minor, patch, build);
+
+		}
+		else {
+
+			len = swprintf(szResult, MAX_PATH, _T("Version %hu.%hu.%hu"),
+				major, minor, patch);
+		}
+
+		m_Version.SetWindowText(szResult);
+	}
+
+	GlobalUnlock(hMem);
+	GlobalFree(hMem);
+
+	return TRUE;
+}
+
 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
 {
 	CDialogEx::DoDataExchange(pDX);
+	DDX_Control(pDX, IDC_VERSION, m_Version);
 }
 
 BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
 END_MESSAGE_MAP()
-
-
-// CRedwaxSignTextMFCDlg dialog
-
 
 
 CRedwaxSignTextMFCDlg::CRedwaxSignTextMFCDlg(CWnd* pParent /*=nullptr*/)

Modified: redwax-signtext-windows/trunk/Redwax SignText/Redwax SignText (MFC)/RedwaxSignTextMFC.rc
==============================================================================
Binary files - no diff available.

Modified: redwax-signtext-windows/trunk/Redwax SignText/Redwax SignText (MFC)/Resource.h
==============================================================================
--- redwax-signtext-windows/trunk/Redwax SignText/Redwax SignText (MFC)/Resource.h	(original)
+++ redwax-signtext-windows/trunk/Redwax SignText/Redwax SignText (MFC)/Resource.h	Sat Jul 27 23:02:32 2024
@@ -13,6 +13,9 @@
 #define IDC_CERTIFICATEBOX              1017
 #define IDC_PINTEXT                     1019
 #define IDSIGN                          1020
+#define IDC_COPYRIGHT                   1021
+#define IDC_VERSION                     1022
+#define IDC_PRODUCT                     1023
 
 // Next default values for new objects
 // 
@@ -20,7 +23,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        133
 #define _APS_NEXT_COMMAND_VALUE         32771
-#define _APS_NEXT_CONTROL_VALUE         1021
+#define _APS_NEXT_CONTROL_VALUE         1023
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif



More information about the rst-commit mailing list