状态保存机制
{
if (0 == acDevName[0])
return 0;
//仅仅是将 字符串写入到了 相关的文件中并没有保存
SetDlgItemText(hWnd, IDC_CTRL_CHANNELNAME, acDevName);
MPU_PAR_SetValue(SelectChannel, "NameUTF8", acDevName);
//保存
char acTemp[200];
char acTempFile[200];
char szBakFileName[200];
HY_DVR_ALIAS_CFG_1 tCfg;
int nSDKRet = 0;
char szSection[30];
char szDefaultName[30];
if (g_tGuiState.m_CHMode[s_iCh])
{
sprintf(szSection, SECTION_IPC_OSD_ALIAS, s_iCh);
}
else
{
sprintf(szSection, SECTION_OSD_ALIAS, s_iCh);
}
sprintf(szDefaultName, DEFNAME_OSD_ALIAS, s_iCh + 1);
HY_DVR_ALIAS_CFG_1 tGetCfg;
memset(&tGetCfg,0,sizeof(tGetCfg));
memset(&tCfg, 0, sizeof(tCfg));
if (g_tGuiState.m_CHMode[s_iCh])
{
MPU_PUB_GetAlias(szSection, szDefaultName, &tGetCfg);
snprintf(acTemp, 200, SECTION_IPC_OSD_ALIAS, s_iCh);
snprintf(acTempFile, 200, IDVR_OSD_ALIAS, s_iCh + 1);
}
else
{
// 保存图片
snprintf(acTempFile, 200, IDVR_OSD_ALIAS, s_iCh + 1);
//备份位图文件名
sprintf(szBakFileName, "%s.bak", acTempFile);
//先备份原有位图
rename(acTempFile, szBakFileName);
//将字符串装换成相关图片
if (0 != SaveStringToBitmap(acTempFile, acDevName, &tCfg.nWidth, &tCfg.nHeight))
{
GUI_ERR("SaveStringToBitmap return erro\n");
//设置失败,恢复备份位图
rename(szBakFileName, acTemp);
return 0;
}
TransBitmapCH(acTempFile); //图片先关的处理
snprintf(acTemp, 200, SECTION_OSD_ALIAS, s_iCh);
nSDKRet = MPU_PUB_GetAlias(acTemp, "CAM", &tGetCfg);//
}
tCfg.bValid = 1;
hecs1_conv_to_uc16((unsigned char *)tCfg.strName, (unsigned char *)acDevName, 20);
tCfg.nCharSet = 1;
nSDKRet = MPU_PUB_SetAlias(acTemp, &tCfg); //保存图片相关的参数
if(0 != nSDKRet)
{
GUI_ERR("MPU_PUB_SetAlias return erro\n");
if (g_tGuiState.m_CHMode[s_iCh])
{
return 0;
}
else
{
//如果失败,则还原之前的配置
nSDKRet = MPU_PUB_SetAlias(acTemp, &tGetCfg);
rename(szBakFileName, acTempFile);
GUI_MessageBox_9000(hWnd,
_T_MAP(26), TC_ERROR, -1, -1, MB_OK);
SetDlgItemText(hWnd, IDC_CTRL_CHANNELNAME, acDevName);
ShowWindow(GetDlgItem(hWnd,IDC_CTRL_CHANNELNAME),SW_HIDE);
ShowWindow(GetDlgItem(hWnd,IDC_CTRL_CHANNELNAME),SW_SHOW);
break;
}
}
//设置点阵到系统sdk
nSDKRet = MPU_AVL_OSD_SetCharBitMap(s_iCh, acTempFile);
if (0 == nSDKRet)
{
if (!g_tGuiState.m_CHMode[s_iCh])
{
//同步相关的图片
UnloadBitmap(&(g_tGuiBmp.ahChName[s_iCh]));
LoadBitmap(HDC_SCREEN, &g_tGuiBmp.ahChName[s_iCh], acTempFile);
SetBmpColorKey(&g_tGuiBmp.ahChName[s_iCh], 0, 0);
SendNotifyMessage(g_tGuiWnd.hDeskWnd, MSG_REFREASHCHANNEL, s_iCh, 0);
//写日志
// 添加设置参数的日志
char szUsername[50];
HANDLE hUser = GetLoginUser();
MPU_USR_GetUserName(hUser, szUsername, 20);
MPU_OPL_AddLog(EDVR_EVENT_SETTING, EDVR_EVENT_SETTING_DETAIL_CODEC_SETTING,
s_iCh, 0, 0, szUsername);
//设置成功,删除备份位图
remove(szBakFileName);
//配置写入到文件,避免图片名称和配置文件中的名称不一致
MPU_PAR_SaveConfig();
}
SetDlgItemText(hWnd, IDC_CTRL_CHANNELNAME, acDevName);
ShowWindow(GetDlgItem(hWnd, IDC_CTRL_CHANNELNAME), SW_HIDE);
ShowWindow(GetDlgItem(hWnd, IDC_CTRL_CHANNELNAME), SW_SHOW);
SendDlgItemMessage(hWnd, IDC_CTRL_CHANNELNAME, MSG_PAINT, 0, 0);
MPU_PRW_RefreshChannel(0, s_iCh);
}
else
{
GUI_ERR("set bmp to dsp fail, return %d\n", nSDKRet);
if (!g_tGuiState.m_CHMode[s_iCh])
{
//设置失败,恢复备份位图
rename(szBakFileName, acTempFile);
//恢复位图到DSP
nSDKRet = MPU_AVL_OSD_SetCharBitMap(s_iCh, acTempFile);
if (0 != nSDKRet)
{
GUI_ERR("restore bmp to dsp fail, return %d\n", nSDKRet);
}
}
if(0 != MPU_PUB_SetAlias(acTemp, &tGetCfg))
{
GUI_ERR("MPU_PUB_SetAlias return erro\n");
return 0;
}
GUI_MessageBox_9000(hWnd,
_T_MAP(26), TC_ERROR, -1, -1, MB_OK);
}
}
第二点;打包日期的问题
写程序,获取最新的时间,用于打包开发