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

  1. /*
  2.  -  P R O P V U . C P P
  3.  -  Copyright (C) 1995 Microsoft Corporation
  4.  -
  5.  *  Purpose:
  6.  *
  7.  */
  8.  
  9. #ifdef WIN32
  10. #ifdef _WIN95
  11. #define _INC_OLE
  12. #endif
  13. #define INC_OLE2
  14. #define INC_RPC
  15. #endif
  16.  
  17. #include <afxwin.h>     
  18. #include <windowsx.h>
  19. #include <stdio.h>
  20. #include <string.h>
  21.  
  22. #ifdef WIN16
  23. #include <compobj.h>
  24. #endif
  25.  
  26. #ifdef WIN32
  27. #include <objbase.h>
  28. #include <objerror.h>
  29. #ifdef _WIN95
  30. #include <ole2.h>
  31. #endif
  32. #endif
  33.  
  34.  
  35. #include <mapiwin.h>
  36. #include <mapix.h>
  37. #include <strtbl.h>
  38. #include <misctool.h>
  39. #include <pvalloc.h>
  40. #include <pventry.h>
  41. #include "resource.h"
  42. #include "propvu.h"
  43. #include "bldprop.h"
  44. #include "oper.h"
  45. #include "getprop.h"
  46. #include "getlist.h"
  47. #include "namesids.h"
  48. #include "iid.h"
  49. #include "results.h"
  50.  
  51. /*
  52.  -  ViewMapiProp
  53.  -
  54.  *  Purpose:
  55.  *
  56.  *  Parameters:
  57.  *
  58.  *  Returns:
  59.  *      void.
  60.  *
  61.  */
  62.  
  63. extern "C"
  64. BOOL ViewMapiProp(LPSTR lpszName, LPMAPIPROP FAR *lppMAPIProp, LPVOID lpvDest,HWND hWnd)
  65. {
  66.     CString     CurrentProp(lpszName);
  67.     CPropDlg    *lpDlgProp = NULL;
  68.     
  69.     
  70.     lpDlgProp   =  new CPropDlg(CurrentProp, lppMAPIProp,lpvDest, hWnd);
  71.  
  72.  
  73.     return TRUE;
  74. }
  75.  
  76. /******************* Message Map ****************************/
  77.  
  78. BEGIN_MESSAGE_MAP(CPropDlg, CDialog)
  79.  
  80.     ON_BN_CLICKED(  IDC_PROPTYPE,       OnType)
  81.     ON_BN_CLICKED(  IDC_PROPID,         OnID)
  82.     ON_BN_CLICKED(  IDC_PROPDATA,       OnData)
  83.     ON_COMMAND(     IDC_PROPSTRING,     OnString)
  84.     ON_COMMAND(     IDC_PROPHEX,        OnHex)
  85.     ON_COMMAND(     IDC_PROPDEC,        OnDecimal)
  86.     ON_COMMAND(     IDC_ADDREF,         OnAddRef)
  87.     ON_COMMAND(     IDC_COPYTO,         OnCopyTo)
  88.     ON_COMMAND(     IDC_DELETEPROP,     OnDeleteProps)
  89.     ON_COMMAND(     IDC_IDSNAMES,       OnGetIDsFromNames)
  90.     ON_COMMAND(     IDC_GETLASTERR,     OnGetLastError)
  91.     ON_COMMAND(     IDC_NAMESIDS,       OnGetNamesFromIDs)
  92.     ON_COMMAND(     IDC_GETPROPS,       OnGetProps)
  93.     ON_COMMAND(     IDC_GETPROPLIST,    OnGetPropList)
  94.     ON_COMMAND(     IDC_OPENPROP,       Stub)
  95.     ON_COMMAND(     IDC_QUERYINT,       OnQueryInterface)
  96.     ON_COMMAND(     IDC_RELEASE,        OnRelease)
  97.     ON_COMMAND(     IDC_SAVECHANGES,    OnSaveChanges)
  98.     ON_COMMAND(     IDC_SETPROPS,       OnSetProps)
  99.     ON_COMMAND(     IDC_COPYPROPS,      OnCopyProps)
  100.     ON_COMMAND(     IDC_CLEARMAPILOG,   OnClearMapiLog)
  101.     ON_COMMAND(     IDC_STOREPROPS,     OnStorePropValsToFile)
  102.                 
  103. END_MESSAGE_MAP()
  104.  
  105.  
  106. /*************************** StorePropValDlg Functions *********************/
  107.  
  108. /********************************************************************/
  109.  
  110. BEGIN_MESSAGE_MAP(CStorePropValDlg, CModalDialog)
  111.  
  112.     ON_BN_CLICKED(  IDC_STORE_BINARY,       OnDumpBinary)
  113.          
  114. END_MESSAGE_MAP()
  115.  
  116. /*******************************************************************/
  117.  
  118. void CStorePropValDlg::OnDumpBinary()
  119. {
  120.     CheckDlgButton(IDC_STORE_BINARY, !IsDlgButtonChecked(IDC_STORE_BINARY) );
  121. }
  122.  
  123.  
  124.  
  125. /*******************************************************************/
  126. /*
  127.  -  CStorePropValDlg::
  128.  -  OnInitDialog
  129.  -
  130.  *  Purpose:
  131.  *      Constructor for main dialog class.
  132.  *
  133.  */
  134. /*******************************************************************/
  135.  
  136. BOOL CStorePropValDlg::OnInitDialog()
  137. {
  138.     DWORD           dwIndex         = 0;
  139.     DWORD           dwReturn        = 0;
  140.  
  141.     SetDlgItemText(IDC_STORE_FILENAME,m_FileName);
  142.     SetDlgItemText(IDC_STORE_TAGID,   m_TagID);
  143.  
  144.     return TRUE;
  145. }
  146.  
  147. /*******************************************************************/
  148. /*
  149.  -  CStorePropValDlg::
  150.  -  OnOK
  151.  -
  152.  *  Purpose:
  153.  *
  154.  */
  155. /*******************************************************************/
  156.  
  157. void CStorePropValDlg::OnOK()
  158. {
  159.     LONG    dRet    = 0;
  160.     
  161.     // get edit control selection and put in data member strings
  162.     *(WORD *)m_szFileName = sizeof(m_szFileName) -1;    // first char has buffer length   
  163.     dRet = SendDlgItemMessage(IDC_STORE_FILENAME,EM_GETLINE,0,(LPARAM)m_szFileName);
  164.     m_szFileName[dRet] = '\0';
  165.  
  166.     // get edit control selection and put in data member strings
  167.     *(WORD *)m_szTagID = sizeof(m_szTagID) -1;    // first char has buffer length   
  168.     dRet = SendDlgItemMessage(IDC_STORE_TAGID,EM_GETLINE,0,(LPARAM)m_szTagID);
  169.     m_szTagID[dRet] = '\0';
  170.  
  171.     if( IsDlgButtonChecked(IDC_STORE_BINARY) )                
  172.         m_ulFlags |= DUMP_BINARY_DATA;
  173.     
  174.     EndDialog(IDOK);
  175.     
  176. }
  177.  
  178.  
  179. /*******************************************************************/
  180. /*
  181.  -  CStorePropValDlg::
  182.  -  ~CStorePropValDlg
  183.  -
  184.  *  Purpose:
  185.  *
  186.  */
  187. /*******************************************************************/
  188.  
  189. CStorePropValDlg::~CStorePropValDlg()
  190. {
  191.  
  192. }
  193.  
  194.  
  195. /*************************** PropDlg Functions *********************/
  196.  
  197. /*******************************************************************/
  198. /*
  199.  -  CPropDlg::
  200.  -  OnStorePropValsToFile
  201.  *
  202.  *  Purpose:
  203.  *      Store PropValues in object to file
  204.  */
  205. /*******************************************************************/
  206.  
  207. void CPropDlg::OnStorePropValsToFile()
  208. {
  209.     ULONG               ulValues        = 0;
  210.     LPSPropValue        lpPropValue     = NULL;
  211.     CGetError           E;
  212.     char                szTag[80];
  213.     char                szFileName[80];
  214.     CStorePropValDlg    StoreProp(this);
  215.     LPTSTR              lpszTemp;
  216.     char                szBuff[512];
  217.     CBldPropDlg         BldProp(this);
  218.     LPSTR               lpszPropID      = NULL;
  219.     ULONG               cbString        = 0;
  220.     ULONG               idx             = 0;
  221.     DWORD               dwIndex         = 0;
  222.     LPSPropValue        lpspva          = NULL;       
  223.  
  224.     // need to set m_lSelectTag in case it is not one of our "MAPI" tags
  225.     //  and it is stored as a hex value so that setprops can
  226.     //  represent this value correctly
  227.     if( HR_FAILED(m_hResult = m_lpEntry->GetProps(NULL, 0, &ulValues, &lpPropValue) ) )
  228.     {
  229.         MessageBox( E.SzError("CPropDlg::OnBldProps()  lpEntry->GetProps()", m_hResult), "Client", MBS_ERROR );
  230.         return;
  231.     }
  232.  
  233.  
  234.     BldProp.m_fIsPropValueArray     = TRUE;
  235.     BldProp.m_lpSetEntry            = m_lpEntry;
  236.     BldProp.m_Operation             = "Dump Selected Properties to File";
  237.     
  238.     // initialize the selected ListBox
  239.     BldProp.m_lppNewPropValue = (LPSPropValue *) PvAlloc(MAX_SET_PROPS * sizeof(LPSPropValue));
  240.     for(idx = 0; idx < ulValues; idx++)
  241.     {
  242.         lpspva = (LPSPropValue) PvAlloc(sizeof(SPropValue));
  243.         CopyPropValue(lpspva,&(lpPropValue[idx]),lpspva);
  244.         BldProp.m_lppNewPropValue[idx] = lpspva;
  245.     }
  246.     BldProp.m_ulNewValues = ulValues;        
  247.    
  248.     BldProp.DoModal();
  249.  
  250.     if(BldProp.m_fCall)
  251.     {
  252.         // find file to open
  253.         lpszTemp = getenv("MAPITEST");
  254.  
  255.         if(lpszTemp)
  256.             strcpy(szFileName, lpszTemp);
  257.         else
  258.             strcpy(szFileName, "c:\\mapitest");
  259.  
  260.         strcat(szFileName, "\\data\\propvu.txt");
  261.  
  262.         // create the tag with braces around it
  263.         strcpy(szTag,"[PVA]");
  264.  
  265.         StoreProp.m_TagID       = szTag;
  266.         StoreProp.m_FileName    = szFileName;
  267.         
  268.         if( StoreProp.DoModal() == IDOK )
  269.         {    
  270.                               
  271.             WritePropValArray(  StoreProp.m_szFileName,
  272.                                 StoreProp.m_szTagID,
  273.                                 BldProp.m_ulNewValues,
  274.                                 BldProp.m_lpspvaSelected,
  275.                                 StoreProp.m_ulFlags);
  276.  
  277.             wsprintf(szBuff,"Stored Props to File: %s with TagID: %s",
  278.                         StoreProp.m_szFileName,StoreProp.m_szTagID);
  279.             dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  280.                             (LPARAM)szBuff );
  281.  
  282.         }
  283.  
  284.     }
  285.     
  286.     if(lpPropValue)
  287.         MAPIFreeBuffer(lpPropValue);
  288. }
  289.  
  290.  
  291.  
  292.  
  293. /*******************************************************************/
  294. /*
  295.  -  CPropDlg::
  296.  -  Stub
  297.  *
  298.  *  Purpose:
  299.  *      Generic stub for functions not yet implemented
  300.  */
  301. /*******************************************************************/
  302.  
  303. void CPropDlg::Stub()
  304. {
  305.     MessageBox("Not Yet Implemented", "Client", MBS_INFO );
  306. }
  307.  
  308. /********************************************************************/
  309. /*
  310.  -  CPropDlg::
  311.  -  ResetPropButtons    (INTERNAL, protected member function)
  312.  -
  313.  *  Purpose:
  314.  *      Reset Property Display configurable buttons to default(string/all)
  315.  *
  316.  *  Returns:
  317.  *      Nothing
  318.  */
  319. /********************************************************************/
  320.  
  321. void CPropDlg::ResetPropButtons()
  322. {
  323.     // set check state of checkboxes (display all fields in string)
  324.     CheckDlgButton(IDC_PROPSTRING,  1);
  325.     CheckDlgButton(IDC_PROPHEX,     0);
  326.     CheckDlgButton(IDC_PROPDEC,     0);
  327.     CheckDlgButton(IDC_PROPTYPE,    1);
  328.     CheckDlgButton(IDC_PROPDATA,    1);
  329.     CheckDlgButton(IDC_PROPID,      1);
  330. }
  331.  
  332.  
  333. /********************************************************************/
  334. /*
  335.  -  CPropDlg::
  336.  -  OnInitDialog
  337.  -
  338.  *  Purpose:
  339.  *      Constructor for main dialog class.
  340.  *
  341.  */
  342. /********************************************************************/
  343.  
  344. BOOL CPropDlg::OnInitDialog()
  345. {
  346.     DWORD           dwIndex         = 0;
  347.     int             rgTabStops[4];
  348.     DWORD           dwReturn        = 0;
  349.  
  350.     if( !m_lpEntry)
  351.          return FALSE;
  352.  
  353.     SetWindowText( m_CurrentProp.GetBuffer(80) );
  354.  
  355.     // disable the system menu close item
  356.     //  this is done because there is a MFC 2.0 bug that
  357.     //  makes you capture several PostNcDestroy messages etc.
  358.     GetSystemMenu(FALSE)->EnableMenuItem(SC_CLOSE, MF_GRAYED);
  359.  
  360.  
  361.     // set size of horizontal scroll and tab stops in prop view listbox
  362.     dwReturn = SendDlgItemMessage(IDC_PROPVIEW,LB_SETHORIZONTALEXTENT,
  363.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  364.  
  365.     rgTabStops[0] = PROP_LISTBOX_TAB1_SIZE ;
  366.     rgTabStops[1] = PROP_LISTBOX_TAB2_SIZE ;
  367.  
  368.     dwReturn = SendDlgItemMessage(IDC_PROPVIEW,LB_SETTABSTOPS,
  369.                     (WPARAM) 2,(LPARAM)rgTabStops );
  370.  
  371.  
  372.     // set size of horizontal scroll and tab stops in MAPI log listbox
  373.     dwReturn = SendDlgItemMessage(IDC_MAPILOG, LB_SETHORIZONTALEXTENT,
  374.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  375.  
  376. //  rgTabStops[0] = MAPILOG_LISTBOX_TAB1_SIZE ;
  377.     rgTabStops[0] = 115 ;
  378.     rgTabStops[1] = PROP_LISTBOX_TAB2_SIZE ;
  379.  
  380.     dwReturn = SendDlgItemMessage(IDC_MAPILOG,LB_SETTABSTOPS,
  381.                     (WPARAM) 2,(LPARAM)rgTabStops );
  382.  
  383.  
  384.  
  385.     // display props
  386.     ResetPropButtons();
  387.  
  388.     RedrawPropTable();
  389.  
  390.     return TRUE;
  391. }
  392.  
  393.  
  394. /*******************************************************************/
  395. /*
  396.  -  CPropDlg::
  397.  -  OnQueryInterface
  398.  -
  399.  *  Purpose:
  400.  */
  401. /*******************************************************************/
  402.  
  403. void CPropDlg::OnQueryInterface()
  404. {
  405.     COperation      QueryIntDlg(this);
  406.     CPropDlg        *lpNewProp          = NULL;
  407.     LPVOID          lpvNew              = NULL;
  408.     LPIID           lpInterface         = NULL;
  409.     CGetError       E;
  410.     ULONG           idx;
  411.     char            szBuff[80];
  412.     int             dRet                = 0;
  413.     DWORD           dwIndex             = 0;
  414.     
  415.  
  416.     // initalize data for dialog box
  417.     QueryIntDlg.m_CurrentOperation= "lpObj->QueryInterface()";
  418.     QueryIntDlg.m_CBText1         = "lpInterface:";
  419.     QueryIntDlg.m_CBText2         = "";
  420.     QueryIntDlg.m_CBText3         = "";
  421.     QueryIntDlg.m_EditText1       = "";
  422.     QueryIntDlg.m_EditText2       = "";
  423.     QueryIntDlg.m_EditText3       = "";
  424.     QueryIntDlg.m_FlagText1       = "";
  425.     QueryIntDlg.m_FlagText2       = "";
  426.     QueryIntDlg.m_FlagText3       = "";
  427.     QueryIntDlg.m_FlagText4       = "";
  428.     QueryIntDlg.m_EditDefault1    = "";
  429.     QueryIntDlg.m_EditDefault2    = "";
  430.     QueryIntDlg.m_EditDefault3    = "";
  431.  
  432.     for(idx = 0; idx < NUM_INTERFACES; idx++)
  433.     {           
  434.         dRet = QueryIntDlg.m_CBContents1.Add( AllIIDs[idx].lpsz);
  435.     }
  436.     dRet = QueryIntDlg.m_CBContents1.Add("NULL");
  437.     dRet = QueryIntDlg.m_CBContents1.Add("Bad Interface Param");
  438.  
  439.     // bring up modal dialog box, and if user hits OK, process operation
  440.     if( QueryIntDlg.DoModal() == IDOK )
  441.     {       
  442.         lpInterface = NULL;
  443.         for(idx = 0; idx < NUM_INTERFACES; idx++)
  444.         {           
  445.             if( !lstrcmp(QueryIntDlg.m_szCB1,AllIIDs[idx].lpsz) )
  446.                 lpInterface =  AllIIDs[idx].lpInterface;               
  447.         }
  448.         if(!lpInterface)
  449.         {        
  450.             if( !lstrcmp(QueryIntDlg.m_szCB1,"NULL") )
  451.                 lpInterface = (LPIID) NULL;
  452.             else if(!lstrcmp(QueryIntDlg.m_szCB1,"Bad Interface Param") )
  453.                 lpInterface = (LPIID) &lpvNew;         // invalid
  454.         }                     
  455.  
  456.         if( HR_FAILED( m_hResult = m_lpEntry->QueryInterface(*lpInterface, &lpvNew) ) )
  457.         {
  458.             MessageBox( E.SzError("m_lpEntry->QueryInterface()", m_hResult),
  459.                             "Client", MBS_ERROR );
  460.             return;
  461.         }               
  462.             
  463.         wsprintf(szBuff,"%s",E.SzError("lpObj->QueryInterface() \tRC: ", m_hResult));
  464.         dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  465.                         (LPARAM)szBuff );        
  466.  
  467.         lpNewProp   =  new CPropDlg("New Interface from QueryInterface",
  468.                            (LPMAPIPROP *) &lpvNew,m_lpvDestObj,(HWND)this->m_hWnd );
  469.     }
  470.  
  471. }
  472.  
  473.  
  474. /*******************************************************************/
  475. /*
  476.  -  CPropDlg::
  477.  -  CopyProps
  478.  *
  479.  *  Purpose:
  480.  */
  481. /*******************************************************************/
  482.  
  483. void CPropDlg::OnCopyProps()
  484. {
  485.  
  486.     LPMAPIPROGRESS  lpProgress      = NULL;
  487.     CResultsDlg     Results(this);
  488.     COperation      CopyPropsDlg(this);
  489.     CBldPropDlg     BldProp(this);
  490.     LPSTR           lpszPropID      = NULL;
  491.     char            szBuffer[512];
  492.     CGetError       E;
  493.     LPSPropProblemArray lpProblems  = NULL;
  494.     LPSPropValue    lpPropValueBefore     = NULL;
  495.     ULONG           ulValuesBefore        = 0;
  496.     LPSPropValue    lpPropValueAfter      = NULL;
  497.     ULONG           ulValuesAfter         = 0;
  498.     char            szBuff[80];
  499.     DWORD           dwIndex         = 0;
  500.     HRESULT         hResult         = hrSuccess;
  501.     int             dRet            = 0;
  502.     ULONG           ulFlags         = 0;
  503.     LPIID           lpInterface     = NULL;
  504.     ULONG           ulUIParam       = 0;
  505.     ULONG           idx;
  506.     
  507.  
  508.     BldProp.m_fIsPropValueArray     = FALSE;
  509.     BldProp.m_lpSetEntry    = m_lpEntry;
  510.     BldProp.m_Operation     = "lpObj->CopyProps() Include PropTagArray";
  511.     BldProp.DoModal();
  512.  
  513.     // initalize data for dialog box
  514.     CopyPropsDlg.m_CurrentOperation= "lpObj->CopyProps()";
  515.     CopyPropsDlg.m_CBText1         = "ulUIParam:";
  516.     CopyPropsDlg.m_CBText3         = "lpInterface:";
  517.     CopyPropsDlg.m_EditText1       = "lpvDestObj:";
  518.     CopyPropsDlg.m_EditText2       = "";
  519.     CopyPropsDlg.m_EditText3       = "";
  520.     CopyPropsDlg.m_FlagText1       = "MAPI_MOVE";
  521.     CopyPropsDlg.m_FlagText2       = "MAPI_NOREPLACE";
  522.     CopyPropsDlg.m_FlagText3       = "MAPI_DIALOG";
  523.     CopyPropsDlg.m_FlagText4       = "MAPI_DECLINE_OK";
  524.     CopyPropsDlg.m_FlagText5       = "Invalid Flag";
  525.     wsprintf(szBuffer,"0x%X",m_lpvDestObj);
  526.     CopyPropsDlg.m_EditDefault1    = szBuffer;
  527.     CopyPropsDlg.m_EditDefault2    = "";
  528.     CopyPropsDlg.m_EditDefault3    = "";
  529.  
  530.     dRet = CopyPropsDlg.m_CBContents1.Add("NULL");
  531.     wsprintf(szBuff,"Parent hWnd == %X",this->m_hWnd);
  532.     dRet = CopyPropsDlg.m_CBContents1.Add(szBuff);
  533.  
  534.     dRet = CopyPropsDlg.m_CBContents3.Add("NULL");
  535.     dRet = CopyPropsDlg.m_CBContents3.Add("Bad Interface Param");
  536.     for(idx = 0; idx < NUM_INTERFACES; idx++)
  537.     {           
  538.         dRet = CopyPropsDlg.m_CBContents3.Add( AllIIDs[idx].lpsz);
  539.     }
  540.  
  541.  
  542.     // bring up modal dialog box, and if user hits OK, process operation
  543.     if( CopyPropsDlg.DoModal() == IDOK )
  544.     {
  545.         // determine state/settings of data in dialog upon closing
  546.         if( CopyPropsDlg.m_bFlag1 )
  547.             ulFlags |= MAPI_MOVE;
  548.  
  549.         if( CopyPropsDlg.m_bFlag2)
  550.             ulFlags |= MAPI_NOREPLACE;
  551.  
  552.         if( CopyPropsDlg.m_bFlag2)
  553.             ulFlags |= MAPI_DIALOG;
  554.  
  555.         if( CopyPropsDlg.m_bFlag4)
  556.             ulFlags |= MAPI_DECLINE_OK;
  557.  
  558.         if( CopyPropsDlg.m_bFlag5)
  559.             ulFlags |= TEST_INVALID_FLAG;
  560.                        
  561.         if( !lstrcmp(CopyPropsDlg.m_szCB1,"NULL") )
  562.             ulUIParam = (ULONG)NULL;
  563.         else
  564.             ulUIParam = (ULONG)(void *)this->m_hWnd;                    
  565.  
  566.         // determine interface of DestObj selected
  567.         
  568.         lpInterface = NULL;
  569.         for(idx = 0; idx < NUM_INTERFACES; idx++)
  570.         {           
  571.             if( !lstrcmp(CopyPropsDlg.m_szCB3,AllIIDs[idx].lpsz) )
  572.                 lpInterface =  AllIIDs[idx].lpInterface;               
  573.         }
  574.         if(!lpInterface)
  575.         {        
  576.             if( !lstrcmp(CopyPropsDlg.m_szCB3,"NULL") )
  577.                 lpInterface = (LPIID) NULL;
  578.             else if(!lstrcmp(CopyPropsDlg.m_szCB3,"Bad Interface Param") )
  579.                 lpInterface = (LPIID) &ulFlags;         // invalid
  580.         }                     
  581.  
  582.         if( HR_FAILED( m_hResult = ((LPMAPIPROP)m_lpvDestObj)->GetProps(NULL, 0, &ulValuesBefore, &lpPropValueBefore) ) )
  583.         {
  584.             MessageBox( E.SzError("CPropDlg::OnCopyProps()  lpEntry->GetProps() Before", m_hResult), "Client", MBS_ERROR );
  585.             return;
  586.         }
  587.  
  588.         if( m_hResult = m_lpEntry->CopyProps(BldProp.m_lpNewPTA,
  589.                                             ulUIParam,
  590.                                             lpProgress,
  591.                                             lpInterface,
  592.                                             m_lpvDestObj,
  593.                                             ulFlags,
  594.                                             &lpProblems) )
  595.         {
  596.             MessageBox( E.SzError("m_lpEntry->CopyProps()", m_hResult),
  597.                             "Client", MBS_ERROR );
  598.         }
  599.  
  600.     
  601.         wsprintf(szBuff,"%s",E.SzError("lpObj->CopyProps() \tRC: ", m_hResult));
  602.         dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  603.                         (LPARAM)szBuff );
  604.  
  605.         if( HR_FAILED(m_hResult = ((LPMAPIPROP)m_lpvDestObj)->GetProps(NULL, 0, &ulValuesAfter, &lpPropValueAfter) ) )
  606.         {
  607.             MessageBox( E.SzError("CPropDlg::OnCopyProps()  lpEntry->GetProps() After", m_hResult), "Client", MBS_ERROR );
  608.             return;
  609.         }
  610.  
  611.         Results.m_lpspvaBefore      = lpPropValueBefore;
  612.         Results.m_cValuesBefore     = ulValuesBefore;    
  613.         Results.m_lpspvaAfter       = lpPropValueAfter;
  614.         Results.m_cValuesAfter      = ulValuesAfter;    
  615.         Results.m_Operation         = "Properties Before/After lpvDestObj->CopyProps()";
  616.         Results.m_lpProblems        = lpProblems;
  617.         Results.m_fIsPropValueArray = FALSE;
  618.         Results.m_lpsptaModify      = BldProp.m_lpNewPTA;
  619.  
  620.         Results.DoModal();
  621.     }
  622.  
  623.     RedrawPropTable();
  624.     
  625.     if(BldProp.m_lpNewPTA)
  626.     {
  627.         PvFree(BldProp.m_lpNewPTA);
  628.         BldProp.m_lpNewPTA = NULL;
  629.     }
  630.     
  631.     if(lpPropValueBefore)
  632.     {
  633.         MAPIFreeBuffer(lpPropValueBefore);
  634.         lpPropValueBefore = NULL;
  635.     }
  636.  
  637.     if(lpPropValueAfter)
  638.     {
  639.         MAPIFreeBuffer(lpPropValueAfter);
  640.         lpPropValueAfter = NULL;
  641.     }
  642.     if(lpProblems)
  643.         MAPIFreeBuffer(lpProblems);
  644. }
  645.  
  646.  
  647.  
  648. /*******************************************************************/
  649. /*
  650.  -  CPropDlg::
  651.  -  OnCopyTo
  652.  -
  653.  *  Purpose:
  654.  */
  655. /*******************************************************************/
  656.  
  657. void CPropDlg::OnCopyTo()
  658. {
  659.  
  660.     LPMAPIPROGRESS  lpProgress      = NULL;
  661.     CResultsDlg     Results(this);
  662.     COperation      CopyToDlg(this);
  663.     CBldPropDlg     BldProp(this);
  664.     CInterfaceDlg   Interface(this);
  665.     LPSTR           lpszPropID      = NULL;
  666.     char            szBuffer[512];
  667.     CGetError       E;
  668.     LPSPropProblemArray lpProblems  = NULL;
  669.     LPSPropValue    lpPropValueBefore     = NULL;
  670.     ULONG           ulValuesBefore        = 0;
  671.     LPSPropValue    lpPropValueAfter      = NULL;
  672.     ULONG           ulValuesAfter         = 0;
  673.     char            szBuff[80];
  674.     DWORD           dwIndex         = 0;
  675.     HRESULT         hResult         = hrSuccess;
  676.     int             dRet            = 0;
  677.     ULONG           ulFlags         = 0;
  678.     LPIID           lpInterface     = NULL;
  679.     ULONG           ulUIParam       = 0;
  680.     ULONG           idx;
  681.     
  682.  
  683.     BldProp.m_fIsPropValueArray     = FALSE;
  684.     BldProp.m_lpSetEntry    = m_lpEntry;
  685.     BldProp.m_Operation     = "lpObj->CopyTo() Exclude PropTagArray";
  686.     BldProp.DoModal();
  687.  
  688.     Interface.DoModal();
  689.  
  690.     // initalize data for dialog box
  691.     CopyToDlg.m_CurrentOperation= "lpObj->CopyTo()";
  692.     CopyToDlg.m_CBText1         = "ulUIParam:";
  693.     CopyToDlg.m_CBText3         = "lpInterface:";
  694.     CopyToDlg.m_EditText1       = "lpvDestObj:";
  695.     CopyToDlg.m_EditText2       = "";
  696.     CopyToDlg.m_EditText3       = "";
  697.     CopyToDlg.m_FlagText1       = "MAPI_MOVE";
  698.     CopyToDlg.m_FlagText2       = "MAPI_NOREPLACE";
  699.     CopyToDlg.m_FlagText3       = "MAPI_DIALOG";
  700.     CopyToDlg.m_FlagText4       = "MAPI_DECLINE_OK";
  701.     CopyToDlg.m_FlagText5       = "Invalid Flag";
  702.     wsprintf(szBuffer,"0x%X",m_lpvDestObj);
  703.     CopyToDlg.m_EditDefault1    = szBuffer;
  704.     CopyToDlg.m_EditDefault2    = "";
  705.     CopyToDlg.m_EditDefault3    = "";
  706.  
  707.     dRet = CopyToDlg.m_CBContents1.Add("NULL");
  708.     wsprintf(szBuff,"Parent hWnd == %X",this->m_hWnd);
  709.     dRet = CopyToDlg.m_CBContents1.Add(szBuff);
  710.  
  711.     for(idx = 0; idx < NUM_INTERFACES; idx++)
  712.     {           
  713.         dRet = CopyToDlg.m_CBContents3.Add( AllIIDs[idx].lpsz);
  714.     }
  715.     dRet = CopyToDlg.m_CBContents3.Add("NULL");
  716.     dRet = CopyToDlg.m_CBContents3.Add("Bad Interface Param");
  717.  
  718.  
  719.     // bring up modal dialog box, and if user hits OK, process operation
  720.     if( CopyToDlg.DoModal() == IDOK )
  721.     {
  722.         // determine state/settings of data in dialog upon closing
  723.         if( CopyToDlg.m_bFlag1 )
  724.             ulFlags |= MAPI_MOVE;
  725.  
  726.         if( CopyToDlg.m_bFlag2)
  727.             ulFlags |= MAPI_NOREPLACE;
  728.  
  729.         if( CopyToDlg.m_bFlag2)
  730.             ulFlags |= MAPI_DIALOG;
  731.  
  732.         if( CopyToDlg.m_bFlag4)
  733.             ulFlags |= MAPI_DECLINE_OK;
  734.  
  735.         if( CopyToDlg.m_bFlag5)
  736.             ulFlags |= TEST_INVALID_FLAG;
  737.                        
  738.         if( !lstrcmp(CopyToDlg.m_szCB1,"NULL") )
  739.             ulUIParam = (ULONG)NULL;
  740.         else
  741.             ulUIParam = (ULONG)(void *)this->m_hWnd;                    
  742.  
  743.         // determine interface of DestObj selected
  744.         
  745.         lpInterface = NULL;
  746.         for(idx = 0; idx < NUM_INTERFACES; idx++)
  747.         {           
  748.             if( !lstrcmp(CopyToDlg.m_szCB3,AllIIDs[idx].lpsz) )
  749.                 lpInterface =  AllIIDs[idx].lpInterface;               
  750.         }
  751.         if(!lpInterface)
  752.         {        
  753.             if( !lstrcmp(CopyToDlg.m_szCB3,"NULL") )
  754.                 lpInterface = (LPIID) NULL;
  755.             else if(!lstrcmp(CopyToDlg.m_szCB3,"Bad Interface Param") )
  756.                 lpInterface = (LPIID) &ulFlags;         // invalid
  757.         }                     
  758.  
  759.         if( HR_FAILED( m_hResult = ((LPMAPIPROP)m_lpvDestObj)->GetProps(NULL, 0, &ulValuesBefore, &lpPropValueBefore) ) )
  760.         {
  761.             MessageBox( E.SzError("CPropDlg::OnCopyTo()  lpEntry->GetProps() Before", m_hResult), "Client", MBS_ERROR );
  762.             return;
  763.         }
  764.  
  765.         if( m_hResult = m_lpEntry->CopyTo(  Interface.m_ciidSelect,
  766.                                             (LPIID)Interface.m_rgiidSelect,
  767.                                             BldProp.m_lpNewPTA,
  768.                                             ulUIParam,
  769.                                             lpProgress,
  770.                                             lpInterface,
  771.                                             m_lpvDestObj,
  772.                                             ulFlags,
  773.                                             &lpProblems) )
  774.         {
  775.             MessageBox( E.SzError("m_lpEntry->CopyTo()", m_hResult),
  776.                             "Client", MBS_ERROR );
  777.         }
  778.  
  779.     
  780.         wsprintf(szBuff,"%s",E.SzError("lpObj->CopyTo() \tRC: ", m_hResult));
  781.         dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  782.                         (LPARAM)szBuff );
  783.  
  784.         if( HR_FAILED(m_hResult = ((LPMAPIPROP)m_lpvDestObj)->GetProps(NULL, 0, &ulValuesAfter, &lpPropValueAfter) ) )
  785.         {
  786.             MessageBox( E.SzError("CPropDlg::OnCopyTo()  lpEntry->GetProps() After", m_hResult), "Client", MBS_ERROR );
  787.             return;
  788.         }
  789.  
  790.         Results.m_lpspvaBefore  = lpPropValueBefore;
  791.         Results.m_cValuesBefore = ulValuesBefore;    
  792.         Results.m_lpspvaAfter   = lpPropValueAfter;
  793.         Results.m_cValuesAfter  = ulValuesAfter;    
  794.         Results.m_Operation     = "Properties Before/After lpvDestObj->CopyTo()";
  795.         Results.m_lpProblems    = lpProblems;
  796.         Results.m_fIsPropValueArray = FALSE;
  797.         Results.m_lpsptaModify  = BldProp.m_lpNewPTA;
  798.  
  799.         Results.DoModal();
  800.     }
  801.  
  802.     RedrawPropTable();
  803.     
  804.     if(BldProp.m_lpNewPTA)
  805.     {
  806.         PvFree(BldProp.m_lpNewPTA);
  807.         BldProp.m_lpNewPTA = NULL;
  808.     }
  809.     
  810.     if(lpPropValueBefore)
  811.     {
  812.         MAPIFreeBuffer(lpPropValueBefore);
  813.         lpPropValueBefore = NULL;
  814.     }
  815.  
  816.     if(lpPropValueAfter)
  817.     {
  818.         MAPIFreeBuffer(lpPropValueAfter);
  819.         lpPropValueAfter = NULL;
  820.     }
  821.     if(lpProblems)
  822.         MAPIFreeBuffer(lpProblems);
  823.  
  824. }
  825.  
  826.     
  827.  
  828. /*******************************************************************/
  829. /*
  830.  -  CPropDlg::
  831.  -  OnAddRef
  832.  -
  833.  *  Purpose:
  834.  */
  835. /*******************************************************************/
  836.  
  837. void CPropDlg::OnAddRef()
  838. {
  839.     DWORD   dwIndex    = 0;
  840.     ULONG   ulRefCount = 0;
  841.     char    szBuff[80];
  842.  
  843.     ulRefCount = m_lpEntry->AddRef();
  844.  
  845.     // keep reference so user never releases to refcount == 0
  846.     m_ulRefCount++;
  847.  
  848.     wsprintf(szBuff,"lpObj->AddRef() \tRC: %lu, Current RefCount >= %lu",ulRefCount,m_ulRefCount);
  849.     dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  850.                         (LPARAM)szBuff );
  851. }
  852.  
  853.  
  854. /*******************************************************************/
  855. /*
  856.  -  CPropDlg::
  857.  -  OnSetProps
  858.  -
  859.  *  Purpose:
  860.  */
  861. /*******************************************************************/
  862.  
  863. void CPropDlg::OnSetProps()
  864. {
  865.     CResultsDlg     Results(this);
  866.     CBldPropDlg     BldProp(this);
  867.     LPSTR           lpszPropID      = NULL;
  868.     LONG            lSelectedTag    = 0;
  869.     CGetError       E;
  870.     LPSPropProblemArray lpProblems  = NULL;
  871.     LPSPropValue    lpPropValueBefore     = NULL;
  872.     ULONG           ulValuesBefore        = 0;
  873.     LPSPropValue    lpPropValueAfter      = NULL;
  874.     ULONG           ulValuesAfter         = 0;
  875.     char            szBuff[80];
  876.     DWORD           dwIndex         = 0;
  877.  
  878.     // need to set m_lSelectTag in case it is not one of our "MAPI" tags
  879.     //  and it is stored as a hex value so that setprops can
  880.     //  represent this value correctly
  881.     if( HR_FAILED( m_hResult = m_lpEntry->GetProps(NULL, 0, &ulValuesBefore, &lpPropValueBefore) ) )
  882.     {
  883.         MessageBox( E.SzError("CPropDlg::OnSetProps()  lpEntry->GetProps() Before", m_hResult), "Client", MBS_ERROR );
  884.         return;
  885.     }
  886.  
  887.     BldProp.m_fIsPropValueArray     = TRUE;
  888.     BldProp.m_lpSetEntry    = m_lpEntry;
  889.     BldProp.m_Operation     = "lpObj->SetProps()";
  890.     BldProp.DoModal();
  891.  
  892.     if(BldProp.m_fCall)
  893.     {
  894.         if(BldProp.m_ulNewValues)
  895.         {
  896.             if( m_hResult = m_lpEntry->SetProps(BldProp.m_ulNewValues, BldProp.m_lpspvaSelected, &lpProblems) )
  897.             {
  898.                 MessageBox( E.SzError("CPropDlg::OnSetProps()", m_hResult),
  899.                                     "Client", MBS_ERROR );
  900.             }
  901.  
  902.             wsprintf(szBuff,"%s",E.SzError("lpObj->SetProps() \tRC: ", m_hResult));
  903.             dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  904.                         (LPARAM)szBuff );
  905.         }
  906.  
  907.         if( HR_FAILED(m_hResult = m_lpEntry->GetProps(NULL, 0, &ulValuesAfter, &lpPropValueAfter) ) )
  908.         {
  909.             MessageBox( E.SzError("CPropDlg::OnSetProps()  lpEntry->GetProps() After", m_hResult), "Client", MBS_ERROR );
  910.             return;
  911.         }
  912.  
  913.  
  914.         Results.m_lpspvaBefore  = lpPropValueBefore;
  915.         Results.m_cValuesBefore = ulValuesBefore;    
  916.         Results.m_lpspvaAfter   = lpPropValueAfter;
  917.         Results.m_cValuesAfter  = ulValuesAfter;    
  918.         Results.m_Operation     = "Properties Before/After lpObj->SetProps()";
  919.         Results.m_lpProblems    = lpProblems;
  920.         Results.m_fIsPropValueArray = TRUE;
  921.         Results.m_lpspvaModify  = BldProp.m_lpspvaSelected;
  922.         Results.m_cValuesModify = BldProp.m_ulNewValues;
  923.  
  924.         Results.DoModal();
  925.     }
  926.     RedrawPropTable();
  927.     
  928.     if(lpPropValueBefore)
  929.     {
  930.         MAPIFreeBuffer(lpPropValueBefore);
  931.         lpPropValueBefore = NULL;
  932.     }
  933.  
  934.     if(lpPropValueAfter)
  935.     {
  936.         MAPIFreeBuffer(lpPropValueAfter);
  937.         lpPropValueAfter = NULL;
  938.     }
  939.     
  940.     if(lpProblems)
  941.     {
  942.         MAPIFreeBuffer(lpProblems);
  943.         lpProblems = NULL;
  944.     }
  945.  
  946. }
  947.  
  948.  
  949. /*******************************************************************/
  950. /*
  951.  -  CPropDlg::
  952.  -  OnDeleteProps
  953.  -
  954.  *  Purpose:
  955.  */
  956. /*******************************************************************/
  957.  
  958. void CPropDlg::OnDeleteProps()
  959. {
  960.     CResultsDlg     Results(this);
  961.     CBldPropDlg     BldProp(this);
  962.     LPSTR           lpszPropID      = NULL;
  963.     CGetError       E;
  964.     LPSPropProblemArray lpProblems  = NULL;
  965.     LPSPropValue    lpPropValueBefore     = NULL;
  966.     ULONG           ulValuesBefore        = 0;
  967.     LPSPropValue    lpPropValueAfter      = NULL;
  968.     ULONG           ulValuesAfter         = 0;
  969.     char            szBuff[80];
  970.     DWORD           dwIndex         = 0;
  971.  
  972.  
  973.     //$ ATTENTION this is dependent on order of properties in listbox
  974.     //      DONT SORT PROPS IN LISTBOX
  975.  
  976.     // need to set m_lSelectTag in case it is not one of our "MAPI" tags
  977.     //  and it is stored as a hex value so that setprops can
  978.     //  represent this value correctly
  979.  
  980.     if( HR_FAILED( m_hResult = m_lpEntry->GetProps(NULL, 0, &ulValuesBefore, &lpPropValueBefore) ) )
  981.     {
  982.         MessageBox( E.SzError("CPropDlg::OnDeleteProps()  lpEntry->GetProps()", m_hResult), "Client", MBS_ERROR );
  983.         return;
  984.     }
  985.     BldProp.m_fIsPropValueArray     = FALSE;
  986.     BldProp.m_lpSetEntry    = m_lpEntry;
  987.     BldProp.m_Operation     = "lpObj->DeleteProps()";
  988.     BldProp.DoModal();
  989.  
  990.     if(BldProp.m_fCall)
  991.     {
  992.         if( HR_FAILED( m_hResult = m_lpEntry->DeleteProps(BldProp.m_lpNewPTA, &lpProblems) ) )
  993.         {
  994.             MessageBox( E.SzError("CPropDlg::OnDeleteProps()", m_hResult),
  995.                                 "Client", MBS_ERROR );
  996.         }
  997.         wsprintf(szBuff,"%s",E.SzError("lpObj->DeleteProps() \tRC: ", m_hResult));
  998.         dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  999.                         (LPARAM)szBuff );
  1000.  
  1001.  
  1002.         if( HR_FAILED( m_hResult = m_lpEntry->GetProps(NULL, 0, &ulValuesAfter, &lpPropValueAfter) ) )
  1003.         {
  1004.             MessageBox( E.SzError("CPropDlg::OnDeleteProps()  lpEntry->GetProps() After", m_hResult), "Client", MBS_ERROR );
  1005.             return;
  1006.         }
  1007.  
  1008.         Results.m_lpspvaBefore  = lpPropValueBefore;
  1009.         Results.m_cValuesBefore = ulValuesBefore;    
  1010.         Results.m_lpspvaAfter   = lpPropValueAfter;
  1011.         Results.m_cValuesAfter  = ulValuesAfter;    
  1012.         Results.m_Operation     = "lpObj->DeleteProps()";
  1013.         Results.m_lpProblems    = lpProblems;
  1014.         Results.m_fIsPropValueArray = FALSE;
  1015.         Results.m_lpsptaModify  = BldProp.m_lpNewPTA;
  1016.  
  1017.         Results.DoModal();
  1018.  
  1019.     }
  1020.  
  1021.     RedrawPropTable();
  1022.  
  1023.     if(BldProp.m_lpNewPTA)
  1024.     {
  1025.         PvFree(BldProp.m_lpNewPTA);
  1026.         BldProp.m_lpNewPTA = NULL;
  1027.     }
  1028.     
  1029.     if(lpPropValueBefore)
  1030.     {
  1031.         MAPIFreeBuffer(lpPropValueBefore);
  1032.         lpPropValueBefore = NULL;
  1033.     }
  1034.  
  1035.     if(lpPropValueAfter)
  1036.     {
  1037.         MAPIFreeBuffer(lpPropValueAfter);
  1038.         lpPropValueAfter = NULL;
  1039.     }
  1040.     if(lpProblems)
  1041.         MAPIFreeBuffer(lpProblems);
  1042.         
  1043. }
  1044.  
  1045.  
  1046. /*******************************************************************/
  1047. /*
  1048.  -  CPropDlg::
  1049.  -  OnGetProps
  1050.  -
  1051.  *  Purpose:
  1052.  */
  1053. /*******************************************************************/
  1054.  
  1055. void CPropDlg::OnGetProps()
  1056. {
  1057.     CBldPropDlg     BldProp(this);
  1058.     CGetPropDlg     GetProp(this);
  1059.     LPSTR           lpszPropID      = NULL;
  1060.     CGetError       E;
  1061.     LPSPropProblemArray lpProblems  = NULL;
  1062.     LPSPropValue    lpPropValue     = NULL;
  1063.     ULONG           ulValues        = 0;
  1064.     DWORD           dwIndex         = 0;
  1065.     char            szBuff[80];
  1066.  
  1067.     BldProp.m_fIsPropValueArray     = FALSE;
  1068.     BldProp.m_lpSetEntry    = m_lpEntry;
  1069.     BldProp.m_Operation     = "lpObj->GetProps()";
  1070.     BldProp.DoModal();
  1071.  
  1072.     if(BldProp.m_fCall)
  1073.     {
  1074.         if( HR_FAILED(m_hResult = m_lpEntry->GetProps(BldProp.m_lpNewPTA, 0, &ulValues, &lpPropValue) ) )
  1075.         {
  1076.             MessageBox( E.SzError("CPropDlg::OnGetProps()  lpEntry->GetProps()",
  1077.                     m_hResult), "Client", MBS_ERROR );
  1078.         }
  1079.         wsprintf(szBuff,"%s",E.SzError("lpObj->GetProps() \tRC: ", m_hResult));
  1080.         dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  1081.                         (LPARAM)szBuff );
  1082.  
  1083.  
  1084.         GetProp.m_lpPTA     = BldProp.m_lpNewPTA;
  1085.         GetProp.m_lpPVA     = lpPropValue;
  1086.         GetProp.m_cValues   = ulValues;
  1087.  
  1088.         GetProp.DoModal();
  1089.  
  1090.         if(BldProp.m_lpNewPTA)
  1091.         {
  1092.             PvFree(BldProp.m_lpNewPTA);
  1093.             BldProp.m_lpNewPTA = NULL;
  1094.         }
  1095.  
  1096.         if(lpPropValue)
  1097.         {
  1098.             MAPIFreeBuffer(lpPropValue);
  1099.             lpPropValue = NULL;
  1100.             ulValues     = 0;
  1101.         }
  1102.     }
  1103. }
  1104.  
  1105.  
  1106. /*******************************************************************/
  1107. /*
  1108.  -  CPropDlg::
  1109.  -  OnGetPropList
  1110.  -
  1111.  *  Purpose:
  1112.  */
  1113. /*******************************************************************/
  1114.  
  1115. void CPropDlg::OnGetPropList()
  1116. {
  1117.     CGetPropListDlg GetPropList(this);
  1118.     LPSPropTagArray lpPTA       = NULL;
  1119.     CGetError       E;
  1120.     char            szBuff[80];
  1121.     DWORD           dwIndex     = 0;
  1122.  
  1123.     if( HR_FAILED(m_hResult = m_lpEntry->GetPropList(0, &lpPTA) ) )
  1124.     {
  1125.         MessageBox( E.SzError("CPropDlg::OnBldProps()  lpEntry->GetPropList()",
  1126.             m_hResult), "Client", MBS_ERROR );
  1127.         return;
  1128.     }
  1129.  
  1130.     GetPropList.m_lpPropTagArray    = lpPTA;
  1131.     GetPropList.DoModal();
  1132.  
  1133.     wsprintf(szBuff,"%s",E.SzError("lpObj->GetPropList() \tRC: ", m_hResult));
  1134.     dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  1135.                         (LPARAM)szBuff );
  1136.  
  1137. }
  1138.  
  1139.  
  1140. /*******************************************************************/
  1141. /*
  1142.  -  CPropDlg::
  1143.  -  OnRelease
  1144.  -
  1145.  *  Purpose:
  1146.  */
  1147. /*******************************************************************/
  1148.  
  1149. void CPropDlg::OnRelease()
  1150. {
  1151.     DWORD   dwIndex    = 0;
  1152.     ULONG   ulRefCount = 0;
  1153.     char    szBuff[80];
  1154.  
  1155.  
  1156.     // cancel out of dialog if we no longer have a valid object
  1157.     if(m_ulRefCount == 1 )
  1158.     {
  1159.         MessageBox( "Current m_ulRefCount == 1, PropDlg will not allow you to Release",
  1160.                  "Warning",MB_OK | MB_ICONINFORMATION);
  1161.         wsprintf(szBuff,"m_ulRefCount == 1, Invalid UI option to Release Object Completely");
  1162.  
  1163.         dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  1164.                         (LPARAM)szBuff );
  1165.         return;
  1166.     }
  1167.  
  1168.     ulRefCount = m_lpEntry->Release();
  1169.  
  1170.     // keep reference so user never releases to refcount == 0
  1171.     m_ulRefCount--;
  1172.  
  1173.     wsprintf(szBuff,"lpObj->Release() \tRC: %lu, Current RefCount >= %lu",ulRefCount,m_ulRefCount);
  1174.     dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  1175.                         (LPARAM)szBuff );
  1176.  
  1177. }
  1178.  
  1179. /*******************************************************************/
  1180. /*
  1181.  -  CPropDlg::
  1182.  -  OnGetLastError
  1183.  -
  1184.  *  Purpose:
  1185.  */
  1186. /*******************************************************************/
  1187.  
  1188. void CPropDlg::OnGetLastError()
  1189. {
  1190.  
  1191. //$ FUTURE use Operation Dialog for this too
  1192. //$ FUTURE Support Unicode
  1193. //$ FUTURE, pass in hResult or allow it on all other dialogs as well
  1194.  
  1195.     CGetError       E;
  1196.     DWORD           dwIndex         = 0;
  1197.     LPMAPIERROR     lpMAPIError     = NULL;
  1198.     HRESULT         hResult         = hrSuccess;
  1199.     char            szBuff[120];
  1200.  
  1201.  
  1202.     if( hResult = m_lpEntry->GetLastError(
  1203.                     m_hResult,
  1204.                     0,
  1205.                     &lpMAPIError))
  1206.     {
  1207.         MessageBox( E.SzError("CPropDlg::OnGetLastError()  lpEntry->GetLastError()", hResult),
  1208.                  "Client", MBS_ERROR );
  1209.         return;
  1210.  
  1211.     }
  1212.  
  1213.     if(lpMAPIError)
  1214.     {
  1215.         wsprintf(szBuff,"lpObj->GetLastError()  \tulLowLevelError == %lu,ulVersion == %lu lpszMessage == %s, lpszComponent == %s, ulContext == %lu",
  1216.                 lpMAPIError->ulLowLevelError,
  1217.                 lpMAPIError->ulVersion,
  1218.                 ((lpMAPIError->lpszError == NULL)     ? "NULL" : lpMAPIError->lpszError),
  1219.                 ((lpMAPIError->lpszComponent == NULL) ? "NULL" : lpMAPIError->lpszComponent),
  1220.                 lpMAPIError->ulContext);
  1221.         dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  1222.                         (LPARAM)szBuff );
  1223.     }
  1224.     
  1225.     if(lpMAPIError)
  1226.         MAPIFreeBuffer(lpMAPIError);
  1227. }
  1228.  
  1229.  
  1230.  
  1231. /*******************************************************************/
  1232. /*
  1233.  -  CPropDlg::
  1234.  -  OnSaveChanges
  1235.  *
  1236.  *  Purpose:
  1237.  *      SaveChanges on Property object
  1238.  *
  1239.  *  Parameters:
  1240.  *      None
  1241.  *
  1242.  *  Returns:
  1243.  *      Nothing
  1244.  *
  1245.  */
  1246. /*******************************************************************/
  1247.  
  1248. void CPropDlg::OnSaveChanges()
  1249. {
  1250.     COperation      SaveChangesDlg(this);
  1251.     CGetError       E;
  1252.     CString         OperName;
  1253.     int             dRet            = 0;
  1254.     ULONG           ulFlags         = 0;
  1255.     char            szBuff[80];
  1256.     DWORD           dwIndex         = 0;
  1257.  
  1258.     // initalize data for dialog box
  1259.  
  1260.     OperName = "lpObj->SaveChanges()";
  1261.  
  1262.     SaveChangesDlg.m_CurrentOperation= OperName;
  1263.  
  1264.     SaveChangesDlg.m_FlagText1       = "KEEP_OPEN_READONLY";
  1265.     SaveChangesDlg.m_FlagText2       = "KEEP_OPEN_READWRITE";
  1266.     SaveChangesDlg.m_FlagText3       = "FORCE_SAVE";
  1267.     SaveChangesDlg.m_FlagText4       = "Invalid Flag";
  1268.  
  1269.     // bring up modal dialog box, and if user hits OK, process operation
  1270.     if( SaveChangesDlg.DoModal() == IDOK )
  1271.     {
  1272.         if( SaveChangesDlg.m_bFlag1 )
  1273.             ulFlags |= KEEP_OPEN_READONLY;
  1274.  
  1275.         if( SaveChangesDlg.m_bFlag2)
  1276.             ulFlags |= KEEP_OPEN_READWRITE;
  1277.  
  1278.         if( SaveChangesDlg.m_bFlag3)
  1279.             ulFlags |= FORCE_SAVE;
  1280.  
  1281.         if( SaveChangesDlg.m_bFlag4)
  1282.             ulFlags |= TEST_INVALID_FLAG;
  1283.  
  1284.         if( m_hResult = m_lpEntry->SaveChanges(ulFlags) )
  1285.         {
  1286.             MessageBox( E.SzError("m_lpEntry->SaveChanges()", m_hResult),
  1287.                             "Client", MBS_ERROR );
  1288.         }
  1289.         wsprintf(szBuff,"%s",E.SzError("lpObj->SaveChanges() \tRC: ", m_hResult));
  1290.         dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  1291.                         (LPARAM)szBuff );
  1292.  
  1293.         RedrawPropTable();
  1294.     }
  1295.  
  1296. }
  1297.  
  1298. /*******************************************************************/
  1299. /*
  1300.  -  CPropDlg::
  1301.  -  OnGetNamesFromIDs
  1302.  -
  1303.  *  Purpose:
  1304.  *
  1305.  *
  1306.  */
  1307. /*******************************************************************/
  1308.  
  1309. void  CPropDlg::OnGetNamesFromIDs()
  1310. {
  1311.     CNamesIDsDlg    DisplayNameIDs(this);
  1312.     COperation      NameIDsDlg(this);
  1313.     CBldPropDlg     BldProp(this);
  1314.     int             dRet            = 0;
  1315.     CGetError       E;
  1316.     LPIID           lpInterface     = NULL;
  1317.     ULONG           idx;
  1318.     DWORD           dwIndex         = 0;
  1319.     ULONG           ulFlags         = 0;
  1320.     HRESULT         hResult         = hrSuccess;
  1321.     char            szBuff[80];
  1322.     char            szTemp[30];
  1323.     ULONG           cPropNames      = 0;          
  1324.     LPMAPINAMEID FAR  *lppPropNames = NULL; 
  1325.     BOOL            fFreeMAPI       = FALSE;
  1326.     GUID            guid;
  1327.    
  1328.     // build up proptag array to select specific property tags in name/id mapping
  1329.     BldProp.m_fIsPropValueArray     = FALSE;
  1330.     BldProp.m_lpSetEntry            = m_lpEntry;
  1331.     BldProp.m_Operation             = "lpObj->GetNamesFromIDs() Select Tags(None == NULL) ";
  1332.     BldProp.DoModal();
  1333.  
  1334.     // initalize data for dialog box
  1335.     NameIDsDlg.m_CurrentOperation= "lpObj->GetNamesFromIDs()";
  1336.     NameIDsDlg.m_CBText1         = "lpInterface:";
  1337.     NameIDsDlg.m_EditText1       = "lpsPropTagArray:";
  1338.     NameIDsDlg.m_FlagText1       = "MAPI_NO_STRINGS";
  1339.     NameIDsDlg.m_FlagText2       = "MAPI_NO_IDS";
  1340.     NameIDsDlg.m_FlagText3       = "Invalid Flag";
  1341.  
  1342.     
  1343.     // if this is NULL, we will have to free with MAPIFreeBuffer and we should add
  1344.     // the null param to NameIDsDlg, else add m_lpNewPTA value to NameIDsDlg
  1345.     if(! BldProp.m_lpNewPTA)
  1346.     {
  1347.         NameIDsDlg.m_EditDefault1    = "NULL";
  1348.         fFreeMAPI = TRUE;                
  1349.     }
  1350.     else
  1351.     {
  1352.         wsprintf(szTemp,"0x%08X",BldProp.m_lpNewPTA);
  1353.         NameIDsDlg.m_EditDefault1    = szTemp;
  1354.         fFreeMAPI = FALSE;
  1355.     }
  1356.  
  1357.     dRet = NameIDsDlg.m_CBContents1.Add("NULL");
  1358.     dRet = NameIDsDlg.m_CBContents1.Add("TEST GUID");
  1359.     dRet = NameIDsDlg.m_CBContents1.Add("Bad Interface Param");
  1360.  
  1361.     for(idx = 0; idx < NUM_INTERFACES; idx++)
  1362.     {           
  1363.         dRet = NameIDsDlg.m_CBContents1.Add( AllIIDs[idx].lpsz);
  1364.     }
  1365.  
  1366.     // bring up modal dialog box, and if user hits OK, process operation
  1367.     if( NameIDsDlg.DoModal() == IDOK )
  1368.     {
  1369.         // determine state/settings of data in dialog upon closing
  1370.         if( NameIDsDlg.m_bFlag1 )
  1371.             ulFlags |= MAPI_NO_STRINGS;
  1372.  
  1373.         if( NameIDsDlg.m_bFlag2 )
  1374.             ulFlags |= MAPI_NO_IDS;
  1375.  
  1376.         if( NameIDsDlg.m_bFlag3 )
  1377.             ulFlags |= TEST_INVALID_FLAG;
  1378.  
  1379.         // determine interface of PropSet selected
  1380.         lpInterface = NULL;
  1381.         for(idx = 0; idx < NUM_INTERFACES; idx++)
  1382.         {           
  1383.             if( !lstrcmp(NameIDsDlg.m_szCB1,AllIIDs[idx].lpsz) )
  1384.                 lpInterface =  AllIIDs[idx].lpInterface;               
  1385.         }
  1386.         if(!lpInterface)
  1387.         {        
  1388.             if( !lstrcmp(NameIDsDlg.m_szCB1,"NULL") )
  1389.                 lpInterface = (LPIID) NULL;
  1390.             else if(!lstrcmp(NameIDsDlg.m_szCB1,"TEST GUID") )
  1391.             {
  1392.                 MakeGuid(   &guid, 
  1393.                             (ULONG) 0x000000F0, 
  1394.                             (WORD)  0x0004,
  1395.                             (WORD)  0x0033,
  1396.                             (BYTE)  0x00,
  1397.                             (BYTE)  0x01,
  1398.                             (BYTE)  0x00,
  1399.                             (BYTE)  0x02,
  1400.                             (BYTE)  0x00,
  1401.                             (BYTE)  0x03,
  1402.                             (BYTE)  0x00,
  1403.                             (BYTE)  0x04);
  1404.                 lpInterface = (LPIID) &guid;                            
  1405.             }
  1406.             else if(!lstrcmp(NameIDsDlg.m_szCB1,"Bad Interface Param") )
  1407.                 lpInterface = (LPIID) &ulFlags;         // invalid
  1408.         }                     
  1409.  
  1410.         if( m_hResult = m_lpEntry->GetNamesFromIDs(                                           
  1411.                                             &BldProp.m_lpNewPTA,
  1412.                                             lpInterface,
  1413.                                             ulFlags,
  1414.                                             &cPropNames,
  1415.                                             &lppPropNames) )
  1416.         {
  1417.             MessageBox( E.SzError("m_lpEntry->GetNamesFromIDs()", m_hResult),
  1418.                             "Client", MBS_ERROR );
  1419.             goto Error;
  1420.         }
  1421.         wsprintf(szBuff,"%s",E.SzError("lpObj->GetNamesFromIDs() \tRC: ", m_hResult));
  1422.         dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  1423.                         (LPARAM)szBuff );
  1424.  
  1425.         DisplayNameIDs.m_lpPTA          = BldProp.m_lpNewPTA;
  1426.         DisplayNameIDs.m_lpPropSetGuid  = lpInterface;
  1427.         DisplayNameIDs.m_ulPropNames    = cPropNames;
  1428.         DisplayNameIDs.m_lppMAPINameID  = lppPropNames;
  1429.  
  1430.         DisplayNameIDs.DoModal();        
  1431.     }
  1432.  
  1433.     RedrawPropTable();
  1434.  
  1435. Error:
  1436.  
  1437.     if(fFreeMAPI)
  1438.     {
  1439.         if(BldProp.m_lpNewPTA)
  1440.         {
  1441.             MAPIFreeBuffer(BldProp.m_lpNewPTA);
  1442.             BldProp.m_lpNewPTA = NULL;
  1443.         }
  1444.     }    
  1445.     else
  1446.     {
  1447.         if(BldProp.m_lpNewPTA)
  1448.         {
  1449.             PvFree(BldProp.m_lpNewPTA);
  1450.             BldProp.m_lpNewPTA = NULL;
  1451.         }
  1452.     }
  1453.  
  1454.     if(lppPropNames)
  1455.         MAPIFreeBuffer(lppPropNames);
  1456. }
  1457.  
  1458.  
  1459. /*******************************************************************/
  1460. /*
  1461.  -  CPropDlg::
  1462.  -  OnGetIDsFromNames
  1463.  -
  1464.  *  Purpose:
  1465.  *
  1466.  *
  1467.  */
  1468. /*******************************************************************/
  1469.  
  1470. void  CPropDlg::OnGetIDsFromNames()
  1471. {
  1472.     CNamesIDsDlg    DisplayNameIDs(this);
  1473.     COperation      GetIDsFromNamesDlg(this);
  1474.     LPIID           lpInterface         = NULL;
  1475.     CGetError       E;
  1476.     ULONG           idx;
  1477.     char            szBuff[80];
  1478.     int             dRet                = 0;
  1479.     ULONG           ulFlags             = 0;
  1480.     DWORD           dwIndex             = 0;
  1481.     ULONG           cPropNames          = 0;          
  1482.     LPMAPINAMEID    *lppPropNames       = NULL; 
  1483.     ULONG           ulUnionType         = 0;
  1484.     ULONG           len1                = 0;
  1485.     ULONG           len2                = 0;
  1486.     ULONG           len3                = 0;
  1487.     ULONG           len4                = 0;
  1488.     ULONG           ulID                = 0;
  1489.     LPSPropTagArray lpPropTagArray      = NULL;
  1490.     GUID            guid;
  1491.  
  1492.     // initalize data for dialog box
  1493.     GetIDsFromNamesDlg.m_CurrentOperation= "lpObj->GetIDsFromNames()";
  1494.     GetIDsFromNamesDlg.m_CBText1         = "lpInterface:";
  1495.     GetIDsFromNamesDlg.m_CBText2         = "Union Type:";
  1496.     GetIDsFromNamesDlg.m_EditText1       = "Name/ID 1";
  1497.     GetIDsFromNamesDlg.m_EditText2       = "Name/ID 2";
  1498.     GetIDsFromNamesDlg.m_EditText3       = "Name/ID 3";
  1499.     GetIDsFromNamesDlg.m_FlagText1       = "MAPI_CREATE";
  1500.     GetIDsFromNamesDlg.m_FlagText2       = "Invalid Flag";
  1501.     GetIDsFromNamesDlg.m_EditDefault1    = "MAPI Name/ID 1";
  1502.     GetIDsFromNamesDlg.m_EditDefault2    = "MAPI Name/ID 2";
  1503.     GetIDsFromNamesDlg.m_EditDefault3    = "MAPI Name/ID 3";
  1504.  
  1505.  
  1506.     dRet = GetIDsFromNamesDlg.m_CBContents2.Add("MNID_ID");
  1507.     dRet = GetIDsFromNamesDlg.m_CBContents2.Add("MNID_STRING");
  1508.  
  1509.     dRet = GetIDsFromNamesDlg.m_CBContents1.Add("NULL");
  1510.     dRet = GetIDsFromNamesDlg.m_CBContents1.Add("TEST GUID");
  1511.     dRet = GetIDsFromNamesDlg.m_CBContents1.Add("Bad Interface Param");
  1512.     for(idx = 0; idx < NUM_INTERFACES; idx++)
  1513.     {           
  1514.         dRet = GetIDsFromNamesDlg.m_CBContents1.Add( AllIIDs[idx].lpsz);
  1515.     }
  1516.  
  1517.     // bring up modal dialog box, and if user hits OK, process operation
  1518.     if( GetIDsFromNamesDlg.DoModal() == IDOK )
  1519.     {
  1520.         // determine state/settings of data in dialog upon closing
  1521.         if( GetIDsFromNamesDlg.m_bFlag1 )
  1522.             ulFlags |= MAPI_CREATE;
  1523.  
  1524.         if( GetIDsFromNamesDlg.m_bFlag2 )
  1525.             ulFlags |= TEST_INVALID_FLAG;
  1526.  
  1527.         // determine interface of PropSet selected
  1528.         lpInterface = NULL;
  1529.         for(idx = 0; idx < NUM_INTERFACES; idx++)
  1530.         {           
  1531.             if( !lstrcmp(GetIDsFromNamesDlg.m_szCB1,AllIIDs[idx].lpsz) )
  1532.                 lpInterface =  AllIIDs[idx].lpInterface;               
  1533.         }
  1534.         if(!lpInterface)
  1535.         {        
  1536.             if( !lstrcmp(GetIDsFromNamesDlg.m_szCB1,"NULL") )
  1537.                 lpInterface = (LPIID) NULL;
  1538.             else if(!lstrcmp(GetIDsFromNamesDlg.m_szCB1,"TEST GUID") )
  1539.             {
  1540.                 MakeGuid(   &guid, 
  1541.                             (ULONG) 0x000000F0, 
  1542.                             (WORD)  0x0004,
  1543.                             (WORD)  0x0033,
  1544.                             (BYTE)  0x00,
  1545.                             (BYTE)  0x01,
  1546.                             (BYTE)  0x00,
  1547.                             (BYTE)  0x02,
  1548.                             (BYTE)  0x00,
  1549.                             (BYTE)  0x03,
  1550.                             (BYTE)  0x00,
  1551.                             (BYTE)  0x04);
  1552.                 lpInterface = (LPIID) &guid;                            
  1553.             }
  1554.             else if(!lstrcmp(GetIDsFromNamesDlg.m_szCB1,"Bad Interface Param") )
  1555.                 lpInterface = (LPIID) &ulFlags;         // invalid
  1556.         }                     
  1557.  
  1558.         // determine UNION type from CB 1
  1559.         if( !lstrcmp(GetIDsFromNamesDlg.m_szCB2,"MNID_ID") )
  1560.             ulUnionType = MNID_ID;
  1561.         else if(!lstrcmp(GetIDsFromNamesDlg.m_szCB2,"MNID_STRING") )
  1562.             ulUnionType = MNID_STRING;
  1563.         else
  1564.             goto Error;
  1565.  
  1566.         lppPropNames = (LPMAPINAMEID *) PvAlloc(3 * sizeof(LPMAPINAMEID));
  1567.         lppPropNames[0] = (LPMAPINAMEID) PvAllocMore(sizeof(MAPINAMEID),lppPropNames);
  1568.         lppPropNames[1] = (LPMAPINAMEID) PvAllocMore(sizeof(MAPINAMEID),lppPropNames);
  1569.         lppPropNames[2] = (LPMAPINAMEID) PvAllocMore(sizeof(MAPINAMEID),lppPropNames);
  1570.         
  1571.         // read data from Edit control 1, 2, and 3  depending on union type
  1572.         // and build up a LPMAPINAMEID structure
  1573.         if(ulUnionType == MNID_ID )
  1574.         {
  1575.             // find out the number of IDs to map == 0 or 1 or 2 or 3
  1576.             // and initialized them with ulKind, lpInterface, and ID data
  1577.  
  1578.             cPropNames = 0;
  1579.             if( len1 = strlen(GetIDsFromNamesDlg.m_szEdit1) )
  1580.             {
  1581.                 len4 = 0;
  1582.                 (*lppPropNames[cPropNames]).lpguid = (LPIID) lpInterface;
  1583.                 (*lppPropNames[cPropNames]).ulKind = ulUnionType;
  1584.                 len4 = lstrlen(GetIDsFromNamesDlg.m_szEdit1);
  1585.                 AsciiToHex(len4,GetIDsFromNamesDlg.m_szEdit1,&ulID);
  1586.                 (*lppPropNames[cPropNames]).Kind.lID = ulID;
  1587.                 cPropNames++;
  1588.             }
  1589.             if( len2 = strlen(GetIDsFromNamesDlg.m_szEdit2) )
  1590.             {
  1591.                 len4 = 0;
  1592.                 (*lppPropNames[cPropNames]).lpguid = (LPIID) lpInterface;
  1593.                 (*lppPropNames[cPropNames]).ulKind = ulUnionType;
  1594.                 len4 = lstrlen(GetIDsFromNamesDlg.m_szEdit2);
  1595.                 AsciiToHex(len4,GetIDsFromNamesDlg.m_szEdit2,&ulID);
  1596.                 (*lppPropNames[cPropNames]).Kind.lID = ulID;
  1597.                 cPropNames++;
  1598.             }
  1599.             if( len3 = strlen(GetIDsFromNamesDlg.m_szEdit3) )
  1600.             {
  1601.                 len4 = 0;
  1602.                 (*lppPropNames[cPropNames]).lpguid = (LPIID) lpInterface;
  1603.                 (*lppPropNames[cPropNames]).ulKind = ulUnionType;
  1604.                 len4 = lstrlen(GetIDsFromNamesDlg.m_szEdit3);
  1605.                 AsciiToHex(len4,GetIDsFromNamesDlg.m_szEdit3,&ulID);
  1606.                 (*lppPropNames[cPropNames]).Kind.lID = ulID;
  1607.                 cPropNames++;
  1608.             }
  1609.         }
  1610.         else // MNID_STRING
  1611.         {
  1612.             // find out the number of IDs to map == 0 or 1 or 2 or 3
  1613.             // and initialized them with ulKind, lpInterface, and String data
  1614.  
  1615.             cPropNames = 0;
  1616.             if( len1 = strlen(GetIDsFromNamesDlg.m_szEdit1) )
  1617.             {
  1618.                 (*lppPropNames[cPropNames]).lpguid = (LPIID) lpInterface;
  1619.                 (*lppPropNames[cPropNames]).ulKind = ulUnionType;
  1620.                 String8ToUnicode(   GetIDsFromNamesDlg.m_szEdit1,
  1621.                                     &((*lppPropNames[cPropNames]).Kind.lpwstrName),
  1622.                                     lppPropNames);
  1623.                 cPropNames++;
  1624.             }
  1625.             if( len2 = strlen(GetIDsFromNamesDlg.m_szEdit2) )
  1626.             {
  1627.                 (*lppPropNames[cPropNames]).lpguid = (LPIID) lpInterface;
  1628.                 (*lppPropNames[cPropNames]).ulKind = ulUnionType;
  1629.                 String8ToUnicode(   GetIDsFromNamesDlg.m_szEdit2,
  1630.                                     &((*lppPropNames[cPropNames]).Kind.lpwstrName),
  1631.                                     lppPropNames);
  1632.                 cPropNames++;
  1633.             }
  1634.             if( len3 = strlen(GetIDsFromNamesDlg.m_szEdit3) )
  1635.             {
  1636.                 (*lppPropNames[cPropNames]).lpguid = (LPIID) lpInterface;
  1637.                 (*lppPropNames[cPropNames]).ulKind = ulUnionType;
  1638.                 String8ToUnicode(   GetIDsFromNamesDlg.m_szEdit3,
  1639.                                     &((*lppPropNames[cPropNames]).Kind.lpwstrName),
  1640.                                     lppPropNames);
  1641.                 cPropNames++;
  1642.             }
  1643.         }
  1644.  
  1645.         if( m_hResult = m_lpEntry->GetIDsFromNames(                                           
  1646.                                             cPropNames,
  1647.                                             lppPropNames,
  1648.                                             ulFlags,
  1649.                                             &lpPropTagArray) )
  1650.         {
  1651.             MessageBox( E.SzError("m_lpEntry->GetIDsFromNames()", m_hResult),
  1652.                             "Client", MBS_ERROR );
  1653.             goto Error;
  1654.         }
  1655.  
  1656.         wsprintf(szBuff,"%s",E.SzError("lpObj->GetIDsFromNames() \tRC: ", m_hResult));
  1657.         dwIndex = SendDlgItemMessage(IDC_MAPILOG,LB_ADDSTRING,0,
  1658.                         (LPARAM)szBuff );
  1659.  
  1660.         DisplayNameIDs.m_lpPTA          = lpPropTagArray;
  1661.         DisplayNameIDs.m_lpPropSetGuid  = lpInterface;
  1662.         DisplayNameIDs.m_ulPropNames    = cPropNames;
  1663.         DisplayNameIDs.m_lppMAPINameID  = lppPropNames;
  1664.  
  1665.         DisplayNameIDs.DoModal();        
  1666.  
  1667.     }
  1668.  
  1669.     RedrawPropTable();
  1670.  
  1671. Error:
  1672.  
  1673.     if(lppPropNames)
  1674.         PvFree(lppPropNames);
  1675.  
  1676.     if(lpPropTagArray)
  1677.         MAPIFreeBuffer(lpPropTagArray);
  1678. }
  1679.  
  1680.  
  1681. /*******************************************************************/
  1682. /*
  1683.  -  CPropDlg::
  1684.  -  OnCancel
  1685.  -
  1686.  *  Purpose:
  1687.  *      Closes the Folder dialog.
  1688.  *
  1689.  */
  1690. /*******************************************************************/
  1691.  
  1692. void CPropDlg::OnCancel()
  1693. {
  1694.     delete this;
  1695. }
  1696.  
  1697. /*******************************************************************/
  1698. /*
  1699.  -  CPropDlg::
  1700.  -  Cleanup()
  1701.  -
  1702.  *  Purpose:
  1703.  *      Destructor for class CFolderDlg and CPropDlg call this
  1704.  *      function that releases and Frees memory
  1705.  *      allocated in class
  1706.  *
  1707.  */
  1708. /*******************************************************************/
  1709.  
  1710. void CPropDlg::Cleanup()
  1711. {
  1712.  
  1713. // do nothing now
  1714. }
  1715.  
  1716. /*
  1717.  -  CPropDlg
  1718.  -  OnClearMapiLog
  1719.  -
  1720.  *  Purpose:
  1721.  *      Clears the logging window.
  1722.  *
  1723.  */
  1724.  
  1725. void CPropDlg::OnClearMapiLog()
  1726. {
  1727.     DWORD   dwIndex = 0;
  1728.  
  1729.     dwIndex = SendDlgItemMessage( IDC_MAPILOG, LB_RESETCONTENT, 0, 0L);
  1730.  
  1731. }
  1732.  
  1733. /*******************************************************************/
  1734. /*
  1735.  -  CPropDlg::
  1736.  -
  1737.  -  OnType
  1738.  -  OnData
  1739.  -  OnIDs
  1740.  -  OnString
  1741.  -  OnHex
  1742.  -  OnDecimal
  1743.  -
  1744.  *  Purpose:
  1745.  *      To determine whether to display different qualities (types,values,data)
  1746.  *      and the method of displaying(HEX, Decimal, String) properties
  1747.  *      of the mapi object in the property listbox on the dialog when
  1748.  *      RedrawPropTable is called
  1749.  *
  1750.  */
  1751. /*******************************************************************/
  1752.  
  1753. void CPropDlg::OnType()
  1754. {
  1755.     CheckDlgButton(IDC_PROPTYPE, !IsDlgButtonChecked(IDC_PROPTYPE) );
  1756.     RedrawPropTable();
  1757. }
  1758.  
  1759. /*******************************************************************/
  1760.  
  1761. void CPropDlg::OnData()
  1762. {
  1763.     CheckDlgButton(IDC_PROPDATA, !IsDlgButtonChecked(IDC_PROPDATA) );
  1764.     RedrawPropTable();
  1765. }
  1766.  
  1767. /*******************************************************************/
  1768.  
  1769. void CPropDlg::OnID()
  1770. {
  1771.     CheckDlgButton(IDC_PROPID, !IsDlgButtonChecked(IDC_PROPID) );
  1772.     RedrawPropTable();
  1773. }
  1774.  
  1775. /*******************************************************************/
  1776.  
  1777. void CPropDlg::OnString()
  1778. {
  1779.     CheckRadioButton(IDC_PROPSTRING,IDC_PROPDEC,IDC_PROPSTRING);
  1780.     RedrawPropTable();
  1781. }
  1782.  
  1783. /*******************************************************************/
  1784.  
  1785. void CPropDlg::OnHex()
  1786. {
  1787.  
  1788.     CheckRadioButton(IDC_PROPSTRING,IDC_PROPDEC,IDC_PROPHEX);
  1789.     RedrawPropTable();
  1790. }
  1791.  
  1792. /*******************************************************************/
  1793.  
  1794. void CPropDlg::OnDecimal()
  1795. {
  1796.     CheckRadioButton(IDC_PROPSTRING,IDC_PROPDEC,IDC_PROPDEC);
  1797.     RedrawPropTable();
  1798. }
  1799.  
  1800. /********************************************************************/
  1801. /*
  1802.  -  CPropDlg::
  1803.  -  RedrawPropTable
  1804.  -
  1805.  *  Purpose:
  1806.  *      To redraw the current property table of folder listbox.  This
  1807.  *      routine gets checkstate of property display checkboxs and
  1808.  *      radio buttons to determine how to display and what to display
  1809.  *
  1810.  *      Assuming the size(in bytes) of the data, types and IDs in
  1811.  *      array size.
  1812.  */
  1813. /********************************************************************/
  1814.  
  1815. void CPropDlg::RedrawPropTable()
  1816. {
  1817.     HRESULT         hResult         = SUCCESS_SUCCESS;
  1818.     CGetError       E;
  1819.     char            szBuffer[1024];
  1820.     int             idx             = 0;
  1821.     DWORD           dwReturn        = 0;
  1822.     LPSPropValue    lpPropValue     = NULL;
  1823.     ULONG           ulValues        = 0;
  1824.     char            szCVals[30];
  1825.                             // assuming size here
  1826.     char szID[50];
  1827.     char szData[512];
  1828.     char szType[32];      // Assumes no PropType string longer than 31 chars
  1829.  
  1830.     // multi value props stuff
  1831.     char            szMV[1024];    
  1832.     char            szMVSeps[]      = ";:.";
  1833.     char            *lpszToken      = NULL;
  1834.     char            szTemp[30];
  1835.     ULONG           ulMVRow         = 0;
  1836.     ULONG           ulMVcValues     = 0;
  1837.     char            *szEnd          = NULL;
  1838.  
  1839.  
  1840.  
  1841.     szBuffer[0] = '\0' ;
  1842.  
  1843.     SendDlgItemMessage(IDC_PROPVIEW,LB_RESETCONTENT,0,0);
  1844.  
  1845.     if( m_hResult = m_lpEntry->GetProps(NULL, 0, &ulValues, &lpPropValue) )
  1846.     {
  1847.         MessageBox( E.SzError("CPropDlg::RedrawPropTable() lpEntry->GetProps()", m_hResult),
  1848.                      "Client", MBS_ERROR );
  1849.         // allow warning messages, dont goto error here
  1850.  
  1851.         // ASSERT THAT there is at least one prop in listbox
  1852.         if(ulValues == 0)
  1853.         {
  1854.             MessageBox( "lpObj->GetProps(NULL) returned ulValues == 0, exiting",
  1855.                      "Client", MBS_ERROR );
  1856.             goto End;
  1857.         }
  1858.     }
  1859.     
  1860.     // DISPLAY Expected lpPTA->cValues
  1861.     wsprintf(szCVals,"cValues:  %lu",ulValues);
  1862.     SetDlgItemText(IDT_CVALUES,szCVals);
  1863.     
  1864.     // determine if string, hex, or decimal and build row of listbox
  1865.     for(idx = 0; idx < ulValues; idx++)
  1866.     {
  1867.         szID[0]     = '\0' ;
  1868.         szData[0]   = '\0' ;
  1869.         szType[0]   = '\0' ;
  1870.         szBuffer[0] = '\0' ;
  1871.  
  1872.         if( IsDlgButtonChecked(IDC_PROPID) )
  1873.         {
  1874.             if( IsDlgButtonChecked(IDC_PROPSTRING) )
  1875.             {
  1876.                 if(GetString("PropIDs", PROP_ID(lpPropValue[idx].ulPropTag), szID ) )
  1877.                 {
  1878.                     lstrcat(szBuffer, szID );
  1879.                     lstrcat(szBuffer, "\t");
  1880.                 }
  1881.                 else
  1882.                 {
  1883.                     wsprintf(szBuffer,"%#04X\t", PROP_ID(lpPropValue[idx].ulPropTag) );
  1884.                 }
  1885.             }
  1886.             else if(  IsDlgButtonChecked(IDC_PROPDEC) )
  1887.             {
  1888.                 wsprintf(szBuffer,"%08d\t", PROP_ID(lpPropValue[idx].ulPropTag), szID );
  1889.             }
  1890.             else if(  IsDlgButtonChecked(IDC_PROPHEX) )
  1891.             {
  1892.                 wsprintf(szBuffer,"%#04X\t", PROP_ID(lpPropValue[idx].ulPropTag) );
  1893.             }
  1894.         }
  1895.  
  1896.         if( IsDlgButtonChecked(IDC_PROPTYPE) )
  1897.         {
  1898.             if( IsDlgButtonChecked(IDC_PROPSTRING) )
  1899.             {
  1900.                 if( GetString("PropType", PROP_TYPE(lpPropValue[idx].ulPropTag), szType) )
  1901.                 {
  1902.                     lstrcat(szBuffer, szType);
  1903.                     lstrcat(szBuffer,"\t");
  1904.                 }
  1905.                 else
  1906.                 {
  1907.                     wsprintf(szType,"%#04X\t", PROP_TYPE(lpPropValue[idx].ulPropTag) );
  1908.                     lstrcat(szBuffer,szType);
  1909.  
  1910.                 }
  1911.             }
  1912.             else if(  IsDlgButtonChecked(IDC_PROPDEC) )
  1913.             {
  1914.                 wsprintf(szType,"%08d\t", PROP_TYPE(lpPropValue[idx].ulPropTag) );
  1915.                 lstrcat(szBuffer,szType);
  1916.             }
  1917.             else if(  IsDlgButtonChecked(IDC_PROPHEX) )
  1918.             {
  1919.                 wsprintf(szType,"%#04X\t", PROP_TYPE(lpPropValue[idx].ulPropTag) );
  1920.                 lstrcat(szBuffer,szType);
  1921.             }
  1922.         }
  1923.  
  1924.                     
  1925.         if( IsDlgButtonChecked(IDC_PROPDATA) )  
  1926.         {   
  1927.             SzGetPropValue(szData,(LPSPropValue) &lpPropValue[idx]);
  1928.  
  1929.             // if it is a MultiValueProperty, parse the output, and add
  1930.             //   more than one row for this property
  1931.             if( (PROP_TYPE(lpPropValue[idx].ulPropTag)) & MV_FLAG )
  1932.             {
  1933.                 // it is multi value, so strtok out the data 
  1934.                 // and add a row for each data value                                                        
  1935.                 ulMVRow = 0;
  1936.  
  1937.                 // determine number of cValues
  1938.                 lpszToken   = strtok(szData,szMVSeps);
  1939.                 ulMVcValues = strtoul(lpszToken,&szEnd,16);        
  1940.  
  1941.                 // rip out first row of multi value prop
  1942.                 lpszToken = strtok(NULL,szMVSeps);
  1943.                                 
  1944.                 // rip out remaining rows                
  1945.                 while( lpszToken != NULL )
  1946.                 {
  1947.                     lstrcpy(szMV,szBuffer);
  1948.                     wsprintf(szTemp,"[%lu] ",ulMVRow);
  1949.                     lstrcat(szMV,szTemp);
  1950.                     lstrcat(szMV,lpszToken);
  1951.                 
  1952.                     dwReturn = SendDlgItemMessage(IDC_PROPVIEW,LB_ADDSTRING,0,
  1953.                             (LPARAM)szMV);
  1954.                 
  1955.                     lpszToken = strtok(NULL,szMVSeps);
  1956.                     ulMVRow++;
  1957.                 }                
  1958.                 
  1959.                 // if all the data was not there, fill in the remainder with bogus stub
  1960.                 while( ulMVRow < ulMVcValues )
  1961.                 {
  1962.                     lstrcpy(szMV,szBuffer);
  1963.                     wsprintf(szTemp,"[%lu] ",ulMVRow);
  1964.                     lstrcat(szMV,szTemp);
  1965.                     lstrcat(szMV,"<No Data Available>");
  1966.                 
  1967.                     dwReturn = SendDlgItemMessage(IDC_PROPVIEW,LB_ADDSTRING,0,
  1968.                             (LPARAM)szMV);
  1969.                     ulMVRow++;                            
  1970.                 }
  1971.             }
  1972.             else            
  1973.             {
  1974.                 lstrcat(szBuffer,szData);
  1975.                 dwReturn = SendDlgItemMessage(IDC_PROPVIEW,LB_ADDSTRING,0,
  1976.                             (LPARAM)szBuffer);
  1977.             }
  1978.         }
  1979.         else
  1980.             dwReturn = SendDlgItemMessage(IDC_PROPVIEW,LB_ADDSTRING,0,
  1981.                             (LPARAM)szBuffer);
  1982.     
  1983.  
  1984.     }  // end of for loop of ulValues in lpPropValue
  1985.  
  1986.     dwReturn = SendDlgItemMessage(IDC_PROPVIEW,LB_SETCURSEL,(WPARAM) -1 ,0 );
  1987.  
  1988. End:
  1989.  
  1990.     if(lpPropValue)
  1991.     {
  1992.         MAPIFreeBuffer(lpPropValue);
  1993.         lpPropValue = NULL;
  1994.     }
  1995. }
  1996.  
  1997.  
  1998.  
  1999.  
  2000. /********************************************************************/
  2001. /********************** CGetError Member Functions ******************/
  2002.  
  2003. /********************************************************************/
  2004. /*
  2005.  -  CGetError::
  2006.  -  SzError       SCODE and ULONG
  2007.  -
  2008.  *  Purpose:
  2009.  *      For printable Error String.  Uses the stringtable
  2010.  *      technology from mapitest.
  2011.  *
  2012.  *  Parameters:
  2013.  *      szMsg       - Message Text
  2014.  *      scResult    - Error Code
  2015.  *
  2016.  *  Returns:
  2017.  *      szError     - Textized information
  2018.  *
  2019.  */
  2020. /********************************************************************/
  2021.  
  2022. LPSTR CGetError::SzError( LPSTR szMsg, SCODE scResult )
  2023. {
  2024.     wsprintf( m_szMessage, "%s: ", szMsg );
  2025.  
  2026.     if(!GetString( "MAPIErrors", scResult, m_szResult ))
  2027.     {
  2028.         lstrcpy(  m_szResult, "??" );
  2029.         wsprintf( m_szBuffer, " %04X", scResult );
  2030.         lstrcat(  m_szResult, m_szBuffer );
  2031.     }
  2032.  
  2033.     lstrcat( m_szMessage, m_szResult );
  2034.  
  2035.     return m_szMessage;
  2036. }
  2037.  
  2038. /********************************************************************/
  2039.  
  2040. #ifdef WIN16
  2041. LPSTR CGetError::SzError( LPSTR szMsg, HRESULT hResult )
  2042. {
  2043.     return( SzError(szMsg, GetScode(hResult) ) );
  2044. }
  2045.  
  2046. #endif 
  2047.  
  2048.  
  2049.  
  2050.  
  2051. /*--------------------*/
  2052. /* Library Init stuff */
  2053. /*--------------------*/
  2054. /********************************************************************/
  2055.  
  2056. /********************************************************************/
  2057.  
  2058. /********************************************************************/
  2059.  
  2060. class CPropViewDLL : public CWinApp
  2061. {
  2062. public:
  2063.     virtual BOOL InitInstance();
  2064.     virtual BOOL ExitInstance();
  2065.  
  2066.     CPropViewDLL(const char *pszAppName)
  2067.             : CWinApp(pszAppName)
  2068.         {
  2069.         }
  2070. };
  2071.  
  2072. BOOL CPropViewDLL::InitInstance()
  2073. {
  2074.     SetDialogBkColor();
  2075.     return TRUE;
  2076. }
  2077.  
  2078.  
  2079. BOOL CPropViewDLL::ExitInstance()
  2080. {
  2081.     return TRUE;
  2082. }
  2083.  
  2084. CPropViewDLL  vtDLL("propvu32.dll");
  2085.