void CClientDemoDlg::ProcSensorAlarm(WPARAM wParam, LPARAM lParam)
{
    //LPLOCAL_ALARM_INFO结构体
    LPLOCAL_ALARM_INFO pAlarmDev = (LPLOCAL_ALARM_INFO)(wParam);
    char *pAlarmInfo = (char *)(lParam);
   //iDeviceIndex结构体中的一个值
    int iDeviceIndex = pAlarmDev->iDeviceIndex;
    
    NET_DVR_SENSOR_ALARM struSensorAlarm = {0};
    memcpy(&struSensorAlarm, pAlarmInfo, sizeof(struSensorAlarm));
    
    memcpy(&m_struSensorAlarm[struSensorAlarm.bySensorChannel - 1], &struSensorAlarm, sizeof(struSensorAlarm));
    
      char szLan[1024] = {0};
    
    sprintf(szLan, "Sensor Alarm:AbsTime[%d]Name[%s]SensorChan[%d]Type[%d]AlramType[%d]AlarmMode[%u]Value[%f]",
        struSensorAlarm.dwAbsTime, struSensorAlarm.byName, struSensorAlarm.bySensorChannel,
        struSensorAlarm.byType, struSensorAlarm.byAlarmType, struSensorAlarm.byAlarmMode, struSensorAlarm.fValue);
    g_pMainDlg->AddLog(iDeviceIndex, ALARM_INFO_T, szLan);
    if (g_pDlgSensor != NULL)
    {
        g_pDlgSensor->SetSensorDate(struSensorAlarm);
    }
    
}

解决方案 »

  1.   

    LPLOCAL_ALARM_INFO这个是什么结构体??
    这个貌似是个自定义消息的响应函数。
    Delphi类似的:
    //自定义消息声明
    const wm_myevent=wm_user+10;
    //消息响应函数声明
    procedure WMEVENT(var Msg: TMessage); message wm_myevent;
      

  2.   

    [Quote=引用 2 楼 m617105 的回复:]
    LPLOCAL_ALARM_INFO这个是什么结构体??typedef struct tagLOCAL_ALARM_INFO
    {
    int iDeviceIndex;
    LONG lCommand;
    tagLOCAL_ALARM_INFO()
    {
    iDeviceIndex = -1;
    lCommand = -1;
    }
    }LOCAL_ALARM_INFO, *LPLOCAL_ALARM_INFO;
      

  3.   

    type 
      LPLOCAL_ALARM_INFO=^LOCAL_ALARM_INFO;
      LOCAL_ALARM_INFO=record
        iDeviceIndex:integer;
        lCommand:LongInt;
    end;
    类似于这样的语句可以这样翻译
    1、memcpy(&struSensorAlarm, pAlarmInfo, sizeof(struSensorAlarm));
    <===>
    Move(struSensorAlarm,pAlarmInfo,sizeof(struSensorAlarm));
    2、sprintf函数功能类似于Format函数
    其他都是一些数据类型的转换可以参考:
    Delphi 与 C/C++ 数据类型对照表
      

  4.   

    var
    pAlarmDev:LPLOCAL_ALARM_INFO;
    iDeviceIndex:integer;
    struSensorAlarm:  NET_DVR_SENSOR_ALARM;
    szLan:string;
    begin
    pAlarmDev:=LPLOCAL_ALARM_INFO(p);
    pAlarmInfo := pAlarmInfo(lParam);
    iDeviceIndex := pAlarmDev.iDeviceIndex;
    struSensorAlarm := 0;
    Move(struSensorAlarm,pAlarmInfo,sizeof(struSensorAlarm));
    szLan:=Format('Sensor Alarm:AbsTime %d Name %s SensorChan %d Type %d AlramType %d AlarmMode %u Value %f ',[struSensorAlarm.dwAbsTime, struSensorAlarm.byName, struSensorAlarm.bySensorChannel,
      struSensorAlarm.byType, struSensorAlarm.byAlarmType, struSensorAlarm.byAlarmMode, struSensorAlarm.fValue]);
      g_pMainDlg.addlog(iDeviceIndex, ALARM_INFO_T, szLan);
       if (g_pDlgSensor <> nil)
      g_pDlgSensor.SetSensorDate(struSensorAlarm);
    随手写的,你试试看。
      

  5.   

    pAlarmDev:=LPLOCAL_ALARM_INFO(wParam);
    第一句是这个,手误了。
      

  6.   

    struSensorAlarm := 0;
    这句应该写成 fillchar(struSensorAlarm ,sizeof(struSensorAlarm ),0)
      

  7.   

    占个位置
    继续努力学习中..........
    顶顶帖子,接分中........顶顶帖子,高手们也请多多赐教
    http://topic.csdn.net/u/20110913/13/59f92d11-1fb0-4b7e-9c4a-e93d8f19c689.html
    http://topic.csdn.net/u/20110611/12/3258c959-4f28-46b7-b5d6-46135d73036b.html
    http://topic.csdn.net/u/20110722/14/89f7440b-c4d7-4c9a-a4bb-a503f5135db2.html
    http://topic.csdn.net/u/20110729/10/a7bfaf06-0cf9-4580-8e91-d4e0b92066c6.html
    http://topic.csdn.net/u/20110811/16/e56e7cc1-d8c9-40af-92e3-c24ca103d17d.html
    http://topic.csdn.net/u/20110830/13/dfae4ca5-d2b9-4889-8a3c-6f7fb61936c9.html
    http://topic.csdn.net/u/20110905/12/a1161adb-8e5d-491a-b302-c9722edf2dab.html
    http://topic.csdn.net/u/20110913/16/2dbcc9db-8f71-40c5-901f-afae9026f7c2.html
    http://topic.csdn.net/u/20110913/13/59f92d11-1fb0-4b7e-9c4a-e93d8f19c689.html
      

  8.   

    呵呵 结贴谢谢cp1982
    vc++里边的转换真让人纠结啊