home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / weblibev / wltestc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-03  |  4.6 KB  |  219 lines

  1. // wltestc.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "wltestc.h"
  6. #include "maindlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. CWLTestApp NEAR theApp;            // the one and only CWLTestApp object
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CWLTestApp static members.
  17.  
  18. const char *CWLTestApp::m_pszBrowserAPIs[] = {
  19.     "GetWindowInfo",
  20.     "ListWindows",
  21.     "ActivateWindow",
  22.     "CloseWindow",
  23.     "SetWindowPos",
  24.     "ShowWindow",
  25.     "ShowFile",
  26.     "OpenURL",
  27.     "SaveURL",
  28.     "PostFormData",
  29.     "SaveFormData",
  30.     "RegisterProtocol",
  31.     "UnregisterProtocol",
  32.     "RegisterURLEcho",
  33.     "UnregisterURLEcho",
  34.     "RegisterViewer",
  35.     "UnregisterViewer",
  36.     "RegisterWindowChange",
  37.     "UnregisterWindowChange",
  38.     "ParseAnchor",
  39.     "GetVersion",
  40.     "QueryURLFile",
  41.     "SetNotifyMethod",
  42.     NULL
  43. };
  44.  
  45. const char *CWLTestApp::m_pszToolbarAPIs[] = {
  46.     "IsToolbarActive",
  47.     "SetActiveToolbar",
  48.     "AddToolbarButton",
  49.     "RemoveToolbarButton",
  50.     "IsToolbarButtonVisible",
  51.     "ShowToolbarButton",
  52.     "EnableToolbarButton",
  53.     "IsToolbarButtonEnabled",
  54.     "GetToolbarText",
  55.     "SetToolbarText",
  56.     "GetToolbarFont",
  57.     "SetToolbarFont",
  58.     "GetToolbarBkgnd",
  59.     "SetToolbarBkgnd",
  60.     "GetToolbarTextColor",
  61.     "SetToolbarTextColor",
  62.     NULL
  63. };
  64.  
  65. const char *CWLTestApp::m_pszHtmlAPIs[] = {
  66.     "EnumParseTree",
  67.     "GetChild",
  68.     "GetParent",
  69.     "GetSibling",
  70.     "GetElementType",
  71.     "GetElementText",
  72.     "GetTextAttr",
  73.     "GetTagName",
  74.     "GetTagType",
  75.     "GetTagAttr",
  76.     "ExtractTagAttr",
  77.     "FindText",
  78.     "FindSpecial",
  79.     "FindComment",
  80.     "FindTagType",
  81.     "FindTagName",
  82.     "FindTagAttr",
  83.     "EnumFindText",
  84.     "EnumFindSpecial",
  85.     "EnumFindComment",
  86.     "EnumFindTagType",
  87.     "EnumFindTagName",
  88.     "EnumFindTagAttr",
  89.     NULL
  90. };
  91.  
  92. const char *CWLTestApp::m_pszUtilAPIs[] = {
  93.     "AppendFormData",
  94.     "GetFormDataLength",
  95.     "ParseAbsoluteURL",
  96.     NULL
  97. };
  98.  
  99. /////////////////////////////////////////////////////////////////////////////
  100. // CWLTestApp message map and methods.
  101.  
  102. BEGIN_MESSAGE_MAP(CWLTestApp, CWinApp)
  103.     //{{AFX_MSG_MAP(CWLTestApp)
  104.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  105.     //}}AFX_MSG_MAP
  106. END_MESSAGE_MAP()
  107.  
  108. CWLTestApp::CWLTestApp()
  109. {
  110. }
  111.  
  112. BOOL CWLTestApp::InitInstance()
  113. {
  114.     SetDialogBkColor();        // set dialog background color to gray
  115.     LoadStdProfileSettings();  // load standard INI file options (including MRU) 
  116.     
  117.     if ((m_strMainWndClass = AfxRegisterWndClass(MAINWNDSTYLE,NULL,
  118.         (HBRUSH) (COLOR_WINDOW + 1),NULL))[0] == '\0')
  119.         return FALSE; 
  120.     
  121.     m_pMainWnd = new CWLTestWnd;
  122.     ASSERT(m_pMainWnd != NULL);
  123.     
  124.     m_pMainWnd->PostMessage(WM_APP_SHOWMAINDLG);
  125.     return TRUE;
  126. }
  127.  
  128. int CWLTestApp::ExitInstance()
  129. {   
  130.     m_pMainWnd->DestroyWindow();
  131.     m_pMainWnd = NULL;
  132.     return CWinApp::ExitInstance();
  133. }
  134.  
  135. /////////////////////////////////////////////////////////////////////////////
  136. // CWLTestWnd -- main app window, invisible, needed so dialog works correctly  
  137.  
  138. BEGIN_MESSAGE_MAP(CWLTestWnd, CWnd)
  139.     //{{AFX_MSG_MAP(CWLTestWnd)
  140.     ON_MESSAGE(WM_APP_SHOWMAINDLG,OnShowMainDlg)
  141.     //}}AFX_MSG_MAP
  142. END_MESSAGE_MAP()
  143.  
  144. CWLTestWnd::CWLTestWnd() : CWnd()
  145. {
  146.     (void) CreateEx(0,theApp.m_strMainWndClass,NULL,WS_OVERLAPPEDWINDOW,0,0,10,10,NULL,0);
  147. }
  148.  
  149. LONG CWLTestWnd::OnShowMainDlg(UINT wParam,LONG lParam)
  150. {
  151.     TRY
  152.     {
  153.         CMainDlg dlg;
  154.         (void) dlg.DoModal();    
  155.     }
  156.     CATCH(CMemoryException,e)
  157.     {
  158.         AfxMessageBox(IDS_ERR_OUTOFMEM);
  159.     }
  160.     END_CATCH
  161.     
  162.     ::PostQuitMessage(0);
  163.     return 0;
  164. }
  165.  
  166. void CWLTestWnd::PostNcDestroy()
  167.     ::MessageBeep(-1);
  168.     delete this;
  169. }
  170.  
  171. /////////////////////////////////////////////////////////////////////////////
  172. // CAboutDlg dialog used for App About
  173.  
  174. class CAboutDlg : public CDialog
  175. {
  176.   public:
  177.     CAboutDlg();
  178.  
  179.   // Dialog Data
  180.     //{{AFX_DATA(CAboutDlg)
  181.     enum { IDD = IDD_ABOUTBOX };
  182.     //}}AFX_DATA
  183.  
  184.   // Implementation
  185.   protected:
  186.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  187.     //{{AFX_MSG(CAboutDlg)
  188.         // No message handlers
  189.     //}}AFX_MSG
  190.     DECLARE_MESSAGE_MAP()
  191. };
  192.  
  193. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  194. {
  195.     //{{AFX_DATA_INIT(CAboutDlg)
  196.     //}}AFX_DATA_INIT
  197. }
  198.  
  199. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  200. {
  201.     CDialog::DoDataExchange(pDX);
  202.     //{{AFX_DATA_MAP(CAboutDlg)
  203.     //}}AFX_DATA_MAP
  204. }
  205.  
  206. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  207.     //{{AFX_MSG_MAP(CAboutDlg)
  208.     //}}AFX_MSG_MAP
  209. END_MESSAGE_MAP()
  210.  
  211. // App command to run the dialog
  212. void CWLTestApp::OnAppAbout()
  213. {
  214.     CAboutDlg aboutDlg;
  215.     aboutDlg.DoModal();
  216. }
  217.  
  218.