home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_tools / vbxstd12 / vbxdemo.cp_ / VBXDEMO.CPP
C/C++ Source or Header  |  1995-01-13  |  7KB  |  233 lines

  1. // vbxdemo.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "vbxdemo.h"
  6. #include "resources.h"
  7. #include "3ddemo.h"
  8. #include "animdemo.h"
  9. #include "combodem.h"
  10. #include "editdemo.h"
  11. #include "fcombode.h"
  12. #include "gaugedem.h"
  13. #include "linedemo.h"
  14. #include "listdemo.h"
  15. #include "flistdem.h"
  16. #include "spindemo.h"
  17. #include "textdemo.h"
  18. #include "picbtnde.h"
  19. #include "tabdemo.h"
  20. #include "ddropdem.h"
  21.  
  22. #include "maindlg.h"
  23. #include <sys\types.h>
  24. #include <sys\stat.h>
  25.  
  26.  
  27. #ifdef _DEBUG
  28. #undef THIS_FILE
  29. static char BASED_CODE THIS_FILE[] = __FILE__;
  30. #endif
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CVbxdemoApp
  34.  
  35. BEGIN_MESSAGE_MAP(CVbxdemoApp, CWinApp)
  36.     //{{AFX_MSG_MAP(CVbxdemoApp)
  37.         // NOTE - the ClassWizard will add and remove mapping macros here.
  38.         //    DO NOT EDIT what you see in these blocks of generated code!
  39.     //}}AFX_MSG_MAP
  40.     // Standard file based document commands
  41. END_MESSAGE_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CVbxdemoApp construction
  45.  
  46. CVbxdemoApp::CVbxdemoApp()
  47. {
  48.     // TODO: add construction code here,
  49.     // Place all significant initialization in InitInstance
  50. }
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // The one and only CVbxdemoApp object
  54.  
  55. CVbxdemoApp NEAR theApp;
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CVbxdemoApp initialization
  59.  
  60. BOOL CVbxdemoApp::InitInstance()
  61. {
  62.     // Standard initialization
  63.     // If you are not using these features and wish to reduce the size
  64.     //  of your final executable, you should remove from the following
  65.     //  the specific initialization routines you do not need.
  66.  
  67.     SetDialogBkColor();        // Set dialog background color to gray
  68.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  69.     EnableVBX();               // Initialize VBX support
  70.  
  71.     // Register the application's document templates.  Document templates
  72.     //  serve as the connection between documents, frame windows and views.
  73.     if ( !AreVBXHere() )
  74.         return TRUE;
  75.     
  76.     IsHlpHere( TRUE );
  77.     
  78.     CMainDlg mainDlg;
  79.     /*AfxGetApp()->*/m_pMainWnd = &mainDlg;
  80.     mainDlg.DoModal();
  81.     
  82.     
  83.     return TRUE;
  84. }
  85.  
  86.  
  87. /////////////////////////////////////////////////////////////////////////////
  88. // VB-Event registration
  89. // (calls to AfxRegisterVBEvent will be placed here by ClassWizard)
  90.  
  91. //{{AFX_VBX_REGISTER_MAP()
  92.     UINT NEAR VBN_DBLCLICK = AfxRegisterVBEvent("DBLCLICK");
  93.     UINT NEAR VBN_KEYDOWN = AfxRegisterVBEvent("KEYDOWN");
  94.     UINT NEAR VBN_UPDATE = AfxRegisterVBEvent("UPDATE");
  95.     UINT NEAR VBN_SCROLLUP = AfxRegisterVBEvent("SCROLLUP");
  96.     UINT NEAR VBN_SCROLLDN = AfxRegisterVBEvent("SCROLLDN");
  97.     UINT NEAR VBN_SELCHANGE = AfxRegisterVBEvent("SELCHANGE");
  98.     UINT NEAR VBN_CLICK = AfxRegisterVBEvent("CLICK");
  99.     UINT NEAR VBN_GOTFOCUS = AfxRegisterVBEvent("GOTFOCUS");
  100.     UINT NEAR VBN_FILEDROPPED = AfxRegisterVBEvent("FILEDROPPED");
  101. //}}AFX_VBX_REGISTER_MAP
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CVbxdemoApp commands
  105.  
  106.             // -----------------------------------------------------------------------------------------
  107.             //    AreVBXHere
  108.             //    Check VBXs 
  109.             // -----------------------------------------------------------------------------------------
  110.             BOOL AreVBXHere()
  111.                 {
  112.             /*    CString FAR szWinDir, szName, szErrorMsg;
  113.                 GetSystemDirectory( szWinDir.GetBuffer(250), 248 );
  114.                 szWinDir.ReleaseBuffer();
  115.                 if ( szWinDir.GetLength() > 3 )
  116.                     szWinDir += "\\";
  117.                 szName = szWinDir;
  118.                 szName += "SPINDLL.DLL";
  119.                 if ( !Exist( szName ) )
  120.                     goto NOT_FOUND;
  121.                 szName = szWinDir;
  122.                 szName += "VBSPIN.VBX";
  123.                 if ( !Exist( szName ) )
  124.                     goto NOT_FOUND;
  125.                 szName = szWinDir;
  126.                 szName += "VBLIST.VBX";
  127.                 if ( !Exist( szName ) )
  128.                     goto NOT_FOUND;
  129.                 szName = szWinDir;
  130.                 szName += "VBFLIST.VBX";
  131.                 if ( !Exist( szName ) )
  132.                     goto NOT_FOUND;
  133.                 szName = szWinDir;
  134.                 szName += "VBCOMBO.VBX";
  135.                 if ( !Exist( szName ) )
  136.                     goto NOT_FOUND;
  137.                 szName = szWinDir;
  138.                 szName += "VBFCOMBO.VBX";
  139.                 if ( !Exist( szName ) )
  140.                     goto NOT_FOUND;
  141.                 szName = szWinDir;
  142.                 szName += "VB3D.VBX";
  143.                 if ( !Exist( szName ) )
  144.                     goto NOT_FOUND;
  145.                 szName = szWinDir;
  146.                 szName += "VBANIM.VBX";
  147.                 if ( !Exist( szName ) )
  148.                     goto NOT_FOUND;
  149.                 szName = szWinDir;
  150.                 szName += "VBDDROP.VBX";
  151.                 if ( !Exist( szName ) )
  152.                     goto NOT_FOUND;
  153.                 szName = szWinDir;
  154.                 szName += "VBEDIT.VBX";
  155.                 if ( !Exist( szName ) )
  156.                     goto NOT_FOUND;
  157.                 szName = szWinDir;
  158.                 szName += "VBGAUGE.VBX";
  159.                 if ( !Exist( szName ) )
  160.                     goto NOT_FOUND;
  161.                 szName = szWinDir;
  162.                 szName += "VBLINE.VBX";
  163.                 if ( !Exist( szName ) )
  164.                     goto NOT_FOUND;
  165.                 szName = szWinDir;
  166.                 szName += "VBNOTE.VBX";
  167.                 if ( !Exist( szName ) )
  168.                     goto NOT_FOUND;
  169.                 szName = szWinDir;
  170.                 szName += "VBPICBTN.VBX";
  171.                 if ( !Exist( szName ) )
  172.                     goto NOT_FOUND;
  173.                 szName = szWinDir;
  174.                 szName += "VBTAB.VBX";
  175.                 if ( !Exist( szName ) )
  176.                     goto NOT_FOUND;
  177.                 szName = szWinDir;
  178.                 szName += "VBTEXT.VBX";
  179.                 if ( !Exist( szName ) )
  180.                     goto NOT_FOUND;
  181.                 return TRUE;
  182.             NOT_FOUND:
  183.                     szErrorMsg = "Error!\n\n";
  184.                     szErrorMsg += szName;
  185.                     szErrorMsg += "\nnot found: to run this demo you must put all VBX Studio VBXs in\nthe WINDOWS\\SYSTEM directory.";
  186.                     AfxMessageBox( szErrorMsg, MB_OK | MB_ICONSTOP );
  187.                     return FALSE;
  188. */
  189. return TRUE;                }
  190.             
  191.             
  192.             // -----------------------------------------------------------------------------------------
  193.             //    IsHlpHere
  194.             //    Check VBXSTD12.HLP 
  195.             // -----------------------------------------------------------------------------------------
  196.             BOOL IsHlpHere( BOOL bShowWarning )
  197.                 {
  198.                 CString FAR szWinDir, szName, szErrorMsg;
  199.                 GetSystemDirectory( szWinDir.GetBuffer(250), 248 );
  200.                 szWinDir.ReleaseBuffer();
  201.                 if ( szWinDir.GetLength() > 3 )
  202.                     szWinDir += "\\";
  203.                 szName = szWinDir;
  204.                 szName += "VBXSTD12.HLP";
  205.                 if ( !Exist( szName ) )                            
  206.                     {
  207.                     if ( bShowWarning )
  208.                         {
  209.                         szErrorMsg = "Warning!\n\n";
  210.                         szErrorMsg += szName;
  211.                         szErrorMsg += "\nnot found. To use this file you must put it in this directory.";
  212.                         AfxMessageBox( szErrorMsg, MB_OK | MB_ICONEXCLAMATION );
  213.                         }
  214.                     return FALSE;
  215.                     }
  216.                 return TRUE;
  217.                 }
  218.             
  219.             
  220.             // -----------------------------------------------------------------------------------------
  221.             //    Exist
  222.             //    Check a file
  223.             // -----------------------------------------------------------------------------------------
  224.             BOOL Exist( LPCSTR szName )
  225.                 {
  226.                 struct _stat StatBuf;
  227.                 if ( _stat( szName, &StatBuf ) )
  228.                     return FALSE;
  229.                 if ( StatBuf.st_mode & _S_IFDIR )
  230.                     return FALSE;
  231.                 return TRUE;
  232.                 }                
  233.