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.

555 lines
15 KiB

  1. // paramvw.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "FaxApi.h"
  5. #include "paramvw.h"
  6. #include "fcnselvw.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. extern CFaxApiApp * pFaxApiBrowserApp;
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CParameterInfoFormView
  15. IMPLEMENT_DYNCREATE(CParameterInfoFormView, CFormView)
  16. CParameterInfoFormView::CParameterInfoFormView()
  17. : CFormView(CParameterInfoFormView::IDD)
  18. {
  19. //{{AFX_DATA_INIT(CParameterInfoFormView)
  20. // NOTE: the ClassWizard will add member initialization here
  21. //}}AFX_DATA_INIT
  22. }
  23. CParameterInfoFormView::~CParameterInfoFormView()
  24. {
  25. }
  26. void CParameterInfoFormView::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CFormView::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(CParameterInfoFormView)
  30. // NOTE: the ClassWizard will add DDX and DDV calls here
  31. //}}AFX_DATA_MAP
  32. }
  33. BEGIN_MESSAGE_MAP(CParameterInfoFormView, CFormView)
  34. //{{AFX_MSG_MAP(CParameterInfoFormView)
  35. ON_LBN_SELCHANGE(IDC_LISTBOX_PARAMETERS, OnSelchangeListboxParameters)
  36. ON_EN_KILLFOCUS(IDC_EDIT_PARAMETER_VALUE, OnKillfocusEditParameterValue)
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CParameterInfoFormView diagnostics
  41. #ifdef _DEBUG
  42. void CParameterInfoFormView::AssertValid() const
  43. {
  44. CFormView::AssertValid();
  45. }
  46. void CParameterInfoFormView::Dump(CDumpContext& dc) const
  47. {
  48. CFormView::Dump(dc);
  49. }
  50. #endif //_DEBUG
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CParameterInfoFormView message handlers
  53. BOOL CParameterInfoFormView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
  54. {
  55. BOOL fReturnValue;
  56. fReturnValue = CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  57. if ( fReturnValue != (BOOL) FALSE )
  58. {
  59. // Save the handle to this view in the CFaxApiApp object.
  60. pFaxApiBrowserApp->StoreParameterInfoFormViewHWND( m_hWnd );
  61. }
  62. return ( fReturnValue );
  63. }
  64. /*
  65. * OnSelchangeListboxParameters
  66. *
  67. * Purpose:
  68. * This function handles the LBN_SELCHANGE messages from the
  69. * Parameter listbox.
  70. *
  71. * Arguments:
  72. * None
  73. *
  74. * Returns:
  75. * None
  76. *
  77. */
  78. void CParameterInfoFormView::OnSelchangeListboxParameters()
  79. {
  80. // Get a pointer to the Parameter listbox.
  81. CListBox * pclbParameterList;
  82. pclbParameterList = (CListBox *) ((CDialog *) this)->
  83. GetDlgItem( IDC_LISTBOX_PARAMETERS );
  84. if ( pclbParameterList != (CListBox *) NULL )
  85. {
  86. // What item is selected ?
  87. int xParameterIndex;
  88. xParameterIndex = pclbParameterList->GetCurSel();
  89. /* Is the item index valid */
  90. if ( xParameterIndex != (int) LB_ERR )
  91. {
  92. // xParameterIndex tells us which parameter is selected, but at this
  93. // point we don't know which Fax API function is selected.
  94. // Get a pointer to the CFaxApiFunctionSelectionFormViewObject.
  95. CFaxApiFunctionSelectionFormView * pcFaxApiFunctionSelectionFormView;
  96. pcFaxApiFunctionSelectionFormView = (CFaxApiFunctionSelectionFormView *)
  97. pFaxApiBrowserApp->GetFaxApiFunctionSelectionFormViewPointer();
  98. // Is the pointer valid ?
  99. if ( pcFaxApiFunctionSelectionFormView !=
  100. (CFaxApiFunctionSelectionFormView *) NULL )
  101. {
  102. // Get a pointer to the CFaxApiFunctionInfo object for the selected
  103. // Fax API function.
  104. CFaxApiFunctionInfo * pcfafiFunctionInfo;
  105. pcfafiFunctionInfo = pcFaxApiFunctionSelectionFormView->
  106. GetSelectedFaxApiFunctionInfoPointer();
  107. // Is the pointer to the CFaxApiFunctionInfo object valid ?
  108. if ( pcfafiFunctionInfo != (CFaxApiFunctionInfo *) NULL )
  109. {
  110. /* Format the parameter value for output. */
  111. CString csParameterValue;
  112. pcfafiFunctionInfo->FormatParameterValueForOutput( xParameterIndex,
  113. (CString &) csParameterValue );
  114. /* Update the Parameter Value edit control. */
  115. CEdit * pceEditControl;
  116. pceEditControl = (CEdit *) ((CDialog *) this)->
  117. GetDlgItem( IDC_EDIT_PARAMETER_VALUE );
  118. if ( pceEditControl != (CEdit *) NULL )
  119. {
  120. pceEditControl->SetWindowText( csParameterValue );
  121. }
  122. /* Limit the amount of text the user may enter. */
  123. SetLimitTextParameterValueEditControl( pcfafiFunctionInfo,
  124. xParameterIndex );
  125. // Update the static text control that displays the parameter name.
  126. CString csParameterName;
  127. pcfafiFunctionInfo->GetParameterName( xParameterIndex,
  128. (CString &) csParameterName );
  129. // Get a pointer to the static text control.
  130. CWnd * pcwndStaticText;
  131. pcwndStaticText = ((CDialog *) this)->
  132. GetDlgItem( IDC_STATIC_PARAMETER_NAME );
  133. if ( pcwndStaticText != (CWnd *) NULL )
  134. {
  135. CString csParameterType;
  136. csParameterType = pcfafiFunctionInfo->
  137. GetParameterTypeString( xParameterIndex );
  138. CString csText;
  139. csText.Format( TEXT("%s %s"),csParameterType, csParameterName );
  140. pcwndStaticText->SetWindowText( csText );
  141. }
  142. // Update the parameter upper limit edit control.
  143. // THE FOLLOWING IS JUST DUMMIED UP !!!
  144. CString csEditControlString; // temporary junk
  145. pceEditControl = (CEdit *) ((CDialog *) this)->
  146. GetDlgItem( IDC_EDIT_PARAM_HI_LIMIT );
  147. if ( pceEditControl != (CEdit *) NULL )
  148. {
  149. csEditControlString.Format( TEXT("Upper limit for %s"), csParameterName );
  150. pceEditControl->SetWindowText( csEditControlString );
  151. }
  152. // Update the parameter lower limit edit control
  153. pceEditControl = (CEdit *) ((CDialog *) this)->
  154. GetDlgItem( IDC_EDIT_PARAM_LOW_LIMIT );
  155. if ( pceEditControl != (CEdit *) NULL )
  156. {
  157. csEditControlString.Format( TEXT("Lower limit for %s"), csParameterName );
  158. pceEditControl->SetWindowText( csEditControlString );
  159. }
  160. // Update the parameter description edit control.
  161. pceEditControl = (CEdit *) ((CDialog *) this)->
  162. GetDlgItem( IDC_EDIT_PARAMETER_DESCRIPTION );
  163. if ( pceEditControl != (CEdit *) NULL )
  164. {
  165. csEditControlString = pcfafiFunctionInfo->
  166. GetParameterDescription( xParameterIndex );
  167. pceEditControl->SetWindowText( csEditControlString );
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }
  174. /*
  175. * ClearParameterEditControlFamily
  176. *
  177. * Purpose:
  178. * This function clears the family of edit controls that is
  179. * associated with the Fax API Function parameter list.
  180. *
  181. * Arguments:
  182. * None
  183. *
  184. * Returns:
  185. * TRUE - indicates success
  186. * FALSE - indicates failure
  187. *
  188. */
  189. BOOL CParameterInfoFormView::ClearParameterEditControlFamily()
  190. {
  191. BOOL fReturnValue = (BOOL) TRUE;
  192. /* Reset the parameter value edit control. */
  193. CEdit * pceEditControl;
  194. pceEditControl = (CEdit *) ((CDialog *) this)->
  195. GetDlgItem( IDC_EDIT_PARAMETER_VALUE );
  196. if ( pceEditControl != (CEdit *) NULL )
  197. {
  198. /* Clear the parameter value edit control. */
  199. pceEditControl->SetSel( 0, -1, (BOOL) TRUE );
  200. pceEditControl->Clear();
  201. }
  202. else
  203. fReturnValue = (BOOL) FALSE;
  204. /* Clear the parameter range edit controls. */
  205. pceEditControl = (CEdit *) ((CDialog *) this)->
  206. GetDlgItem( IDC_EDIT_PARAM_HI_LIMIT );
  207. if ( pceEditControl != (CEdit *) NULL )
  208. {
  209. pceEditControl->SetReadOnly( (BOOL) FALSE );
  210. pceEditControl->SetSel( 0, -1, (BOOL) TRUE );
  211. pceEditControl->Clear();
  212. pceEditControl->SetReadOnly( (BOOL) TRUE );
  213. }
  214. else
  215. fReturnValue = (BOOL) FALSE;
  216. pceEditControl = (CEdit *) ((CDialog *) this)->
  217. GetDlgItem( IDC_EDIT_PARAM_LOW_LIMIT );
  218. if ( pceEditControl != (CEdit *) NULL )
  219. {
  220. pceEditControl->SetReadOnly( (BOOL) FALSE );
  221. pceEditControl->SetSel( 0, -1, (BOOL) TRUE );
  222. pceEditControl->Clear();
  223. pceEditControl->SetReadOnly( (BOOL) TRUE );
  224. }
  225. else
  226. fReturnValue = (BOOL) FALSE;
  227. /* Clear the parameter meaning edit control. */
  228. pceEditControl = (CEdit *) ((CDialog *) this)->
  229. GetDlgItem( IDC_EDIT_PARAMETER_DESCRIPTION );
  230. if ( pceEditControl != (CEdit *) NULL )
  231. {
  232. pceEditControl->SetReadOnly( (BOOL) FALSE );
  233. pceEditControl->SetSel( 0, -1, (BOOL) TRUE );
  234. pceEditControl->Clear();
  235. pceEditControl->SetReadOnly( (BOOL) TRUE );
  236. }
  237. else
  238. fReturnValue = (BOOL) FALSE;
  239. /* Clear the static text control. */
  240. // Get a pointer to the static text control.
  241. CWnd * pcwndStaticText;
  242. pcwndStaticText = ((CDialog *) this)->
  243. GetDlgItem( IDC_STATIC_PARAMETER_NAME );
  244. if ( pcwndStaticText != (CWnd *) NULL )
  245. {
  246. pcwndStaticText->SetWindowText( TEXT("") );
  247. }
  248. else
  249. fReturnValue = (BOOL) FALSE;
  250. return ( fReturnValue );
  251. }
  252. /*
  253. * UpdateParameterListbox
  254. *
  255. * Purpose:
  256. * This function fills the parameter listbox with the names of the
  257. * parameters for the selected Fax Api function.
  258. *
  259. * Arguments:
  260. * pcfafiFunctionInfo - points to the CFaxApiFunctionInfo object for
  261. * the selected Fax API function.
  262. *
  263. * Returns:
  264. * TRUE - indicates that the listbox was updated successfully.
  265. * FALSE - indicates that some error occured.
  266. *
  267. */
  268. BOOL CParameterInfoFormView::UpdateParameterListbox( CFaxApiFunctionInfo * pcfafiFunctionInfo )
  269. {
  270. BOOL fReturnValue;
  271. CListBox * pclbParameterList;
  272. /* Get a pointer to the Parameter listbox. */
  273. pclbParameterList = (CListBox *) ((CDialog *) this)->
  274. GetDlgItem( IDC_LISTBOX_PARAMETERS );
  275. /* Is the pointer valid ? */
  276. if ( pclbParameterList != (CListBox *) NULL )
  277. {
  278. /* Empty the listbox. */
  279. pclbParameterList->ResetContent();
  280. /* Add entries to the parameter listbox. */
  281. int xNumberOfParameters;
  282. xNumberOfParameters = pcfafiFunctionInfo->GetNumberOfParameters();
  283. CString csEntry;
  284. int xParameterIndex;
  285. for ( xParameterIndex = 0; xParameterIndex < xNumberOfParameters; xParameterIndex++)
  286. {
  287. pcfafiFunctionInfo->GetParameterName( xParameterIndex, (CString &) csEntry );
  288. if ( csEntry.IsEmpty() == (BOOL) FALSE )
  289. {
  290. pclbParameterList->InsertString( xParameterIndex, (LPCTSTR) csEntry );
  291. }
  292. }
  293. fReturnValue = (BOOL) TRUE;
  294. }
  295. else
  296. fReturnValue = (BOOL) FALSE;
  297. return ( fReturnValue );
  298. }
  299. /*
  300. * SetLimitTextParameterValueEditControl
  301. *
  302. * Purpose:
  303. * This function limits the amount of text that can be entered
  304. * into the parameter value edit control.
  305. *
  306. * Arguments:
  307. * pcfafiFunctionInfo - points to the CFaxApiFunctionInfo object for
  308. * function selected in the function list.
  309. * xParameterIndex = the index into the CFaxApiFunctionParameterInfo
  310. * object array member of the CFaxApiFunction object for
  311. * the function selected in the function list to the
  312. * CFaxApiFunctionParameterInfo object for the parameter
  313. * selected in the parameter list.
  314. *
  315. * Returns:
  316. * None
  317. *
  318. */
  319. void CParameterInfoFormView::SetLimitTextParameterValueEditControl( CFaxApiFunctionInfo * pcfafiFunctionInfo,
  320. int xParameterIndex )
  321. {
  322. int xParameterValueEditControlTextLimit;
  323. xParameterValueEditControlTextLimit =
  324. pcfafiFunctionInfo->GetMaxParamValueStringLength( xParameterIndex );
  325. CEdit * pceEditControl;
  326. /* Set the text limit. */
  327. pceEditControl = (CEdit *) ((CDialog *) this)->GetDlgItem( IDC_EDIT_PARAMETER_VALUE );
  328. if ( pceEditControl != (CEdit *) NULL )
  329. {
  330. pceEditControl->SetLimitText( xParameterValueEditControlTextLimit );
  331. }
  332. }
  333. /*
  334. * OnKillfocusEditParameterValue
  335. *
  336. * Purpose:
  337. * This function processes the EN_KILLFOCUS messages from the
  338. * parameter value edit control. It reads the content of the
  339. * edit control and stores it in the memory allocated by the
  340. * CFaxApiFunctionInfo object for parameter values.
  341. *
  342. * Arguments:
  343. * None
  344. *
  345. * Returns:
  346. * None
  347. *
  348. */
  349. void CParameterInfoFormView::OnKillfocusEditParameterValue()
  350. {
  351. CEdit * pceEditControl;
  352. // Get a pointer to the Parameter Value edit control.
  353. pceEditControl = (CEdit *) ((CDialog *) this)->
  354. GetDlgItem( IDC_EDIT_PARAMETER_VALUE );
  355. // Is the pointer valid ?
  356. if ( pceEditControl != (CEdit *) NULL )
  357. {
  358. /* Read the parameter value edit control. */
  359. CString csParameterValue;
  360. pceEditControl->GetWindowText( (CString &) csParameterValue );
  361. /* Get the index into the parameter list. */
  362. CListBox * pclbParameterList;
  363. pclbParameterList = (CListBox *) GetDlgItem( IDC_LISTBOX_PARAMETERS );
  364. /* Is the pointer valid ? */
  365. if ( pclbParameterList != (CListBox *) NULL )
  366. {
  367. int xParameterIndex;
  368. xParameterIndex = pclbParameterList->GetCurSel();
  369. /* Is the index valid ? */
  370. if ( xParameterIndex != (int) LB_ERR )
  371. {
  372. // xParameterIndex tells us which parameter is selected, but at this
  373. // point we don't know which Fax API function is selected.
  374. // Get a pointer to the CFaxApiFunctionSelectionFormViewObject.
  375. CFaxApiFunctionSelectionFormView * pcFaxApiFunctionSelectionFormView;
  376. pcFaxApiFunctionSelectionFormView = (CFaxApiFunctionSelectionFormView *)
  377. pFaxApiBrowserApp->GetFaxApiFunctionSelectionFormViewPointer();
  378. // Is the pointer valid ?
  379. if ( pcFaxApiFunctionSelectionFormView !=
  380. (CFaxApiFunctionSelectionFormView *) NULL )
  381. {
  382. // Get a pointer to the CFaxApiFunctionInfo object for the selected
  383. // Fax API function.
  384. CFaxApiFunctionInfo * pcfafiFunctionInfo;
  385. pcfafiFunctionInfo = pcFaxApiFunctionSelectionFormView->
  386. GetSelectedFaxApiFunctionInfoPointer();
  387. // Is the pointer to the CFaxApiFunctionInfo object valid ?
  388. if ( pcfafiFunctionInfo != (CFaxApiFunctionInfo *) NULL )
  389. {
  390. /* Store the new parameter value. */
  391. pcfafiFunctionInfo->StoreParameterValue( xParameterIndex,
  392. (const CString &) csParameterValue );
  393. }
  394. }
  395. }
  396. }
  397. }
  398. }