Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

285 lines
7.4 KiB

  1. // exelogvw.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "FaxApi.h"
  5. #include "exelogvw.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. extern CFaxApiApp * pFaxApiBrowserApp;
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CExecutionLogFormView
  14. IMPLEMENT_DYNCREATE(CExecutionLogFormView, CFormView)
  15. CExecutionLogFormView::CExecutionLogFormView()
  16. : CFormView(CExecutionLogFormView::IDD)
  17. {
  18. //{{AFX_DATA_INIT(CExecutionLogFormView)
  19. // NOTE: the ClassWizard will add member initialization here
  20. //}}AFX_DATA_INIT
  21. }
  22. CExecutionLogFormView::~CExecutionLogFormView()
  23. {
  24. }
  25. void CExecutionLogFormView::DoDataExchange(CDataExchange* pDX)
  26. {
  27. CFormView::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(CExecutionLogFormView)
  29. // NOTE: the ClassWizard will add DDX and DDV calls here
  30. //}}AFX_DATA_MAP
  31. }
  32. BEGIN_MESSAGE_MAP(CExecutionLogFormView, CFormView)
  33. //{{AFX_MSG_MAP(CExecutionLogFormView)
  34. // NOTE - the ClassWizard will add and remove mapping macros here.
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CExecutionLogFormView diagnostics
  39. #ifdef _DEBUG
  40. void CExecutionLogFormView::AssertValid() const
  41. {
  42. CFormView::AssertValid();
  43. }
  44. void CExecutionLogFormView::Dump(CDumpContext& dc) const
  45. {
  46. CFormView::Dump(dc);
  47. }
  48. #endif //_DEBUG
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CExecutionLogFormView message handlers
  51. BOOL CExecutionLogFormView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
  52. {
  53. BOOL fReturnValue;
  54. fReturnValue = CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  55. if ( fReturnValue != (BOOL) FALSE )
  56. {
  57. // Save the handle to this view in the CFaxApiApp object.
  58. pFaxApiBrowserApp->StoreExecutionLogFormViewHWND( m_hWnd );
  59. }
  60. return ( fReturnValue );
  61. }
  62. BOOL CExecutionLogFormView::UpdateExecutionLogEditCtrl( CString & rcsExecutionLogString )
  63. {
  64. BOOL fReturnValue;
  65. // Get a pointer to the Execution Log edit control.
  66. CEdit * pceExecutionLogEditCtrl;
  67. pceExecutionLogEditCtrl = (CEdit *) ((CDialog *) this)->
  68. GetDlgItem( IDC_EDIT_EXECUTION_LOG );
  69. // Is the pointer valid ?
  70. if ( pceExecutionLogEditCtrl != (CEdit *) NULL )
  71. {
  72. pceExecutionLogEditCtrl->SetWindowText( rcsExecutionLogString );
  73. }
  74. else
  75. {
  76. fReturnValue = (BOOL) FALSE;
  77. }
  78. return ( fReturnValue );
  79. }
  80. /*
  81. * UpdateExecutionLogBeforeApiCall
  82. *
  83. * Purpose:
  84. * This function writes a block of text to the execution log edit control
  85. * in preparation for executing the selected Fax Api function.
  86. *
  87. * Arguments:
  88. * pcfafiFunctionInfo - points to the CFaxApiFunctionInfo object for
  89. * the selected Fax Api function.
  90. *
  91. * Returns:
  92. * none
  93. *
  94. */
  95. void CExecutionLogFormView::UpdateExecutionLogBeforeApiCall( CFaxApiFunctionInfo * pcfafiFunctionInfo )
  96. {
  97. /* Get a pointer to the Output edit control. */
  98. CEdit * pceEditControl;
  99. pceEditControl = (CEdit *) ((CDialog *) this)->GetDlgItem( IDC_EDIT_EXECUTION_LOG );
  100. if ( pceEditControl != (CEdit *) NULL )
  101. {
  102. CString csFunctionName;
  103. CString csText;
  104. csFunctionName = pcfafiFunctionInfo->GetFunctionName();
  105. csText.Format( TEXT("\r\nCalling %s\r\n"), csFunctionName );
  106. AddTextToEditControl( pceEditControl, (const CString &) csText );
  107. int xNumberOfParameters;
  108. xNumberOfParameters = pcfafiFunctionInfo->GetNumberOfParameters();
  109. if ( xNumberOfParameters > 0 )
  110. {
  111. int xParameterIndex;
  112. CString csParameterName;
  113. CString csParameterValue;
  114. for ( xParameterIndex = 0; xParameterIndex < xNumberOfParameters; xParameterIndex++ )
  115. {
  116. pcfafiFunctionInfo->GetParameterName( xParameterIndex,
  117. (CString &) csParameterName );
  118. pcfafiFunctionInfo->FormatParameterValueForOutput( xParameterIndex,
  119. (CString &) csParameterValue );
  120. csText.Format( TEXT(" %s = \t%s\r\n"), csParameterName, csParameterValue );
  121. AddTextToEditControl( pceEditControl, (const CString &) csText );
  122. }
  123. }
  124. }
  125. }
  126. /*
  127. * UpdateExecutionLogAfterApiReturn
  128. *
  129. * Purpose:
  130. * This function writes a block of text to the output exit control
  131. * after execution of the selected Fax Api function.
  132. *
  133. * Arguments:
  134. * pcfafiFunctionInfo - points to the CFaxApiFunctionInfo object for
  135. * the selected Fax Api function.
  136. *
  137. * Returns:
  138. * none
  139. *
  140. */
  141. void CExecutionLogFormView::UpdateExecutionLogAfterApiReturn( CFaxApiFunctionInfo * pcfafiFunctionInfo )
  142. {
  143. /* Get a pointer to the Execution Log edit control. */
  144. CEdit * pceEditControl;
  145. pceEditControl = (CEdit *) ((CDialog *) this)->GetDlgItem( IDC_EDIT_EXECUTION_LOG );
  146. if ( pceEditControl != (CEdit *) NULL )
  147. {
  148. CString csFunctionName;
  149. CString csText;
  150. csFunctionName = pcfafiFunctionInfo->GetFunctionName();
  151. csText.Format( TEXT("\r\n%s returned:\r\n"), csFunctionName );
  152. AddTextToEditControl( pceEditControl, (const CString &) csText );
  153. CString csReturnValue;
  154. pcfafiFunctionInfo->FormatReturnValueForOutput( (CString &) csReturnValue );
  155. csText.Format( TEXT(" %s\r\n"), csReturnValue );
  156. AddTextToEditControl( pceEditControl, (const CString &) csText );
  157. int xNumberOfParameters;
  158. xNumberOfParameters = pcfafiFunctionInfo->GetNumberOfParameters();
  159. if ( xNumberOfParameters > 0 )
  160. {
  161. int xParameterIndex;
  162. CString csParameterName;
  163. CString csParameterValue;
  164. for ( xParameterIndex = 0; xParameterIndex < xNumberOfParameters; xParameterIndex++ )
  165. {
  166. pcfafiFunctionInfo->GetParameterName( xParameterIndex,
  167. (CString &) csParameterName );
  168. pcfafiFunctionInfo->FormatParameterValueForOutput( xParameterIndex,
  169. (CString &) csParameterValue );
  170. csText.Format( TEXT(" %s = \t%s\r\n"), csParameterName, csParameterValue );
  171. AddTextToEditControl( pceEditControl, (const CString &) csText );
  172. }
  173. }
  174. }
  175. }
  176. /*
  177. * AddTextToEditControl
  178. *
  179. * Purpose:
  180. * This function adds text to an edit control.
  181. *
  182. * Arguments:
  183. * pceEditControl - points to the CEdit object
  184. * rcsText - a reference to CString that contains the text
  185. * to be added to the edit control.
  186. *
  187. * may want to add num chars parameter later !
  188. *
  189. * Returns:
  190. * None
  191. *
  192. */
  193. void CExecutionLogFormView::AddTextToEditControl( CEdit * pceEditControl, const CString & rcsText )
  194. {
  195. if ( pceEditControl != (CEdit *) NULL )
  196. {
  197. /* Set the insertion point at the end of the text. */
  198. pceEditControl->SetSel( -1, 50000 ); // 50000 is arbitrary !
  199. /* Turn off READ ONLY. */
  200. pceEditControl->SetReadOnly( (BOOL) FALSE );
  201. /* Write the string to the edit control. */
  202. pceEditControl->ReplaceSel( (LPCTSTR) rcsText );
  203. /* Turn on READ ONLY. */
  204. pceEditControl->SetReadOnly( (BOOL) TRUE );
  205. }
  206. }