|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionAs you can see in the snapshot above, Internet Explorer (IE version 5 and above) lets you use a bitmap as a skin/wallpaper for the IE toolbar,
just to make it a bit more interesting. This tiny utility allows you set/remove IE skin with a
convenient dialog based application. In the process, we delve into Windows Registry programming using
The utility is a simple dialog based application, with plain vanilla GUI as you can see above. The code can be easily divided into the handlers of the buttons shown above. Rest of the article will discuss the important steps with the relevant code snippets. Choosing a bitmapThe void CIESkinDlg :: OnChoose() { //open a file dialog with only BMP files filter, //other formats not allowed LPCTSTR lpszFilter = "Bitmap Files (*.bmp)|*.bmp||"; CFileDialog dlgFile(TRUE,NULL,NULL,OFN_FILEMUSTEXIST|OFN_EXPLORER, lpszFilter,this); if(IDOK == dlgFile.DoModal()) { m_szFilePath = dlgFile.GetPathName(); //display file path in the edit box SetDlgItemText(IDC_EDIT,m_szFilePath); } } Set bitmap as a skinTo set selected bitmap file as a skin for Internet Explorer, you must specify path of the
selected file as a value data for the registry value HKEY_CURRENT_USER
\Software
\Microsoft
\Internet Explorer
\Toolbar
The registry
modifications are done using the class The function BOOL CIESkinDlg :: SetIESkin()
{
LONG lResult = 0;
CRegKey reg;
//open the required registry key
LPCTSTR lpszKey = "Software\\Microsoft\\Internet Explorer\\Toolbar";
lResult = reg.Open(HKEY_CURRENT_USER,lpszKey);
//check if opened successfully
if(ERROR_SUCCESS != lResult)
{
return FALSE;
}
//set the value
lResult = reg.SetValue(m_szFilePath,"BackBitmap");
if(ERROR_SUCCESS != lResult)
{
return FALSE;
}
//done, close and return success
reg.Close();
return TRUE;
}
Let's look into some LONG Open( HKEY hKeyParent, LPCTSTR lpszKeyName,
REGSAM samDesired = KEY_ALL_ACCESS )
Another function used here is The function All these functions return Removing the skinTo remove the skin from IE you need to delete the registry value The BOOL CIESkinDlg :: RemoveIESkin()
{
LONG lResult = 0;
CRegKey reg;
//open the required registry key
LPCTSTR lpszKey = "Software\\Microsoft\\Internet Explorer\\Toolbar";
lResult = reg.Open(HKEY_CURRENT_USER,lpszKey);
//check if opened successfully
if(ERROR_SUCCESS != lResult)
{
return FALSE;
}
//delete the value "BackBitmap" from toolbar
lResult = reg.DeleteValue("BackBitmap");
//check if deleted successfully
if(ERROR_SUCCESS != lResult)
{
return FALSE; //perhaps value not found, if skin is not set
}
//done, return success
reg.Close();
return TRUE;
}
The function LONG DeleteValue( LPCTSTR lpszValue ) The function accepts parameter That's it!Really! That ends all the important code of this utility. Rest of the bits and pieces can be found in the source code. Once you start experimenting with various bmp files using this utility, you can make your IE look really cool. Also, as a side effect, your outlook express will also start flaunting this new skin. You can use this code to develop a full-fledged IE customization utility, which could have a custom title, custom revolving logo, brand logo etc. by setting the appropriate registry values. The details about these registry settings can be obtained form the MSDN site. Happy coding and debugging ;)
|
||||||||||||||||||||||