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

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

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


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


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


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


STDMETHODIMP TDLPortOCXImpl::get_AlignDisabled(VARIANT_BOOL* Value)
{
  try
  {
   *Value = m_VclCtl->AlignDisabled;
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortOCX);
  }
  return S_OK;
};


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


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


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


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


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


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


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


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


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


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


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


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


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


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


STDMETHODIMP TDLPortOCXImpl::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_IDLPortOCX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortOCXImpl::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_IDLPortOCX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortOCXImpl::set_DoubleBuffered(VARIANT_BOOL 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_IDLPortOCX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortOCXImpl::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_IDLPortOCX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortOCXImpl::set_Enabled(VARIANT_BOOL 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_IDLPortOCX);
  }
  return S_OK;
};


STDMETHODIMP TDLPortOCXImpl::set_HardAccess(VARIANT_BOOL 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_IDLPortOCX);
  }
  return S_OK;
};


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


STDMETHODIMP TDLPortOCXImpl::SetSubComponent(VARIANT_BOOL IsSubComponent)
{
  try
  {
  m_VclCtl->SetSubComponent(IsSubComponent);
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IDLPortOCX);
  }
  return S_OK;
};


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


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


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


STDMETHODIMP TDLPortOCXImpl::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_IDLPortOCX);
  }
  return S_OK;
};


