home *** CD-ROM | disk | FTP | other *** search
- // Controls.cpp : Defines the class behaviors for the application.
- //
-
- #include "stdafx.h"
- #include "Controls.h"
- #include "MyPropertySheet.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- ////////////////////////////////////////////////////////////////////////////
- // CControlsApp
-
- BEGIN_MESSAGE_MAP(CControlsApp, CWinApp)
- //{{AFX_MSG_MAP(CControlsApp)
- ON_COMMAND(IDR_FILE_OPEN, OnFileOpen)
- ON_COMMAND(ID_FILE_EXIT, OnFileExit)
- ON_COMMAND(ID_TOOLS_APPLYSKIN, OnToolsApplyskin)
- ON_COMMAND(ID_TOOLS_REMOVESKIN, OnToolsRemoveskin)
- ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)
- ON_COMMAND(ID_SKINS_GLAUCOUSTRACK, OnSkinsGlaucoustrack)
- ON_COMMAND(ID_SKINS_METALLIC, OnSkinsMetallic)
- ON_COMMAND(ID_SKINS_RUBY, OnSkinsRuby)
- ON_COMMAND(ID_SKINS_SKINCRAFTER, OnSkinsSkincrafter)
- ON_COMMAND(ID_SKINS_TECHNOBRONZE, OnSkinsTechnobronze)
- ON_COMMAND(ID_SKINS_TIGEREYE, OnSkinsTigereye)
- ON_COMMAND(ID_SKINS_ADDSKIN, OnSkinsAddskin)
- //}}AFX_MSG_MAP
- ON_COMMAND(ID_HELP, CWinApp::OnHelp)
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CControlsApp construction
-
- CControlsApp::CControlsApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CControlsApp object
-
- CControlsApp theApp;
-
- /////////////////////////////////////////////////////////////////////////////
- // CControlsApp initialization
-
- BOOL CControlsApp::InitInstance()
- {
- // Standard initialization
- // If you are not using these features and wish to reduce the size
- // of your final executable, you should remove from the following
- // the specific initialization routines you do not need.
-
- // Initialize the common controls library
- INITCOMMONCONTROLSEX icex;
- icex.dwSize = sizeof( icex );
- icex.dwICC = ICC_DATE_CLASSES | ICC_INTERNET_CLASSES;
- VERIFY( InitCommonControlsEx( &icex ) );
-
- CoInitialize(NULL);
- AfxOleInit();
- AfxInitRichEdit();
- AfxEnableControlContainer();
-
- m_pSkin.CreateDispatch("SkinCrafter.SCSkin");
-
- m_pSkin.InitLicenKeys("0","SKINCRAFTER","SKINCRAFTER.COM","support@skincrafter.com","DEMOSKINCRAFTERLICENCE");
-
- m_pSkin.DefineLanguage(0);
- m_pSkin.InitDecoration(1);
-
- CMyPropertySheet propSheet;
- propSheet.m_psh.dwFlags |= PSH_NOAPPLYNOW;
- propSheet.m_psh.dwFlags &= ~PSH_HASHELP;
- m_pMainWnd = &propSheet;
-
- ZeroMemory(&skinPath, _MAX_PATH);
- cmdStartNum = 35500;
-
- HKEY hk;
- DWORD dwData;
- if(RegOpenKeyEx( HKEY_LOCAL_MACHINE,
- "Software\\SkinCrafter\\SkinCrafter Demo",
- 0, KEY_QUERY_VALUE, &hk) != ERROR_SUCCESS);
-
- if(RegQueryValueEx(hk,"SkinPath",NULL,NULL,(LPBYTE)skinPath,&dwData) != ERROR_SUCCESS)
- Beep (1000,50);
-
- int nResponse = propSheet.DoModal();
-
- if (nResponse == IDOK)
- {
- // TODO: Place code here to handle when the dialog is
- // dismissed with OK
- }
- else if (nResponse == IDCANCEL)
- {
- // TODO: Place code here to handle when the dialog is
- // dismissed with Cancel
- }
-
- // Since the dialog has been closed, return FALSE so that we exit the
- // application, rather than start the application's message pump.
- return FALSE;
- }
-
- void CControlsApp::OnProperties()
- {
- // TODO: The property sheet attached to your project
- // via this function is not hooked up to any message
- // handler. In order to actually use the property sheet,
- // you will need to associate this function with a control
- // in your project such as a menu item or tool bar button.
-
- CMyPropertySheet propSheet;
-
- propSheet.DoModal();
-
- // This is where you would retrieve information from the property
- // sheet if propSheet.DoModal() returned IDOK. We aren't doing
- // anything for simplicity.
- }
-
- void CControlsApp::OnFileOpen()
- {
- // TODO: Add your command handler code here
- CString Filter("SkinCrafter files (*.skf)|*.skf||");
-
- CFileDialog FileDlg(TRUE, "skf", NULL, NULL, Filter);
- FileDlg.m_ofn.lpstrTitle = "Select file";
-
- HKEY hk;
- DWORD dwData;
-
- if (RegCreateKey(HKEY_LOCAL_MACHINE,
- "Software\\SkinCrafter\\SkinCrafter Demo", &hk))
- int err = 1;
-
- char skinPath[_MAX_PATH] = "";
- RegQueryValueEx(hk,"SkinPath",NULL,NULL,(LPBYTE)skinPath,&dwData);
-
- RegCloseKey(hk);
-
- FileDlg.m_ofn.lpstrInitialDir = skinPath;
-
- if(IDOK == FileDlg.DoModal())
- {
- CString SelectedFile = FileDlg.GetPathName();
-
- theApp.m_pSkin.LoadSkinFromFile(SelectedFile);
- theApp.m_pSkin.ApplySkin();
-
- theApp.m_pSkin.UpdateControl(0);
- }
- }
-
- void CControlsApp::OnFileExit()
- {
- // TODO: Add your command handler code here
- ((CDialog*)m_pMainWnd)->EndDialog(0);
- }
-
- void CControlsApp::OnToolsApplyskin()
- {
- HWND myWin = theApp.GetMainWnd()->m_hWnd;
- HMENU myMenu = GetMenu(myWin);
- CheckMenuItem(myMenu, 35500 ,MF_CHECKED);
- // TODO: Add your command handler code here
- theApp.m_pSkin.ApplySkin();
- }
-
- void CControlsApp::OnToolsRemoveskin()
- {
- // TODO: Add your command handler code here
- theApp.m_pSkin.RemoveSkin();
- }
-
- int CControlsApp::ExitInstance()
- {
- // TODO: Add your specialized code here and/or call the base class
- theApp.m_pSkin.DeInitDecoration();
-
- return CWinApp::ExitInstance();
- }
-
- BOOL CControlsApp::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
- {
- // TODO: Add your specialized code here and/or call the base class
- if(nID == ID_HELP && nCode == CN_COMMAND)
- return FALSE;
- else if (nID >= (UINT)cmdStartNum && nID <= (UINT)cmdStartNum+9)
- {
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
- int num = nID - cmdStartNum;
- CString filepath = "";
- filepath.Format ("%s\\%s", skinPath,customSkinNames[num]);
- OFSTRUCT strF;
- HFILE hFile = OpenFile( filepath, &strF, OF_EXIST);
- if ( hFile != -1 )
- {
- theApp.m_pSkin.LoadSkinFromFile(filepath);
- theApp.m_pSkin.ApplySkin();
- lastSkinID = nID;
- lastSkin = customSkinNames[num];
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_CHECKED);
- }
- return FALSE;
- }
- else if (nID == 35600)
- {
- theApp.m_pSkin.RemoveSkin();
- CString filepath = "";
- filepath.Format ("%s\\%s", skinPath,lastSkin);
-
- if (lastSkin!="GlaucousTrack.skf" && lastSkin!="Metallic.skf" && lastSkin!="Ruby.skf" && lastSkin!="SkinCrafter.skf" && lastSkin!="TechnoBronze.skf" && lastSkin!="Tiger-eye.skf")
- {
- OFSTRUCT strF;
- HFILE hFile = OpenFile( filepath, &strF, OF_EXIST);
- if ( hFile != -1 )
- DeleteFile(filepath);
- }
- return FALSE;
- }
-
- return CWinApp::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
- }
-
- void CControlsApp::OnHelpAbout()
- {
- // TODO: Add your command handler code here
- m_pSkin.AboutSkinCrafter();
- }
-
- void CControlsApp::OnSkinsGlaucoustrack()
- {
- // TODO: Add your command handler code here
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
- CString filepath = "";
- filepath.Format ("%s\\GlaucousTrack.skf", skinPath);
- theApp.m_pSkin.LoadSkinFromFile(filepath);
- theApp.m_pSkin.ApplySkin();
- lastSkinID = ID_SKINS_GLAUCOUSTRACK;
- lastSkin = "GlaucousTrack.skf";
-
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_GLAUCOUSTRACK ,MF_CHECKED);
- }
-
- void CControlsApp::OnSkinsMetallic()
- {
- // TODO: Add your command handler code here
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
- CString filepath = "";
- filepath.Format ("%s\\Metallic.skf", skinPath);
- theApp.m_pSkin.LoadSkinFromFile(filepath);
- theApp.m_pSkin.ApplySkin();
- lastSkinID = ID_SKINS_METALLIC;
- lastSkin = "Metallic.skf";
-
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_METALLIC ,MF_CHECKED);
- }
-
- void CControlsApp::OnSkinsRuby()
- {
- // TODO: Add your command handler code here
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
- CString filepath = "";
- filepath.Format ("%s\\Ruby.skf", skinPath);
- theApp.m_pSkin.LoadSkinFromFile(filepath);
- theApp.m_pSkin.ApplySkin();
- lastSkinID = ID_SKINS_RUBY;
- lastSkin = "Ruby.skf";
-
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_RUBY ,MF_CHECKED);
- }
-
- void CControlsApp::OnSkinsSkincrafter()
- {
- // TODO: Add your command handler code here
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
- CString filepath = "";
- filepath.Format ("%s\\SkinCrafter.skf", skinPath);
- theApp.m_pSkin.LoadSkinFromFile(filepath);
- theApp.m_pSkin.ApplySkin();
- lastSkinID = ID_SKINS_SKINCRAFTER;
- lastSkin = "SkinCrafter.skf";
-
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_SKINCRAFTER ,MF_CHECKED);
- }
-
- void CControlsApp::OnSkinsTechnobronze()
- {
- // TODO: Add your command handler code here
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
- CString filepath = "";
- filepath.Format ("%s\\TechnoBronze.skf", skinPath);
- theApp.m_pSkin.LoadSkinFromFile(filepath);
- theApp.m_pSkin.ApplySkin();
- lastSkinID = ID_SKINS_TECHNOBRONZE;
- lastSkin = "TechnoBronze.skf";
-
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_TECHNOBRONZE ,MF_CHECKED);
- }
-
- void CControlsApp::OnSkinsTigereye()
- {
- // TODO: Add your command handler code here
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
- CString filepath = "";
- filepath.Format ("%s\\Tiger-eye.skf", skinPath);
- theApp.m_pSkin.LoadSkinFromFile(filepath);
- theApp.m_pSkin.ApplySkin();
- lastSkinID = ID_SKINS_TIGEREYE;
- lastSkin = "Tiger-eye.skf";
-
- CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_TIGEREYE ,MF_CHECKED);
- }
-
- void CControlsApp::OnSkinsAddskin()
- {
- }
-