home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / msmqocm.cab / mqapitst.cpp < prev    next >
C/C++ Source or Header  |  1997-10-06  |  4KB  |  175 lines

  1. // test.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "MQApitst.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "testDoc.h"
  9. #include "testView.h"
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CTestApp
  19.  
  20. BEGIN_MESSAGE_MAP(CTestApp, CWinApp)
  21.     //{{AFX_MSG_MAP(CTestApp)
  22.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  23.         // NOTE - the ClassWizard will add and remove mapping macros here.
  24.         //    DO NOT EDIT what you see in these blocks of generated code!
  25.     //}}AFX_MSG_MAP
  26.     // Standard file based document commands
  27.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  28.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  29. END_MESSAGE_MAP()
  30.  
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CTestApp construction
  33.  
  34. CTestApp::CTestApp()
  35. {
  36.     // TODO: add construction code here,
  37.     // Place all significant initialization in InitInstance
  38. }
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // The one and only CTestApp object
  42.  
  43. CTestApp theApp;
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CTestApp initialization
  47.  
  48. BOOL CTestApp::InitInstance()
  49. {
  50.     // Standard initialization
  51.     // If you are not using these features and wish to reduce the size
  52.     //  of your final executable, you should remove from the following
  53.     //  the specific initialization routines you do not need.
  54.  
  55. #ifdef _AFXDLL
  56.     Enable3dControls();            // Call this when using MFC in a shared DLL
  57. #else
  58.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  59. #endif
  60.  
  61.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  62.  
  63.     // Register the application's document templates.  Document templates
  64.     //  serve as the connection between documents, frame windows and views.
  65.  
  66.     CSingleDocTemplate* pDocTemplate;
  67.     pDocTemplate = new CSingleDocTemplate(
  68.         IDR_MAINFRAME,
  69.         RUNTIME_CLASS(CTestDoc),
  70.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  71.         RUNTIME_CLASS(CTestView));
  72.     AddDocTemplate(pDocTemplate);
  73.  
  74.     // Parse command line for standard shell commands, DDE, file open
  75.     CCommandLineInfo cmdInfo;
  76.     ParseCommandLine(cmdInfo);
  77.  
  78.     // Dispatch commands specified on the command line
  79.     if (!ProcessShellCommand(cmdInfo))
  80.         return FALSE;
  81.  
  82.     return TRUE;
  83. }
  84.  
  85. /////////////////////////////////////////////////////////////////////////////
  86. // CAboutDlg dialog used for App About
  87.  
  88. class CAboutDlg : public CDialog
  89. {
  90. public:
  91.     CAboutDlg();
  92.  
  93. // Dialog Data
  94.     //{{AFX_DATA(CAboutDlg)
  95.     enum { IDD = IDD_ABOUTBOX };
  96.     //}}AFX_DATA
  97.  
  98.     // ClassWizard generated virtual function overrides
  99.     //{{AFX_VIRTUAL(CAboutDlg)
  100.     protected:
  101.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  102.     //}}AFX_VIRTUAL
  103.  
  104. // Implementation
  105. protected:
  106.     //{{AFX_MSG(CAboutDlg)
  107.         // No message handlers
  108.     //}}AFX_MSG
  109.     DECLARE_MESSAGE_MAP()
  110. };
  111.  
  112. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  113. {
  114.     //{{AFX_DATA_INIT(CAboutDlg)
  115.     //}}AFX_DATA_INIT
  116. }
  117.  
  118. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  119. {
  120.     CDialog::DoDataExchange(pDX);
  121.     //{{AFX_DATA_MAP(CAboutDlg)
  122.     //}}AFX_DATA_MAP
  123. }
  124.  
  125. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  126.     //{{AFX_MSG_MAP(CAboutDlg)
  127.         // No message handlers
  128.     //}}AFX_MSG_MAP
  129. END_MESSAGE_MAP()
  130.  
  131. // App command to run the dialog
  132. void CTestApp::OnAppAbout()
  133. {
  134.     CAboutDlg aboutDlg;
  135.     aboutDlg.DoModal();
  136. }
  137.  
  138. /////////////////////////////////////////////////////////////////////////////
  139. // CTestApp commands
  140.  
  141.  
  142. //
  143. // Pointer to hold the main window pointer.
  144. //
  145. CWnd* pMainView;
  146.  
  147. extern "C" void  PrintToScreen(const TCHAR * Format, ...)
  148. {
  149.    
  150.  
  151.    TCHAR szText[500];
  152.    va_list l;
  153.    static len = 0;
  154.  
  155.  
  156.     //Format the string
  157.     va_start(l, Format); 
  158. #ifdef UNICODE
  159.     vswprintf(szText, Format, l);
  160. #else
  161.     vsprintf(szText, Format, l);
  162. #endif
  163.  
  164.  
  165.        CEdit& rfMainEdit = ((CTestView*)pMainView)->GetEditCtrl();
  166.  
  167.     int i = rfMainEdit.GetLineCount();
  168.  
  169.     ((CTestView*)pMainView)->GetEditCtrl().SetSel(INT_MAX,INT_MAX);
  170.     ((CTestView*)pMainView)->GetEditCtrl().ReplaceSel(szText);
  171.     ((CTestView*)pMainView)->GetEditCtrl().ReplaceSel(TEXT("\r\n"));
  172.     len += lstrlen(szText) + 2;
  173.     ((CTestView*)pMainView)->GetDocument()->SetModifiedFlag(FALSE);
  174. }
  175.