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 / tcprops / tcextpg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  1.2 KB  |  53 lines

  1. // TCExtPg.Cpp : Implementation of CTCExtPage
  2. #include "StdAfx.H"
  3. #include "TCExtPg.H"
  4. #include "TCProps.H"
  5.  
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CTCExtPage
  8.  
  9. LRESULT CTCExtPage::OnInitDialog( UINT /* nMessage */, WPARAM /* wParam */,
  10.    LPARAM /* lParam */, BOOL& bHandled )
  11. {
  12.    USES_CONVERSION;
  13.    BSTR bstrName;
  14.    CComQIPtr< ITCExtendedControl, &IID_ITCExtendedControl > pControl;
  15.  
  16.    pControl = m_ppUnk[0];
  17.    _ASSERTE( pControl != NULL );
  18.  
  19.    bstrName = NULL;
  20.    pControl->get_Name( &bstrName );
  21.    SetDlgItemText( IDC_NAME, OLE2CT( bstrName ) );
  22.    SysFreeString( bstrName );
  23.  
  24.    bHandled = TRUE;
  25.  
  26.    return( FALSE );
  27. }
  28.  
  29. STDMETHODIMP CTCExtPage::Apply()
  30. {
  31.    UINT iObject;
  32.    BSTR bstrName;
  33.  
  34.    bstrName = NULL;
  35.    GetDlgItemText( IDC_NAME, bstrName );
  36.  
  37.     ATLTRACE( _T( "CTCExtPage::Apply\n" ) );
  38.     for( iObject = 0; iObject < m_nObjects; iObject++ )
  39.     {
  40.       CComPtr< ITCExtendedControl > pControl;
  41.  
  42.       m_ppUnk[iObject]->QueryInterface( IID_ITCExtendedControl,
  43.         (void**)&pControl );
  44.       pControl->put_Name( bstrName );
  45.       pControl.Release();
  46.    }
  47.    SysFreeString( bstrName );
  48.  
  49.     m_bDirty = FALSE;
  50.  
  51.     return( S_OK );
  52. }
  53.