home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / EXPERT.PAK / TDIALOG.OWL < prev    next >
Text File  |  1995-08-29  |  7KB  |  244 lines

  1. '////////////////////////////////////////////////////////////////////////////////////   
  2. '   Expert PROJECT
  3. '   Expert - (C) Copyright 1993 by Borland International, Inc. All Rights Reserved.
  4. '
  5. '   SUBSYSTEM:    OWL code template
  6. '   FILE:         TDialog.OWL
  7. '
  8. '
  9. '   OVERVIEW
  10. '   ========
  11. '   Definition of all OWL classes when can be generated by  the CODEGEN phase of
  12. '   AppGen and ClassExpert.  AppGen generates when all options have been selected
  13. '   and multiple classes are generated.  ClassExpert uses the CODEGEN phase when
  14. '   a new class is generated.
  15. '////////////////////////////////////////////////////////////////////////////////////   
  16.  
  17.  
  18. <<[H]TDialog [[TDialog]]
  19. ##{hheader.snp}
  20. #include <owl\owlpch.h>
  21. #pragma hdrstop
  22.  
  23. ##<<TApplication QUERY_FILENAME_CPP [[Filename]]
  24. #include "[[Filename]].rh"                  // Definition of all resources.
  25.  
  26.  
  27. //{{TDialog = [[TDialog]]}}
  28. class [[TDialog]] : public TDialog {
  29. public:
  30. ##QUERY_DLOG [[DLogRsrc]]
  31.     [[TDialog]] (TWindow *parent, TResId resId = [[DLogRsrc]], TModule *module = 0);
  32.     virtual ~[[TDialog]] ();
  33.  
  34. //{{[[TDialog]]VIRTUAL_BEGIN}}
  35. public:
  36.     void SetupWindow ();
  37. ##:DBVirtual(\\"[[TDialog]]", "SetupWindow")
  38. //{{[[TDialog]]VIRTUAL_END}}
  39. };    //{{[[TDialog]]}}
  40.  
  41.  
  42. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
  43. // Reading the VERSIONINFO resource.
  44. class ProjectRCVersion {
  45. public:
  46.     ProjectRCVersion (TModule *module);
  47.     virtual ~ProjectRCVersion ();
  48.  
  49.     bool GetProductName (LPSTR &prodName);
  50.     bool GetProductVersion (LPSTR &prodVersion);
  51.     bool GetCopyright (LPSTR ©right);
  52.     bool GetDebug (LPSTR &debug);
  53.  
  54. protected:
  55.     LPBYTE      TransBlock;
  56.     void FAR    *FVData;
  57.  
  58. private:
  59. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
  60.     // Don't allow this object to be copied.
  61.     ProjectRCVersion (const ProjectRCVersion &);
  62.     ProjectRCVersion & operator =(const ProjectRCVersion &);
  63. };
  64. ##{hfooter.snp}
  65. >>[H]TDialog [[TDialog]]
  66.  
  67.  
  68. '
  69. ' TDialog CPP file.
  70. '
  71. <<[CPP]TDialog [[TDialog]]
  72. ##{cheader.snp}
  73. #include <owl\owlpch.h>
  74. #pragma hdrstop
  75.  
  76. #if !defined(__FLAT__)
  77. #include <ver.h>
  78. #endif
  79.  
  80. ##<<TApplication QUERY_FILE_H [[FileName]]
  81. #include "[[FileName]]"
  82. ##QUERY_FILE_H [[FileName]]
  83. #include "[[FileName]]"
  84.  
  85.  
  86. ProjectRCVersion::ProjectRCVersion (TModule *module)
  87. {
  88.     char    appFName[255];
  89.     char    subBlockName[255];
  90.     DWORD   fvHandle;
  91.     UINT    vSize;
  92.  
  93.     FVData = 0;
  94.  
  95.     module->GetModuleFileName(appFName, sizeof(appFName));
  96.     OemToAnsi(appFName, appFName);
  97.     DWORD dwSize = ::GetFileVersionInfoSize(appFName, &fvHandle);
  98.     if (dwSize) {
  99.         FVData  = (void FAR *)new char[(UINT)dwSize];
  100.         if (::GetFileVersionInfo(appFName, fvHandle, dwSize, FVData)) {
  101.             // Copy string to buffer so if the -dc compiler switch (Put constant strings in code segments)
  102.             // is on VerQueryValue will work under Win16.  This works around a problem in Microsoft's ver.dll
  103.             // which writes to the string pointed to by subBlockName.
  104.             strcpy(subBlockName, "\\VarFileInfo\\Translation"); 
  105.             if (!::VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&TransBlock, &vSize)) {
  106.                 delete FVData;
  107.                 FVData = 0;
  108.             } else
  109.                 // Swap the words so wsprintf will print the lang-charset in the correct format.
  110.                 *(DWORD *)TransBlock = MAKELONG(HIWORD(*(DWORD *)TransBlock), LOWORD(*(DWORD *)TransBlock));
  111.         }
  112.     }
  113. }
  114.  
  115.  
  116. ProjectRCVersion::~ProjectRCVersion ()
  117. {
  118.     if (FVData)
  119.         delete FVData;
  120. }
  121.  
  122.  
  123. bool ProjectRCVersion::GetProductName (LPSTR &prodName)
  124. {
  125.     UINT    vSize;
  126.     char    subBlockName[255];
  127.  
  128.     if (FVData) {
  129.         wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"ProductName");
  130.         return FVData ? ::VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&prodName, &vSize) : false;
  131.     } else
  132.         return false;
  133. }
  134.  
  135.  
  136. bool ProjectRCVersion::GetProductVersion (LPSTR &prodVersion)
  137. {
  138.     UINT    vSize;
  139.     char    subBlockName[255];
  140.  
  141.     if (FVData) {
  142.         wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"ProductVersion");
  143.         return FVData ? ::VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&prodVersion, &vSize) : false;
  144.     } else
  145.         return false;
  146. }
  147.  
  148.  
  149. bool ProjectRCVersion::GetCopyright (LPSTR ©right)
  150. {
  151.     UINT    vSize;
  152.     char    subBlockName[255];
  153.  
  154.     if (FVData) {
  155.         wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"LegalCopyright");
  156.         return FVData ? ::VerQueryValue(FVData, subBlockName, (void FAR* FAR*)©right, &vSize) : false;
  157.     } else
  158.         return false;
  159. }
  160.  
  161.  
  162. bool ProjectRCVersion::GetDebug (LPSTR &debug)
  163. {
  164.     UINT    vSize;
  165.     char    subBlockName[255];
  166.  
  167.     if (FVData) {
  168.         wsprintf(subBlockName, "\\StringFileInfo\\%08lx\\%s", *(DWORD *)TransBlock, (LPSTR)"SpecialBuild");
  169.         return FVData ? ::VerQueryValue(FVData, subBlockName, (void FAR* FAR*)&debug, &vSize) : false;
  170.     } else
  171.         return false;
  172. }
  173.  
  174.  
  175. //{{[[TDialog]] Implementation}}
  176.  
  177.  
  178. ##--BEGIN-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  179. //////////////////////////////////////////////////////////
  180. // [[TDialog]]
  181. // ==========
  182. // Construction/Destruction handling.
  183. ##--END-- @QUERY_APPL_COMMENT == VALUE_VERBOSE
  184. [[TDialog]]::[[TDialog]] (TWindow *parent, TResId resId, TModule *module)
  185.     : TDialog(parent, resId, module)
  186. {
  187.     // INSERT>> Your constructor code here.
  188. }
  189.  
  190.  
  191. [[TDialog]]::~[[TDialog]] ()
  192. {
  193.     Destroy();
  194.  
  195.     // INSERT>> Your destructor code here.
  196. }
  197.  
  198.  
  199. void [[TDialog]]::SetupWindow ()
  200. {
  201.     LPSTR prodName = 0, prodVersion = 0, copyright = 0, debug = 0;
  202.  
  203. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
  204.     // Get the static text for the value based on VERSIONINFO.
  205.     TStatic *versionCtrl = new TStatic(this, IDC_VERSION, 255);
  206.     TStatic *copyrightCtrl = new TStatic(this, IDC_COPYRIGHT, 255);
  207.     TStatic *debugCtrl = new TStatic(this, IDC_DEBUG, 255);
  208.  
  209.     TDialog::SetupWindow();
  210.  
  211. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
  212.     // Process the VERSIONINFO.
  213.     ProjectRCVersion applVersion(GetModule());
  214.  
  215. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
  216.     // Get the product name and product version strings.
  217.     if (applVersion.GetProductName(prodName) && applVersion.GetProductVersion(prodVersion)) {
  218. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE 2
  219.         // IDC_VERSION is the product name and version number, the initial value of IDC_VERSION is
  220.         // the word Version (in whatever language) product name VERSION product version.
  221.         char    buffer[255];
  222.         char    versionName[128];
  223.  
  224.         buffer[0] = '\0';
  225.         versionName[0] = '\0';
  226.  
  227.         versionCtrl->GetText(versionName, sizeof(versionName));
  228.         wsprintf(buffer, "%s %s %s", prodName, versionName, prodVersion);
  229.  
  230.         versionCtrl->SetText(buffer);
  231.     }
  232.  
  233. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
  234.     //Get the legal copyright string.
  235.     if (applVersion.GetCopyright(copyright))
  236.         copyrightCtrl->SetText(copyright);
  237.  
  238. ##:@QUERY_APPL_COMMENT == VALUE_VERBOSE
  239.     // Only get the SpecialBuild text if the VERSIONINFO resource is there.
  240.     if (applVersion.GetDebug(debug))
  241.         debugCtrl->SetText(debug);
  242. }
  243. >>[CPP]TDialog [[TDialog]]
  244.