Updated to include new registry entries

This commit is contained in:
locka%iol.ie 1999-10-19 19:06:31 +00:00
parent d9ca4e3f07
commit c041069a12
4 changed files with 159 additions and 21 deletions

View File

@ -26,22 +26,32 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// Dialog
//
IDD_REGMOZCTL_DIALOG DIALOGEX 0, 0, 210, 116
IDD_REGMOZCTL_DIALOG DIALOGEX 0, 0, 210, 199
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "RegMozCtl"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDI_MOZILLA,IDC_STATIC,7,7,20,20
LTEXT "This application registers/deregisters the Mozilla Control and ensures that its dependent DLLs are listed as SHARED so that they can be found when the control is used by other applications.",
IDC_STATIC,34,7,169,35
LTEXT "You must choose the directory containing the Mozilla control and click on the Register or Deregister as appropriate.",
IDC_STATIC,7,47,196,24
DEFPUSHBUTTON "&Register",IDC_REGISTER,7,95,50,14
PUSHBUTTON "&Unregister",IDC_UNREGISTER,80,95,50,14
PUSHBUTTON "&Close",IDCANCEL,153,95,50,14
ICON IDI_ICON2,IDC_STATIC,7,7,21,20
EDITTEXT IDC_MOZILLADIR,7,73,179,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_PICKDIR,190,73,13,14
IDC_STATIC,7,47,196,17
EDITTEXT IDC_MOZILLADIR,7,70,182,14,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_PICKDIR,190,70,13,14
LTEXT "Now choose the component registry file and component directory the control uses or let RegMozCtl try to guess correct values for you.",
IDC_STATIC,7,89,196,27
EDITTEXT IDC_COMPONENTFILE,7,134,182,14,ES_AUTOHSCROLL |
WS_DISABLED
PUSHBUTTON "...",IDC_PICKCOMPONENTFILE,190,134,13,14,WS_DISABLED
EDITTEXT IDC_COMPONENTPATH,7,157,182,14,ES_AUTOHSCROLL |
WS_DISABLED
PUSHBUTTON "...",IDC_PICKCOMPONENTPATH,190,157,13,14,WS_DISABLED
DEFPUSHBUTTON "&Register",IDC_REGISTER,7,178,50,14
PUSHBUTTON "&Unregister",IDC_UNREGISTER,80,178,50,14
PUSHBUTTON "&Close",IDCANCEL,153,178,50,14
CONTROL "Automatic",IDC_AUTOMATIC,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,119,46,10
END
@ -101,7 +111,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 203
TOPMARGIN, 7
BOTTOMMARGIN, 109
BOTTOMMARGIN, 192
END
END
#endif // APSTUDIO_INVOKED
@ -165,7 +175,7 @@ END
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\RegMozCtl.ico"
IDI_ICON2 ICON DISCARDABLE "MozillaBrowser.ico"
IDI_MOZILLA ICON DISCARDABLE "MozillaBrowser.ico"
#endif // English (U.K.) resources
/////////////////////////////////////////////////////////////////////////////

View File

@ -11,6 +11,11 @@
static char THIS_FILE[] = __FILE__;
#endif
#define MOZ_CONTROL_REG_KEY _T("Software\\Mozilla\\")
#define MOZ_CONTROL_REG_VALUE_DIR _T("Dir")
#define MOZ_CONTROL_REG_VALUE_COMPONENT_PATH _T("ComponentPath")
#define MOZ_CONTROL_REG_VALUE_COMPONENT_FILE _T("ComponentFile")
/////////////////////////////////////////////////////////////////////////////
// CRegMozCtlDlg dialog
@ -19,10 +24,14 @@ CRegMozCtlDlg::CRegMozCtlDlg(CWnd* pParent /*=NULL*/)
{
//{{AFX_DATA_INIT(CRegMozCtlDlg)
m_szMozillaDir = _T("");
m_szComponentPath = _T("");
m_szComponentFile = _T("");
m_bAutomatic = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_hIcon = AfxGetApp()->LoadIcon(IDI_MOZILLA);
m_bAutomatic = TRUE;
GetCurrentDirectory(1024, m_szMozillaDir.GetBuffer(1024));
m_szMozillaDir.ReleaseBuffer();
}
@ -31,7 +40,14 @@ void CRegMozCtlDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRegMozCtlDlg)
DDX_Control(pDX, IDC_COMPONENTPATH, m_edtComponentPath);
DDX_Control(pDX, IDC_COMPONENTFILE, m_edtComponentFile);
DDX_Control(pDX, IDC_PICKCOMPONENTPATH, m_btnPickComponentPath);
DDX_Control(pDX, IDC_PICKCOMPONENTFILE, m_btnPickComponentFile);
DDX_Text(pDX, IDC_MOZILLADIR, m_szMozillaDir);
DDX_Text(pDX, IDC_COMPONENTPATH, m_szComponentPath);
DDX_Text(pDX, IDC_COMPONENTFILE, m_szComponentFile);
DDX_Check(pDX, IDC_AUTOMATIC, m_bAutomatic);
//}}AFX_DATA_MAP
}
@ -42,6 +58,9 @@ BEGIN_MESSAGE_MAP(CRegMozCtlDlg, CDialog)
ON_BN_CLICKED(IDC_REGISTER, OnRegister)
ON_BN_CLICKED(IDC_UNREGISTER, OnUnregister)
ON_BN_CLICKED(IDC_PICKDIR, OnPickDir)
ON_BN_CLICKED(IDC_PICKCOMPONENTFILE, OnPickComponentFile)
ON_BN_CLICKED(IDC_PICKCOMPONENTPATH, OnPickComponentPath)
ON_BN_CLICKED(IDC_AUTOMATIC, OnAutomatic)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@ -50,15 +69,39 @@ END_MESSAGE_MAP()
BOOL CRegMozCtlDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
// Get values from the registry
TCHAR szValue[1024];
DWORD dwSize = sizeof(szValue) / sizeof(szValue[0]);
CRegKey cKey;
cKey.Create(HKEY_LOCAL_MACHINE, MOZ_CONTROL_REG_KEY);
memset(szValue, 0, sizeof(szValue));
if (cKey.QueryValue(szValue, MOZ_CONTROL_REG_VALUE_COMPONENT_PATH, &dwSize) == ERROR_SUCCESS)
{
m_szComponentPath = CString(szValue);
}
dwSize = sizeof(szValue) / sizeof(szValue[0]);
memset(szValue, 0, sizeof(szValue));
if (cKey.QueryValue(szValue, MOZ_CONTROL_REG_VALUE_COMPONENT_FILE, &dwSize) == ERROR_SUCCESS)
{
m_szComponentFile = CString(szValue);
}
dwSize = sizeof(szValue) / sizeof(szValue[0]);
memset(szValue, 0, sizeof(szValue));
if (cKey.QueryValue(szValue, MOZ_CONTROL_REG_VALUE_DIR, &dwSize) == ERROR_SUCCESS)
{
m_szMozillaDir = CString(szValue);
}
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
}
@ -143,8 +186,8 @@ void CRegMozCtlDlg::RegisterMozillaControl(BOOL bRegister)
}
cKey.Close();
cKey.Create(HKEY_LOCAL_MACHINE, _T("Software\\Mozilla"));
cKey.SetValue(m_szMozillaDir, _T("MozillaDir"));
cKey.Create(HKEY_LOCAL_MACHINE, MOZ_CONTROL_REG_KEY);
cKey.SetValue(m_szMozillaDir, MOZ_CONTROL_REG_VALUE_DIR);
cKey.Close();
// Now register the mozilla control
@ -164,7 +207,6 @@ void CRegMozCtlDlg::RegisterMozillaControl(BOOL bRegister)
AfxMessageBox(bRegister ? _T("Register completed") : _T("Unregister completed"));
}
void CRegMozCtlDlg::OnPickDir()
{
BROWSEINFO bi;
@ -191,7 +233,7 @@ void CRegMozCtlDlg::OnPickDir()
if (SHGetPathFromIDList(pItemList, szPath))
{
// Chop off the end path seperator
// Chop off the end path separator
int nPathSize = strlen(szPath);
if (nPathSize > 0)
{
@ -202,11 +244,82 @@ void CRegMozCtlDlg::OnPickDir()
}
m_szMozillaDir = CString(szPath);
if (m_bAutomatic)
{
m_szComponentPath = m_szMozillaDir + "\\components";
m_szComponentFile = m_szMozillaDir + "\\component.reg";
}
UpdateData(FALSE);
}
pShellAllocator->Free(pItemList);
pShellAllocator->Release();
}
}
}
}}
void CRegMozCtlDlg::OnPickComponentFile()
{
CFileDialog dlg(TRUE, NULL, m_szComponentFile);
if (dlg.DoModal() == IDOK)
{
m_szComponentFile = dlg.GetPathName();
UpdateData(FALSE);
}
}
void CRegMozCtlDlg::OnPickComponentPath()
{
BROWSEINFO bi;
TCHAR szFolder[MAX_PATH + 1];
memset(szFolder, 0, sizeof(szFolder));
memset(&bi, 0, sizeof(bi));
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = szFolder;
bi.lpszTitle = _T("Pick a folder to scan");
// Open the folder browser dialog
LPITEMIDLIST pItemList = SHBrowseForFolder(&bi);
if (pItemList)
{
IMalloc *pShellAllocator = NULL;
SHGetMalloc(&pShellAllocator);
if (pShellAllocator)
{
char szPath[MAX_PATH + 1];
if (SHGetPathFromIDList(pItemList, szPath))
{
// Chop off the end path separator
int nPathSize = strlen(szPath);
if (nPathSize > 0)
{
if (szPath[nPathSize - 1] == '\\')
{
szPath[nPathSize - 1] = '\0';
}
}
m_szComponentPath = CString(szPath);
UpdateData(FALSE);
}
pShellAllocator->Free(pItemList);
pShellAllocator->Release();
}
}
}
void CRegMozCtlDlg::OnAutomatic()
{
UpdateData(TRUE);
m_edtComponentFile.EnableWindow(!m_bAutomatic);
m_btnPickComponentFile.EnableWindow(!m_bAutomatic);
m_edtComponentPath.EnableWindow(!m_bAutomatic);
m_btnPickComponentPath.EnableWindow(!m_bAutomatic);
}

View File

@ -20,7 +20,14 @@ public:
// Dialog Data
//{{AFX_DATA(CRegMozCtlDlg)
enum { IDD = IDD_REGMOZCTL_DIALOG };
CEdit m_edtComponentPath;
CEdit m_edtComponentFile;
CButton m_btnPickComponentPath;
CButton m_btnPickComponentFile;
CString m_szMozillaDir;
CString m_szComponentPath;
CString m_szComponentFile;
BOOL m_bAutomatic;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
@ -41,6 +48,9 @@ protected:
afx_msg void OnRegister();
afx_msg void OnUnregister();
afx_msg void OnPickDir();
afx_msg void OnPickComponentFile();
afx_msg void OnPickComponentPath();
afx_msg void OnAutomatic();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

View File

@ -4,11 +4,16 @@
//
#define IDD_REGMOZCTL_DIALOG 102
#define IDR_MAINFRAME 128
#define IDI_ICON2 130
#define IDI_MOZILLA 130
#define IDC_REGISTER 1001
#define IDC_UNREGISTER 1002
#define IDC_MOZILLADIR 1003
#define IDC_PICKDIR 1004
#define IDC_COMPONENTFILE 1005
#define IDC_PICKCOMPONENTFILE 1006
#define IDC_COMPONENTPATH 1007
#define IDC_PICKCOMPONENTPATH 1008
#define IDC_AUTOMATIC 1009
// Next default values for new objects
//
@ -16,7 +21,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1005
#define _APS_NEXT_CONTROL_VALUE 1010
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif