home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / tstcon / methoddg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  16.8 KB  |  607 lines

  1. // CMethodDlg.Cpp : implementation file
  2. //
  3.  
  4. #include "StdAfx.H"
  5. #include "TestCon.H"
  6. #include "Resource.HM"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CMethodDlg dialog
  16.  
  17.  
  18. CMethodDlg::CMethodDlg( CWnd* pParent, IDispatch* pDispatch,
  19.    CInterfaceInfo* pInterfaceInfo ) :
  20.    CDialog( CMethodDlg::IDD, pParent ),
  21.    m_pDispatch( pDispatch ),
  22.    m_pInterfaceInfo( pInterfaceInfo ),
  23.    m_pMethodInfo( NULL ),
  24.    m_pvarParams( NULL ),
  25.    m_piParamTypes( NULL ),
  26.    m_pvarCurrentParam( NULL ),
  27.    m_tException( FALSE )
  28. {
  29.    _ASSERTE( m_pDispatch != NULL );
  30.    _ASSERTE( m_pInterfaceInfo != NULL );
  31.  
  32.    //{{AFX_DATA_INIT(CMethodDlg)
  33.    //}}AFX_DATA_INIT
  34. }
  35.  
  36. CMethodDlg::~CMethodDlg()
  37. {
  38.    delete[] m_pvarParams;
  39.    delete[] m_piParamTypes;
  40. }
  41.  
  42. void CMethodDlg::DoDataExchange(CDataExchange* pDX)
  43. {
  44.     CDialog::DoDataExchange(pDX);
  45.     //{{AFX_DATA_MAP(CMethodDlg)
  46.     DDX_Control(pDX, IDC_STATIC_PARAMETERVALUE, m_staticParameterValue);
  47.     DDX_Control(pDX, IDC_EXCEPTIONDESC, m_editExceptionDesc);
  48.     DDX_Control(pDX, IDC_EXCEPTIONSOURCE, m_editExceptionSource);
  49.     DDX_Control(pDX, IDC_RETURNVALUE, m_editReturnValue);
  50.     DDX_Control(pDX, IDC_PARAMVALUE, m_editParamValue);
  51.     DDX_Control(pDX, IDC_PARAMS, m_listParams);
  52.     DDX_Control(pDX, IDC_PARAMTYPE, m_cboxParamType);
  53.     DDX_Control(pDX, IDC_METHODNAME, m_cboxMethodName);
  54.     //}}AFX_DATA_MAP
  55. }
  56.  
  57.  
  58. BEGIN_MESSAGE_MAP(CMethodDlg, CDialog)
  59.     //{{AFX_MSG_MAP(CMethodDlg)
  60.     ON_CBN_SELCHANGE(IDC_METHODNAME, OnMethodNameSelChange)
  61.     ON_NOTIFY(LVN_ITEMCHANGED, IDC_PARAMS, OnParamsItemChanged)
  62.     ON_BN_CLICKED(IDC_SETVALUE, OnSetValue)
  63.     ON_BN_CLICKED(IDC_INVOKE, OnInvoke)
  64.     ON_EN_SETFOCUS(IDC_PARAMVALUE, OnParamValueSetFocus)
  65.     ON_EN_CHANGE(IDC_PARAMVALUE, OnParamValueChange)
  66.     ON_BN_CLICKED(IDC_EXCEPTIONHELP, OnExceptionHelp)
  67.     ON_CBN_SELCHANGE(IDC_PARAMTYPE, OnParamTypeSelChange)
  68.     ON_BN_CLICKED(IDC_CHOOSECOLOR, OnChooseColor)
  69.     ON_BN_CLICKED(IDC_CHOOSEFONT, OnChooseFont)
  70.     ON_WM_HELPINFO()
  71.     ON_WM_CONTEXTMENU()
  72.     //}}AFX_MSG_MAP
  73. END_MESSAGE_MAP()
  74.  
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CMethodDlg message handlers
  77.  
  78. BOOL CMethodDlg::OnInitDialog()
  79. {
  80.    int iMethod;
  81.    int iType;
  82.    int iItem;
  83.    CMethodInfo* pMethodInfo;
  84.    CString strMethodName;
  85.    CString strColumnName;
  86.  
  87.    CDialog::OnInitDialog();
  88.  
  89.    // Populate the method name combo box with the names of all of the methods
  90.    // on this interface.
  91.    for( iMethod = 0; iMethod < m_pInterfaceInfo->GetNumMethods(); iMethod++ )
  92.    {
  93.       pMethodInfo = m_pInterfaceInfo->GetMethod( iMethod );
  94.  
  95.       // Add on a description of the method type (propget, propput, etc.).
  96.       strMethodName = pMethodInfo->GetName();
  97.       strMethodName += _T( " (" );
  98.       strMethodName += InvokeKindToString( pMethodInfo->GetInvokeKind() );
  99.       strMethodName += _T( ")" );
  100.  
  101.       m_cboxMethodName.AddString( strMethodName );
  102.    }
  103.  
  104.    // Add the appropriate columns to the parameter list control.
  105.    strColumnName.LoadString( IDS_PARAMETER );
  106.    m_listParams.InsertColumn( 0, strColumnName, LVCFMT_LEFT, 125 );
  107.    strColumnName.LoadString( IDS_VALUE );
  108.    m_listParams.InsertColumn( 1, strColumnName, LVCFMT_LEFT, 150 );
  109.    strColumnName.LoadString( IDS_TYPE );
  110.    m_listParams.InsertColumn( 2, strColumnName, LVCFMT_LEFT, 100 );
  111.  
  112.    m_listParams.SetColumnWidth( 2, LVSCW_AUTOSIZE_USEHEADER );
  113.  
  114.    // Add all available VARTYPEs to the parameter type combo box.
  115.    for( iType = 0; iType < NUM_VARTYPES; iType++ )
  116.    {
  117.       iItem = m_cboxParamType.AddString( VTIToString( iType ) );
  118.       m_cboxParamType.SetItemData( iItem, iType );
  119.    }
  120.  
  121.    m_cboxMethodName.SetCurSel( 0 );
  122.    OnMethodNameSelChange();
  123.  
  124.    return( TRUE );
  125. }
  126.  
  127. void CMethodDlg::OnMethodNameSelChange()
  128. {
  129.    int iMethod;
  130.    int iParam;
  131.    CMethodParamInfo* pParamInfo = 0;
  132.    COleVariant* pvarParam = 0;
  133.  
  134.    iMethod = m_cboxMethodName.GetCurSel();
  135.    ASSERT( iMethod != CB_ERR );
  136.    m_pMethodInfo = m_pInterfaceInfo->GetMethod( iMethod );
  137.  
  138.    // Clean up from the old method.
  139.    m_varResult.Clear();
  140.    m_editReturnValue.SetWindowText( _T( "" ) );
  141.    m_editParamValue.SetWindowText( _T( "" ) );
  142.    m_listParams.DeleteAllItems();
  143.    delete[] (COleVariant*)m_pvarParams;
  144.    m_pvarParams = NULL;
  145.    m_pvarCurrentParam = NULL;
  146.    delete[] m_piParamTypes;
  147.    m_piParamTypes = NULL;
  148.    m_excepInfo.Clear();
  149.    m_editExceptionSource.SetWindowText( _T( "" ) );
  150.    m_editExceptionDesc.SetWindowText( _T( "" ) );
  151.    GetDlgItem( IDC_EXCEPTIONHELP )->EnableWindow( FALSE );
  152.  
  153.    // Allocate the parameters for the new method.
  154.    if( m_pMethodInfo->GetNumParams() > 0 )
  155.    {
  156.       m_pvarParams = new COleVariant[m_pMethodInfo->GetNumParams()];
  157.       m_piParamTypes = new int[m_pMethodInfo->GetNumParams()];
  158.    }
  159.  
  160.    // Fill in the info for each parameter.
  161.    for( iParam = 0; iParam < m_pMethodInfo->GetNumParams(); iParam++ )
  162.    {
  163.       pParamInfo = m_pMethodInfo->GetParam( iParam );
  164.       m_listParams.InsertItem( iParam, pParamInfo->GetName() );
  165.       m_listParams.SetItemText( iParam, 0, pParamInfo->GetName() );
  166.       TRY
  167.       {
  168.          pvarParam = GetParam( iParam );
  169.          pvarParam->ChangeType( pParamInfo->GetType() );
  170.       }
  171.       CATCH( COleException, e )
  172.       {
  173.          TRACE( "Warning: ChangeType failed during initialization.\n" );
  174.       }
  175.       END_CATCH
  176.       m_piParamTypes[iParam] = VTToVTI( pvarParam->vt );
  177.  
  178.       DisplayParamValueInList( iParam );
  179.    }
  180.  
  181.    if( m_pMethodInfo->GetNumParams() > 0 )
  182.    {
  183.       // Enable the parameter entry controls.
  184.       m_cboxParamType.EnableWindow( TRUE );
  185.  
  186.       // Select the first parameter.
  187.       m_listParams.SetItemState( 0, LVIS_SELECTED, LVIS_SELECTED );
  188.  
  189.       // Let the user start editing the first parameter's value.
  190.       if( m_editParamValue.IsWindowEnabled() )
  191.       {
  192.          m_editParamValue.SetSel( 0, -1 );
  193.       }
  194.    }
  195.    else
  196.    {
  197.       // OnParamsItemChanged isn't going to update the parameter type combo
  198.       // box, so do it here.
  199.       m_cboxParamType.SetCurSel( -1 );
  200.       OnParamTypeSelChange();
  201.  
  202.       // Disable the parameter entry controls.
  203.       m_cboxParamType.EnableWindow( FALSE );
  204.  
  205.       // Set the Invoke button to be the default.
  206.       SetDefID( IDC_INVOKE );
  207.    }
  208. }
  209.  
  210. void CMethodDlg::OnParamsItemChanged( NMHDR* pNMHDR, LRESULT* pResult )
  211. {
  212.    NM_LISTVIEW* pNMListView;
  213.  
  214.    pNMListView = (NM_LISTVIEW*)pNMHDR;
  215.    *pResult = 0;
  216.  
  217.    if( pNMListView->uChanged&LVIF_STATE )
  218.    {
  219.       if( pNMListView->uNewState&LVIS_SELECTED )
  220.       {
  221.          // Display the info for the new parameter
  222.          m_iCurrentParam = pNMListView->iItem;
  223.          m_pParamInfo = m_pMethodInfo->GetParam( m_iCurrentParam );
  224.          m_pvarCurrentParam = GetParam( m_iCurrentParam );
  225. //         m_cboxParamType.SetCurSel( m_piParamTypes[m_iCurrentParam] );
  226.          m_cboxParamType.SelectString( -1, VTIToString( m_piParamTypes[
  227.             m_iCurrentParam] ) );
  228.          OnParamTypeSelChange();
  229. //         DisplayParamValue( m_iCurrentParam );
  230.       }
  231.    }
  232. }
  233.  
  234. void CMethodDlg::OnSetValue()
  235. {
  236.    int iType;
  237.    int iItem;
  238.    CString strEditText;
  239.    COleVariant varDisplay;
  240.    CString strValue;
  241.  
  242.    m_editParamValue.GetWindowText( strEditText );
  243.  
  244.    *m_pvarCurrentParam = strEditText;
  245.  
  246.    TRY
  247.    {
  248.       iItem = m_cboxParamType.GetCurSel();
  249.       ASSERT( iItem != CB_ERR );
  250.       iType = m_cboxParamType.GetItemData( iItem );
  251.      m_pvarCurrentParam->ChangeType( VTIToVT( iType ) );
  252.       DisplayParamValueInList( m_iCurrentParam );
  253.       m_piParamTypes[m_iCurrentParam] = iType;
  254.       if( m_iCurrentParam == (m_pMethodInfo->GetNumParams()-1) )
  255.       {
  256.          // We just set the last parameter, so set the Invoke button to be the
  257.          // default button.
  258.          SetDefID( IDC_INVOKE );
  259.       }
  260.       else
  261.       {
  262.          // Move on to the next parameter.
  263.          m_listParams.SetItemState( m_iCurrentParam+1, LVIS_SELECTED,
  264.             LVIS_SELECTED );
  265.          SetDefID( IDC_SETVALUE );
  266.          m_editParamValue.SetSel( 0, -1 );
  267.       }
  268.    }
  269.    CATCH( COleException, e )
  270.    {
  271.       TRACE( "ChangeType() failed.\n" );
  272.    }
  273.    END_CATCH
  274. }
  275.  
  276. void CMethodDlg::OnInvoke()
  277. {
  278.    DISPPARAMS dpParams;
  279.    HRESULT hResult;
  280.    UINT iArgErr;
  281.    DISPID dispidArg;
  282.    CString strReturnValue;
  283.  
  284.    if( m_pvarCurrentParam != NULL )
  285.    {
  286.       OnSetValue();
  287.    }
  288.  
  289.    dpParams.rgvarg = m_pvarParams;
  290.    dpParams.cArgs = m_pMethodInfo->GetNumParams();
  291.  
  292.    if( m_pMethodInfo->GetInvokeKind() == DISPATCH_PROPERTYPUT )
  293.    {
  294.       dispidArg = DISPID_PROPERTYPUT;
  295.       dpParams.rgdispidNamedArgs = &dispidArg;
  296.       dpParams.cNamedArgs = 1;
  297.    }
  298.    else
  299.    {
  300.       dpParams.rgdispidNamedArgs = NULL;
  301.       dpParams.cNamedArgs = 0;
  302.    }
  303.  
  304.    m_varResult.Clear();
  305.    m_excepInfo.Clear();
  306.    m_tException = FALSE;
  307.  
  308.    TRY
  309.    {
  310.       hResult = m_pDispatch->Invoke( m_pMethodInfo->GetID(), IID_NULL,
  311.          GetUserDefaultLCID(), WORD( m_pMethodInfo->GetInvokeKind() ),
  312.          &dpParams, &m_varResult, &m_excepInfo, &iArgErr );
  313.       if( FAILED( hResult ) )
  314.       {
  315.  
  316.          TRACE( "Invoke() failed\n" );
  317.        if( hResult == DISP_E_EXCEPTION )
  318.        {
  319.           m_tException = TRUE;
  320.        }
  321.          AfxThrowOleException( hResult );
  322.       }
  323.       strReturnValue = VariantToString( m_varResult );
  324.       strReturnValue += _T( " (" );
  325.       strReturnValue += VTToString( m_varResult.vt );
  326.       strReturnValue += _T( ")" );
  327.       m_editReturnValue.SetWindowText( strReturnValue );
  328.    }
  329.    CATCH( COleException, e )
  330.    {
  331.    }
  332.    END_CATCH
  333.  
  334.    DisplayExceptionInfo();
  335. }
  336.  
  337. void CMethodDlg::OnParamValueSetFocus()
  338. {
  339.    // The ParamValue edit box just got the keyboard focus.  The user should be
  340.    // able to set the value to the contents of the edit box just by hitting
  341.    // ENTER.
  342.    SetDefID( IDC_SETVALUE );
  343. }
  344.  
  345. void CMethodDlg::OnParamValueChange()
  346. {
  347.    // The user is typing in the ParamValue edit box, so set the default button
  348.    // to SetValue.
  349.    SetDefID( IDC_SETVALUE );
  350. }
  351.  
  352. void CMethodDlg::DisplayParamValueInList( int iParam )
  353. {
  354.    COleVariant varDisplay;
  355.    CString strTemp;
  356.    CString strValue;
  357.    COleVariant* pvarParam;
  358.  
  359.    pvarParam = GetParam( iParam );
  360.    if( m_piParamTypes[iParam] == VTI_COLOR )
  361.    {
  362.       ASSERT( pvarParam->vt == VT_I4 );
  363.       strValue.Format( "%#8.8x", pvarParam->lVal );
  364.       m_listParams.SetItemText( iParam, 1, strValue );
  365.    }
  366.    else
  367.    {
  368.       TRY
  369.       {
  370.          varDisplay.ChangeType( VT_BSTR, pvarParam );
  371.          strValue = varDisplay.bstrVal;
  372.          m_listParams.SetItemText( iParam, 1, strValue );
  373.          m_editParamValue.SetWindowText( strValue );
  374.       }
  375.       CATCH( COleException, e )
  376.       {
  377.          TRACE( "ChangeType failed\n" );
  378.          strValue.LoadString( IDS_UNABLETOREPRESENT );
  379.          m_listParams.SetItemText( iParam, 1, strValue );
  380.          m_editParamValue.SetWindowText( _T( "" ) );
  381.       }
  382.       END_CATCH
  383.    }
  384.  
  385.    m_listParams.SetItemText( iParam, 2, VTToString( pvarParam->vt ) );
  386. //   m_cboxParamType.SetCurSel( m_piParamTypes[iParam] );
  387. }
  388.  
  389. COleVariant* CMethodDlg::GetParam( int iParam )
  390. {
  391.    // Dispatch parameters are in reverse order.
  392.    return( &m_pvarParams[(m_pMethodInfo->GetNumParams()-1)-iParam] );
  393. }
  394.  
  395. void CMethodDlg::DisplayExceptionInfo()
  396. {
  397.    USES_CONVERSION;
  398.    CString strSource;
  399.    CString strDesc;
  400.  
  401.    if( m_tException )
  402.    {
  403.       if( m_excepInfo.bstrSource != NULL )
  404.       {
  405.          m_editExceptionSource.SetWindowText( OLE2CT(
  406.            m_excepInfo.bstrSource ) );
  407.       }
  408.       else
  409.       {
  410.         strSource.LoadString( IDS_UNSPECIFIEDSOURCE );
  411.          m_editExceptionSource.SetWindowText( strSource );
  412.       }
  413.  
  414.       if( m_excepInfo.bstrDescription != NULL )
  415.       {
  416.          m_editExceptionDesc.SetWindowText( OLE2CT(
  417.             m_excepInfo.bstrDescription ) );
  418.       }
  419.       else
  420.       {
  421.         strDesc.LoadString( IDS_UNSPECIFIEDEXCEPTION );
  422.          m_editExceptionDesc.SetWindowText( strDesc );
  423.       }
  424.  
  425.       if( m_excepInfo.bstrHelpFile != NULL )
  426.       {
  427.          GetDlgItem( IDC_EXCEPTIONHELP )->EnableWindow( TRUE );
  428.       }
  429.       else
  430.       {
  431.          GetDlgItem( IDC_EXCEPTIONHELP )->EnableWindow( FALSE );
  432.       }
  433.    }
  434.    else
  435.    {
  436.       m_editExceptionSource.SetWindowText( _T( "" ) );
  437.       m_editExceptionDesc.SetWindowText( _T( "" ) );
  438.       GetDlgItem( IDC_EXCEPTIONHELP )->EnableWindow( FALSE );
  439.    }
  440. }
  441.  
  442. void CMethodDlg::OnExceptionHelp()
  443. {
  444.    USES_CONVERSION;
  445.  
  446.    ASSERT( m_excepInfo.bstrHelpFile != NULL );
  447.  
  448.    ::WinHelp( AfxGetMainWnd()->GetSafeHwnd(), OLE2CT(
  449.       m_excepInfo.bstrHelpFile ), HELP_CONTEXT, m_excepInfo.dwHelpContext );
  450. }
  451.  
  452. void CMethodDlg::OnParamTypeSelChange()
  453. {
  454.    int iType;
  455.    int iItem;
  456.  
  457.    iItem = m_cboxParamType.GetCurSel();
  458.    if( iItem == CB_ERR )
  459.    {
  460.       iType = -1;
  461.    }
  462.    else
  463.    {
  464.       iType = m_cboxParamType.GetItemData( iItem );
  465.    }
  466.  
  467.    switch( iType )
  468.    {
  469.    case -1:
  470.       // No type was selected
  471.       GetDlgItem( IDC_CHOOSEFONT )->EnableWindow( FALSE );
  472.       GetDlgItem( IDC_CHOOSEFONT )->ShowWindow( SW_HIDE );
  473.       GetDlgItem( IDC_CHOOSECOLOR )->EnableWindow( FALSE );
  474.       GetDlgItem( IDC_CHOOSECOLOR )->ShowWindow( SW_HIDE );
  475.       GetDlgItem( IDC_SETVALUE )->EnableWindow( FALSE );
  476.       GetDlgItem( IDC_SETVALUE )->ShowWindow( SW_NORMAL );
  477.       m_staticParameterValue.ShowWindow( SW_NORMAL );
  478.       m_editParamValue.EnableWindow( FALSE );
  479.       m_editParamValue.ShowWindow( SW_NORMAL );
  480.       break;
  481.  
  482.    case VTI_COLOR:
  483.       GetDlgItem( IDC_CHOOSEFONT )->EnableWindow( FALSE );
  484.       GetDlgItem( IDC_CHOOSEFONT )->ShowWindow( SW_HIDE );
  485.       GetDlgItem( IDC_SETVALUE )->EnableWindow( FALSE );
  486.       GetDlgItem( IDC_SETVALUE )->ShowWindow( SW_HIDE );
  487.       m_staticParameterValue.ShowWindow( SW_HIDE );
  488.       m_editParamValue.EnableWindow( FALSE );
  489.       m_editParamValue.ShowWindow( SW_HIDE );
  490.       GetDlgItem( IDC_CHOOSECOLOR )->ShowWindow( SW_NORMAL );
  491.       GetDlgItem( IDC_CHOOSECOLOR )->EnableWindow( TRUE );
  492.       break;
  493.  
  494.    case VTI_FONT:
  495.       GetDlgItem( IDC_CHOOSECOLOR )->EnableWindow( FALSE );
  496.       GetDlgItem( IDC_CHOOSECOLOR )->ShowWindow( SW_HIDE );
  497.       GetDlgItem( IDC_SETVALUE )->EnableWindow( FALSE );
  498.       GetDlgItem( IDC_SETVALUE )->ShowWindow( SW_HIDE );
  499.       m_staticParameterValue.ShowWindow( SW_HIDE );
  500.       m_editParamValue.EnableWindow( FALSE );
  501.       m_editParamValue.ShowWindow( SW_HIDE );
  502.       GetDlgItem( IDC_CHOOSEFONT )->ShowWindow( SW_NORMAL );
  503.       GetDlgItem( IDC_CHOOSEFONT )->EnableWindow( TRUE );
  504.       break;
  505.  
  506.    default:
  507.       GetDlgItem( IDC_CHOOSEFONT )->EnableWindow( FALSE );
  508.       GetDlgItem( IDC_CHOOSEFONT )->ShowWindow( SW_HIDE );
  509.       GetDlgItem( IDC_CHOOSECOLOR )->EnableWindow( FALSE );
  510.       GetDlgItem( IDC_CHOOSECOLOR )->ShowWindow( SW_HIDE );
  511.       m_staticParameterValue.ShowWindow( SW_NORMAL );
  512.       m_editParamValue.ShowWindow( SW_SHOWNORMAL );
  513.       m_editParamValue.EnableWindow( TRUE );
  514.       GetDlgItem( IDC_SETVALUE )->ShowWindow( SW_NORMAL );
  515.       GetDlgItem( IDC_SETVALUE )->EnableWindow( TRUE );
  516.       break;
  517.    }
  518. }
  519.  
  520. void CMethodDlg::OnChooseColor()
  521. {
  522.    CColorDialog dlg;
  523.    int nResult;
  524.  
  525.    nResult = dlg.DoModal();
  526.    if( nResult != IDOK )
  527.    {
  528.       return;
  529.    }
  530.  
  531.    *m_pvarCurrentParam = long( dlg.GetColor() );
  532.    m_piParamTypes[m_iCurrentParam] = VTI_COLOR;
  533.    DisplayParamValueInList( m_iCurrentParam );
  534. }
  535.  
  536. void CMethodDlg::OnChooseFont()
  537. {
  538.    USES_CONVERSION;
  539.    CFontDialog dlg;
  540.    int nResult;
  541.    IFontDispPtr pFont;
  542.    FONTDESC desc;
  543.    HRESULT hResult;
  544.  
  545.    nResult = dlg.DoModal();
  546.    if( nResult != IDOK )
  547.    {
  548.       return;
  549.    }
  550.  
  551.    memset( &desc, 0, sizeof( desc ) );
  552.    desc.cbSizeofstruct = sizeof( desc );
  553.    desc.lpstrName = T2OLE( dlg.m_cf.lpLogFont->lfFaceName );
  554.    desc.cySize = COleCurrency( dlg.m_cf.iPointSize/10, 1000*
  555.       (dlg.m_cf.iPointSize%10) );
  556.    desc.sWeight = short( dlg.m_cf.lpLogFont->lfWeight );
  557.    desc.sCharset = dlg.m_cf.lpLogFont->lfCharSet;
  558.    desc.fItalic = dlg.m_cf.lpLogFont->lfItalic;
  559.    desc.fUnderline = dlg.m_cf.lpLogFont->lfUnderline;
  560.    desc.fStrikethrough = dlg.m_cf.lpLogFont->lfStrikeOut;
  561.  
  562.    hResult = OleCreateFontIndirect( &desc, IID_IFontDisp, (void**)&pFont );
  563.    if( FAILED( hResult ) )
  564.    {
  565.       TRACE( "OleCreateFontIndirect() failed\n" );
  566.    }
  567.  
  568.    m_pvarCurrentParam->Clear();
  569.    m_pvarCurrentParam->vt = VT_DISPATCH;
  570.    m_pvarCurrentParam->pdispVal = pFont;
  571.    m_pvarCurrentParam->pdispVal->AddRef();
  572.  
  573.    m_piParamTypes[m_iCurrentParam] = VTI_FONT;
  574.    DisplayParamValueInList( m_iCurrentParam );
  575. }
  576.  
  577. static DWORD rgmapCHID[] =
  578. {
  579.    IDC_METHODNAME, HIDC_METHODNAME,
  580.    IDC_PARAMS, HIDC_PARAMS,
  581.    IDC_INVOKE, HIDC_INVOKE,
  582.    IDC_PARAMVALUE, HIDC_PARAMVALUE,
  583.    IDC_PARAMTYPE, HIDC_PARAMTYPE,
  584.    IDC_SETVALUE, HIDC_SETVALUE,
  585.    IDC_RETURNVALUE, HIDC_RETURNVALUE,
  586.    IDC_EXCEPTIONSOURCE, HIDC_EXCEPTIONSOURCE,
  587.    IDC_EXCEPTIONDESC, HIDC_EXCEPTIONDESC,
  588.    IDC_EXCEPTIONHELP, HIDC_EXCEPTIONHELP,
  589.    IDC_CHOOSECOLOR, HIDC_CHOOSECOLOR,
  590.    IDC_CHOOSEFONT, HIDC_CHOOSEFONT,
  591.    IDC_STATIC_PARAMETERVALUE, DWORD( -1 ),
  592.    0, 0
  593. };
  594.  
  595. BOOL CMethodDlg::OnHelpInfo( HELPINFO* pHelpInfo )
  596. {
  597.    return( ::WinHelp( HWND( pHelpInfo->hItemHandle ),
  598.       AfxGetApp()->m_pszHelpFilePath, HELP_WM_HELP, DWORD( LPVOID(
  599.       rgmapCHID ) ) ) );
  600. }
  601.  
  602. void CMethodDlg::OnContextMenu( CWnd* pWnd, CPoint /* point */ )
  603. {
  604.    ::WinHelp( HWND( *pWnd ), AfxGetApp()->m_pszHelpFilePath, HELP_CONTEXTMENU,
  605.       DWORD( LPVOID( rgmapCHID ) ) );
  606. }
  607.