void CPowerDlg::OnOK() { int nWallID = -1; int nBlockID = -1; int nOutputID = -1; int nIndex = m_cbWall.GetCurSel(); if (nIndex >= 0) { nWallID = m_cbWall.GetItemData(nIndex); } nIndex = m_cbBlock.GetCurSel(); if (nIndex >= 0) { nBlockID = m_cbBlock.GetItemData(nIndex); } nIndex = m_cbOutput.GetCurSel(); if (nIndex >= 0) { nOutputID = m_cbOutput.GetItemData(nIndex); } BOOL bPowerOn = (m_cbPower.GetCurSel() == 0 ? TRUE : FALSE); std::string strBlockID; if (nWallID >= 0 && nWallID < m_vecWall.size()) { const AV_CFG_MonitorWall& wall = m_vecWall[nWallID]; if (nBlockID >= 0 && nBlockID < wall.nBlockCount) { const AV_CFG_MonitorWallBlock& block = wall.stuBlocks[nBlockID]; strBlockID = block.szCompositeID; } } if (nWallID >= 0) { DH_IN_WM_POWER_CTRL stuInParam = { sizeof(DH_IN_WM_POWER_CTRL) }; stuInParam.bPowerOn = bPowerOn; stuInParam.nMonitorWallID = nWallID; stuInParam.pszBlockID = strBlockID.c_str(); stuInParam.nTVID = nOutputID; if (!CLIENT_PowerControl(m_lLoginID, &stuInParam, NULL)) { MsgBoxErr("Power control error."); } } //CDialog::OnOK(); }
void TMain::ReportMail() { if (CheckForSave()) return; ShowWaitCursor(); try { TFileIni* FileIni = CreateINIFile(); bool UseUTF8 = FileIni->ReadBool("E-Mail", "UseUTF8", false); String MailClient = FileIni->ReadString("E-Mail", "Client", ""); String S = Format(IDS_MAIL_TO, ARRAYOFCONST((FileIni->ReadString("E-Mail", "Address", ""), StrToUrl(FileIni->ReadString("E-Mail", "Subject", ""), UseUTF8), StrToUrl(Memo->Lines->Text, UseUTF8)))); delete FileIni; // MsgBox(S); CopyToClipBoard(S); RestoreCursor(); return; if (MailClient != "") { if (!EXEIsRunning(MailClient, true)) { ShellExec(MailClient); Delay(1000); } } ShellExec(S); } catch (Exception *E) { MsgBoxErr(E->Message); } RestoreCursor(); }
bool TMain::CheckForSave() { bool Result = Memo->Lines->Text.IsEmpty(); if (Result) MsgBoxErr(LoadStr(IDS_ERROR_MEMO_CLEAR)); return Result; }
void CSpliceScreenConfigDlg::InitUI() { m_wndWall.CreateEx(WS_EX_CLIENTEDGE, NULL, NULL, WS_CHILD | WS_VISIBLE, CRect(0, 0, 465, 385), this, 22333); m_cbTVLayoutRow.SetCurSel(0); m_cbTVLayoutColumn.SetCurSel(0); m_cbTVSizeRow.SetCurSel(0); m_cbTVSizeColumn.SetCurSel(0); CheckDlgButton(IDC_RADIO_LAYOUT_2x2, TRUE); CheckDlgButton(IDC_RADIO_SIZE_1x1, TRUE); OnRadioLayout(); OnRadioSize(); const int nMaxNameLen = 60; CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_SPLICE_NAME); pEdit->LimitText(nMaxNameLen); pEdit = (CEdit*)GetDlgItem(IDC_EDIT_SPLICE_ID); pEdit->LimitText(nMaxNameLen); // fill outputs m_lbOutputs.ResetContent(); const CDecoder* pDecoder = ((CDemoMonitorWallDlg*)GetParent())->GetDecoderInfo(); CDecChnMap::const_iterator it = pDecoder->GetDecChnMap().begin(); for (; it != pDecoder->GetDecChnMap().end(); ++it) { if (!it->second.m_bSpliceScreen) { int nIndex = m_lbOutputs.AddString(it->second.ToString()); m_lbOutputs.SetItemData(nIndex, it->first); } } // get config const int nMaxJsonLen = 64 * 1024; char* pszJsonBuf = new char[nMaxJsonLen]; memset(pszJsonBuf, 0, nMaxJsonLen); // 解码器使用老协议配置拼接屏 if (_stricmp(CDecoderNVD::DCID(), pDecoder->GetDeviceClass()) == 0) { // 解码器的拼接屏ID无法设置 GetDlgItem(IDC_EDIT_SPLICE_ID)->EnableWindow(FALSE); // 获取电视墙配置 if (CLIENT_GetNewDevConfig(m_lLoginID, CFG_CMD_MONITORWALL, -1, pszJsonBuf, nMaxJsonLen, NULL)) { const int nMaxMonitorWall = 1; AV_CFG_MonitorWall* pstuWall = new AV_CFG_MonitorWall[nMaxMonitorWall]; for (int i = 0; i < nMaxMonitorWall; ++i) { pstuWall[i].nStructSize = sizeof(AV_CFG_MonitorWall); for (int j = 0; j < AV_CFG_Max_Block_In_Wall; ++j) { pstuWall[i].stuBlocks[j].nStructSize = sizeof(AV_CFG_MonitorWallBlock); pstuWall[i].stuBlocks[j].stuRect.nStructSize = sizeof(AV_CFG_Rect); for (int k = 0; k < AV_CFG_Max_TV_In_Block; ++k) { pstuWall[i].stuBlocks[j].stuTVs[k].nStructSize = sizeof(AV_CFG_MonitorWallTVOut); } } } int nRetLen = 0; if (CLIENT_ParseData(CFG_CMD_MONITORWALL, pszJsonBuf, pstuWall, pstuWall->nStructSize * nMaxMonitorWall, &nRetLen)) { m_wndWall.ClearBlock(); m_wndWall.SetName(pstuWall->szName); m_wndWall.SetGridLayout(CSize(pstuWall->nColumn, pstuWall->nLine)); // 获取拼接屏配置 if (CLIENT_GetNewDevConfig(m_lLoginID, CFG_CMD_SPLICESCREEN, -1, pszJsonBuf, nMaxJsonLen, NULL)) { int nMaxSpliceScreen = 32; AV_CFG_SpliceScreen* pstuScreen = new AV_CFG_SpliceScreen[nMaxSpliceScreen]; for (int i = 0; i < nMaxSpliceScreen; ++i) { pstuScreen[i].nStructSize = sizeof(AV_CFG_SpliceScreen); } if (CLIENT_ParseData(CFG_CMD_SPLICESCREEN, pszJsonBuf, pstuScreen, pstuScreen->nStructSize * nMaxSpliceScreen, &nRetLen)) { int nSpliceCount = nRetLen / pstuScreen->nStructSize; // 拼接屏数量 for (int k = 0; k < nSpliceCount; ++k) { AV_CFG_SpliceScreen* p = pstuScreen + k; // 判断该拼接屏是否包含在电视墙配置中 if (_stricmp(p->szWallName, pstuWall->szName) == 0 && p->nBlockID >= 0 && p->nBlockID < pstuWall->nBlockCount) { int j = 0; const AV_CFG_MonitorWallBlock& block = pstuWall->stuBlocks[p->nBlockID]; WMBlock wmblock(&m_wndWall); wmblock.bNew = TRUE; sprintf(wmblock.szCompositeID, "%d", p->nBlockID); strcpy(wmblock.szName, p->szName); wmblock.stuTVSize.cx = block.nColumn; wmblock.stuTVSize.cy = block.nLine; wmblock.stuBlockSize.cx = (block.stuRect.nRight - block.stuRect.nLeft + 1) / block.nColumn; wmblock.stuBlockSize.cy = (block.stuRect.nBottom - block.stuRect.nTop + 1) / block.nLine; wmblock.stuLeftTop.x = block.stuRect.nLeft * m_wndWall.GetGridSize().cx; wmblock.stuLeftTop.y = block.stuRect.nTop * m_wndWall.GetGridSize().cy; for (j = 0; j < block.nTVCount; ++j) { wmblock.vecOutputs.push_back(block.stuTVs[j].nChannelID); } m_wndWall.AddBlock(wmblock); } } } delete[] pstuScreen; } } delete[] pstuWall; } } // 其他设备使用新协议 else { if (CLIENT_GetNewDevConfig(m_lLoginID, CFG_CMD_MONITORWALL, -1, pszJsonBuf, nMaxJsonLen, NULL, WAIT_TIME)) { AV_CFG_MonitorWall* pstuWall = new AV_CFG_MonitorWall(); if( NULL == pstuWall ) { return; } memset(pstuWall , 0 , sizeof(AV_CFG_MonitorWall)); pstuWall->nStructSize = sizeof(AV_CFG_MonitorWall); for (int i = 0; i < AV_CFG_Max_Block_In_Wall; ++i) { pstuWall->stuBlocks[i].nStructSize = sizeof(AV_CFG_MonitorWallBlock); pstuWall->stuBlocks[i].stuRect.nStructSize = sizeof(AV_CFG_MonitorWallTVOut); for (int j = 0; j < AV_CFG_Max_TV_In_Block; ++j) { pstuWall->stuBlocks[i].stuTVs[j].nStructSize = sizeof(AV_CFG_MonitorWallTVOut); } } int nRetLen = 0; if (CLIENT_ParseData(CFG_CMD_MONITORWALL, pszJsonBuf, pstuWall, sizeof(AV_CFG_MonitorWall), &nRetLen)) { m_wndWall.ClearBlock(); m_wndWall.SetName(pstuWall->szName); m_wndWall.SetGridLayout(CSize(pstuWall->nColumn, pstuWall->nLine)); for (int i = 0; i < pstuWall->nBlockCount; ++i) { AV_CFG_MonitorWallBlock* pBlockInfo = pstuWall->stuBlocks + i; //if (pBlockInfo->nTVCount > 0) if (*pBlockInfo->szCompositeID) { WMBlock block(&m_wndWall); block.bNew = TRUE; strcpy(block.szCompositeID, pBlockInfo->szCompositeID); strcpy(block.szName, pBlockInfo->szName); block.stuTVSize.cx = pBlockInfo->nColumn; block.stuTVSize.cy = pBlockInfo->nLine; block.stuBlockSize.cx = (pBlockInfo->stuRect.nRight - pBlockInfo->stuRect.nLeft + 1) / pBlockInfo->nColumn; block.stuBlockSize.cy = (pBlockInfo->stuRect.nBottom - pBlockInfo->stuRect.nTop + 1) / pBlockInfo->nLine; block.stuLeftTop.x = pBlockInfo->stuRect.nLeft * m_wndWall.GetGridSize().cx; block.stuLeftTop.y = pBlockInfo->stuRect.nTop * m_wndWall.GetGridSize().cy; for (int j = 0; j < pBlockInfo->nTVCount; ++j) { block.vecOutputs.push_back(pBlockInfo->stuTVs[j].nChannelID); } m_wndWall.AddBlock(block); } } } else { MsgBox0("Parse config data (monitor wall) error."); } delete pstuWall; } else { MsgBoxErr("Get config (monitor wall) error."); } } delete[] pszJsonBuf; }
int playWAVEFile(const char *lpszWAVEFileName) { static int init = 0; static HWND hwStopper; static int counter = 0; DWORD dwReturn; MCI_OPEN_PARMS mciOpenParms; MCI_PLAY_PARMS mciPlayParms; // Open the device by specifying the device and filename. // MCI will choose a device capable of playing the specified file. if(!init){ WNDCLASS wc = { 0, /* UINT style; */ SoundStopper, /*WNDPROC lpfnWndProc; */ 0, /*int cbClsExtra; */ 0, /*int cbWndExtra; */ NULL, /*HINSTANCE hInstance; */ NULL, /*HICON hIcon; */ NULL, /*HCURSOR hCursor; */ NULL, /*HBRUSH hbrBackground; */ NULL, /*LPCTSTR lpszMenuName; */ "SoundStopperClass", /*LPCTSTR lpszClassName; */ }; ATOM atom; wc.hInstance = (HINSTANCE)GetModuleHandle(NULL);; if(!(atom = RegisterClass(&wc)) || !(hwStopper = CreateWindow((LPCTSTR)atom, "SoundStopper", 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL))){ MsgBoxErr(); return 1; } init = 1; } { WCHAR alias[5]; alias[0] = '0' + counter % 10; alias[1] = '0' + counter / 10 % 10; alias[2] = '0' + counter / 10 / 10 % 10; alias[3] = '\0'; counter++; mciOpenParms.lpstrDeviceType = "waveaudio"; mciOpenParms.lpstrElementName = lpszWAVEFileName; mciOpenParms.lpstrAlias = alias; if (dwReturn = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT | MCI_OPEN_ALIAS, (DWORD)(LPVOID) &mciOpenParms)) { // Failed to open device. Don't close it; just return error. return (dwReturn); } // The device opened successfully; get the device ID. wDeviceID = mciOpenParms.wDeviceID; } { UINT num; DWORD vol; num = waveOutGetNumDevs(); if(num) auxGetVolume(0, &vol); num; } // Begin playback. The window procedure function for the parent // window will be notified with an MM_MCINOTIFY message when // playback is complete. At this time, the window procedure closes // the device. mciPlayParms.dwCallback = (DWORD) hwStopper; if (dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)(LPVOID) &mciPlayParms)) { mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL); return (dwReturn); } return (0L); }