ActiveXperts
SMS & MMS Toolkit


 Product Overview

 Supported Protocols:
 
 How to use

 Online Samples

 Download (.exe)

 Brochure (.pdf)

 Manual (.htm)

 Release Notes


Support

 Knowledge Base

 Forum

 Contact Support


Purchase

 Licensing

 Pricing

 Order now


Providers

 SMPP Providers

 MMS Providers

 TAP/UCP Providers

 SNPP Providers


Related documents

 Case studies

 SMS Documents

 GSM Network Codes

 TAPI Documents

 About Mobile
 Communications


 AT Commands

 RFC's


  Download ActiveXperts SMS and MMS Toolkit 5.0  (6826 KB - .exe file)
  Download Manual  (623 KB - .htm file)


Using the SMS and MMS Toolkit with Visual C++ 5.x/6.x (MM1 Connection)


The SMS and MMS Toolkit is a software development kit (SDK) to enhance an application or script with SMS, MMS and Pager functionality.
An SMS messages can be sent using a GSM/GPRS modem, an SMPP provider, an HTTP compliant SMS provider or using a standard dialup or fixed-line SMS modem.
An MMS messages can be sent via a GSM/GPRS modem (MM1), an SMTP server (MM4) or an XML/SOAP compliant provider (MM7).

SMS features:
  • Send and receive numeric- and alphanumeric text SMS messages
  • Verify delivery of outgoing SMS messages
  • Support for multimedia SMS messages, including ringtones, pictures and logo's
  • Support for WAP Push, WAP Bookmarks, vCards, voicemail/e-mail/fax/MMS indications
  • Support for Unicode, to support foreign languages like Chinese, Turkisch, etc.
  • Support for multi-part messages, to allow messages longer than 160 characters
  • Support for GSM modems, GSM phones, SMS/HTTP providers, SMPP (Short Message Peer to Peer) providers, TAP/XIO and UCP dial-in SMSC providers
  • Support Multi-threading environments. The component is thread-safe, which means it can be used in a multi-threaded environment
  • Samples included for various development platforms: MS Visual Basic, MS Visual Basic .NET, MS Visual C++, MS Visual Studio C# .NET, ASP, ASP .NET, Borland Delphi, Borland C++ Builder, ColdFusion and more
MMS features:
  • Support for many multimedia formats incl.: JPG, GIF, PNG, BMP, WBMP, TIF, WAV, MP3, MIDI, AC3, GP3, AVI, MPG, MP4, VCARD, VCALENDAR, JAR and more
  • Support for MM1 (MMS over WAP), MM4 (MMS over SMTP) and MM7 (MMS over HTML/SOAP)
Pager features:
  • Send alpha-numeric Pager messages through SNPP

This document describes how the SMS and MMS Toolkit can be integrated into Visual C++ projects.


Step 1: Download and install the SMS and MMS Toolkit

Download the SMS and MMS Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.



Step 2: Create a new Visual C++ project

Launch 'Microsoft Visual C++' from the Start menu, and choose 'New' from the 'File Menu'. The 'New' dialog appears.
Select the type of project (for instance: 'Win32 Console Application'), enter a 'Project name' and select the 'Location':

    
    (Click on the picture to enlarge)

Select the kind of project, for instance a 'Hello, world!' application and click 'Finish':

    
    (Click on the picture to enlarge)

A new Project is created now.



Step 3: Refer to the SMS and MMS Toolkit Library

Before you can use the SMS and MMS Toolkit, you need to refer to the SMS and MMS Toolkit library. The actually reference files are shipped with the product and are located in the following directory:
    
    C:\Program Files\ActiveXperts\xmstoolkit\Examples\Visual C++\Include
Copy all files in the above directory ('AXmsCtrl.h', 'AXmsCtrl_i.c' and 'AXmsConstants.h') to your project directory.



Step 4: Declare and create the SMS and MMS Toolkit objects

On top of your code, declare the following objects:
    IMmsProtocolMm1  *m_pConnection    = NULL;
    IMmsMessage      *m_pMessage       = NULL;
    IMmsSlide        *m_pSlide         = NULL;

Since the SMS and MMS Toolkit is a COM object, you must initialize the COM library before they can call COM library functions (e.g. SMS and MMS Toolkit functions):
   CoInitialize(NULL);
Create the GSM objects in the following way:
   CoCreateInstance ( CLSID_MmsProtocolMm1, NULL, CLSCTX_INPROC_SERVER, IID_IMmsProtocolMm1, (void**) &m_pConnection );
   CoCreateInstance ( CLSID_MmsMessage,     NULL, CLSCTX_INPROC_SERVER, IID_IMmsMessage,     (void**) &m_pMessage );
   CoCreateInstance ( CLSID_MmsSlide,       NULL, CLSCTX_INPROC_SERVER, IID_IMmsSlide,       (void**) &m_pSlide );



Step 5: Send MMS messages

You can now send MMS messages using a connected GSM GPRS/EDGE/UMTS modem.

The following code shows how to send a MMS using C++ :
#include "stdafx.h"
#include "Demo.h"
#include "DemoDlg.h"

#include <comdef.h>

/////////////////////////////////////////////////////////////////////////////

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////

#include "..\include\AXmsCtrl_i.c"
#include "HyperLink.h"

/////////////////////////////////////////////////////////////////////////////

#include "DialogLicensing.h"
#include "DialogRegister.h"
#include "DialogPincode.h"
#include "DialogText.h"

/////////////////////////////////////////////////////////////////////////////

CDemoDlg::CDemoDlg(CWnd* pParent /*=NULL*/)	: CDialog(CDemoDlg::IDD, pParent)
{
  //{{AFX_DATA_INIT(CDemoDlg)
  m_strAPN      = _T("MMS");
  m_strFrom     = _T("");
  m_strGateway  = _T("10.250.255.183");
  m_strLogfile  = _T("");
  m_strLogin    = _T("");
  m_strPassword = _T("");
  m_strResult   = _T("N/A");
  m_strSubject  = _T("MMS Message");
  m_strTo       = _T("+31647134225");
  m_strResponse = _T("N/A");
  //}}AFX_DATA_INIT

  m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

  m_pConnection = NULL;
  m_pMessage    = NULL;

  HRESULT hr = S_OK;

  CoInitialize ( NULL );

  hr = CoCreateInstance(CLSID_MmsProtocolMm1, NULL, CLSCTX_INPROC_SERVER, IID_IMmsProtocolMm1, (void**) &m_pConnection );
	
  if( ! SUCCEEDED( hr ) )
  {
    m_pConnection = NULL;	
    return;
  }

  hr = CoCreateInstance(CLSID_MmsMessage, NULL, CLSCTX_INPROC_SERVER, IID_IMmsMessage, (void**) &m_pMessage );
	
  if( ! SUCCEEDED( hr ) )
  {
    m_pMessage = NULL;	
    return;
  }

  hr = CoCreateInstance(CLSID_MmsSlide, NULL, CLSCTX_INPROC_SERVER, IID_IMmsSlide, (void**) &m_pSlide );
	
  if( ! SUCCEEDED( hr ) )
  {
    m_pSlide = NULL;	
    return;
  }

  LoadSettings ();
}

/////////////////////////////////////////////////////////////////////////////

CDemoDlg::~CDemoDlg ()
{
  SaveSettings ();
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::DoDataExchange(CDataExchange* pDX)
{
  CDialog::DoDataExchange(pDX);
  //{{AFX_DATA_MAP(CDemoDlg)
  DDX_Control(pDX, IDC_TREE, m_Tree);
  DDX_Control(pDX, IDC_STATIC_LINK, m_linkMMSC);
  DDX_Control(pDX, IDC_COMBO_DEVICE, m_comboDevice);
  DDX_Text(pDX, IDC_EDIT_APN, m_strAPN);
  DDX_Text(pDX, IDC_EDIT_FROM, m_strFrom);
  DDX_Text(pDX, IDC_EDIT_GATEWAY, m_strGateway);
  DDX_Text(pDX, IDC_EDIT_LOGFILE, m_strLogfile);
  DDX_Text(pDX, IDC_EDIT_LOGIN, m_strLogin);
  DDX_Text(pDX, IDC_EDIT_PASSWORD, m_strPassword);
  DDX_Text(pDX, IDC_EDIT_RESULT, m_strResult);
  DDX_Text(pDX, IDC_EDIT_SERVER, m_strServer);
  DDX_Text(pDX, IDC_EDIT_SUBJECT, m_strSubject);
  DDX_Text(pDX, IDC_EDIT_TO, m_strTo);
  DDX_Text(pDX, IDC_STATIC_RESPONSE, m_strResponse);
  //}}AFX_DATA_MAP
}

/////////////////////////////////////////////////////////////////////////////

BEGIN_MESSAGE_MAP(CDemoDlg, CDialog)
  //{{AFX_MSG_MAP(CDemoDlg)
  ON_WM_PAINT()
  ON_WM_QUERYDRAGICON()
  ON_BN_CLICKED(IDC_BUTTON_VIEW, OnButtonView)
  ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
  ON_BN_CLICKED(IDC_BUTTON_SEND, OnButtonSend)
  ON_BN_CLICKED(IDC_BUTTON_LOADCFG, OnButtonLoadcfg)
  ON_BN_CLICKED(IDC_BUTTON_SAVECFG, OnButtonSavecfg)
  ON_BN_CLICKED(IDC_BUTTON_LICENSING, OnButtonLicensing)
  ON_BN_CLICKED(IDC_BUTTON_PINCODE, OnButtonPincode)
  ON_BN_CLICKED(IDC_BUTTON_SLIDE, OnButtonSlide)
  ON_NOTIFY(TVN_SELCHANGED, IDC_TREE, OnSelchangedTree)
  ON_BN_CLICKED(IDC_BUTTON_TEXT, OnButtonText)
  ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
  //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

BOOL CDemoDlg::OnInitDialog()
{
  CDialog::OnInitDialog();

  LONG	lDeviceCount    = 0L;
  BSTR	bstrDevice      = NULL;
  TCHAR	szTempPath      [ MAX_PATH + 1 ];

  m_pConnection->GetDeviceCount ( &lDeviceCount );

  for ( long l = 0; l < lDeviceCount; l++ )
  {
    m_pConnection->GetDevice ( l, &bstrDevice );

    m_comboDevice.AddString ( (LPCWSTR) bstrDevice );
  }

  SetIcon(m_hIcon, TRUE);   // Set big icon
  SetIcon(m_hIcon, FALSE);  // Set small icon
	
  m_comboDevice.SetCurSel ( 0 );
	
  GetTempPath( MAX_PATH - 14, szTempPath );
  if( szTempPath[ 0 ] == '\0' || szTempPath[ lstrlen( szTempPath ) - 1 ] != '\\' )
    _tcscat( szTempPath, _T("\\") );
    m_strLogfile  = szTempPath;
    m_strLogfile += "MmsLog.txt";

  m_linkMMSC.SetURL			( "http://www.activexperts.com/xmstoolkit/MMSClist" );

  m_ImageList.Create ( 16, 16, ILC_MASK , 4, 4 );

  m_ImageList.Add ( AfxGetApp ()->LoadIcon ( IDI_ICON_IMAGE   ) );
  m_ImageList.Add ( AfxGetApp ()->LoadIcon ( IDI_ICON_TEXT    ) );
  m_ImageList.Add ( AfxGetApp ()->LoadIcon ( IDI_ICON_SLIDE   ) );

  m_Tree.SetImageList ( &m_ImageList, LVSIL_NORMAL );

  m_Tree.EnsureVisible ( m_Tree.InsertItem ( TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE, L"Slide", 2, 2, 0, 0, 0 ,NULL, NULL ) );
  m_Tree.EnsureVisible ( m_Tree.InsertItem ( TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE, L"Hello World!!!", 1, 1, 0, 0, 1 ,
                        m_Tree.GetFirstVisibleItem (), NULL ) );

  UpdateData ( FALSE );
	
  return TRUE;
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnPaint() 
{
  if (IsIconic())
  {
    CPaintDC dc(this); // device context for painting

    SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

    // Center icon in client rectangle
    int cxIcon = GetSystemMetrics(SM_CXICON);
    int cyIcon = GetSystemMetrics(SM_CYICON);
    CRect rect;
    GetClientRect(&rect);
    int x = (rect.Width() - cxIcon + 1) / 2;
    int y = (rect.Height() - cyIcon + 1) / 2;

    // Draw the icon
    dc.DrawIcon(x, y, m_hIcon);
  }
  else
  {
    CDialog::OnPaint();
  }
}

/////////////////////////////////////////////////////////////////////////////

HCURSOR CDemoDlg::OnQueryDragIcon()
{
  return (HCURSOR) m_hIcon;
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnButtonView() 
{
  UpdateData();
	
  if (!m_strLogfile.GetLength()) return;

  if (ShellExecute(NULL,_T("open"),m_strLogfile,NULL,NULL,SW_SHOWDEFAULT ) == INVALID_HANDLE_VALUE) 
  {
    AfxMessageBox (_T("Can't run viewer"),MB_OK);
  }	
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnButtonLoadcfg() 
{
  BSTR	bstrTemp = NULL;

  UpdateData ();

  CString		strDirectory	= "";

  GetConfigDirectory ( strDirectory );

  strDirectory += L"\\Providers\\Mms\\Mm1";

  CFileDialog cfd ( TRUE, L"MM1", NULL, 0,  L"MM1 Connection Files (*.MM1)|*.MM1||\0\0");

  cfd.m_ofn.lpstrInitialDir = strDirectory;

  if ( cfd.DoModal () == IDOK )
  {
    bstrTemp = m_strLogfile.AllocSysString ();
    m_pConnection->put_LogFile ( bstrTemp );
    SysFreeString ( bstrTemp );

    bstrTemp = cfd.GetPathName ().AllocSysString ();
    m_pConnection->ProviderProviderLoadConfig ( bstrTemp );
    SysFreeString ( bstrTemp );

    if ( GetResult () == 0L )
    {
      m_pConnection->get_ProviderAPN ( &bstrTemp );
      m_strAPN = bstrTemp;
      SysFreeString ( bstrTemp );

      m_pConnection->get_ProviderAPNAccount ( &bstrTemp );
      m_strLogin = bstrTemp;
      SysFreeString ( bstrTemp );

      m_pConnection->get_ProviderAPNPassword ( &bstrTemp );
      m_strPassword = bstrTemp;
      SysFreeString ( bstrTemp );

      m_pConnection->get_ProviderWAPGateway ( &bstrTemp );
      m_strGateway =  bstrTemp;
      SysFreeString ( bstrTemp );

      m_pConnection->get_ProviderMMSC ( &bstrTemp );
      m_strServer = bstrTemp;
      SysFreeString ( bstrTemp );

      UpdateData ( FALSE );
    }
  }
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnButtonSavecfg() 
{
  UpdateData ();

  BSTR bstrTemp = NULL;

  CString   strDirectory	= "";

  GetConfigDirectory ( strDirectory );

  strDirectory += L"\\Providers\\Mms\\Mm1";

  CFileDialog cfd  ( FALSE, L"MM1", 0, NULL, L"MM1 Connection Files (*.MM1)|*.MM1||\0\0");

  if ( cfd.DoModal () == IDOK )
  {
    bstrTemp = m_strAPN.AllocSysString ();
    m_pConnection->put_ProviderAPN ( bstrTemp );
    SysFreeString ( bstrTemp );

    bstrTemp = m_strGateway.AllocSysString ();
    m_pConnection->put_ProviderWAPGateway ( bstrTemp );
    SysFreeString ( bstrTemp );

    bstrTemp = m_strServer.AllocSysString ();
    m_pConnection->put_ProviderMMSC ( bstrTemp );
    SysFreeString ( bstrTemp );

    bstrTemp = m_strLogin.AllocSysString ();
    m_pConnection->put_ProviderAPNAccount ( bstrTemp );
    SysFreeString ( bstrTemp );

    bstrTemp = m_strPassword.AllocSysString ();
    m_pConnection->put_ProviderAPNPassword ( bstrTemp );
    SysFreeString ( bstrTemp );
		
    bstrTemp = m_strLogfile.AllocSysString ();
    m_pConnection->put_LogFile ( bstrTemp );
    SysFreeString ( bstrTemp );

    bstrTemp = cfd.GetPathName ().AllocSysString ();
    m_pConnection->ProviderSaveConfig ( bstrTemp );
    SysFreeString ( bstrTemp );

    GetResult ();
  }
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnButtonSend() 
{
  UpdateData ();

  WCHAR         wszTemp  [ 2048 ];
  BSTR          bstrTemp = NULL;

  // Set Device
  m_comboDevice.GetWindowText ( wszTemp, 2048 );
  m_pConnection->put_Device ( wszTemp );

  m_pMessage->Clear ();

  bstrTemp = m_strTo.AllocSysString ();
  m_pMessage->AddRecipient ( bstrTemp );
  SysFreeString ( bstrTemp );

  bstrTemp = m_strFrom.AllocSysString ();
  m_pMessage->put_From ( bstrTemp );
  SysFreeString ( bstrTemp );
	
  bstrTemp = m_strSubject.AllocSysString ();
  m_pMessage->put_Subject ( bstrTemp );
  SysFreeString ( bstrTemp );

  HTREEITEM hItem = m_Tree.GetRootItem ();

  while (hItem != NULL)
  {
    HTREEITEM hItemItem = m_Tree.GetChildItem ( hItem );

    m_pSlide->Clear	();

    while ( hItemItem )
    {
      if ( m_Tree.GetItemData ( hItemItem ) == 0 )
      {
        bstrTemp = m_Tree.GetItemText ( hItemItem ).AllocSysString ();
        m_pSlide->AddAttachment ( bstrTemp );
        SysFreeString ( bstrTemp );
      }
      else
      {
        bstrTemp = m_Tree.GetItemText ( hItemItem ).AllocSysString ();
        m_pSlide->AddText ( bstrTemp );
        SysFreeString ( bstrTemp );
      }

      hItemItem = m_Tree.GetNextItem (hItemItem, TVGN_NEXT );
    }

    m_pMessage->AddSlide ( &_variant_t ( ( IDispatch*) m_pSlide ) );

    hItem = m_Tree.GetNextSiblingItem(hItem);
  }

  // Set MMS Server Parameters

  bstrTemp = m_strAPN.AllocSysString ();
  m_pConnection->put_ProviderAPN ( bstrTemp );
  SysFreeString ( bstrTemp );

  bstrTemp = m_strGateway.AllocSysString ();
  m_pConnection->put_ProviderWAPGateway ( bstrTemp );
  SysFreeString ( bstrTemp );

  bstrTemp = m_strServer.AllocSysString ();
  m_pConnection->put_ProviderMMSC ( bstrTemp );
  SysFreeString ( bstrTemp );

  bstrTemp = m_strLogin.AllocSysString ();
  m_pConnection->put_ProviderAPNAccount ( bstrTemp );
  SysFreeString ( bstrTemp );

  bstrTemp = m_strPassword.AllocSysString ();
  m_pConnection->put_ProviderAPNPassword ( bstrTemp );
  SysFreeString ( bstrTemp );

  bstrTemp = m_strLogfile.AllocSysString ();
  m_pConnection->put_LogFile ( bstrTemp );
  SysFreeString ( bstrTemp );

  AfxGetApp()->DoWaitCursor ( 1 );

  SaveSettings ();

  // Send The Message
  m_pConnection->Connect ();

  if ( GetResult () == 0L )
  {
    m_pConnection->Send ( &_variant_t ( ( IDispatch*) m_pMessage ) );

    GetResult ();

    m_pConnection->Disconnect ();
  }

  AfxGetApp()->DoWaitCursor ( 0 );
}

/////////////////////////////////////////////////////////////////////////////

LONG CDemoDlg::GetResult()
{
  LONG lLastError			= 0L;

  BSTR bstrResult			= NULL;
  BSTR bstrResponse		= NULL;

  m_pConnection->get_LastError		( &lLastError );
  m_pConnection->get_ProviderResponse	( &bstrResponse );

  if ( lLastError )
  {	
    m_pConnection->GetErrorDescription ( lLastError, &bstrResult );
		
    m_strResult.Format ( L"ERROR %ld (%ls)", lLastError, bstrResult );
  }
  else
  {
    m_strResult = _T ( "SUCCESS" );
  }

  m_strResponse = bstrResponse;
		
  UpdateData (false);

  if ( bstrResult		) ::SysFreeString (bstrResult	);
  if ( bstrResponse	) ::SysFreeString (bstrResponse	);

  return lLastError;
}

/////////////////////////////////////////////////////////////////////////////

VOID CDemoDlg::SaveSettings()
{
  AfxGetApp ()->WriteProfileString	( _T ( "MMS" ), _T ("APN" ),      m_strAPN      );
  AfxGetApp ()->WriteProfileString	( _T ( "MMS" ), _T ("Login" ),    m_strLogin    );
  AfxGetApp ()->WriteProfileString	( _T ( "MMS" ), _T ("Password" ), m_strPassword );
  AfxGetApp ()->WriteProfileString	( _T ( "MMS" ), _T ("Gateway" ),  m_strGateway  );
  AfxGetApp ()->WriteProfileString	( _T ( "MMS" ), _T ("Server" ),   m_strServer   );
}

/////////////////////////////////////////////////////////////////////////////

VOID CDemoDlg::LoadSettings()
{
  m_strAPN       = AfxGetApp ()->GetProfileString	( _T ( "MMS" ), _T ( "APN"      ), _T ( "MMS" ) );
  m_strLogin     = AfxGetApp ()->GetProfileString	( _T ( "MMS" ), _T ( "Login"    ), _T ( "" ) );
  m_strPassword  = AfxGetApp ()->GetProfileString	( _T ( "MMS" ), _T ( "Password" ), _T ( "" ) );	
  m_strGateway   = AfxGetApp ()->GetProfileString	( _T ( "MMS" ), _T ( "Gateway"  ), _T ( "10.250.255.183" ) );
  m_strServer    = AfxGetApp ()->GetProfileString	( _T ( "MMS" ), _T ( "Server"   ), _T ( "http://mms.orange.nl:8002/" ) );
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnButtonLicensing() 
{
  CDialogLicensing Dialog;
  Dialog.DoModal ();
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnButtonPincode() 
{
  WCHAR	wszTemp [ 2048 ];

  BSTR bstrPinCode  = NULL;
  BSTR bstrTemp     = NULL;

  UpdateData ( TRUE );

  if ( m_pConnection == NULL )
  {
    m_strResult = "Failed to load AXmsCtrl.dll";

    UpdateData ( FALSE );

    return;
  }

  CDialogPincode Dlg;

  if ( Dlg.DoModal () == IDOK )
  {
    if (Dlg.m_strPinCode.GetLength () )
    {
      bstrPinCode	 = Dlg.m_strPinCode.AllocSysString ();

      m_comboDevice.GetWindowText ( wszTemp, 2048 );
		
      // Set Device
      m_pConnection->put_Device ( wszTemp );

      // Set LogFile
      bstrTemp = m_strLogfile.AllocSysString ();
      m_pConnection->put_LogFile ( bstrTemp );
      ::SysFreeString ( bstrTemp );

      AfxGetApp()->DoWaitCursor ( 1 );

      m_pConnection->EnterPin ( bstrPinCode );

      AfxGetApp()->DoWaitCursor ( 0 );

      GetResult ();

      SysFreeString ( bstrPinCode );
    }
  }
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnButtonSlide() 
{
  HTREEITEM hTreeItem = m_Tree.InsertItem ( TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE, L"Slide"
                                            , 2, 2, 0, 0, 0 ,NULL, NULL );

  if ( hTreeItem )
  {
    m_Tree.EnsureVisible ( hTreeItem );
    m_Tree.SelectItem    ( hTreeItem );
  }
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnButtonText() 
{
  DialogText Dialog;

  if ( Dialog.DoModal () == IDOK )
  {
    m_Tree.EnsureVisible ( m_Tree.InsertItem ( TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE
	                       , Dialog.m_strText, 1, 1, 0, 0, 1 ,m_Tree.GetSelectedItem (), NULL ) );
  }
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnButtonBrowse() 
{
  UpdateData ();

  CFileDialog cfd ( TRUE, NULL, 0, NULL,  L"All Files (*.*)|*.*||\0\0");

  if ( cfd.DoModal () == IDOK )
  {
    CString strImage = cfd.GetPathName ();
	
    m_Tree.EnsureVisible ( m_Tree.InsertItem ( TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE, strImage
	                       , 0, 0, 0, 0, 0 ,m_Tree.GetSelectedItem (), NULL ) );
	
    UpdateData ( FALSE );
  }	
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnButtonDelete() 
{
  m_Tree.DeleteItem ( m_Tree.GetSelectedItem () );	

  if ( m_Tree.GetCount () == 0 )
  {
    GetDlgItem ( IDC_BUTTON_BROWSE )->EnableWindow ( FALSE );
    GetDlgItem ( IDC_BUTTON_TEXT   )->EnableWindow ( FALSE );
    GetDlgItem ( IDC_BUTTON_DELETE )->EnableWindow ( FALSE );
  }
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult) 
{
  NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
	
  GetDlgItem ( IDC_BUTTON_BROWSE )->EnableWindow ( FALSE );
  GetDlgItem ( IDC_BUTTON_TEXT   )->EnableWindow ( FALSE );
  GetDlgItem ( IDC_BUTTON_DELETE )->EnableWindow ( FALSE );

 if ( pNMTreeView->itemNew.hItem )
 {
    CString strLabel = m_Tree.GetItemText ( pNMTreeView->itemNew.hItem );

    if ( strLabel.Find ( L"Slide" ) == 0 )
    {
      GetDlgItem ( IDC_BUTTON_BROWSE )->EnableWindow ( TRUE );
      GetDlgItem ( IDC_BUTTON_TEXT   )->EnableWindow ( TRUE );
      GetDlgItem ( IDC_BUTTON_DELETE )->EnableWindow ( TRUE );
    }
  }

  *pResult = 0;
}

/////////////////////////////////////////////////////////////////////////////

void CDemoDlg::GetConfigDirectory(CString & strDirectory)
{
  HKEY   hKey;
  DWORD  dwSize   = MAX_PATH;
  CHAR   lpszData [ MAX_PATH + 1 ];
  DWORD  dwType;

  if ( RegOpenKeyExA ( HKEY_LOCAL_MACHINE, "Software\\ActiveXperts\\SMS and MMS Toolkit", 0, KEY_READ, &hKey ) != ERROR_SUCCESS )
  {
    return;
  }
	 
  RegQueryValueExA ( hKey, "InstallRoot", NULL, &dwType, ( unsigned char * ) lpszData, &dwSize );

  strDirectory = lpszData;

  RegCloseKey( hKey );
}

/////////////////////////////////////////////////////////////////////////////
There are many working samples included with the product.
You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/XmsToolkit.





The ActiveXperts SMS and MMS Toolkit is a SMS development component (SDK). This control can be used by any Windows development platform, including Visual Basic .NET, Visual CSharp .NET, ASP .NET (VB,CS), ASP, Visual Basic, Visual Basic for Applications (VBA), Visual Studio/Visual C++, Borland Delphi and C++ Builder, PHP, ColdFusion, HTML, VBScript and any other ActiveX/COM compliant platform. The SMS and MMS Toolkit is an ActiveXperts Software B.V. Product.

Copyright ©1999-2007 ActiveXperts Software. All rights reserved.