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

  1. /*******************************************************************/
  2. /*
  3.  -  compare.cpp
  4.  -  Copyright (C) 1995 Microsoft Corporation
  5.  -
  6.  *  Purpose:
  7.  *      Contains member functions for CCompareDlg
  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. #ifdef WIN16
  38. #include <mapiwin.h>    
  39. #endif
  40. #include <mapix.h>      
  41. #include <strtbl.h>     
  42. #include <misctool.h>
  43. #include "resource.h"   
  44. #include "propvu.h"  
  45. #include "compare.h"
  46.  
  47. /*******************************************************************/
  48. /**************************** GETPROPS *****************************/
  49.  
  50. /******************* Set Property Message Map *********************/
  51.  
  52. BEGIN_MESSAGE_MAP(CCompareDlg, CModalDialog)
  53.  
  54.     ON_COMMAND(         IDC_COMP_DUMP_BEFORE,     OnDumpPropValsBeforeToFile)
  55.     ON_COMMAND(         IDC_COMP_DUMP_AFTER,      OnDumpPropValsAfterToFile)
  56.              
  57. END_MESSAGE_MAP()
  58.  
  59. /********************************************************************/
  60. /*
  61.  -  CCompareDlg::
  62.  -  OnInitDialog
  63.  -
  64.  *  Purpose:
  65.  *
  66.  */
  67. /********************************************************************/
  68.  
  69. BOOL CCompareDlg::OnInitDialog()
  70. {       
  71.     SetWindowText( m_Operation.GetBuffer(40) );
  72.  
  73.     SendDlgItemMessage(IDC_COMP_BEFORE,LB_RESETCONTENT,0,0);
  74.     SendDlgItemMessage(IDC_COMP_AFTER, LB_RESETCONTENT,0,0);
  75.  
  76.     if( (!m_lpspvaBefore) || (!m_lpspvaAfter) || (!m_cValuesBefore) || (!m_cValuesAfter))
  77.     {
  78.         MessageBox( "CCompareDlg::OnInitDialog  (!m_lpspvaBefore) || (!m_lpspvaAfter) || (!m_cValuesBefore) || (!m_cValuesAfter) ",
  79.                     "Client", MBS_ERROR );
  80.         goto error;
  81.     }           
  82.  
  83.     DisplayProps();
  84.  
  85.     return TRUE;    
  86.  
  87. error:
  88.  
  89.     if(m_lpspvaBefore)
  90.     {
  91.         MAPIFreeBuffer(m_lpspvaBefore);
  92.         m_lpspvaBefore          = NULL;
  93.         m_cValuesBefore         = 0;
  94.     }
  95.     
  96.     if(m_lpspvaAfter)
  97.     {
  98.         MAPIFreeBuffer(m_lpspvaAfter);
  99.         m_lpspvaAfter           = NULL;
  100.         m_cValuesAfter          = 0;
  101.     }
  102.     
  103.     return FALSE;
  104. }
  105.  
  106.  
  107.  
  108. /*******************************************************************/
  109. /*
  110.  -  CBldPropDlg::
  111.  -  DisplayProps
  112.  *
  113.  *  Purpose:
  114.  *
  115.  *  Parameters:
  116.  *
  117.  *  Returns:
  118.  *
  119.  */
  120. /*******************************************************************/
  121.  
  122. void CCompareDlg::DisplayProps()
  123. {
  124.     char            szBuffer[1024];
  125.     int             idx             = 0;
  126.     int             rgTabStops[4];
  127.     DWORD           dwReturn        = 0;      
  128.     char            szActualCVals[30];
  129.  
  130.     char szID[50];
  131.     char szData[512];
  132.     char szType[32];      // Assumes no PropType string longer than 31 chars
  133.  
  134.     
  135.     // BEFORE DISPLAY
  136.         
  137.     // DISPLAY Actual m_cValues
  138.     wsprintf(szActualCVals,"cValues:  %lu",m_cValuesBefore);
  139.     SetDlgItemText(IDT_COMP_CVALBEFORE,szActualCVals);
  140.     
  141.     // DISPLAY PropValue Array
  142.     szBuffer[0] = '\0' ;
  143.  
  144.     SendDlgItemMessage(IDC_COMP_BEFORE,LB_RESETCONTENT,0,0);
  145.  
  146.     // load properties into listbox
  147.     dwReturn = SendDlgItemMessage(IDC_COMP_BEFORE,LB_SETHORIZONTALEXTENT,
  148.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  149.  
  150.     rgTabStops[0] = PROP_LISTBOX_TAB1_SIZE ;
  151.     rgTabStops[1] = PROP_LISTBOX_TAB2_SIZE ;
  152.  
  153.     dwReturn = SendDlgItemMessage(IDC_COMP_BEFORE,LB_SETTABSTOPS,
  154.                     (WPARAM) 2,(LPARAM)rgTabStops );
  155.     
  156.     for(idx = 0; idx < m_cValuesBefore; idx++)
  157.     {   
  158.         szID[0]     = '\0' ;
  159.         szData[0]   = '\0' ;
  160.         szType[0]   = '\0' ;
  161.         szBuffer[0] = '\0' ;
  162.             
  163.         if(GetString("PropIDs", PROP_ID(m_lpspvaBefore[idx].ulPropTag), szID ) )
  164.         {
  165.             lstrcat(szBuffer, szID );               
  166.             lstrcat(szBuffer, "\t");
  167.         }
  168.         else
  169.         {
  170.             wsprintf(szBuffer,"%#04X\t", PROP_ID(m_lpspvaBefore[idx].ulPropTag) );      
  171.         }
  172.  
  173.         if( GetString("PropType", PROP_TYPE(m_lpspvaBefore[idx].ulPropTag), szType) )
  174.         {
  175.             lstrcat(szBuffer, szType);
  176.             lstrcat(szBuffer,"\t");
  177.         }       
  178.         else
  179.         {
  180.             wsprintf(szType,"%#04X\t", PROP_TYPE(m_lpspvaBefore[idx].ulPropTag) );
  181.             lstrcat(szBuffer,szType);
  182.         }
  183.         
  184.         SzGetPropValue(szData,(LPSPropValue) &m_lpspvaBefore[idx]);
  185.         lstrcat(szBuffer,szData);
  186.  
  187.         dwReturn = SendDlgItemMessage(IDC_COMP_BEFORE,LB_ADDSTRING,0,
  188.                             (LPARAM)szBuffer);
  189.     
  190.     } 
  191.  
  192.     // AFTER DISPLAY
  193.     
  194.     
  195.     // DISPLAY Actual m_cValues
  196.     wsprintf(szActualCVals,"cValues:  %lu",m_cValuesAfter);
  197.     SetDlgItemText(IDC_COMP_CVALAFTER,szActualCVals);
  198.     
  199.     // DISPLAY PropValue Array
  200.     szBuffer[0] = '\0' ;
  201.  
  202.     SendDlgItemMessage(IDC_COMP_AFTER,LB_RESETCONTENT,0,0);
  203.  
  204.     // load properties into listbox
  205.     dwReturn = SendDlgItemMessage(IDC_COMP_AFTER,LB_SETHORIZONTALEXTENT,
  206.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  207.  
  208.     rgTabStops[0] = PROP_LISTBOX_TAB1_SIZE ;
  209.     rgTabStops[1] = PROP_LISTBOX_TAB2_SIZE ;
  210.  
  211.     dwReturn = SendDlgItemMessage(IDC_COMP_AFTER,LB_SETTABSTOPS,
  212.                     (WPARAM) 2,(LPARAM)rgTabStops );
  213.     
  214.     for(idx = 0; idx < m_cValuesAfter; idx++)
  215.     {   
  216.         szID[0]     = '\0' ;
  217.         szData[0]   = '\0' ;
  218.         szType[0]   = '\0' ;
  219.         szBuffer[0] = '\0' ;
  220.             
  221.         if(GetString("PropIDs", PROP_ID(m_lpspvaAfter[idx].ulPropTag), szID ) )
  222.         {
  223.             lstrcat(szBuffer, szID );               
  224.             lstrcat(szBuffer, "\t");
  225.         }
  226.         else
  227.         {
  228.             wsprintf(szBuffer,"%#04X\t", PROP_ID(m_lpspvaAfter[idx].ulPropTag) );       
  229.         }
  230.  
  231.         if( GetString("PropType", PROP_TYPE(m_lpspvaAfter[idx].ulPropTag), szType) )
  232.         {
  233.             lstrcat(szBuffer, szType);
  234.             lstrcat(szBuffer,"\t");
  235.         }       
  236.         else
  237.         {
  238.             wsprintf(szType,"%#04X\t", PROP_TYPE(m_lpspvaAfter[idx].ulPropTag) );
  239.             lstrcat(szBuffer,szType);
  240.         }
  241.         
  242.         SzGetPropValue(szData,(LPSPropValue) &m_lpspvaAfter[idx]);
  243.         lstrcat(szBuffer,szData);
  244.  
  245.         dwReturn = SendDlgItemMessage(IDC_COMP_AFTER,LB_ADDSTRING,0,
  246.                             (LPARAM)szBuffer);
  247.     
  248.     } 
  249.  
  250.     dwReturn = SendDlgItemMessage(IDC_COMP_AFTER,LB_SETCURSEL,(WPARAM) -1 ,0 );
  251.     dwReturn = SendDlgItemMessage(IDC_COMP_BEFORE,LB_SETCURSEL,(WPARAM) -1 ,0 );
  252. }
  253.  
  254.  
  255. /*******************************************************************/
  256. /*
  257.  -  CCompareDlg::
  258.  -  ~CCompareDlg
  259.  -
  260.  *  Purpose:
  261.  *      Destructor for class CCompareDlg. Releases and Frees memory
  262.  *      allocated in this class
  263.  *
  264.  */
  265. /*******************************************************************/
  266.  
  267. CCompareDlg::~CCompareDlg()
  268. {
  269.  
  270.  
  271.  
  272.  
  273. /*******************************************************************/
  274. /*
  275.  -  CCompareDlg::
  276.  -  OnDumpPropValsBeforeToFile
  277.  *
  278.  *  Purpose:
  279.  *      Store PropValues in object to file
  280.  */
  281. /*******************************************************************/
  282.  
  283. void CCompareDlg::OnDumpPropValsBeforeToFile()
  284. {
  285.     char                szTag[80];
  286.     char                szFileName[80];
  287.     CStorePropValDlg    StoreProp(this);
  288.     LPTSTR              lpszTemp;
  289.         
  290.     // find file to open
  291.     lpszTemp = getenv("MAPITEST");
  292.  
  293.     if(lpszTemp)
  294.         strcpy(szFileName, lpszTemp);
  295.     else
  296.         strcpy(szFileName, "c:\\mapitest");
  297.  
  298.     strcat(szFileName, "\\data\\propvu.txt");
  299.  
  300.     // create the tag with braces around it
  301.     strcpy(szTag,"[PROPS BEFORE 0001]");
  302.  
  303.     StoreProp.m_TagID       = szTag;
  304.     StoreProp.m_FileName    = szFileName;
  305.     
  306.     if( StoreProp.DoModal() == IDOK )
  307.     {    
  308.         if((m_cValuesBefore != 0) && (m_lpspvaBefore != NULL) )
  309.         {
  310.             WritePropValArray( StoreProp.m_szFileName,
  311.                         StoreProp.m_szTagID,
  312.                         m_cValuesBefore,
  313.                         m_lpspvaBefore,
  314.                         StoreProp.m_ulFlags);
  315.         }                        
  316.     }
  317. }
  318.  
  319. /*******************************************************************/
  320. /*
  321.  -  CCompareDlg::
  322.  -  OnDumpPropValsAfterToFile
  323.  *
  324.  *  Purpose:
  325.  *      Store PropValues in object to file
  326.  */
  327. /*******************************************************************/
  328.  
  329. void CCompareDlg::OnDumpPropValsAfterToFile()
  330. {
  331.     char                szTag[80];
  332.     char                szFileName[80];
  333.     CStorePropValDlg    StoreProp(this);
  334.     LPTSTR              lpszTemp;
  335.         
  336.     // find file to open
  337.     lpszTemp = getenv("MAPITEST");
  338.  
  339.     if(lpszTemp)
  340.         strcpy(szFileName, lpszTemp);
  341.     else
  342.         strcpy(szFileName, "c:\\mapitest");
  343.  
  344.     strcat(szFileName, "\\data\\propvu.txt");
  345.  
  346.     // create the tag with braces around it
  347.     strcpy(szTag,"[PROPS AFTER 0001]");
  348.  
  349.     StoreProp.m_TagID       = szTag;
  350.     StoreProp.m_FileName    = szFileName;
  351.     
  352.     if( StoreProp.DoModal() == IDOK )
  353.     {    
  354.         if((m_cValuesAfter != 0) && (m_lpspvaAfter != NULL) )
  355.         {
  356.             WritePropValArray( StoreProp.m_szFileName,
  357.                         StoreProp.m_szTagID,
  358.                         m_cValuesAfter,
  359.                         m_lpspvaAfter,
  360.                         StoreProp.m_ulFlags);
  361.         }                        
  362.     }
  363. }
  364.  
  365.