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

  1. /*******************************************************************/
  2. /*
  3.  -  prop.cpp
  4.  -  Copyright (C) 1995 Microsoft Corporation
  5.  -
  6.  *  Purpose:
  7.  *      Contains member functions for CPropDlg.  This modal dialog
  8.  *      allows selective setting of properties on new, existing, and
  9.  *      current properties.
  10.  */
  11. /*******************************************************************/
  12.                                                    
  13. #undef  CINTERFACE      // C++ calling convention for mapi calls
  14.  
  15. #ifdef WIN32
  16. #ifdef _WIN95
  17. #define _INC_OLE
  18. #endif
  19. #define INC_OLE2
  20. #define INC_RPC
  21. #endif
  22.  
  23. #include <afxwin.h>     
  24. #include <windowsx.h>
  25. #include <string.h>
  26.  
  27. #ifdef WIN16
  28. #include <compobj.h>
  29. #endif
  30.  
  31. #ifdef WIN32
  32. #include <objbase.h>
  33. #include <objerror.h>
  34. #ifdef _WIN95
  35. #include <ole2.h>
  36. #endif
  37. #endif
  38.  
  39. #ifdef WIN16
  40. #include <mapiwin.h>    
  41. #endif
  42. #include <mapix.h>      
  43. #include <strtbl.h>     
  44. #include <misctool.h>
  45. #include "resource.h"   
  46. #include "mdbview.h" 
  47. #include "oper.h"
  48.  
  49. /*************************** PropDlg Functions *********************/
  50.  
  51. /*******************************************************************/
  52. /*
  53.  -  CPropDlg::
  54.  -  Stub
  55.  *
  56.  *  Purpose:
  57.  *      Generic stub for functions not yet implemented
  58.  */
  59. /*******************************************************************/
  60.  
  61. void CPropDlg::Stub()
  62. {   
  63.     MessageBox("Not Yet Implemented", "Client", MBS_INFO );
  64. }   
  65.  
  66. /********************************************************************/
  67. /*
  68.  -  CPropDlg::
  69.  -  ResetPropButtons    (INTERNAL, protected member function)
  70.  -
  71.  *  Purpose:
  72.  *      Reset Property Display configurable buttons to default(string/all)
  73.  *
  74.  *  Returns:
  75.  *      Nothing
  76.  */     
  77. /********************************************************************/
  78.  
  79. void CPropDlg::ResetPropButtons()
  80. {
  81.     // set check state of checkboxes (display all fields in string)
  82.     CheckDlgButton(IDC_STRING,  1);
  83.     CheckDlgButton(IDC_HEX,     0);
  84.     CheckDlgButton(IDC_DECIMAL, 0);
  85.     CheckDlgButton(IDC_TYPES,   1);
  86.     CheckDlgButton(IDC_DATA,    1);
  87.     CheckDlgButton(IDC_VALUES,  1);
  88. }   
  89.    
  90. /*******************************************************************/
  91. /*
  92.  -  CPropDlg::
  93.  -
  94.  -  OnType
  95.  -  OnData
  96.  -  OnValues
  97.  -  OnString
  98.  -  OnHex
  99.  -  OnDecimal
  100.  -
  101.  *  Purpose:
  102.  *      To determine whether to display different qualities (types,values,data)
  103.  *      and the method of displaying(HEX, Decimal, String) properties
  104.  *      of the mapi object in the property listbox on the dialog when
  105.  *      RedrawPropTable is called   
  106.  *
  107.  */
  108. /*******************************************************************/
  109.  
  110. void CPropDlg::OnType()
  111. {   
  112.     CheckDlgButton(IDC_TYPES, !IsDlgButtonChecked(IDC_TYPES) );
  113.     RedrawPropTable();
  114. }
  115.  
  116. /*******************************************************************/
  117.  
  118. void CPropDlg::OnData()
  119. {   
  120.     CheckDlgButton(IDC_DATA, !IsDlgButtonChecked(IDC_DATA) );
  121.     RedrawPropTable();
  122. }      
  123.  
  124. /*******************************************************************/
  125.  
  126. void CPropDlg::OnValues()
  127. {   
  128.     CheckDlgButton(IDC_VALUES, !IsDlgButtonChecked(IDC_VALUES) );
  129.     RedrawPropTable();
  130. }
  131.  
  132. /*******************************************************************/
  133.  
  134. void CPropDlg::OnString()
  135. {   
  136.     CheckRadioButton(IDC_STRING,IDC_DECIMAL,IDC_STRING);
  137.     RedrawPropTable();
  138. }
  139.  
  140. /*******************************************************************/
  141.  
  142. void CPropDlg::OnHex()
  143. {   
  144.  
  145.     CheckRadioButton(IDC_STRING,IDC_DECIMAL,IDC_HEX);
  146.     RedrawPropTable();
  147. }
  148.  
  149. /*******************************************************************/
  150.  
  151. void CPropDlg::OnDecimal()
  152. {   
  153.     CheckRadioButton(IDC_STRING,IDC_DECIMAL,IDC_DECIMAL);
  154.     RedrawPropTable();
  155. }
  156.  
  157. /*
  158.  -  CPropDlg
  159.  -  OnClearMapiLog
  160.  -
  161.  *  Purpose:
  162.  *      Clears the logging window.
  163.  *
  164.  */
  165.  
  166. void CPropDlg::OnClearMapiLog()
  167. {
  168.     DWORD   dwIndex = 0;
  169.  
  170.     dwIndex = SendDlgItemMessage( IDC_MAPILOG, LB_RESETCONTENT, 0, 0L);
  171. }
  172.  
  173. /********************************************************************/
  174. /*
  175.  -  CPropDlg::
  176.  -  RedrawPropTable
  177.  -
  178.  *  Purpose:
  179.  *      To redraw the current property table of folder listbox.  This
  180.  *      routine gets checkstate of property display checkboxs and 
  181.  *      radio buttons to determine how to display and what to display
  182.  *
  183.  *      Assuming the size(in bytes) of the data, types and IDs in
  184.  *      array size.
  185.  */
  186. /********************************************************************/
  187.  
  188. void CPropDlg::RedrawPropTable()
  189. {
  190.     HRESULT         hResult         = SUCCESS_SUCCESS;
  191.     CGetError       E;
  192.     char            szBuffer[1024];
  193.     int             idx             = 0;
  194.     int             rgTabStops[4];
  195.     DWORD           dwReturn        = 0;
  196.     LPSPropValue    lpPropValue     = NULL;
  197.     ULONG           ulValues        = 0;
  198.     
  199.     // multi value props stuff    
  200.     char            szMV[1024];    
  201.     char            szMVSeps[]      = ";:.";
  202.     char            *lpszToken      = NULL;
  203.     char            szTemp[30];
  204.     ULONG           ulMVRow         = 0;
  205.     ULONG           ulMVcValues     = 0;
  206.     char            *szEnd          = NULL;
  207.  
  208.                             // assuming size here
  209.     char szID[50];
  210.     char szData[512];
  211.     char szType[32];      // Assumes no PropType string longer than 31 chars
  212.  
  213.     szBuffer[0] = '\0' ;
  214.  
  215.     SendDlgItemMessage(IDC_PROPS,LB_RESETCONTENT,0,0);
  216.     
  217.     hResult = m_lpEntry->GetProps(NULL,0, &ulValues, &lpPropValue);
  218.  
  219.     wsprintf(m_szLogBuf,"m_lpEntry->GetProps(NULL,0,&ulValues,&lpPropValue)\t SC: %s",
  220.                         GetString( "MAPIErrors", GetScode(hResult), m_szError ) );
  221.  
  222.     if( HR_FAILED(hResult))    
  223.     {
  224.         MessageBox( m_E.SzError("m_lpEntry->GetProps()", hResult), 
  225.                             "Client", MBS_ERROR );
  226.         return;
  227.     }
  228.  
  229.     // load properties into listbox
  230.     dwReturn = SendDlgItemMessage(IDC_PROPS,LB_SETHORIZONTALEXTENT,
  231.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  232.  
  233.     rgTabStops[0] = PROP_LISTBOX_TAB1_SIZE ;
  234.     rgTabStops[1] = PROP_LISTBOX_TAB2_SIZE ;
  235.  
  236.     dwReturn = SendDlgItemMessage(IDC_PROPS,LB_SETTABSTOPS,
  237.                     (WPARAM) 2,(LPARAM)rgTabStops );
  238.     
  239.     // determine if string, hex, or decimal and build row of listbox
  240.     for(idx = 0; idx < ulValues; idx++)
  241.     {   
  242.         szID[0]     = '\0' ;
  243.         szData[0]   = '\0' ;
  244.         szType[0]   = '\0' ;
  245.         szBuffer[0] = '\0' ;
  246.             
  247.         if( 1 )
  248.         {
  249.             if( 1 )
  250.             {
  251.                 if(GetString("PropIDs", PROP_ID(lpPropValue[idx].ulPropTag), szID ) )
  252.                 {
  253.                     lstrcat(szBuffer, szID );               
  254.                     lstrcat(szBuffer, "\t");
  255.                 }
  256.                 else
  257.                 {
  258.                     wsprintf(szBuffer,"%#04X\t", PROP_ID(lpPropValue[idx].ulPropTag) );     
  259.                 }
  260.             }
  261.             else if(  IsDlgButtonChecked(IDC_DECIMAL) )
  262.             {
  263.                 wsprintf(szBuffer,"%08d\t", PROP_ID(lpPropValue[idx].ulPropTag), szID );
  264.             }
  265.             else if(  IsDlgButtonChecked(IDC_HEX) )
  266.             {
  267.                 wsprintf(szBuffer,"%#04X\t", PROP_ID(lpPropValue[idx].ulPropTag) );     
  268.             }               
  269.         }
  270.  
  271.         if( 1 )  
  272.         {
  273.             if( 1 )
  274.             {
  275.                 if( GetString("PropType", PROP_TYPE(lpPropValue[idx].ulPropTag), szType) )
  276.                 {
  277.                     lstrcat(szBuffer, szType);
  278.                     lstrcat(szBuffer,"\t");
  279.                 }       
  280.                 else
  281.                 {
  282.                     wsprintf(szType,"%#04X\t", PROP_TYPE(lpPropValue[idx].ulPropTag) );
  283.                     lstrcat(szBuffer,szType);
  284.  
  285.                 }
  286.             }
  287.             else if(  IsDlgButtonChecked(IDC_DECIMAL) )
  288.             {
  289.                 wsprintf(szType,"%08d\t", PROP_TYPE(lpPropValue[idx].ulPropTag) );
  290.                 lstrcat(szBuffer,szType);
  291.             }
  292.             else if(  IsDlgButtonChecked(IDC_HEX) )
  293.             {
  294.                 wsprintf(szType,"%#04X\t", PROP_TYPE(lpPropValue[idx].ulPropTag) );
  295.                 lstrcat(szBuffer,szType);
  296.             }
  297.         }           
  298.  
  299.                     
  300.         if( 1 ) 
  301.         {   
  302.             SzGetPropValue(szData,(LPSPropValue) &lpPropValue[idx]);
  303.  
  304.             // if it is a MultiValueProperty, parse the output, and add
  305.             //   more than one row for this property
  306.             if( (PROP_TYPE(lpPropValue[idx].ulPropTag)) & MV_FLAG )
  307.             {
  308.                 // it is multi value, so strtok out the data 
  309.                 // and add a row for each data value                                                        
  310.                 ulMVRow = 0;
  311.  
  312.                 // determine number of cValues
  313.                 lpszToken   = strtok(szData,szMVSeps);
  314.                 ulMVcValues = strtoul(lpszToken,&szEnd,16);        
  315.  
  316.                 // rip out first row of multi value prop
  317.                 lpszToken = strtok(NULL,szMVSeps);
  318.                                 
  319.                 // rip out remaining rows                
  320.                 while( lpszToken != NULL )
  321.                 {
  322.                     lstrcpy(szMV,szBuffer);
  323.                     wsprintf(szTemp,"[%lu] ",ulMVRow);
  324.                     lstrcat(szMV,szTemp);
  325.                     lstrcat(szMV,lpszToken);
  326.                 
  327.                     dwReturn = SendDlgItemMessage(IDC_PROPS,LB_ADDSTRING,0,
  328.                             (LPARAM)szMV);
  329.                 
  330.                     lpszToken = strtok(NULL,szMVSeps);
  331.                     ulMVRow++;
  332.                 }                
  333.                 
  334.                 // if all the data was not there, fill in the remainder with bogus stub
  335.                 while( ulMVRow < ulMVcValues )
  336.                 {
  337.                     lstrcpy(szMV,szBuffer);
  338.                     wsprintf(szTemp,"[%lu] ",ulMVRow);
  339.                     lstrcat(szMV,szTemp);
  340.                     lstrcat(szMV,"<No Data Available>");
  341.                 
  342.                     dwReturn = SendDlgItemMessage(IDC_PROPS,LB_ADDSTRING,0,
  343.                             (LPARAM)szMV);
  344.                     ulMVRow++;                            
  345.                 }
  346.             }
  347.             else            
  348.             {
  349.                 lstrcat(szBuffer,szData);
  350.                 dwReturn = SendDlgItemMessage(IDC_PROPS,LB_ADDSTRING,0,
  351.                             (LPARAM)szBuffer);
  352.             }
  353.         }
  354.         else
  355.             dwReturn = SendDlgItemMessage(IDC_PROPS,LB_ADDSTRING,0,
  356.                             (LPARAM)szBuffer);
  357.     
  358.     }  // end of for loop of ulValues in lpPropValue
  359.  
  360.     dwReturn = SendDlgItemMessage(IDC_PROPS,LB_SETCURSEL,(WPARAM) -1 ,0 );
  361.  
  362.     
  363.     if(lpPropValue)
  364.     {
  365.         MAPIFreeBuffer(lpPropValue);
  366.         wsprintf(m_szLogBuf,"MAPIFreeBuffer(%s)", "lpPropValue from GetProps" );
  367.     }
  368. }
  369.  
  370.  
  371.  
  372.