home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / Chip_2002-02_cd1.bin / sharewar / apaths / APSOURCE.ZIP / AboutTab.c next >
C/C++ Source or Header  |  2001-03-26  |  7KB  |  195 lines

  1. /* AboutTab - March 26th, 2001
  2. **
  3. **      Copyright (c) 1997-2001 by Gregory Braun. All rights reserved.
  4. **
  5. **      This routine displays information about the AppPaths Control Panel
  6. **      applet. Private (static) routines are included to initialize the
  7. **      property page sheet when first invoked.
  8. **
  9. **      Called:     dlg = handle to the dialog window.
  10. **                  msg = the MS Windows WM_xxxxxx message to be handled.
  11. **                  wp  = the WPARAM specific to the message being sent
  12. **                  lp  = the LPARAM specific to the message being sent
  13. **
  14. **      Returns:    TRUE upon success, or FALSE if the user pressed [Cancel],
  15. **                  or an internal error exists.
  16. **
  17. **      Notes:      The VERSION resource is read and the information found
  18. **                  there is used as the text for this property sheet.
  19. **
  20. **                  If the initialization routine fails to find the VERSION
  21. **                  resource the default fields as specified in the dialog
  22. **                  box template are used in their place.
  23. **
  24. **                  Information about the AppPaths module is recorded in
  25. **                  four (4) places:
  26. **
  27. **                      The VERSION resource
  28. **                      The dialog box template
  29. **                      The APP_xxxx string resource IDs
  30. **                      The AboutTab function itself.
  31. **
  32. **                  Changes must be made to all four of these locations
  33. **                  to insure the proper display of version information
  34. **                  on all MS Windows 95/98/NT systems.
  35. **
  36. */
  37.  
  38. #include "AppPaths.h"
  39.  
  40. static VERSION  version = {
  41.                             "ProductName",      BLANK_STR,APP_NAME,        "Application Paths 2000",
  42.                             "LegalCopyright",   BLANK_STR,APP_COPYRIGHT,   "⌐ 1997-2001 Gregory Braun. All rights reserved.",
  43.                             "FileDescription",  BLANK_STR,APP_DESCRIPTION, "MS Windows Application Paths Control Panel Applet",
  44.                             "FileVersion",      BLANK_STR,APP_VERSION,     "Version 2.5",
  45.                             "Release",          BLANK_STR,APP_RELEASE,     "This software is distributed as freeware. You may copy and distribute this program as long as all copyright notices remain intact and the application files are not modified in any way.",
  46.                             "Comments",         BLANK_STR,APP_COMMENTS,    "Visit the Software Design Web Site on the Internet to download the latest versions of all my software programs. Free source code for this Control Panel Applet is also available there.",
  47.                             "WebSite",          BLANK_STR,APP_WEBSITE,     "http://www.gregorybraun.com",
  48.                           };
  49.  
  50.  
  51. static BOOL             initiate    (HWND dlg);
  52. static BOOL             verify      (HWND dlg);
  53. static BOOL             website     (HWND dlg,int item);
  54.  
  55. extern UINT CALLBACK AboutTab (HWND dlg,UINT msg,WPARAM wp,LPARAM lp)
  56. {
  57.     auto int                item = LOWORD (wp);
  58.  
  59.     auto BOOL               good;
  60.  
  61.     switch (msg) {
  62.  
  63.         case WM_COMMAND :
  64.  
  65.              switch (item) {
  66.  
  67.                  case ABOUT_WEBSITE_BTN :
  68.                       website (dlg,item);
  69.                       break;
  70.                       }
  71.  
  72.              break;
  73.  
  74.         case WM_HELP :
  75.              HelpTip (dlg,((LPHELPINFO) lp)->iCtrlId);
  76.              break;
  77.  
  78.         case WM_NOTIFY :
  79.  
  80.              switch (((LPNMHDR) lp)->code) {
  81.  
  82.                 case PSN_SETACTIVE :
  83.                      initiate (dlg);
  84.                      break;
  85.  
  86.                 case PSN_KILLACTIVE :
  87.                      good = verify (dlg);
  88.                      SetWindowLong (dlg,DWL_MSGRESULT,!good);
  89.                      return ((good) ? FALSE : TRUE);
  90.                      break;
  91.  
  92.                 case PSN_APPLY :
  93.                      good = verify (dlg);
  94.                      SetWindowLong (dlg,DWL_MSGRESULT,good);
  95.                      return ((good) ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE);
  96.                      break;
  97.  
  98.                 case PSN_HELP :
  99.                      HelpTopic (dlg,ABOUT_TAB);
  100.                      break;
  101.  
  102.  
  103.                default :
  104.                      break;
  105.                      }
  106.  
  107.              break;
  108.  
  109.         break;
  110.         }
  111.  
  112.      return (FALSE);
  113. }
  114.  
  115. static BOOL initiate (HWND dlg)
  116. {
  117.     auto LPSTR      info    = NULL;
  118.     auto UINT       lid     = GetUserDefaultLangID ();
  119.  
  120.     auto int        inx;
  121.  
  122.     auto DWORD      size;
  123.     auto DWORD      status;
  124.  
  125.     auto UINT       count;
  126.  
  127.     auto UINT       language;
  128.     auto UINT       *translation;
  129.  
  130.     auto LPSTR      ptr;
  131.  
  132.     auto char       string[PSTRING];
  133.     auto char       windows[PSTRING];
  134.     auto char       unicode[PSTRING];
  135.  
  136.     if ((size = GetFileVersionInfoSize (program,&status)) == NIL)
  137.         goto fail;
  138.  
  139.     if ((info = GlobalAllocPtr (GHND,size)) == NULL)
  140.         goto fail;
  141.  
  142.     if (!GetFileVersionInfo (program,NIL,size,info))
  143.         goto fail;
  144.  
  145.     if (!VerQueryValue (info,VARFILEINFO_STR,(void **)&translation,&count))
  146.         goto fail;
  147.  
  148.     language = MAKELONG (HIWORD (*translation),LOWORD (*translation));
  149.  
  150.     for (inx = NIL; inx < VERSION_ITEM_MAX; inx++) {
  151.  
  152.         wsprintf (windows,WIN_RES_FMT,lid,version.item[inx].label);
  153.         wsprintf (unicode,UNI_RES_FMT,lid,version.item[inx].label);
  154.         wsprintf (string, LNG_RES_FMT,language,version.item[inx].label);
  155.  
  156.         if (VerQueryValue (info,windows,&ptr,&count))
  157.             lstrcpy (version.item[inx].value,ptr);
  158.  
  159.         else if (VerQueryValue (info,unicode,&ptr,&count))
  160.             lstrcpy (version.item[inx].value,ptr);
  161.  
  162.         else if (VerQueryValue (info,string,&ptr,&count))
  163.             lstrcpy (version.item[inx].value,ptr);
  164.  
  165.         else if (!LoadString (applet,version.item[inx].id,version.item[inx].value,PSTRING))
  166.             lstrcpy (version.item[inx].value,version.item[inx].sub);
  167.  
  168.         SetDlgItemText (dlg,ABOUT_NAME_TXT + inx,version.item[inx].value);
  169.         }
  170.  
  171. fail:
  172.  
  173.     if (info) GlobalFreePtr (info);
  174.  
  175.     return (TRUE);
  176. }
  177.  
  178. static BOOL verify (HWND dlg)
  179. {
  180.     UNUSED_ARG (dlg);
  181.  
  182.     return (TRUE);
  183. }
  184.  
  185. static BOOL website (HWND dlg,int item)
  186. {
  187.     auto char   text[PSTRING];
  188.  
  189.     GetDlgItemText (dlg,item,text,PSTRING);
  190.  
  191.     return (WebSite (dlg,text));
  192. }
  193.  
  194. /* end of AboutTab.c - written by Gregory Braun */
  195.