⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readstatus.cpp

📁 介绍控制器运动的例子
💻 CPP
字号:
// ReadStatus.cpp: implementation of the ReadStatus class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MFCMove.h"
#include "ReadStatus.h"
#include "MFCMoveDlg.h"

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

// ATL defined structure for defining the parameter data of the callback.  
// In this case there are two prameters.
_ATL_FUNC_INFO ReadAlertInfo = {CC_STDCALL, VT_EMPTY, 2, {VT_I4,VT_I4}};

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

ReadStatus::ReadStatus(void *winPtr)
{
  // We could have passed in just the specific data needed, to make this more
  // generic, but passing in the window pointer makes it look more MFC like.
  CMFCMoveDlg *workIt = (CMFCMoveDlg *) winPtr;
 	m_hDialog = workIt->m_hWnd;                       // window handle for messages

  m_stat.CreateInstance(BOXBRIDGELib::CLSID_Status);// start up COM Interface
  HRESULT hr = DispEventAdvise((IUnknown*)m_stat);

  m_stat->PutnStatusWaitRate(7);                    // Minimum time between status events
  m_stat->PutnBPS(workIt->m_BPS);                   // Set BPS
  m_stat->PutnPort(workIt->m_Port);                 // Set Port
  m_stat->PutbstrIP(workIt->m_IP.AllocSysString()); // Set IP Address
  m_stat->PutnBus(workIt->m_BusType?1:0);           // Set Bus, checked(true) is ISA, else PCI
  m_stat->Connect(workIt->m_Transport,workIt->m_CardNbr);// Connect to Transport
  //if(!m_stat->GetisOffline()){
  //  m_Msgid = m_stat->AddACRCustom(_T("P6916"));    // Start the status queue - p6916 is the ACR global clock
  //}
}

ReadStatus::~ReadStatus()
{
  if(m_stat){
    //m_stat->DelStatus(m_Msgid);
    DispEventUnadvise((IUnknown*)m_stat);
    m_stat->Disconnect();
    m_stat = NULL;         // Setting smart pointers to NULL is *VERY IMPORTANT*
  }
}

void __stdcall ReadStatus::ReadAlert(long msg, long err)
{
  // Pass on the message id in a windows message
  // Either Send or Post message can be used.
  //::SendMessage(workIt->m_hDialog,WMU_UpdateStats,0,msg);
  ::PostMessage(m_hDialog,WMU_UpdateStats,0,msg);
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -