Back to index

lightning-sunbird  0.9+nobinonly
PickerDlg.cpp
Go to the documentation of this file.
00001 // PickerDlg.cpp : implementation file
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "cbrowse.h"
00006 #include "PickerDlg.h"
00007 
00008 #ifdef _DEBUG
00009 #define new DEBUG_NEW
00010 #undef THIS_FILE
00011 static char THIS_FILE[] = __FILE__;
00012 #endif
00013 
00014 // CLSIDs for the Mozilla and IE browser controls
00015 
00016 static const CLSID CLSID_Mozilla =
00017 { 0x1339B54C, 0x3453, 0x11D2, { 0x93, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
00018 
00019 // XX is a hack to avoid linker errors with some Platform SDKs defining
00020 // a GUID with the same name
00021 static const CLSID CLSID_XXInternetExplorer =
00022 { 0x8856F961, 0x340A, 0x11D0, { 0xA9, 0x6B, 0x00, 0xC0, 0x4F, 0xD7, 0x05, 0xA2 } };
00023 
00024 static const CLSID CLSID_MSHTML = 
00025 { 0x2D360200, 0xFFF5, 0x11D1, { 0x8D, 0x03, 0x00, 0xA0, 0xC9, 0x59, 0xBC, 0x0A } };
00026 
00027 struct BrowserControl
00028 {
00029        TCHAR *szName;
00030        const CLSID *clsid;
00031 };
00032 
00033 BrowserControl aControls[] =
00034 {
00035        { _T("Mozilla Control"), &CLSID_Mozilla },
00036        { _T("Internet Explorer Control"), &CLSID_XXInternetExplorer }
00037 };
00038 
00039 
00041 // CPickerDlg dialog
00042 
00043 
00044 CPickerDlg::CPickerDlg(CWnd* pParent /*=NULL*/)
00045        : CDialog(CPickerDlg::IDD, pParent)
00046 {
00047        //{{AFX_DATA_INIT(CPickerDlg)
00048        m_szTestURL = _T("");
00049        m_szTestCGI = _T("");
00050        m_bDebugging = FALSE;
00051        m_sDebugFlags = _T("");
00052        m_bUseCustom = FALSE;
00053        //}}AFX_DATA_INIT
00054        m_clsid = CLSID_NULL;
00055 
00056        CWinApp *pApp = AfxGetApp();
00057        m_szTestURL = pApp->GetProfileString(SECTION_TEST, KEY_TESTURL, KEY_TESTURL_DEFAULTVALUE);
00058        m_szTestCGI = pApp->GetProfileString(SECTION_TEST, KEY_TESTCGI, KEY_TESTCGI_DEFAULTVALUE);
00059        m_sDebugFlags = _T("NSPR_LOG_MODULES=nsComponentManager:5");
00060 }
00061 
00062 void CPickerDlg::DoDataExchange(CDataExchange* pDX)
00063 {
00064        CDialog::DoDataExchange(pDX);
00065        //{{AFX_DATA_MAP(CPickerDlg)
00066        DDX_Control(pDX, IDC_LISTBROWSER, m_lbPicker);
00067        DDX_Text(pDX, IDC_TESTURL, m_szTestURL);
00068        DDX_Text(pDX, IDC_TESTCGI, m_szTestCGI);
00069        DDX_Check(pDX, IDC_CHECK1, m_bDebugging);
00070        DDX_Text(pDX, IDC_EDIT1, m_sDebugFlags);
00071        DDX_Check(pDX, IDC_OVERRIDE, m_bUseCustom);
00072        //}}AFX_DATA_MAP
00073 }
00074 
00075 
00076 BEGIN_MESSAGE_MAP(CPickerDlg, CDialog)
00077        //{{AFX_MSG_MAP(CPickerDlg)
00078        ON_BN_CLICKED(IDOK, OnOk)
00079        ON_LBN_DBLCLK(IDC_LISTBROWSER, OnDblclkListbrowser)
00080        //}}AFX_MSG_MAP
00081 END_MESSAGE_MAP()
00082 
00084 // CPickerDlg message handlers
00085 
00086 BOOL CPickerDlg::OnInitDialog() 
00087 {
00088        CDialog::OnInitDialog();
00089 
00090        for (int i = 0; i < sizeof(aControls) / sizeof(aControls[0]); i++)
00091        {
00092               m_lbPicker.AddString(aControls[i].szName);
00093        }
00094        m_lbPicker.SetCurSel(0);
00095               
00096        return TRUE;  // return TRUE unless you set the focus to a control
00097                      // EXCEPTION: OCX Property Pages should return FALSE
00098 }
00099 
00100 
00101 void CPickerDlg::OnOk() 
00102 {
00103        UpdateData();
00104 
00105        int nItem = m_lbPicker.GetCurSel();
00106        if (nItem == LB_ERR)
00107        {
00108               AfxMessageBox(IDS_CHOOSEBROWSER);
00109               return;
00110        }
00111 
00112        m_clsid = *aControls[nItem].clsid;
00113 
00114        CWinApp *pApp = AfxGetApp();
00115        pApp->WriteProfileString(SECTION_TEST, KEY_TESTURL, m_szTestURL);
00116        pApp->WriteProfileString(SECTION_TEST, KEY_TESTCGI, m_szTestCGI);
00117 
00118        if (m_bDebugging)
00119        {
00120               putenv("NSPR_LOG_FILE=.\\mozilla.log");
00121               putenv(m_sDebugFlags);
00122        }
00123 
00124        EndDialog(IDOK);
00125 }
00126 
00127 
00128 void CPickerDlg::OnDblclkListbrowser() 
00129 {
00130        OnOk();
00131 }