home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / GETDLL.ZIP / DllInfoDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-12  |  6.6 KB  |  247 lines

  1. // DllInfoDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DllInfo.h"
  6. #include "DllInfoDlg.h"
  7. #include "LibraryInfo.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CAboutDlg dialog used for App About
  17.  
  18. class CAboutDlg : public CDialog
  19. {
  20. public:
  21.     CAboutDlg();
  22.  
  23. // Dialog Data
  24.     //{{AFX_DATA(CAboutDlg)
  25.     enum { IDD = IDD_ABOUTBOX };
  26.     //}}AFX_DATA
  27.  
  28.     // ClassWizard generated virtual function overrides
  29.     //{{AFX_VIRTUAL(CAboutDlg)
  30.     protected:
  31.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  32.     //}}AFX_VIRTUAL
  33.  
  34. // Implementation
  35. protected:
  36.     //{{AFX_MSG(CAboutDlg)
  37.     //}}AFX_MSG
  38.     DECLARE_MESSAGE_MAP()
  39. };
  40.  
  41. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  42. {
  43.     //{{AFX_DATA_INIT(CAboutDlg)
  44.     //}}AFX_DATA_INIT
  45. }
  46.  
  47. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  48. {
  49.     CDialog::DoDataExchange(pDX);
  50.     //{{AFX_DATA_MAP(CAboutDlg)
  51.     //}}AFX_DATA_MAP
  52. }
  53.  
  54. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  55.     //{{AFX_MSG_MAP(CAboutDlg)
  56.         // No message handlers
  57.     //}}AFX_MSG_MAP
  58. END_MESSAGE_MAP()
  59.  
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CDllInfoDlg dialog
  62.  
  63. CDllInfoDlg::CDllInfoDlg(CWnd* pParent /*=NULL*/)
  64.     : CDialog(CDllInfoDlg::IDD, pParent)
  65. {
  66.     //{{AFX_DATA_INIT(CDllInfoDlg)
  67.     m_szDllName = _T("");
  68.     m_szCompanyName = _T("");
  69.     m_szCopyRight = _T("");
  70.     m_szDescription = _T("");
  71.     m_szFileOS = _T("");
  72.     m_szFileType = _T("");
  73.     m_szFileVersion = _T("");
  74.     m_szInternalName = _T("");
  75.     m_szOriginalName = _T("");
  76.     m_szProductName = _T("");
  77.     m_szProductVersion = _T("");
  78.     m_szVersion = _T("");
  79.     //}}AFX_DATA_INIT
  80.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  81.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  82. }
  83.  
  84. void CDllInfoDlg::DoDataExchange(CDataExchange* pDX)
  85. {
  86.     CDialog::DoDataExchange(pDX);
  87.     //{{AFX_DATA_MAP(CDllInfoDlg)
  88.     DDX_Control(pDX, IDC_VERSION_STATIC, m_VersionStatic);
  89.     DDX_Control(pDX, IDC_PRODVER_STATIC, m_ProdVsnStatic);
  90.     DDX_Control(pDX, IDC_PRODNAME_STATIC, m_ProdNameStatic);
  91.     DDX_Control(pDX, IDC_ORIGNAME_STATIC, m_OrigNameStatic);
  92.     DDX_Control(pDX, IDC_INTNAME_STATIC, m_InternalNameStatic);
  93.     DDX_Control(pDX, IDC_FILEVER_STATIC, m_FileVsnStatic);
  94.     DDX_Control(pDX, IDC_FILEOS_STATIC, m_FileOSStatic);
  95.     DDX_Control(pDX, IDC_DESC_STATIC, m_DescriptionStatic);
  96.     DDX_Control(pDX, IDC_COPYRIGHT_STATIC, m_CopyRightStatic);
  97.     DDX_Control(pDX, IDC_COMPNAME_STATIC, m_CompNameStatic);
  98.     DDX_Control(pDX, IDC_FILETYPE_STATIC, m_FileTypeStaic);
  99.     DDX_Control(pDX, IDC_DLLNAME_EDIT, m_DllNameEdit);
  100.     DDX_Text(pDX, IDC_DLLNAME_EDIT, m_szDllName);
  101.     DDX_Text(pDX, IDC_COMPNAME_STATIC, m_szCompanyName);
  102.     DDX_Text(pDX, IDC_COPYRIGHT_STATIC, m_szCopyRight);
  103.     DDX_Text(pDX, IDC_DESC_STATIC, m_szDescription);
  104.     DDX_Text(pDX, IDC_FILEOS_STATIC, m_szFileOS);
  105.     DDX_Text(pDX, IDC_FILETYPE_STATIC, m_szFileType);
  106.     DDX_Text(pDX, IDC_FILEVER_STATIC, m_szFileVersion);
  107.     DDX_Text(pDX, IDC_INTNAME_STATIC, m_szInternalName);
  108.     DDX_Text(pDX, IDC_ORIGNAME_STATIC, m_szOriginalName);
  109.     DDX_Text(pDX, IDC_PRODNAME_STATIC, m_szProductName);
  110.     DDX_Text(pDX, IDC_PRODVER_STATIC, m_szProductVersion);
  111.     DDX_Text(pDX, IDC_VERSION_STATIC, m_szVersion);
  112.     //}}AFX_DATA_MAP
  113. }
  114.  
  115. BEGIN_MESSAGE_MAP(CDllInfoDlg, CDialog)
  116.     //{{AFX_MSG_MAP(CDllInfoDlg)
  117.     ON_WM_SYSCOMMAND()
  118.     ON_WM_PAINT()
  119.     ON_WM_QUERYDRAGICON()
  120.     ON_EN_CHANGE(IDC_DLLNAME_EDIT, OnChangeDllnameEdit)
  121.     //}}AFX_MSG_MAP
  122. END_MESSAGE_MAP()
  123.  
  124. /////////////////////////////////////////////////////////////////////////////
  125. // CDllInfoDlg message handlers
  126.  
  127. BOOL CDllInfoDlg::OnInitDialog()
  128. {
  129.     CDialog::OnInitDialog();
  130.  
  131.     // Add "About..." menu item to system menu.
  132.  
  133.     // IDM_ABOUTBOX must be in the system command range.
  134.     ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  135.     ASSERT(IDM_ABOUTBOX < 0xF000);
  136.  
  137.     CMenu* pSysMenu = GetSystemMenu(FALSE);
  138.     if (pSysMenu != NULL)
  139.     {
  140.         CString strAboutMenu;
  141.         strAboutMenu.LoadString(IDS_ABOUTBOX);
  142.         if (!strAboutMenu.IsEmpty())
  143.         {
  144.             pSysMenu->AppendMenu(MF_SEPARATOR);
  145.             pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  146.         }
  147.     }
  148.  
  149.     // Set the icon for this dialog.  The framework does this automatically
  150.     //  when the application's main window is not a dialog
  151.     SetIcon(m_hIcon, TRUE);            // Set big icon
  152.     SetIcon(m_hIcon, FALSE);        // Set small icon
  153.     
  154.     // TODO: Add extra initialization here
  155.     
  156.     return TRUE;  // return TRUE  unless you set the focus to a control
  157. }
  158.  
  159. void CDllInfoDlg::OnSysCommand(UINT nID, LPARAM lParam)
  160. {
  161.     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  162.     {
  163.         CAboutDlg dlgAbout;
  164.         dlgAbout.DoModal();
  165.     }
  166.     else
  167.     {
  168.         CDialog::OnSysCommand(nID, lParam);
  169.     }
  170. }
  171.  
  172. // If you add a minimize button to your dialog, you will need the code below
  173. //  to draw the icon.  For MFC applications using the document/view model,
  174. //  this is automatically done for you by the framework.
  175.  
  176. void CDllInfoDlg::OnPaint() 
  177. {
  178.     if (IsIconic())
  179.     {
  180.         CPaintDC dc(this); // device context for painting
  181.  
  182.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  183.  
  184.         // Center icon in client rectangle
  185.         int cxIcon = GetSystemMetrics(SM_CXICON);
  186.         int cyIcon = GetSystemMetrics(SM_CYICON);
  187.         CRect rect;
  188.         GetClientRect(&rect);
  189.         int x = (rect.Width() - cxIcon + 1) / 2;
  190.         int y = (rect.Height() - cyIcon + 1) / 2;
  191.  
  192.         // Draw the icon
  193.         dc.DrawIcon(x, y, m_hIcon);
  194.     }
  195.     else
  196.     {
  197.         CDialog::OnPaint();
  198.     }
  199. }
  200.  
  201. // The system calls this to obtain the cursor to display while the user drags
  202. //  the minimized window.
  203. HCURSOR CDllInfoDlg::OnQueryDragIcon()
  204. {
  205.     return (HCURSOR) m_hIcon;
  206. }
  207.  
  208. void CDllInfoDlg::OnChangeDllnameEdit() 
  209. {
  210.      m_DllNameEdit.GetWindowText (m_szDllName);
  211. }
  212.  
  213. void CDllInfoDlg::OnOK() 
  214. {
  215.     DLLINFO dllInfo;
  216.     
  217.     if (m_szDllName.IsEmpty ()) {
  218.         AfxMessageBox (_T("No Dll/Exe name specified."), MB_ICONINFORMATION);
  219.         return;
  220.     }
  221.  
  222.     if (m_LibInfo.GetDllName () != m_szDllName) {
  223.  
  224.         m_LibInfo.SetDllName (m_szDllName);
  225.  
  226.         if (!m_LibInfo.GetDllInfo (dllInfo)) {
  227.             AfxMessageBox (_T("Failed to get DLL information."), MB_ICONINFORMATION);
  228.             return;
  229.         }
  230.         
  231.         m_szFileOS = dllInfo.stFileOS;
  232.         m_szFileType = dllInfo.stFileType;
  233.         m_szFileVersion = dllInfo.stFileVersion;
  234.         m_szCopyRight = dllInfo.stCopyRight;
  235.         m_szDescription = dllInfo.stDescription;
  236.         m_szInternalName = dllInfo.stInternalName;
  237.         m_szOriginalName = dllInfo.stOriginalName;
  238.         m_szProductName = dllInfo.stProductName;
  239.         m_szProductVersion = dllInfo.stProductVersion;
  240.         m_szVersion = dllInfo.stDllVersion;
  241.         m_szCompanyName = dllInfo.stCompany;
  242.     }
  243.  
  244.     UpdateData (FALSE);
  245.     
  246. }
  247.