home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / CMCD1104.ISO / Software / Shareware / Programare / skincraft / SkinCrafter_v1.4.12_Demo.msi / _49E29CB9A65AABBF653C1037E1AA74B6 / _7F160BF9B70B43F2B25FFBAC51F34D0D < prev    next >
Encoding:
Text File  |  2004-06-30  |  9.6 KB  |  326 lines

  1. // Controls.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Controls.h"
  6. #include "MyPropertySheet.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. ////////////////////////////////////////////////////////////////////////////
  15. // CControlsApp
  16.  
  17. BEGIN_MESSAGE_MAP(CControlsApp, CWinApp)
  18.     //{{AFX_MSG_MAP(CControlsApp)
  19.     ON_COMMAND(IDR_FILE_OPEN, OnFileOpen)
  20.     ON_COMMAND(ID_FILE_EXIT, OnFileExit)
  21.     ON_COMMAND(ID_TOOLS_APPLYSKIN, OnToolsApplyskin)
  22.     ON_COMMAND(ID_TOOLS_REMOVESKIN, OnToolsRemoveskin)
  23.     ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)
  24.     ON_COMMAND(ID_SKINS_GLAUCOUSTRACK, OnSkinsGlaucoustrack)
  25.     ON_COMMAND(ID_SKINS_METALLIC, OnSkinsMetallic)
  26.     ON_COMMAND(ID_SKINS_RUBY, OnSkinsRuby)
  27.     ON_COMMAND(ID_SKINS_SKINCRAFTER, OnSkinsSkincrafter)
  28.     ON_COMMAND(ID_SKINS_TECHNOBRONZE, OnSkinsTechnobronze)
  29.     ON_COMMAND(ID_SKINS_TIGEREYE, OnSkinsTigereye)
  30.     ON_COMMAND(ID_SKINS_ADDSKIN, OnSkinsAddskin)
  31.     //}}AFX_MSG_MAP
  32.     ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  33. END_MESSAGE_MAP()
  34.  
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CControlsApp construction
  37.  
  38. CControlsApp::CControlsApp()
  39. {
  40.     // TODO: add construction code here,
  41.     // Place all significant initialization in InitInstance
  42. }
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // The one and only CControlsApp object
  46.  
  47. CControlsApp theApp;
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CControlsApp initialization
  51.  
  52. BOOL CControlsApp::InitInstance()
  53. {
  54.     // Standard initialization
  55.     // If you are not using these features and wish to reduce the size
  56.     //  of your final executable, you should remove from the following
  57.     //  the specific initialization routines you do not need.
  58.     
  59.     // Initialize the common controls library
  60.     INITCOMMONCONTROLSEX icex;
  61.     icex.dwSize = sizeof( icex );
  62.     icex.dwICC = ICC_DATE_CLASSES | ICC_INTERNET_CLASSES;
  63.     VERIFY( InitCommonControlsEx( &icex ) );
  64.  
  65.     CoInitialize(NULL);
  66.     AfxOleInit();
  67.     AfxInitRichEdit();
  68.     AfxEnableControlContainer();
  69.  
  70.     m_pSkin.CreateDispatch("SkinCrafter.SCSkin");
  71.             
  72.     m_pSkin.InitLicenKeys("0","SKINCRAFTER","SKINCRAFTER.COM","support@skincrafter.com","DEMOSKINCRAFTERLICENCE");
  73.  
  74.     m_pSkin.DefineLanguage(0);
  75.     m_pSkin.InitDecoration(1);
  76.  
  77.     CMyPropertySheet propSheet;
  78.     propSheet.m_psh.dwFlags |= PSH_NOAPPLYNOW;
  79.     propSheet.m_psh.dwFlags &= ~PSH_HASHELP;
  80.     m_pMainWnd = &propSheet;
  81.  
  82.     ZeroMemory(&skinPath, _MAX_PATH);
  83.     cmdStartNum = 35500;
  84.  
  85.     HKEY hk; 
  86.     DWORD dwData; 
  87.     if(RegOpenKeyEx( HKEY_LOCAL_MACHINE,
  88.                "Software\\SkinCrafter\\SkinCrafter Demo",
  89.                0, KEY_QUERY_VALUE, &hk) != ERROR_SUCCESS);
  90.  
  91.     if(RegQueryValueEx(hk,"SkinPath",NULL,NULL,(LPBYTE)skinPath,&dwData) != ERROR_SUCCESS)
  92.         Beep (1000,50);
  93.  
  94.     int nResponse = propSheet.DoModal();
  95.  
  96.     if (nResponse == IDOK)
  97.     {
  98.         // TODO: Place code here to handle when the dialog is
  99.         //  dismissed with OK
  100.     }
  101.     else if (nResponse == IDCANCEL)
  102.     {
  103.         // TODO: Place code here to handle when the dialog is
  104.         //  dismissed with Cancel
  105.     }
  106.  
  107.     // Since the dialog has been closed, return FALSE so that we exit the
  108.     //  application, rather than start the application's message pump.
  109.     return FALSE;
  110. }
  111.  
  112. void CControlsApp::OnProperties()
  113. {
  114.     // TODO: The property sheet attached to your project
  115.     // via this function is not hooked up to any message
  116.     // handler.  In order to actually use the property sheet,
  117.     // you will need to associate this function with a control
  118.     // in your project such as a menu item or tool bar button.
  119.  
  120.     CMyPropertySheet propSheet;
  121.  
  122.     propSheet.DoModal();
  123.  
  124.     // This is where you would retrieve information from the property
  125.     // sheet if propSheet.DoModal() returned IDOK.  We aren't doing
  126.     // anything for simplicity.
  127. }
  128.  
  129. void CControlsApp::OnFileOpen()
  130. {
  131.     // TODO: Add your command handler code here
  132.     CString Filter("SkinCrafter files (*.skf)|*.skf||");
  133.  
  134.     CFileDialog FileDlg(TRUE, "skf", NULL, NULL, Filter);
  135.     FileDlg.m_ofn.lpstrTitle = "Select file";
  136.  
  137.     HKEY hk;
  138.     DWORD dwData;
  139.  
  140.     if (RegCreateKey(HKEY_LOCAL_MACHINE,
  141.             "Software\\SkinCrafter\\SkinCrafter Demo", &hk))
  142.         int err = 1;
  143.  
  144.     char skinPath[_MAX_PATH] = "";
  145.     RegQueryValueEx(hk,"SkinPath",NULL,NULL,(LPBYTE)skinPath,&dwData);
  146.             
  147.     RegCloseKey(hk);
  148.  
  149.     FileDlg.m_ofn.lpstrInitialDir = skinPath;
  150.  
  151.     if(IDOK == FileDlg.DoModal())
  152.     {
  153.         CString SelectedFile = FileDlg.GetPathName();
  154.  
  155.         theApp.m_pSkin.LoadSkinFromFile(SelectedFile);
  156.         theApp.m_pSkin.ApplySkin();
  157.         
  158.         theApp.m_pSkin.UpdateControl(0);
  159.     }
  160. }
  161.  
  162. void CControlsApp::OnFileExit()
  163. {
  164.     // TODO: Add your command handler code here
  165.     ((CDialog*)m_pMainWnd)->EndDialog(0);
  166. }
  167.  
  168. void CControlsApp::OnToolsApplyskin()
  169. {
  170.     HWND myWin = theApp.GetMainWnd()->m_hWnd;
  171.     HMENU myMenu = GetMenu(myWin);
  172.     CheckMenuItem(myMenu, 35500 ,MF_CHECKED);
  173.     // TODO: Add your command handler code here
  174.     theApp.m_pSkin.ApplySkin();
  175. }
  176.  
  177. void CControlsApp::OnToolsRemoveskin()
  178. {
  179.     // TODO: Add your command handler code here
  180.     theApp.m_pSkin.RemoveSkin();
  181. }
  182.  
  183. int CControlsApp::ExitInstance()
  184. {
  185.     // TODO: Add your specialized code here and/or call the base class
  186.     theApp.m_pSkin.DeInitDecoration();
  187.     
  188.     return CWinApp::ExitInstance();
  189. }
  190.  
  191. BOOL CControlsApp::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
  192. {
  193.     // TODO: Add your specialized code here and/or call the base class
  194.     if(nID == ID_HELP && nCode == CN_COMMAND)
  195.         return FALSE;
  196.     else if (nID >= (UINT)cmdStartNum && nID <= (UINT)cmdStartNum+9)
  197.     {
  198.         CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
  199.         int num = nID - cmdStartNum;
  200.         CString filepath = "";
  201.         filepath.Format ("%s\\%s", skinPath,customSkinNames[num]);
  202.         OFSTRUCT strF;
  203.         HFILE hFile = OpenFile( filepath, &strF, OF_EXIST);
  204.         if ( hFile != -1 )
  205.         {
  206.             theApp.m_pSkin.LoadSkinFromFile(filepath);
  207.             theApp.m_pSkin.ApplySkin();
  208.             lastSkinID = nID;
  209.             lastSkin = customSkinNames[num];
  210.             CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_CHECKED);
  211.         }
  212.         return FALSE;
  213.     }
  214.     else if (nID == 35600)
  215.     {
  216.         theApp.m_pSkin.RemoveSkin();
  217.         CString filepath = "";
  218.         filepath.Format ("%s\\%s", skinPath,lastSkin);
  219.  
  220.         if (lastSkin!="GlaucousTrack.skf" && lastSkin!="Metallic.skf" && lastSkin!="Ruby.skf" && lastSkin!="SkinCrafter.skf" && lastSkin!="TechnoBronze.skf" && lastSkin!="Tiger-eye.skf")
  221.         {
  222.             OFSTRUCT strF;
  223.             HFILE hFile = OpenFile( filepath, &strF, OF_EXIST);
  224.             if ( hFile != -1 )
  225.                 DeleteFile(filepath);
  226.         }
  227.         return FALSE;
  228.     }
  229.  
  230.     return CWinApp::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  231. }
  232.  
  233. void CControlsApp::OnHelpAbout()
  234. {
  235.     // TODO: Add your command handler code here
  236.     m_pSkin.AboutSkinCrafter();
  237. }
  238.  
  239. void CControlsApp::OnSkinsGlaucoustrack() 
  240. {
  241.     // TODO: Add your command handler code here
  242.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
  243.     CString filepath = "";
  244.     filepath.Format ("%s\\GlaucousTrack.skf", skinPath);
  245.     theApp.m_pSkin.LoadSkinFromFile(filepath);
  246.     theApp.m_pSkin.ApplySkin();
  247.     lastSkinID = ID_SKINS_GLAUCOUSTRACK;
  248.     lastSkin = "GlaucousTrack.skf";
  249.  
  250.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_GLAUCOUSTRACK ,MF_CHECKED);
  251. }
  252.  
  253. void CControlsApp::OnSkinsMetallic() 
  254. {
  255.     // TODO: Add your command handler code here
  256.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
  257.     CString filepath = "";
  258.     filepath.Format ("%s\\Metallic.skf", skinPath);
  259.     theApp.m_pSkin.LoadSkinFromFile(filepath);
  260.     theApp.m_pSkin.ApplySkin();
  261.     lastSkinID = ID_SKINS_METALLIC;
  262.     lastSkin = "Metallic.skf";
  263.  
  264.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_METALLIC ,MF_CHECKED);
  265. }
  266.  
  267. void CControlsApp::OnSkinsRuby()
  268. {
  269.     // TODO: Add your command handler code here
  270.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
  271.     CString filepath = "";
  272.     filepath.Format ("%s\\Ruby.skf", skinPath);
  273.     theApp.m_pSkin.LoadSkinFromFile(filepath);
  274.     theApp.m_pSkin.ApplySkin();
  275.     lastSkinID = ID_SKINS_RUBY;
  276.     lastSkin = "Ruby.skf";
  277.  
  278.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_RUBY ,MF_CHECKED);
  279. }
  280.  
  281. void CControlsApp::OnSkinsSkincrafter() 
  282. {
  283.     // TODO: Add your command handler code here
  284.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
  285.     CString filepath = "";
  286.     filepath.Format ("%s\\SkinCrafter.skf", skinPath);
  287.     theApp.m_pSkin.LoadSkinFromFile(filepath);
  288.     theApp.m_pSkin.ApplySkin();
  289.     lastSkinID = ID_SKINS_SKINCRAFTER;
  290.     lastSkin = "SkinCrafter.skf";
  291.  
  292.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_SKINCRAFTER ,MF_CHECKED);
  293. }
  294.  
  295. void CControlsApp::OnSkinsTechnobronze() 
  296. {
  297.     // TODO: Add your command handler code here
  298.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
  299.     CString filepath = "";
  300.     filepath.Format ("%s\\TechnoBronze.skf", skinPath);
  301.     theApp.m_pSkin.LoadSkinFromFile(filepath);
  302.     theApp.m_pSkin.ApplySkin();
  303.     lastSkinID = ID_SKINS_TECHNOBRONZE;
  304.     lastSkin = "TechnoBronze.skf";
  305.  
  306.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_TECHNOBRONZE ,MF_CHECKED);
  307. }
  308.  
  309. void CControlsApp::OnSkinsTigereye() 
  310. {
  311.     // TODO: Add your command handler code here
  312.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), lastSkinID ,MF_UNCHECKED);
  313.     CString filepath = "";
  314.     filepath.Format ("%s\\Tiger-eye.skf", skinPath);
  315.     theApp.m_pSkin.LoadSkinFromFile(filepath);
  316.     theApp.m_pSkin.ApplySkin();
  317.     lastSkinID = ID_SKINS_TIGEREYE;
  318.     lastSkin = "Tiger-eye.skf";
  319.  
  320.     CheckMenuItem(GetMenu(theApp.GetMainWnd()->m_hWnd), ID_SKINS_TIGEREYE ,MF_CHECKED);
  321. }
  322.  
  323. void CControlsApp::OnSkinsAddskin()
  324. {
  325. }
  326.