GME  13
CompInfoDlg.cpp
Go to the documentation of this file.
00001 // CompInfoDlg.cpp : implementation file
00002 //
00003 #include "stdafx.h"
00004 #include "mgautil.h"
00005 #include "CompInfoDlg.h"
00006 
00007 #ifdef _DEBUG
00008 #define new DEBUG_NEW
00009 #undef THIS_FILE
00010 static char THIS_FILE[] = __FILE__;
00011 #endif
00012 
00014 // CCompInfoDlg dialog
00015 
00016 
00017 CCompInfoDlg::CCompInfoDlg(IMgaRegistrar *reg,  CWnd* pParent /*=NULL*/)
00018         : CDialog(CCompInfoDlg::IDD, pParent),  registrar(reg)
00019 {
00020 
00021         //{{AFX_DATA_INIT(CCompInfoDlg)
00022         m_name = _T("");
00023         m_paradigm = _T("");
00024         m_engine = _T("");
00025         m_filename = _T("");
00026         m_description = _T("");
00027         m_progid = _T("");
00028         m_version = _T("");
00029         //}}AFX_DATA_INIT
00030 }
00031 
00032 
00033 void CCompInfoDlg::DoDataExchange(CDataExchange* pDX)
00034 {
00035         CDialog::DoDataExchange(pDX);
00036         //{{AFX_DATA_MAP(CCompInfoDlg)
00037         DDX_Control(pDX, IDC_ENGINECOMBO, m_execeng);
00038         DDX_Text(pDX, IDC_NAME, m_name);
00039         DDX_Text(pDX, IDC_PARADIGM, m_paradigm);
00040         DDX_Text(pDX, IDC_FILENAME, m_filename);
00041         DDX_Text(pDX, IDC_DESCRIPTION, m_description);
00042         DDX_Text(pDX, IDC_PROGID, m_progid);
00043         DDX_Text(pDX, IDC_VERSION, m_version);
00044         //}}AFX_DATA_MAP
00045 }
00046 
00047 
00048 BEGIN_MESSAGE_MAP(CCompInfoDlg, CDialog)
00049         //{{AFX_MSG_MAP(CCompInfoDlg)
00050         //}}AFX_MSG_MAP
00051 END_MESSAGE_MAP()
00052 
00054 // CCompInfoDlg message handlers
00055 
00056 void CCompInfoDlg::OnOK() 
00057 {
00058         UpdateData();
00059 
00060         int v;
00061 
00062         if(m_progid.Find('.') < 0) {
00063                 AfxMessageBox(_T("ProgID must contain at least one '.'"));
00064         }
00065         else if(_stscanf_s(m_version, _T("%d"), &v) != 1 || v <= 0) {
00066                 AfxMessageBox(_T("Version ID must start with a number > 0"));
00067         }
00068         else if (m_execeng.GetCurSel() == -1)
00069         {
00070                 AfxMessageBox(_T("No execution engine selected"));
00071         }
00072         else {
00073                 m_execeng.GetLBText(m_execeng.GetCurSel(),engine);
00074                 CDialog::OnOK();
00075         }
00076 }
00077 
00078 BOOL CCompInfoDlg::OnInitDialog() 
00079 {
00080         CDialog::OnInitDialog();
00081         
00082         CComVariant v;
00083         COMTHROW(registrar->get_Components(REGACCESS_BOTH, &v));
00084 
00085         CComBstrObjArray progids;
00086         MoveTo(v, progids);
00087 
00088         int sel = 0;
00089         for(int i = 0; i < progids.GetSize(); ++i)      {
00090                         componenttype_enum type;
00091                         CComBSTR dummy;
00092                         HRESULT hr = registrar->QueryComponent(CComBSTR(progids[i]), &type, &dummy, REGACCESS_PRIORITY);
00093                         if(hr != S_OK || ! (type & COMPONENTTYPE_EXECENGINE)) continue;
00094                         CString name(progids[i]);
00095                         int p = m_execeng.AddString(name);
00096                         if(name.Find(_T("attern")) >= 0) sel = p;
00097         }
00098         m_execeng.SetCurSel(sel);
00099         return TRUE;  // return TRUE unless you set the focus to a control
00100                       // EXCEPTION: OCX Property Pages should return FALSE
00101 }