home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / sdk / mapi / win16 / dev / propvu / problem.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-11  |  6.0 KB  |  247 lines

  1. /*******************************************************************/
  2. /*
  3.  -  problem.cpp
  4.  -  Copyright (C) 1995 Microsoft Corporation
  5.  -
  6.  *  Purpose:
  7.  *      Contains member functions for CProblemDlg
  8.  */
  9. /*******************************************************************/
  10.                                                    
  11. #undef  CINTERFACE      // C++ calling convention for mapi calls
  12.  
  13. #ifdef WIN32
  14. #ifdef _WIN95
  15. #define _INC_OLE
  16. #endif
  17. #define INC_OLE2
  18. #define INC_RPC
  19. #endif
  20.  
  21. #include <afxwin.h>     
  22. #include <windowsx.h>
  23. #include <string.h>
  24.  
  25. #ifdef WIN16
  26. #include <compobj.h>
  27. #endif
  28.  
  29. #ifdef WIN32
  30. #include <objbase.h>
  31. #include <objerror.h>
  32. #ifdef _WIN95
  33. #include <ole2.h>
  34. #endif
  35. #endif
  36.  
  37.  
  38. #ifdef WIN16
  39. #include <mapiwin.h>    
  40. #endif
  41. #include <mapix.h>      
  42. #include <strtbl.h>     
  43. #include <misctool.h>
  44. #include "resource.h"   
  45. #include "propvu.h"  
  46. #include "problem.h"
  47.  
  48.  
  49. #define PROBLEM_LISTBOX_TAB1_SIZE    47
  50. #define PROBLEM_LISTBOX_TAB2_SIZE    190
  51.  
  52.  
  53. /*******************************************************************/
  54. /**************************** GETPROPS *****************************/
  55.  
  56. /******************* Fld Message Map ****************************/
  57.  
  58. BEGIN_MESSAGE_MAP(CProblemDlg, CDialog)
  59.  
  60.     ON_COMMAND( IDC_PROB_DUMPPROB,  OnDumpProblemsToFile)
  61.  
  62. END_MESSAGE_MAP()
  63.  
  64.  
  65. /********************************************************************/
  66. /*
  67.  -  CProblemDlg::
  68.  -  OnInitDialog
  69.  -
  70.  *  Purpose:
  71.  *
  72.  */
  73. /********************************************************************/
  74.  
  75. BOOL CProblemDlg::OnInitDialog()
  76. {
  77.     HRESULT         hResult         = hrSuccess;
  78.     CGetError       E;
  79.     int             rgTabStops[4];
  80.     DWORD           dwReturn        = 0;      
  81.         
  82.     SetWindowText( m_Operation.GetBuffer(15) );
  83.  
  84.     SendDlgItemMessage(IDC_PROB_DISPLAY,LB_RESETCONTENT,0,0);
  85.  
  86.     if( !m_lpProblems)
  87.     {
  88.         MessageBox( "CProblemDlg::OnInitDialog  lpProblems == NULL",
  89.                     "Client", MBS_ERROR );
  90.         goto error;
  91.     }           
  92.  
  93.     // load properties into listbox
  94.     dwReturn = SendDlgItemMessage(IDC_PROB_DISPLAY, LB_SETHORIZONTALEXTENT,
  95.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  96.  
  97.     rgTabStops[0] = PROBLEM_LISTBOX_TAB1_SIZE ;
  98.     rgTabStops[1] = PROBLEM_LISTBOX_TAB2_SIZE ;
  99.  
  100.     dwReturn = SendDlgItemMessage(IDC_PROB_DISPLAY,LB_SETTABSTOPS,
  101.                     (WPARAM) 2,(LPARAM)rgTabStops );
  102.  
  103.     DisplayProblems();
  104.  
  105.     return TRUE;    
  106.  
  107. error:
  108.  
  109.     return FALSE;
  110. }
  111.  
  112. /*******************************************************************/
  113. /*
  114.  -  CBldPropDlg::
  115.  -  DisplayProblems
  116.  *
  117.  *  Purpose:
  118.  *
  119.  *  Parameters:
  120.  *
  121.  *  Returns:
  122.  *
  123.  */
  124. /*******************************************************************/
  125.  
  126. void CProblemDlg::DisplayProblems()
  127. {
  128.     char            szBuffer[1024];
  129.     int             idx             = 0;
  130.     DWORD           dwReturn        = 0;      
  131.     char            szCProblems[30];
  132.     char            szIndex[10];
  133.     char            szPropTag[50];
  134.     char            szScError[50];      
  135.  
  136.         
  137.     // DISPLAY Expected lpPTA->cValues
  138.     wsprintf(szCProblems,"cProblems:  %lu",m_lpProblems->cProblem);
  139.     SetDlgItemText(IDT_PROB_CPROBLEMS,szCProblems);
  140.  
  141.     szBuffer[0] = '\0' ;
  142.  
  143.     SendDlgItemMessage(IDC_PROB_DISPLAY,LB_RESETCONTENT,0,0);
  144.  
  145.  
  146.     // DISPLAY ALL PROBLEMS         
  147.     for(idx = 0; idx < m_lpProblems->cProblem; idx++)
  148.     {   
  149.         szIndex[0]      = '\0' ;
  150.         szPropTag[0]    = '\0' ;
  151.         szScError[0]    = '\0' ;
  152.             
  153.  
  154.         wsprintf(szBuffer,"%lu",m_lpProblems->aProblem[idx].ulIndex);
  155.         lstrcat(szBuffer, "\t");
  156.  
  157.  
  158.         if(GetString("PropTags", m_lpProblems->aProblem[idx].ulPropTag, szPropTag ) )
  159.         {
  160.             lstrcat(szBuffer, szPropTag );              
  161.             lstrcat(szBuffer, "\t");
  162.         }
  163.         else
  164.         {
  165.             wsprintf(szPropTag,"%#04X\t", m_lpProblems->aProblem[idx].ulPropTag );      
  166.             lstrcat(szBuffer,szPropTag);
  167.         }
  168.  
  169.         if( GetString("MAPIErrors", m_lpProblems->aProblem[idx].scode, szScError) )
  170.         {
  171.             lstrcat(szBuffer, szScError);
  172.             lstrcat(szBuffer,"\t");
  173.         }       
  174.         else
  175.         {
  176.             wsprintf(szScError,"%#04X\t",  m_lpProblems->aProblem[idx].scode );
  177.             lstrcat(szBuffer,szScError);
  178.         }
  179.         dwReturn = SendDlgItemMessage(IDC_PROB_DISPLAY,LB_ADDSTRING,0,
  180.                             (LPARAM)szBuffer);
  181.     
  182.     }  
  183.    
  184.     dwReturn = SendDlgItemMessage(IDC_PROB_DISPLAY,LB_SETCURSEL,(WPARAM) -1 ,0 );
  185. }
  186.  
  187.  
  188. /*******************************************************************/
  189. /*
  190.  -  CProblemDlg::
  191.  -  ~CProblemDlg
  192.  -
  193.  *  Purpose:
  194.  *      Destructor for class CProblemDlg. Releases and Frees memory
  195.  *      allocated in this class
  196.  *
  197.  */
  198. /*******************************************************************/
  199.  
  200. CProblemDlg::~CProblemDlg()
  201. {
  202.  
  203.  
  204. /*******************************************************************/
  205. /*
  206.  -  CPropDlg::
  207.  -  OnStorePropValsToFile
  208.  *
  209.  *  Purpose:
  210.  *      Store PropValues in object to file
  211.  */
  212. /*******************************************************************/
  213.  
  214. void CProblemDlg::OnDumpProblemsToFile()
  215. {
  216.     char                szTag[80];
  217.     char                szFileName[80];
  218.     LPTSTR              lpszTemp;
  219.     CStorePropValDlg    StoreProp(this);
  220.         
  221.     // find file to open
  222.     lpszTemp = getenv("MAPITEST");
  223.  
  224.     if(lpszTemp)
  225.         strcpy(szFileName, lpszTemp);
  226.     else
  227.         strcpy(szFileName, "c:\\mapitest");
  228.  
  229.     strcat(szFileName, "\\data\\propvu.txt");
  230.  
  231.     // create the tag with braces around it
  232.     strcpy(szTag,"[PROBLEM00001]");       
  233.  
  234.     StoreProp.m_TagID       = szTag;
  235.     StoreProp.m_FileName    = szFileName;
  236.         
  237.     if( StoreProp.DoModal() == IDOK )
  238.     {    
  239.         WriteProblemArray( StoreProp.m_szFileName,
  240.                       StoreProp.m_szTagID,
  241.                       m_lpProblems);
  242.     }
  243. }
  244.  
  245.  
  246.