//$$---- Source du contrôle ActiveX ---- (stActiveXControlSource)
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include <atl\atlvcl.h>

#include "DLPortIOXImpl1.h"
#include "About1.h"
//---------------------------------------------------------------------------
#pragma link "DLPortIOX"
#pragma package(smart_init)
STDMETHODIMP TDLPortIOXXImpl::AboutBox()
{
  try
  {
  ShowDLPortIOCXAbout();
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::CloseDriver()
{
  try
  {
  m_VclCtl->CloseDriver();
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::DrawTextBiDiModeFlagsReadingOnly(long* Value)
{
  try
  {
  *Value = m_VclCtl->DrawTextBiDiModeFlagsReadingOnly();
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::get_ActiveHW(TOLEBOOL* Value)
{
  try
  {
   *Value = m_VclCtl->ActiveHW;
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::get_Cursor(short* Value)
{
  try
  {
   *Value = (short)(m_VclCtl->Cursor);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::get_DLLPath(BSTR* Value)
{
  try
  {
    *Value = WideString(m_VclCtl->DLLPath).Copy();
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::get_DoubleBuffered(TOLEBOOL* Value)
{
  try
  {
   *Value = m_VclCtl->DoubleBuffered;
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::get_DriverPath(BSTR* Value)
{
  try
  {
    *Value = WideString(m_VclCtl->DriverPath).Copy();
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::get_Enabled(TOLEBOOL* Value)
{
  try
  {
   *Value = m_VclCtl->Enabled;
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::get_HardAccess(TOLEBOOL* Value)
{
  try
  {
   *Value = m_VclCtl->HardAccess;
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::get_LastError(BSTR* Value)
{
  try
  {
    *Value = WideString(m_VclCtl->LastError).Copy();
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::get_LPTNumPorts(unsigned_char* Value)
{
  try
  {
   *Value = (unsigned_char)(m_VclCtl->LPTNumPorts);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::get_Visible(TOLEBOOL* Value)
{
  try
  {
   *Value = m_VclCtl->Visible;
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::get_VisibleDockClientCount(long* Value)
{
  try
  {
   *Value = (long)(m_VclCtl->VisibleDockClientCount);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::GetLPTBasePort(short PortNr, long* Value)
{
  try
  {
  *Value = m_VclCtl->GetLPTBasePort(PortNr);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::InitiateAction()
{
  try
  {
  m_VclCtl->InitiateAction();
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::IsRightToLeft(TOLEBOOL* Value)
{
  try
  {
  *Value = m_VclCtl->IsRightToLeft();
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::OpenDriver()
{
  try
  {
  m_VclCtl->OpenDriver();
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::ReadPort(long Address, short* Value)
{
  try
  {
  *Value = m_VclCtl->ReadPort(Address);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::ReadPortFIFO(long PortAddr, long NumPorts,
  long Buffer)
{
  try
  {
  /* m_VclCtl->ReadPortFIFO( [INCOMPAT_TYPE(COMP(65535), TLB(3), Buffer )]);*/
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::set_Cursor(short Value)
{
  try
  {
    const DISPID dispid = 27;
    if (FireOnRequestEdit(dispid) == S_FALSE)
     return S_FALSE;
    m_VclCtl->Cursor = (TCursor)(Value);
    FireOnChanged(dispid);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::set_DLLPath(BSTR Value)
{
  try
  {
    const DISPID dispid = 11;
    if (FireOnRequestEdit(dispid) == S_FALSE)
      return S_FALSE;
    m_VclCtl->DLLPath = AnsiString(Value);
    FireOnChanged(dispid);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::set_DoubleBuffered(TOLEBOOL Value)
{
  try
  {
    const DISPID dispid = 16;
    if (FireOnRequestEdit(dispid) == S_FALSE)
     return S_FALSE;
    m_VclCtl->DoubleBuffered = Value;
    FireOnChanged(dispid);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::set_DriverPath(BSTR Value)
{
  try
  {
    const DISPID dispid = 10;
    if (FireOnRequestEdit(dispid) == S_FALSE)
      return S_FALSE;
    m_VclCtl->DriverPath = AnsiString(Value);
    FireOnChanged(dispid);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::set_Enabled(TOLEBOOL Value)
{
  try
  {
    const DISPID dispid = -514;
    if (FireOnRequestEdit(dispid) == S_FALSE)
     return S_FALSE;
    m_VclCtl->Enabled = Value;
    FireOnChanged(dispid);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::set_HardAccess(TOLEBOOL Value)
{
  try
  {
    const DISPID dispid = 13;
    if (FireOnRequestEdit(dispid) == S_FALSE)
     return S_FALSE;
    m_VclCtl->HardAccess = Value;
    FireOnChanged(dispid);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::set_Visible(TOLEBOOL Value)
{
  try
  {
    const DISPID dispid = 26;
    if (FireOnRequestEdit(dispid) == S_FALSE)
     return S_FALSE;
    m_VclCtl->Visible = Value;
    FireOnChanged(dispid);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::UseRightToLeftReading(TOLEBOOL* Value)
{
  try
  {
  *Value = m_VclCtl->UseRightToLeftReading();
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::UseRightToLeftScrollBar(TOLEBOOL* Value)
{
  try
  {
  *Value = m_VclCtl->UseRightToLeftScrollBar();
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::WritePort(long Address, short Data)
{
  try
  {
  m_VclCtl->WritePort(Address, Data);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortIOXXImpl::WritePortFIFO(long PortAddr, long NumPorts,
  long Buffer)
{
  try
  {
  /* m_VclCtl->WritePortFIFO( [INCOMPAT_TYPE(COMP(65535), TLB(3), Buffer )]);*/
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortIOXX);
  }
  return S_OK;
};


