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

  1. /*******************************************************************/
  2. /*
  3.  -  NamesIDs.cpp
  4.  -  Copyright (C) 1995 Microsoft Corporation
  5.  -
  6.  *  Purpose:
  7.  *      Contains member functions for CNamesIDsDlg
  8.  */
  9. /*******************************************************************/
  10.                                                    
  11. #undef  CINTERFACE      // C++ calling convention for mapi calls
  12.  
  13. #ifdef WIN32
  14. #ifdef _WIN95
  15. #define _INC_OLE
  16. #endif
  17. #define INC_OLE2
  18. #define INC_RPC
  19. #endif
  20.  
  21. #include <afxwin.h>     
  22. #include <windowsx.h>
  23. #include <string.h>
  24.  
  25. #ifdef WIN16
  26. #include <compobj.h>
  27. #endif
  28.  
  29. #ifdef WIN32
  30. #include <objbase.h>
  31. #include <objerror.h>
  32. #ifdef _WIN95
  33. #include <ole2.h>
  34. #endif
  35. #endif
  36.  
  37.  
  38. #ifdef WIN16
  39. #include <mapiwin.h>    
  40. #endif
  41. #include <mapix.h>      
  42. #include <strtbl.h>     
  43. #include <misctool.h>
  44. #include "resource.h"   
  45. #include "propvu.h"  
  46. #include "namesids.h"
  47.  
  48.  
  49. /*******************************************************************/
  50. /**************************** GETPROPID **************************/
  51.  
  52. /********************************************************************/
  53. /*
  54.  -  CNamesIDsDlg::
  55.  -  OnInitDialog
  56.  -
  57.  *  Purpose:
  58.  *
  59.  */
  60. /********************************************************************/
  61.  
  62. BOOL CNamesIDsDlg::OnInitDialog()
  63. {
  64.     HRESULT         hResult         = hrSuccess;
  65.     CGetError       E;
  66.     int             rgTabStops[6];
  67.     DWORD           dwReturn        = 0;      
  68.     char            szBuffer[80];
  69.     
  70.         
  71.     SendDlgItemMessage(IDC_NAMEID_DISPLAY,LB_RESETCONTENT,0,0);
  72.  
  73.     if( !m_lpPTA)
  74.     {
  75.         MessageBox( "CNamesIDsDlg::OnInitDialog  lpPTA == NULL",
  76.                     "Client", MBS_ERROR );
  77.         goto error;
  78.     }           
  79.  
  80.     if(m_lpPTA->cValues != m_ulPropNames)
  81.     {
  82.  
  83.         wsprintf(szBuffer,"m_lpPTA->cValues == %lu != m_ulPropNames == %lu",
  84.                 m_lpPTA->cValues,m_ulPropNames);
  85.         MessageBox( "CNamesIDsDlg::OnInitDialog  m_lpPTA->cValues != m_ulPropNames",
  86.               "Client", MBS_ERROR );
  87.         MessageBox( szBuffer,"Client", MBS_ERROR );
  88.     }
  89.  
  90.     // load properties into listbox
  91.     dwReturn = SendDlgItemMessage(IDC_NAMEID_DISPLAY, LB_SETHORIZONTALEXTENT,
  92.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  93.  
  94.     rgTabStops[0] = 32;
  95.     rgTabStops[1] = 180;
  96.  
  97.     dwReturn = SendDlgItemMessage(IDC_NAMEID_DISPLAY,LB_SETTABSTOPS,
  98.                     (WPARAM) 2,(LPARAM)rgTabStops );
  99.  
  100.     DisplayNamesIDs();
  101.  
  102.     return TRUE;    
  103.  
  104. error:
  105.  
  106.     return FALSE;
  107. }
  108.  
  109. /*******************************************************************/
  110. /*
  111.  -  CBldPropDlg::
  112.  -  DisplayPropList
  113.  *
  114.  *  Purpose:
  115.  *
  116.  *  Parameters:
  117.  *
  118.  *  Returns:
  119.  *
  120.  */
  121. /*******************************************************************/
  122.  
  123. void CNamesIDsDlg::DisplayNamesIDs()
  124. {
  125.     char            szTemp[200];
  126.     char            szTemp1[400];
  127.     char            szBuffer[2048];
  128.     int             idx             = 0;
  129.     DWORD           dwReturn        = 0;      
  130.     char            szID[50];
  131.     DWORD           dwRet               = 0;
  132. #ifdef WIN16
  133.     WCHAR *pwsz;
  134.     ULONG   cch;
  135. #endif
  136.  
  137.         
  138.     szBuffer[0] = '\0' ;
  139.     SendDlgItemMessage( IDC_NAMEID_DISPLAY,LB_RESETCONTENT,0,0);    
  140.            
  141.     for(idx = 0; idx < m_lpPTA->cValues; idx++)
  142.     {   
  143.         szID[0]     = '\0' ;
  144.         szBuffer[0] = '\0' ;
  145.         szTemp[0]   = '\0' ;
  146.         
  147.         // PROPID
  148.         wsprintf(szBuffer,"%#04X\t", PROP_ID(m_lpPTA->aulPropTag[idx]) );       
  149.  
  150.         SzIIDToString(szTemp, (*m_lppMAPINameID[idx]).lpguid);
  151.  
  152.         lstrcat(szBuffer,szTemp);
  153.         lstrcat(szBuffer,"\t");
  154.         
  155.         // Mapped Name
  156.         if( !m_lppMAPINameID[idx] )
  157.             continue;
  158.         
  159.         switch( (*m_lppMAPINameID[idx]).ulKind )
  160.         {
  161.             case MNID_ID:
  162.             {
  163.                  wsprintf( szTemp1, "(*lppPropNames[%d]).Kind.lID = %ld", idx, (*m_lppMAPINameID[idx]).Kind.lID );
  164.                  lstrcat(szBuffer,szTemp1);
  165.             }
  166.             break;
  167.             
  168.             case MNID_STRING:
  169.             {
  170. #ifdef WIN16
  171.                 pwsz = (*m_lppMAPINameID[idx]).Kind.lpwstrName;
  172.     
  173.                 cch = 0;
  174.                 while (*pwsz++ != 0)
  175.                 {
  176.                     szTemp1[cch]=(char)*pwsz;
  177.                     cch += 1;
  178.                 }
  179.                 lstrcat(szBuffer,szTemp1);
  180.             
  181. #else
  182.                 if( (*m_lppMAPINameID[idx]).Kind.lpwstrName )
  183.                 {
  184.                     wsprintf( szTemp1, "(*lppPropNames[%d]).Kind.lpwstrName = %ws", idx, (*m_lppMAPINameID[idx]).Kind.lpwstrName );
  185.                     lstrcat(szBuffer,szTemp1);
  186.                 }
  187.                 else
  188.                 {
  189.                     wsprintf( szTemp1, "(*lppPropNames[%d]) = NULL", idx );
  190.                     lstrcat(szBuffer,szTemp1);
  191.                 }
  192. #endif
  193.             }
  194.             break;
  195.             
  196.             default:
  197.             {
  198.                 wsprintf( szTemp1, "(*lppPropNames[idx]).ulKind = %lu  Invalid ID type in MAPINAMEID", (*m_lppMAPINameID[idx]).ulKind );  
  199.                 lstrcat(szBuffer,szTemp1);
  200.             }
  201.         }
  202.  
  203.         SendDlgItemMessage(IDC_NAMEID_DISPLAY, LB_ADDSTRING, 0, (LPARAM)szBuffer);
  204.     }  
  205.     
  206.     dwReturn = SendDlgItemMessage(IDC_NAMEID_DISPLAY,LB_SETCURSEL,(WPARAM) -1 ,0 );
  207.  
  208. }
  209.  
  210. /*******************************************************************/
  211. /*
  212.  -  CNamesIDsDlg::
  213.  -  ~CNamesIDsDlg
  214.  -
  215.  *  Purpose:
  216.  *      Destructor for class CNamesIDsDlg. Releases and Frees memory
  217.  *      allocated in this class
  218.  *
  219.  */
  220. /*******************************************************************/
  221.  
  222. CNamesIDsDlg::~CNamesIDsDlg()
  223. {
  224.  
  225.  
  226.