|
| 1 | +/** |
| 2 | +
|
| 3 | + This module defines a class which represents the main form for the application which displays a |
| 4 | + treeview of the RAD Studio installations and the Experts, Known Packages and Know IDE Packages |
| 5 | + within each installation. |
| 6 | +
|
| 7 | + @Author David Hoyle |
| 8 | + @Version 1.0 |
| 9 | + @Date 13 Jul 2019 |
| 10 | +
|
| 11 | + @license |
| 12 | +
|
| 13 | + Expert Manager - a C++ Builder application for managing RAD Studio Experts (DLL and Packages) |
| 14 | + in multiple version of RAD Studio. |
| 15 | + |
| 16 | + Copyright (C) 2019 David Hoyle (https://github.com/DGH2112/Expert-Manager) |
| 17 | +
|
| 18 | + This program is free software: you can redistribute it and/or modify |
| 19 | + it under the terms of the GNU General Public License as published by |
| 20 | + the Free Software Foundation, either version 3 of the License, or |
| 21 | + (at your option) any later version. |
| 22 | +
|
| 23 | + This program is distributed in the hope that it will be useful, |
| 24 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 | + GNU General Public License for more details. |
| 27 | +
|
| 28 | + You should have received a copy of the GNU General Public License |
| 29 | + along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 30 | +
|
| 31 | + @todo Consider replacing the list veiws and treeview with TVirtualStringTree instances. |
| 32 | + @todo Or instead of the above maintain the lists in the background and sync them with the listview |
| 33 | + so the listviews do not need rendering for each change. |
| 34 | +
|
| 35 | +**/ |
| 36 | +#include <vcl.h> |
| 37 | +#include <memory> |
| 38 | +#pragma hdrstop |
| 39 | + |
| 40 | +#include "ExpertMgrAboutBoxForm.h" |
| 41 | + |
| 42 | +#pragma package(smart_init) |
| 43 | +#pragma resource "*.dfm" |
| 44 | +TfrmExpertMgrAboutBox *frmExpertMgrAboutBox; |
| 45 | + |
| 46 | +/** |
| 47 | + |
| 48 | + This is the constructor for the TfrmExpertMgrAboutBox class. |
| 49 | +
|
| 50 | + @precon None. |
| 51 | + @postcon None. |
| 52 | + |
| 53 | +**/ |
| 54 | +__fastcall TfrmExpertMgrAboutBox::TfrmExpertMgrAboutBox(TComponent* Owner) : TForm(Owner) {} |
| 55 | + |
| 56 | +/** |
| 57 | + |
| 58 | + This method invokes the About Box. |
| 59 | +
|
| 60 | + @precon None. |
| 61 | + @postcon The About Box is displayed on the form. |
| 62 | + |
| 63 | +**/ |
| 64 | +void TfrmExpertMgrAboutBox::Execute() { |
| 65 | + std::unique_ptr<TfrmExpertMgrAboutBox> F( new TfrmExpertMgrAboutBox( Application->MainForm )); |
| 66 | + F->ShowModal(); |
| 67 | +} |
| 68 | + |
| 69 | +/** |
| 70 | + |
| 71 | + This method is an on create event hander for the form. |
| 72 | +
|
| 73 | + @precon None. |
| 74 | + @postcon Updates some of the controls on the form before it is displayed. |
| 75 | +
|
| 76 | + @param Sender as a TObject |
| 77 | + |
| 78 | +**/ |
| 79 | +void __fastcall TfrmExpertMgrAboutBox::FormCreate(TObject *Sender) { |
| 80 | + TDateTime dtDateTime = 0; |
| 81 | + FileAge(ParamStr(0), dtDateTime); |
| 82 | + lblBuildDate->Caption = L"Build Date: " + FormatDateTime("ddd dd mmm yyyy @ hh:nn", dtDateTime); |
| 83 | + DWORD iVerHandle = NULL; |
| 84 | + String strFileName = ParamStr(0); |
| 85 | + DWORD iVerInfoSize = GetFileVersionInfoSize(ParamStr(0).c_str(), &iVerHandle); |
| 86 | + if (iVerInfoSize) { |
| 87 | + LPSTR VerInfo = new char [iVerInfoSize]; |
| 88 | + try { |
| 89 | + if (GetFileVersionInfo(ParamStr(0).c_str(), iVerHandle, iVerInfoSize, VerInfo)) { |
| 90 | + unsigned int iVerValueSize = 0; |
| 91 | + LPBYTE lpBuffer = NULL; |
| 92 | + if (VerQueryValue(VerInfo, TEXT("\\"), (VOID FAR* FAR*)&lpBuffer, &iVerValueSize)) { |
| 93 | + if (iVerValueSize) { |
| 94 | + VS_FIXEDFILEINFO *VerValue = (VS_FIXEDFILEINFO *)lpBuffer; |
| 95 | + int iMajor = VerValue->dwFileVersionMS >> 16; |
| 96 | + int iMinor = VerValue->dwFileVersionMS & 0xFFFF; |
| 97 | + int iBugFix = VerValue->dwFileVersionLS >> 16; |
| 98 | + int iBuild = VerValue->dwFileVersionLS & 0xFFFF; |
| 99 | + String strBugFix = " abcedfghijklmnopqrstuvwxyz"; |
| 100 | + #ifdef DEBUG |
| 101 | + String strBuildMsg = "Expert Manager %d.%d%s (DEBUG Build %d.%d.%d.%d)"; |
| 102 | + #else |
| 103 | + String strBuildMsg = "Expert Manager %d.%d%s (Build %d.%d.%d.%d)"; |
| 104 | + #endif |
| 105 | + lblBuild->Caption = Format(strBuildMsg, |
| 106 | + ARRAYOFCONST((iMajor, iMinor, strBugFix[iBugFix + 1], iMajor, iMinor, iBugFix, iBuild))); |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + } __finally { |
| 111 | + delete[] VerInfo; |
| 112 | + } |
| 113 | + } |
| 114 | +} |
| 115 | + |
0 commit comments