home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 September (Japanese) / CICA Shareware for Windows CD-ROM (Walnut Creek) (September 1995) (Japanese) (Disc 2).iso / disc2 / patches / symantec / mfcsim.exe / SIMNEW.EXE / MFC / SAMPLES / DIB / USERCODE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-06  |  8.8 KB  |  400 lines

  1. // Filename: USERCODE.CPP                                   
  2. // "DIB" Generated by Visual Programmer
  3. // Author:   Blue Sky                                       
  4.  
  5. // 
  6. // ***********************************************************************
  7. // Code in this file is initially generated by the Switch-It Module.
  8. // This file contains functions you can change
  9. // to provide whatever functionality you require.
  10. // 
  11. // 
  12. // 
  13. // For more information,
  14. // see the section "How code is generated" in the documentation.
  15. // 
  16. // ***********************************************************************
  17. // 
  18.  
  19. #include "AFXWIN.H"
  20. #include "DIB.H"
  21.  
  22. WMPDEBUG
  23.  
  24. #ifdef _DEBUG
  25. #undef THIS_FILE
  26. static char BASED_CODE THIS_FILE[] = __FILE__;
  27. #endif
  28.  
  29.  
  30. #include "USERCODE.WMC"
  31.     
  32.     
  33. CBitmapInstance CBitInst;
  34.  
  35.  
  36.  
  37. // *************************************************************
  38. // Class definition for Class: Cwm_AboutDlg
  39. // Base Class                : Cwm_AboutBaseDlg
  40. // Derived from MFC Class    : CDialog
  41. // *************************************************************
  42.  
  43. class Cwm_AboutDlg : public Cwm_AboutBaseDlg
  44. {
  45. public:
  46.     Cwm_AboutDlg(LPCSTR lpszTemplateName,CWnd *pParentWnd);
  47.     Cwm_AboutDlg() : Cwm_AboutBaseDlg() {};
  48.  
  49. #ifdef _DEBUG
  50.     virtual void AssertValid() const;
  51.     virtual void Dump(CDumpContext& dc) const;
  52. #endif
  53.  
  54.     virtual BOOL OnInitDialog();
  55.     virtual void OnOK();
  56.     virtual void OnCancel();
  57.  
  58.     // YOU CAN ADD YOUR OWN CODE HERE
  59.  
  60.  
  61. protected:
  62.     //{{SIM_MSG_PROTO(Cwm_AboutDlg)
  63.     // DO NOT EDIT what you see in this block of generated code.
  64.     //}}SIM_MSG_PROTO(Cwm_AboutDlg)
  65.  
  66. protected:
  67.     virtual void DoDataExchange(CDataExchange* pDX);   // DDX/DDV support
  68.  
  69.     DECLARE_DYNCREATE(Cwm_AboutDlg)
  70.  
  71.     DECLARE_MESSAGE_MAP()
  72.  
  73. };
  74.  
  75.  
  76. // *************************************************************
  77. //   C Startup function for modal dialogbox ABOUT
  78. // *************************************************************
  79.  
  80. int BLD_AboutDlgFunc(CWnd *pWnd)
  81.     {
  82.     int iRet;
  83.     Cwm_AboutDlg TheDlg ("ABOUT",pWnd);
  84.  
  85.     iRet=TheDlg.DoModal();
  86.     if( -1 == iRet )
  87.         {
  88.         BLDDisplayMessage (::GetActiveWindow (), BLD_CannotCreate,
  89.             "ABOUT", MB_OK | MB_ICONHAND);
  90.         }
  91.     return iRet;
  92.     }
  93.  
  94.  
  95.  
  96. // *************************************************************
  97. // Member Functions for Class: Cwm_AboutDlg
  98. // Base Class                : Cwm_AboutBaseDlg
  99. // Derived from MFC Class    : CDialog
  100. // *************************************************************
  101.  
  102. Cwm_AboutDlg::Cwm_AboutDlg(LPCSTR lpszTemplateName,CWnd *pParentWnd)
  103.   : Cwm_AboutBaseDlg(lpszTemplateName,pParentWnd)
  104. {
  105. }
  106.  
  107.  
  108.  
  109. BOOL Cwm_AboutDlg::OnInitDialog()
  110. {
  111.     return Cwm_AboutBaseDlg::OnInitDialog();
  112. }
  113.  
  114.  
  115.  
  116.  
  117. void Cwm_AboutDlg::OnOK()
  118. {
  119.     Cwm_AboutBaseDlg::OnOK();
  120. }
  121.  
  122.  
  123.  
  124. void Cwm_AboutDlg::OnCancel()
  125. {
  126.     Cwm_AboutBaseDlg::OnCancel();
  127. }
  128.  
  129.  
  130. IMPLEMENT_DYNCREATE(Cwm_AboutDlg, Cwm_AboutBaseDlg)
  131.  
  132. BEGIN_MESSAGE_MAP(Cwm_AboutDlg, Cwm_AboutBaseDlg)
  133.  
  134.     // YOU CAN ADD YOUR OWN CODE HERE
  135.  
  136.     //{{SIM_MSG_MAP(Cwm_AboutDlg)
  137.     // DO NOT EDIT what you see in this block of generated code.
  138.     //}}SIM_MSG_MAP(Cwm_AboutDlg)
  139.  
  140. END_MESSAGE_MAP()
  141.  
  142.  
  143. //{{SIM_MSG_BODY(Cwm_AboutDlg)
  144. // Message Handler Functions for you to edit will come here.
  145.  
  146.  
  147. //}}SIM_MSG_BODY(Cwm_AboutDlg)
  148.  
  149.  
  150.  
  151. void Cwm_AboutDlg::DoDataExchange(CDataExchange* pDX)
  152. {
  153.     Cwm_AboutBaseDlg::DoDataExchange(pDX);
  154.  
  155.     // YOU CAN ADD YOUR OWN CODE HERE
  156.  
  157.  
  158.     //{{SIM_DATA_MAP(Cwm_AboutDlg)
  159.     // DO NOT EDIT what you see in this block of generated code.
  160.  
  161.     //}}SIM_DATA_MAP
  162. }
  163.  
  164.  
  165.  
  166. // *************************************************************
  167. // Cwm_AboutDlg diagnostics
  168.  
  169. #ifdef _DEBUG
  170. void Cwm_AboutDlg::AssertValid() const
  171. {
  172.     Cwm_AboutBaseDlg::AssertValid();
  173. }
  174.  
  175. void Cwm_AboutDlg::Dump(CDumpContext& dc) const
  176. {
  177.     Cwm_AboutBaseDlg::Dump(dc);
  178. }
  179.  
  180. #endif //_DEBUG
  181.  
  182.  
  183.  
  184. //  User Defined Code 
  185. BOOL BLD_RedUDCFunc(CWnd *pWnd)
  186.     {
  187.     CBitInst.SwitchBMP(IDM_Red,"RED.DLL");
  188.     return TRUE;
  189.     }
  190.  
  191.  
  192. //  User Defined Code 
  193. BOOL BLD_BlueUDCFunc(CWnd *pWnd)
  194.     {
  195.     CBitInst.SwitchBMP(IDM_Blue,"BLUE.DLL");
  196.     return TRUE;
  197.     }
  198.  
  199.  
  200. //  User Defined Code 
  201. BOOL BLD_OwnUDCFunc(CWnd *pWnd)
  202.     {
  203.     CBitInst.SwitchBMP(IDM_Own,NULL);
  204.     return TRUE;
  205.     }
  206.  
  207.  
  208. // *************************************************************
  209. // Class definition for Class: Cwm_DIBClientDlg
  210. // Base Class                : Cwm_DIBClientBaseDlg
  211. // Derived from MFC Class    : CFormView
  212. // *************************************************************
  213.  
  214. class Cwm_DIBClientDlg : public Cwm_DIBClientBaseDlg
  215. {
  216. public:
  217.     Cwm_DIBClientDlg(LPCSTR lpszTemplateName);
  218.     Cwm_DIBClientDlg() : Cwm_DIBClientBaseDlg() {};
  219.  
  220. #ifdef _DEBUG
  221.     virtual void AssertValid() const;
  222.     virtual void Dump(CDumpContext& dc) const;
  223. #endif
  224.  
  225.     virtual BOOL OnInitDialog();
  226.  
  227.     // YOU CAN ADD YOUR OWN CODE HERE
  228.  
  229.  
  230. protected:
  231.     //{{SIM_MSG_PROTO(Cwm_DIBClientDlg)
  232.     // DO NOT EDIT what you see in this block of generated code.
  233.     //}}SIM_MSG_PROTO(Cwm_DIBClientDlg)
  234.  
  235. protected:
  236.     virtual void DoDataExchange(CDataExchange* pDX);   // DDX/DDV support
  237.  
  238.     DECLARE_DYNCREATE(Cwm_DIBClientDlg)
  239.  
  240.     DECLARE_MESSAGE_MAP()
  241.  
  242. };
  243.  
  244.  
  245. // *************************************************************
  246. //   C Startup function client area controls CLIENT
  247. // *************************************************************
  248.  
  249. CWnd* BLD_DIBClientClFunc (CWnd* pWnd)
  250. {
  251.     Cwm_DIBClientDlg*    pTheClientDlg;
  252.     pTheClientDlg = new Cwm_DIBClientDlg("CLIENT");
  253.     if(!pTheClientDlg->Create(pWnd))
  254.         {
  255.         BLDDisplayMessage (::GetActiveWindow (), BLD_CannotCreate,
  256.             "CLIENT", MB_OK | MB_ICONHAND);
  257.         return NULL;
  258.         }
  259.     return pTheClientDlg;
  260. }
  261.  
  262.  
  263.  
  264. // *************************************************************
  265. // Member Functions for Class: Cwm_DIBClientDlg
  266. // Base Class                : Cwm_DIBClientBaseDlg
  267. // Derived from MFC Class    : CFormView
  268. // *************************************************************
  269.  
  270. Cwm_DIBClientDlg::Cwm_DIBClientDlg(LPCSTR lpszTemplateName)
  271.   : Cwm_DIBClientBaseDlg(lpszTemplateName)
  272. {
  273. }
  274.  
  275.  
  276.  
  277. BOOL Cwm_DIBClientDlg::OnInitDialog()
  278. {
  279.     return Cwm_DIBClientBaseDlg::OnInitDialog();
  280. }
  281.  
  282.  
  283. IMPLEMENT_DYNCREATE(Cwm_DIBClientDlg, Cwm_DIBClientBaseDlg)
  284.  
  285. BEGIN_MESSAGE_MAP(Cwm_DIBClientDlg, Cwm_DIBClientBaseDlg)
  286.  
  287.     // YOU CAN ADD YOUR OWN CODE HERE
  288.  
  289.     //{{SIM_MSG_MAP(Cwm_DIBClientDlg)
  290.     // DO NOT EDIT what you see in this block of generated code.
  291.     //}}SIM_MSG_MAP(Cwm_DIBClientDlg)
  292.  
  293. END_MESSAGE_MAP()
  294.  
  295.  
  296. //{{SIM_MSG_BODY(Cwm_DIBClientDlg)
  297. // Message Handler Functions for you to edit will come here.
  298.  
  299.  
  300. //}}SIM_MSG_BODY(Cwm_DIBClientDlg)
  301.  
  302.  
  303.  
  304. void Cwm_DIBClientDlg::DoDataExchange(CDataExchange* pDX)
  305. {
  306.     Cwm_DIBClientBaseDlg::DoDataExchange(pDX);
  307.  
  308.     // YOU CAN ADD YOUR OWN CODE HERE
  309.  
  310.  
  311.     //{{SIM_DATA_MAP(Cwm_DIBClientDlg)
  312.     // DO NOT EDIT what you see in this block of generated code.
  313.  
  314.     //}}SIM_DATA_MAP
  315. }
  316.  
  317.  
  318.  
  319. // *************************************************************
  320. // Cwm_DIBClientDlg diagnostics
  321.  
  322. #ifdef _DEBUG
  323. void Cwm_DIBClientDlg::AssertValid() const
  324. {
  325.     Cwm_DIBClientBaseDlg::AssertValid();
  326. }
  327.  
  328. void Cwm_DIBClientDlg::Dump(CDumpContext& dc) const
  329. {
  330.     Cwm_DIBClientBaseDlg::Dump(dc);
  331. }
  332.  
  333. #endif //_DEBUG
  334.  
  335.  
  336.  
  337. // ****************************************************************************
  338. // Member functions for CBitmapInstance
  339. // ****************************************************************************
  340.  
  341. // Constructor
  342. CBitmapInstance::CBitmapInstance()
  343. {
  344.     hBMPLib        = 0;
  345.     iLastCheck    = IDM_Own;
  346. }
  347.  
  348.  
  349. BOOL CBitmapInstance::SwitchBMP(int iMenuId,char *pDLL)
  350. {
  351.     HINSTANCE    hNewLib;
  352.     char        path[256];
  353.     CMenu *        pMenu;
  354.     char        *pStr;
  355.  
  356.     if (!pDLL)
  357.         hNewLib    = 0;                    // Use own BMPs
  358.     else
  359.         {
  360.         if (!::GetModuleFileName(AfxGetInstanceHandle(),path,sizeof(path)))
  361.             return FALSE;
  362.         pStr        = strrchr(path,'\\');
  363.         if (!pStr)
  364.             return FALSE;
  365.         pStr++;
  366.         lstrcpy(pStr,pDLL);
  367.         hNewLib        = LoadLibrary(path);
  368.         if (hNewLib<HINSTANCE_ERROR)
  369.             return FALSE;                // Couldn't load DLL use previous setting
  370.         }
  371.  
  372.     if (hBMPLib)
  373.         FreeLibrary(hBMPLib);
  374.     hBMPLib        = hNewLib;        
  375.     // hBMPInst is used by MFC SIM functions to load bitmaps
  376.     if (hNewLib)
  377.         hBMPInst= hNewLib;
  378.     else
  379.         hBMPInst= 0;
  380.     if (!TheApp.m_pMainWnd)
  381.         return FALSE;
  382.     TheApp.m_pMainWnd->InvalidateRect(NULL,FALSE);
  383.     pMenu        = TheApp.m_pMainWnd->GetMenu();
  384.     if (!pMenu)
  385.         return FALSE;
  386.     pMenu->CheckMenuItem(iLastCheck,MF_BYCOMMAND|MF_UNCHECKED);
  387.     pMenu->CheckMenuItem(iMenuId,MF_BYCOMMAND|MF_CHECKED);
  388.     iLastCheck    = iMenuId;
  389.     return TRUE;
  390. }
  391.  
  392.  
  393. BOOL CBitmapInstance::FreeLib()
  394. {
  395.     if (hBMPLib)
  396.         FreeLibrary(hBMPLib);
  397.     hBMPLib    = 0;
  398.     return TRUE;
  399. }
  400.