bool Sample::LoadSprite(TCHAR* pFileName) { TCHAR pBuffer[256] = { 0, }; TCHAR pTemp[256] = { 0, }; FILE* fp; _wfopen_s(&fp, pFileName, _T("rt")); if (fp = NULL)return false; int iNumSprite = 0; _fgetts(pBuffer, _countof(pBuffer), fp); _stscanf_s(pBuffer, _T("%s%d"), pTemp, _countof(pTemp), &iNumSprite); m_SpriteList.resize(iNumSprite); int iNumFrame = 0; for (int iSprite = 0; iSprite < iNumSprite; iSprite++) { _fgetts(pBuffer, _countof(pBuffer), fp); _stscanf_s(pBuffer, _T("%s%d"), pTemp, _countof(pTemp), &iNumFrame); int iNumber; m_SpriteList[iSprite].resize(iNumFrame); for (int iFrame = 0;iFrame < iNumFrame; iFrame++) { RECT rt; _fgetts(pBuffer, _countof(pBuffer), fp); _stscanf_s(pBuffer, _T("%d%d%d%d%d"), &iNumber, &rt.left, &rt.top, &rt.right, &rt.bottom); m_SpriteList[iSprite][iFrame] = rt; } } fclose(fp); return true; }
int getIntDevID(TCHAR strDevID[]) //DevID is in form like: "ROOT\\NET\\0008" { TRACE_ENTER(); int iDevID = -1; int iMatched = _stscanf_s(strDevID, _T("ROOT\\NET\\%04d"), &iDevID); TRACE_PRINT2("_stscanf_s: iMatched = %d, iDevID = %d.", iMatched, iDevID); if (iMatched != 1) iDevID = -1; TRACE_EXIT(); return iDevID; }
/** * @brief 解析文本框的格式 * @note 在文本框中 / 表示列表框中当前值不会被更改。 V 表示数值 V 将被应用到指定一行或一组行。 V/i 或 V/+i (或 V/-i)表示从 V 开始的步进 (或步减)值将被应用到指定一组行上。 (+ 符号为可选)。 /i 或 /+i (或 /-i)表示步进(或步减) 将被应用到指定一组行的已存在数值上。 * @param COleVariant* pEditVariant 编辑框的内容 * @param COleVariant* pListVariant 文本框的内容 * @param int nIndex 循环次数,如V/i的格式时,用于计算 V + nIndex*i * @return */ COleVariant CGridCtrlOperation::GetValueForTextField(COleVariant* pEditVariant,COleVariant* pListVariant,int nIndex) { int nPos; CString strData; COleVariant oResultVariant; try { // 格式 V ,不是字符串 if(pEditVariant->vt!=VT_BSTR) { return *pEditVariant; } strData = *pEditVariant; // 格式 / if(!strData.CompareNoCase(_T("/"))) { return *pListVariant; } // 格式 V nPos = strData.Find('/'); if(nPos<0) { return *pEditVariant; } else if(nPos ==0) // 解析格式 /i { strData.Remove('/'); oResultVariant = strData; oResultVariant.ChangeType(VT_R4); pListVariant->ChangeType(VT_R4); oResultVariant.fltVal = pListVariant->fltVal + nIndex * oResultVariant.fltVal; return oResultVariant; } else // 解析格式 V/i { float fValue,fStep; strData.Replace(_T("/"),_T(" ")); _stscanf_s(LPCTSTR(strData),_T("%f%f"),&fValue,&fStep); oResultVariant = fValue + nIndex * fStep; return oResultVariant; } } catch (CException* ) { oResultVariant.vt = VT_EMPTY; } return oResultVariant; }
CGoToDlg::CGoToDlg(REFERENCE_TIME time, REFERENCE_TIME maxTime, double fps, CWnd* pParent /*=NULL*/) : CDialog(CGoToDlg::IDD, pParent) , m_time(time) , m_maxTime(maxTime) , m_fps(fps) { if (m_fps == 0) { CString str = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_GOTO_FPS, _T("0")); float fps; if (_stscanf_s(str, _T("%f"), &fps) == 1) { m_fps = fps; } } }
BOOL Profile::GetInt(const TCHAR *szOption, int *pValue) { TCHAR buf[256]={ 0 }; if( GetPrivateProfileString(_szSectionName, szOption, 0, buf, 256, _szFileName) == 0 ) { return FALSE; // Key empty or not exist } else // Key not empty { if( _stscanf_s(buf, _T("%d"), pValue) == 1) // Numeric { return TRUE; } return FALSE; } }
int ValueList::GetValue(CString key, int def) { FieldIterator it; for (it = fieldsBegin(); it != fieldsEnd(); it++) { XMLField *f = *it; if (f->key == key) { int val; if (_stscanf_s(f->value, _T("%d"), &val) == 1) { return val; } else { return def; } } } return def; }
unsigned char CHgzComboBox::GetWindowDec( void ) { CString str; GetWindowText(str); CStringArray arr; hgzExtractSubStrings(arr, str, _T(" +")); unsigned int *pi = new unsigned int[arr.GetSize()]; int i; for (i = 0; i < arr.GetSize(); i++) { _stscanf_s(arr[i], _T("%d"), pi + i); } unsigned char x = (unsigned char)pi[0]; delete [] pi; return x; }
void CIWinSyncDlg::WriteSettings() { //Get the path to sync and save in registry CEdit* pPathEditBox = NULL; pPathEditBox = (CEdit*) GetDlgItem(IDC_EDIT_PATH); if (pPathEditBox != NULL) { TCHAR szTempPath[MAX_PATH]; pPathEditBox->GetWindowTextW(szTempPath,MAX_PATH); if(m_pszCurrentSyncPath != NULL) { free(m_pszCurrentSyncPath); m_pszCurrentSyncPath = (TCHAR *) malloc((_tcslen(szTempPath)+1) *sizeof(TCHAR)); } _tcscpy_s(m_pszCurrentSyncPath,(_tcslen(szTempPath)+1),szTempPath); } pPathEditBox = NULL; WriteRegStringValue(_T("Software\\IWinSync"), _T("CurSyncPath"),m_pszCurrentSyncPath); //get the sync interval CEdit* pIntervalEditBox = NULL; pIntervalEditBox = (CEdit*) GetDlgItem(IDC_EDIT_INTERVAL); if (pIntervalEditBox != NULL) { TCHAR szSyncInterval[50]; pIntervalEditBox->GetWindowTextW(szSyncInterval,50); DWORD dwScanInterval = 0; _stscanf_s(szSyncInterval,_T("%u"),&dwScanInterval); m_nSyncInterval = dwScanInterval * 60000; } pIntervalEditBox = NULL; WriteRegDWordValue(_T("Software\\IWinSync"), _T("SyncInterval"),m_nSyncInterval/60000); CListBox * pLoggingLevelList = (CListBox*) GetDlgItem(IDC_LIST_LOGLEVEL); if (pLoggingLevelList != NULL) { m_dwLogLevel = pLoggingLevelList->GetCurSel(); } pLoggingLevelList = NULL; if (m_dwLogLevel < 0 || m_dwLogLevel > 2) { m_dwLogLevel = DEFAULT_LOG_LEVEL; } WriteRegDWordValue(_T("Software\\IWinSync"), _T("LogLevel"),m_dwLogLevel); }
HRESULT CPatchDlg::ParseServerCfg(CString cfgPath) { BKIni::Document ini; int nFileCount=100; HRESULT hr=S_OK; BKIni::Section section; if (FAILED(hr)) return hr; ini.LoadFile(cfgPath); if (!ini.HasSection(L"config")) return E_FAIL; section=ini[L"config"]; //初始化 nFileCount=section[L"maxFileCount"].GetValueDWORD(); sBaseAddress=section[_T("baseAddress")].GetValueString(); section=ini[L"file"]; m_mapSvrFileVersion.RemoveAll(); Log(_T("分析服务端的文件列表,基址%s,最大文件数%d\r\n"),sBaseAddress,nFileCount); for (int i=1; i<nFileCount; ++i) { wchar_t szItem[10] = {0}; wsprintf(szItem, L"f%d", i); CString str, sFile, sVer, sTmp; DWORD dwCrc=0; if (!section.HasKey(szItem)) break; str=section[szItem].GetValueString(); PFILEUPDATESVRDATA pData=new FILEUPDATESVRDATA(); AfxExtractSubString(sFile,str,0,L','); AfxExtractSubString(pData->sFilePath,str,1,L','); AfxExtractSubString(sVer,str,2,L','); AfxExtractSubString(sTmp,str,3,L','); _stscanf_s(sTmp.GetString(),_T("%x"),&dwCrc); pData->sFileName=sFile; pData->sVersion=sVer; pData->nCrc32=dwCrc; m_mapSvrFileVersion.SetAt(sFile.MakeUpper(),pData); //Log(_T("服务端文件:%-25s,版本:%10s\r\n"),pData->sFileName,pData->sVersion); } return S_OK; }
//***************************************************************************************** void CIconListItem::OnDrawValue (CDC* pDC, CRect rect) { CBCGPGridCtrl* pGridCtrl = GetOwnerList(); ASSERT_VALID (pGridCtrl); ASSERT_VALID (pDC); CString strVal = (LPCTSTR)(_bstr_t) m_varValue; if (strVal.IsEmpty () || m_imageListIcons.GetCount () == 0) { return; } int nIndex = -1; #if _MSC_VER < 1400 _stscanf (strVal, _T("%d"), &nIndex); #else _stscanf_s (strVal, _T("%d"), &nIndex); #endif if (nIndex < 0) { return; } CRect rectImage = rect; rectImage.right = rectImage.left + rectImage.Height () + 2 * nIconMargin; m_imageListIcons.DrawEx (pDC, rectImage, nIndex, CBCGPToolBarImages::ImageAlignHorzCenter, CBCGPToolBarImages::ImageAlignVertCenter); if (!m_lstIconNames.IsEmpty ()) { CFont* pOldFont = pDC->SelectObject (pGridCtrl->GetFont ()); CString str = m_lstIconNames.GetAt (m_lstIconNames.FindIndex (nIndex)); rect.left = rectImage.right; pDC->DrawText (str, rect, DT_SINGLELINE | DT_VCENTER); pDC->SelectObject (pOldFont); } m_bValueIsTrancated = FALSE; }
void CPlayerSubresyncBar::UpdateStrings() { CString str; if (m_mode == TEXTSUB) { for (int i = 0, j = (int)m_sts.GetCount(); i < j; i++) { STSStyle stss; m_sts.GetStyle(i, stss); m_list.SetItemText(i, COL_TEXT, m_sts.GetStrW(i, true)); m_list.SetItemText(i, COL_STYLE, m_sts[i].style); m_list.SetItemText(i, COL_FONT, stss.fontName); str.Format(_T("%d"), stss.charSet); m_list.SetItemText(i, COL_CHARSET, str); m_list.SetItemText(i, COL_UNICODE, m_sts.IsEntryUnicode(i) ? _T("yes") : _T("no")); str.Format(_T("%d"), m_sts[i].layer); m_list.SetItemText(i, COL_LAYER, str); m_list.SetItemText(i, COL_ACTOR, m_sts[i].actor); m_list.SetItemText(i, COL_EFFECT, m_sts[i].effect); } } else if (m_mode == VOBSUB) { for (int i = 0, j = (int)m_sts.GetCount(); i < j; i++) { int vobid, cellid, forced; TCHAR c; if (_stscanf_s(m_sts.GetStrW(i), _T("%d%c%d%c%d"), &vobid, &c, 1, &cellid, &c, 1, &forced) != 5) { continue; } if (vobid < 0) { str = _T("-"); } else { str.Format(_T("%d"), vobid); } m_list.SetItemText(i, COL_VOBID, str); if (cellid < 0) { str = _T("-"); } else { str.Format(_T("%d"), cellid); } m_list.SetItemText(i, COL_CELLID, str); str = forced ? _T("Yes") : _T(""); m_list.SetItemText(i, COL_FORCED, str); } } }
void CPlayerSubresyncBar::SaveSubtitle() { CMainFrame* pFrame = ((CMainFrame*)AfxGetMainWnd()); if (!pFrame) { return; } CLSID clsid; m_pSubStream->GetClassID(&clsid); if (clsid == __uuidof(CVobSubFile) && m_mode == VOBSUB) { CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)m_pSubStream; CAutoLock cAutoLock(m_pSubLock); ASSERT(pVSF->m_iLang >= 0); CAtlArray<CVobSubFile::SubPos>& sp = pVSF->m_langs[pVSF->m_iLang].subpos; for (size_t i = 0, j = sp.GetCount(); i < j; i++) { sp[i].fValid = false; } for (int i = 0, j = (int)m_sts.GetCount(); i < j; i++) { int vobid, cellid, forced, spnum; TCHAR c; if (_stscanf_s(m_sts.GetStrW(i), _T("%d%c%d%c%d%c%d"), &vobid, &c, 1, &cellid, &c, 1, &forced, &c, 1, &spnum) != 7) { continue; } sp[spnum].start = m_sts[i].start; sp[spnum].stop = m_sts[i].end; sp[spnum].fValid = true; } } else if (clsid == __uuidof(CRenderedTextSubtitle) && m_mode == TEXTSUB) { CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream; CAutoLock cAutoLock(m_pSubLock); pRTS->Copy(m_sts); } else { return; } pFrame->InvalidateSubtitle(); }
void CFavoriteOrganizeDlg::SetupList(bool fSave) { int i = m_tab.GetCurSel(); if (fSave) { CAtlList<CString> sl; for (int j = 0; j < m_list.GetItemCount(); j++) { CAtlList<CString> args; ExplodeEsc(m_sl[i].GetAt((POSITION)m_list.GetItemData(j)), args, _T(';')); args.RemoveHead(); args.AddHead(m_list.GetItemText(j, 0)); sl.AddTail(ImplodeEsc(args, _T(';'))); } m_sl[i].RemoveAll(); m_sl[i].AddTailList(&sl); } else { m_list.DeleteAllItems(); POSITION pos = m_sl[i].GetHeadPosition(), tmp; while (pos) { tmp = pos; CAtlList<CString> sl; ExplodeEsc(m_sl[i].GetNext(pos), sl, _T(';'), 3); int n = m_list.InsertItem(m_list.GetItemCount(), sl.RemoveHead()); m_list.SetItemData(n, (DWORD_PTR)tmp); if (!sl.IsEmpty()) { REFERENCE_TIME rt = 0; if (1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0) { DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt); CString str; str.Format(_T("[%02d:%02d:%02d]"), hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds); m_list.SetItemText(n, 1, str); } } } UpdateColumnsSizes(); } }
int CHgzComboBox::GetWindowHex(unsigned char * pHex) { CString str; GetWindowText(str); CStringArray arr; hgzExtractSubStrings(arr, str, _T(" +")); unsigned int *pi = new unsigned int[arr.GetSize()]; int i; for (i = 0; i < arr.GetSize(); i++) { _stscanf_s(arr[i], _T("%x"), pi + i); pHex[i] = (unsigned char)pi[i]; // 将输入序列的高字节存储在 Bytes 中的低地址中。(Big-Endian) } delete [] pi; return i; }
UUID UUIDFromString(LPCTSTR const &String) { UUID output; // Work around VC++ missing support for "hhX" int tail8[8]; int result = _stscanf_s(String, _T("%8X-%4hX-%4hX-%2X%2X-%2X%2X%2X%2X%2X%2X"), &output.Data1, &output.Data2, &output.Data3, &tail8[0], &tail8[1], &tail8[2], &tail8[3], &tail8[4], &tail8[5], &tail8[6], &tail8[7]); if (result < 0) FAIL(_T("Converting from string to GUID failed with error code %d"), errno); if (result < 11) FAIL(_T("Converting from string to GUID failed strating from %d"), result + 1); // Work around VC++ missing support for "hhX" for (int i = 0; i < 8; i++) output.Data4[i] = tail8[i]; return output; }
UUID UUIDFromString(TString const &Str) { Cardinal128 Value; // Work around VC++ missing support for "hhX" int tail8[8]; int result = _stscanf_s(Str.c_str(), _T("%8X-%4hX-%4hX-%2X%2X-%2X%2X%2X%2X%2X%2X"), &Value.U32[0], &Value.U16[2], &Value.U16[3], &tail8[0], &tail8[1], &tail8[2], &tail8[3], &tail8[4], &tail8[5], &tail8[6], &tail8[7]); if (result < 0) FAIL(_T("Converting from string to GUID failed with error code %d"), errno); if (result < 11) FAIL(_T("Converting from string to GUID failed strating from %d"), result + 1); // Work around VC++ missing support for "hhX" for (int i = 0; i < 8; i++) Value.U8[8+i] = tail8[i]; return (UUID &)Value; }
int CHgzComboBox::GetWindowDec(int *pDec) { CString str; GetWindowText(str); CStringArray arr; hgzExtractSubStrings(arr, str, _T(" +")); int *pi = new int[arr.GetSize()]; int i; for (i = 0; i < arr.GetSize(); i++) { _stscanf_s(arr[i], _T("%d"), pi + i); pDec[i] = pi[i]; // 将输入序列的高字节存储在 Bytes 中的低地址中。(Big-Endian) } delete [] pi; return i; }
BOOL CSummInfo::IncrRevNum() { ULONG count; #if _MSC_VER < 1400 _stscanf((LPCTSTR)GetRevNum(), _T("%lu"), &count); #else _stscanf_s((LPCTSTR)GetRevNum(), _T("%lu"), &count); #endif count++; TCHAR buff[20]; #if _MSC_VER < 1400 _stprintf(buff, _T("%lu"), min(20, count)); #else _stprintf_s(buff, 20, _T("%lu"), count); #endif return m_pSection->Set(PIDSI_REVNUMBER, (void*)buff, VT_LPSTR); }
// 创建UDP的SOCKET套接字并设置 //************************************ // Method: OnCreateUDPSocket // FullName: CTabUartToUdp::OnCreateUDPSocket // Access: private // Returns: void // Qualifier: // Parameter: void //************************************ void CTabUartToUdp::OnCreateUDPSocket(void) { CString str = _T(""); GetDlgItem(IDC_EDIT_PORT_REC)->GetWindowText(str); // 0x9002 _stscanf_s(str,_T("%x"), &m_uiRecPort); m_UdpSocket = socket(AF_INET, SOCK_DGRAM, 0); m_RecvAddr.sin_family = AF_INET; // 填充套接字地址结构 m_RecvAddr.sin_port = htons(static_cast<unsigned short>(m_uiRecPort)); m_RecvAddr.sin_addr.S_un.S_addr = INADDR_ANY; int iReturn = bind(m_UdpSocket, reinterpret_cast<sockaddr*>(&m_RecvAddr), sizeof(m_RecvAddr)); // 绑定本地地址 listen(m_UdpSocket, 2); WSAAsyncSelect(m_UdpSocket, this->m_hWnd, WM_UARTTOUDPSOCKET, FD_READ); // 设置异步套接字 if (iReturn == SOCKET_ERROR) { str = _T("串口转UDP端口创建失败!"); m_pLogFile->OnWriteLogFile(_T("CTabUartToUdp::OnOpenCom"), str, ErrorStatus); AfxMessageBox(str); } else { m_pLogFile->OnWriteLogFile(_T("CTabUartToUdp::OnOpenCom"), _T("串口转UDP端口创建成功!"), SuccessStatus); int nSendBuf = UartToUDPBufSize; iReturn = setsockopt(m_UdpSocket, SOL_SOCKET, SO_SNDBUF, reinterpret_cast<const char *>(&nSendBuf), sizeof(int)); if (iReturn == SOCKET_ERROR) { str = _T("UDP转串口端口设置发送缓冲区设置失败!"); AfxMessageBox(str); m_pLogFile->OnWriteLogFile(_T("CTabUartToUdp::OnOpenCom"), str, ErrorStatus); } int nRecvBuf = UartToUDPBufSize; iReturn = setsockopt(m_UdpSocket, SOL_SOCKET, SO_RCVBUF, reinterpret_cast<const char *>(&nRecvBuf), sizeof(int)); if (iReturn == SOCKET_ERROR) { str = _T("UDP转串口端口设置接收缓冲区设置失败!"); AfxMessageBox(str); m_pLogFile->OnWriteLogFile(_T("CTabUartToUdp::OnOpenCom"), str, ErrorStatus); } // 避免端口阻塞 OnAvoidIOBlock(m_UdpSocket); } }
// 打开 //************************************ // Method: OnOpen // FullName: CTabSample::OnOpen // Access: private // Returns: void // Qualifier: // Parameter: void //************************************ void CTabSample::OnOpen(void) { CString str = _T(""); GetDlgItem(IDC_EDIT_SENDPORT)->GetWindowText(str); _stscanf_s(str,_T("%x"), &m_uiSendPort); m_oThreadManage.m_oHeartBeatThread.m_uiSendPort = m_uiSendPort; m_oThreadManage.m_oHeadFrameSocket.m_uiSendPort = m_uiSendPort; m_oThreadManage.m_oTailFrameSocket.m_uiSendPort = m_uiSendPort; m_oThreadManage.m_oTailTimeFrameSocket.m_uiSendPort = m_uiSendPort; m_oThreadManage.m_oSysTimeSocket.m_uiSendPort = m_uiSendPort; m_oThreadManage.m_oADCSetSocket.m_uiSendPort = m_uiSendPort; m_oThreadManage.m_oADCDataRecThread.m_uiSendPort = m_uiSendPort; m_oThreadManage.m_oIPSetSocket.m_uiSendPort = m_uiSendPort; GetDlgItem(IDC_EDIT_SENDPORT)->EnableWindow(FALSE); GetDlgItem(IDC_CHECK_HEARTBEAT)->EnableWindow(TRUE); m_oThreadManage.OnOpen(); }
BOOL GetPorts(Port p[], int &count, BOOL fGetCountOnly) { BOOL fRet = FALSE; TCHAR buf[65535]; unsigned long dwChars = QueryDosDevice(NULL, buf, sizeof(buf)); int x = 0; if ( dwChars == 0 ) { TRACE(_T("Error with querydosdevice: (%ld)\n"), GetLastError()); fRet = FALSE; } else { TCHAR *ptr = buf; int port; while (dwChars) { if ( _stscanf_s(ptr, "COM%d", &port) == 1 ) { if ( ! fGetCountOnly ) { p[x].iPort = port; p[x].fHasRA = FALSE; } x++; } TCHAR *temp_ptr = strchr(ptr,0); dwChars -= (DWORD)((temp_ptr-ptr)/sizeof(TCHAR)+1); ptr = temp_ptr+1; } // while fRet = TRUE; if ( fGetCountOnly ) { count = x; } } return fRet; }
// 打开串口 //************************************ // Method: OnOpenCom // FullName: CTabUartToUdp::OnOpenCom // Access: public // Returns: void // Qualifier: // Parameter: void //************************************ void CTabUartToUdp::OnOpenCom(void) { int iPort = 0; int iBaud = 0; CString str = _T(""); CString strIP = _T(""); int iSendPort = 0; OnCloseCom(); UpdateData(TRUE); iPort = OnGetSerialPortCom(); iBaud = OnGetSerialPortBaud(); // @@@@@@@@ cxm 2011.11.25 提供给用户暂不提供mscomm控件的串口功能 // m_ctrlMSComm1.put_CommPort(static_cast<short>(iPort)); // str.Format(_T("%d,n,8,1"), iBaud); // m_ctrlMSComm1.put_Settings(str); // // if(!m_ctrlMSComm1.get_PortOpen()) // { // m_ctrlMSComm1.put_PortOpen(TRUE); // m_pLogFile->OnWriteLogFile(_T("CTabUartToUdp::OnOpenCom"), _T("成功打开串口!"), SuccessStatus); // m_uiSerialPortComCurSel = m_comboSerialPortCom.GetCurSel(); // m_uiSerialPortBaudCurSel = m_comboSerialPortBaud.GetCurSel(); // OnCreateUDPSocket(); // ControlDisable(); // AfxMessageBox(_T("Open Serial Port Successful!")); // } GetDlgItem(IDC_EDIT_PORT_UARTTOUDP)->GetWindowText(str); _stscanf_s(str, _T("%x"), &iSendPort); GetDlgItem(IDC_IPADDRESS_UARTTOUDP)->GetWindowText(str); strIP = str; m_SendToAddr.sin_family = AF_INET; // 填充套接字地址结构 m_SendToAddr.sin_port = htons(static_cast<unsigned short>(iSendPort)); m_SendToAddr.sin_addr.S_un.S_addr = inet_addr(ConvertCStringToConstCharPointer(strIP)); KillTimer(TabUartToUdpRecTimerNb); SetTimer(TabUartToUdpRecTimerNb, TabUartToUdpRecTimerSet, NULL); }
//************************************************************************** void CBCGPRibbonComboBox::DropDownList () { ASSERT_VALID (this); if (IsDisabled ()) { return; } if (m_pWndEdit->GetSafeHwnd () != NULL && !m_pWndEdit->IsWindowVisible ()) { return; } if (CBCGPPopupMenu::GetActiveMenu () != NULL) { if (CBCGPPopupMenu::GetActiveMenu ()->GetMenuBar () != m_pParentMenu) { CBCGPPopupMenu::GetActiveMenu ()->SendMessage (WM_CLOSE); return; } } CBCGPBaseRibbonElement::OnShowPopupMenu (); if (m_bIsCalculator) { if (m_pCalcPopup != NULL) { m_pCalcPopup->SendMessage (WM_CLOSE); m_pCalcPopup = NULL; SetDroppedDown(NULL); } else { if (CBCGPPopupMenu::GetActiveMenu () != NULL) { if (CBCGPPopupMenu::GetActiveMenu ()->GetMenuBar () != m_pParentMenu) { CBCGPPopupMenu::GetActiveMenu ()->SendMessage (WM_CLOSE); return; } } CBCGPBaseRibbonElement::OnShowPopupMenu (); double dblValue = 0.; CString strValue = GetEditText (); if (!strValue.IsEmpty ()) { strValue.Replace (_T(','), _T('.')); #if _MSC_VER < 1400 _stscanf (strValue, _T("%lf"), &dblValue); #else _stscanf_s (strValue, _T("%lf"), &dblValue); #endif } m_pCalcPopup = new CBCGPCalculatorPopup (dblValue, 0, this); m_pCalcPopup->m_bAutoDestroyParent = FALSE; m_pCalcPopup->SetParentRibbonElement (this); CBCGPCalculator* pCalc = DYNAMIC_DOWNCAST (CBCGPCalculator, m_pCalcPopup->GetMenuBar()); if (pCalc != NULL) { ASSERT_VALID (pCalc); if (!m_lstCalcAdditionalCommands.IsEmpty ()) { pCalc->SetAdditionalCommands (m_lstCalcAdditionalCommands); } if (!m_lstCalcExtCommands.IsEmpty ()) { pCalc->SetExtendedCommands (m_lstCalcExtCommands); } if (!m_strCalcDisplayFormat.IsEmpty()) { pCalc->SetDisplayFormat(m_strCalcDisplayFormat); } } CRect rectWindow; m_pWndEdit->GetWindowRect (rectWindow); if (!m_pCalcPopup->Create (m_pWndEdit, rectWindow.left - m_szMargin.cx, rectWindow.bottom + m_szMargin.cy, NULL, TRUE)) { ASSERT (FALSE); m_pCalcPopup = NULL; } else { SetDroppedDown(m_pCalcPopup); m_pCalcPopup->GetMenuBar()->SetFocus (); CRect rect; m_pCalcPopup->GetWindowRect (&rect); m_pCalcPopup->UpdateShadow (&rect); } } return; } CBCGPDropDownList* pList = new CBCGPDropDownList (this); pList->SetParentRibbonElement (this); int i = 0; for (POSITION pos = m_lstItems.GetHeadPosition (); pos != NULL; i++) { CString strItem = m_lstItems.GetNext (pos); pList->AddString (strItem); if (m_bHasEditBox && strItem == m_strEdit) { m_iSelIndex = i; } } pList->SetCurSel (m_iSelIndex); pList->SetMaxHeight (m_nDropDownHeight); pList->SetMinWidth (m_rect.Width ()); CWnd* pWndParent = GetParentWnd (); if (pWndParent == NULL) { ASSERT (FALSE); return; } const BOOL bIsRTL = (pWndParent->GetExStyle () & WS_EX_LAYOUTRTL); CRect rect = m_rectCommand.IsRectEmpty () ? m_rect : m_rectCommand; pWndParent->ClientToScreen (&rect); SetDroppedDown (pList); if (m_pParent != NULL) { ASSERT_VALID (m_pParent); m_pParent->HighlightPanel (NULL, CPoint (-1, -1)); } if (m_pWndEdit->GetSafeHwnd () != NULL) { m_pWndEdit->SetFocus (); m_pWndEdit->SetSel (0, -1); } if (m_bResizeDropDownList) { pList->EnableVertResize (2 * globalData.GetTextHeight ()); } pList->Track (CPoint ( bIsRTL ? rect.right : rect.left, rect.bottom), pWndParent->GetOwner ()); }
////////////////////////////////////////////////////////////////////////// //Purpose: GetUserDefaultUILanguage for downlevel platforms (Win9x, NT4). //Input: szDllName - the string resource dll name to search. Ex: ToolUI.dll //Output: TCHAR *szPathOut - filled with absolute path to dll, if found. // size_t sizeInCharacters - buffer size in characters //Returns: Success - HMODULE of found dll, Failure - NULL ////////////////////////////////////////////////////////////////////////// HRESULT GetUserDefaultUILanguageLegacyCompat(LANGID* pLangid) { HRESULT hr=E_FAIL; if (pLangid == NULL) { return E_POINTER; } PFNGETUSERDEFAULTUILANGUAGE pfnGetUserDefaultUILanguage; HINSTANCE hKernel32 = ::GetModuleHandle(_T("kernel32.dll")); pfnGetUserDefaultUILanguage = (PFNGETUSERDEFAULTUILANGUAGE)::GetProcAddress(hKernel32, "GetUserDefaultUILanguage"); if(pfnGetUserDefaultUILanguage != NULL) { *pLangid = pfnGetUserDefaultUILanguage(); hr = S_OK; } else { // We're not on an MUI-capable system. OSVERSIONINFO version; memset(&version, 0, sizeof(version)); version.dwOSVersionInfoSize = sizeof(version); ::GetVersionEx(&version); if( version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { // We're on Windows 9x, so look in the registry for the UI language HKEY hKey = NULL; LONG nResult = ::RegOpenKeyEx(HKEY_CURRENT_USER, _T( "Control Panel\\Desktop\\ResourceLocale" ), 0, KEY_READ, &hKey); if (nResult == ERROR_SUCCESS) { DWORD dwType; TCHAR szValue[16]; ULONG nBytes = sizeof( szValue ); nResult = ::RegQueryValueEx(hKey, NULL, NULL, &dwType, LPBYTE( szValue ), &nBytes ); if ((nResult == ERROR_SUCCESS) && (dwType == REG_SZ)) { DWORD dwLangID; int nFields = _stscanf_s( szValue, _T( "%x" ), &dwLangID ); if( nFields == 1 ) { *pLangid = LANGID( dwLangID ); hr = S_OK; } } ::RegCloseKey(hKey); } } else { // We're on NT 4. The UI language is the same as the language of the version // resource in ntdll.dll HMODULE hNTDLL = ::GetModuleHandle( _T( "ntdll.dll" ) ); if (hNTDLL != NULL) { *pLangid = 0; ::EnumResourceLanguages( hNTDLL, RT_VERSION, MAKEINTRESOURCE( 1 ), _EnumResLangProc, reinterpret_cast< LONG_PTR >( pLangid ) ); if (*pLangid != 0) { hr = S_OK; } } } } return hr; }
void CDnsSettingDlg::UpdateRuleList() { LSTATUS status = ERROR_SUCCESS; DWORD cbSize = 0; HKEY hKey = NULL; TCHAR buffer[256]={0}; DWORD i; BOOL bOtherAccess = 0; status = RegCreateKey( (static_cast<CCactiWallApp*>(AfxGetApp()))->m_hKey, _T("dnsrules"), &hKey ); if( status != ERROR_SUCCESS) { AfxMessageBox(_T("获取DNS规则失败(001)"),MB_OK | MB_ICONWARNING ); return; } cbSize = sizeof( buffer ); status = RegQueryValueEx( hKey, _T("other_access"), NULL, NULL, (LPBYTE)buffer, &cbSize ); if( status != ERROR_SUCCESS ) { bOtherAccess = TRUE; AfxMessageBox(_T("读取DNS信息失败(otheraccess)")); } ASSERT( cbSize == sizeof(DWORD)); if( *(PDWORD)buffer == 0 ) bOtherAccess = FALSE; else bOtherAccess = TRUE; m_RuleList.DeleteAllItems(); for( i = 0,cbSize = sizeof( buffer); ERROR_SUCCESS == RegEnumKey( hKey,i,buffer,cbSize / sizeof(TCHAR)); i++) { HKEY hRuleKey = NULL; DWORD crcName = 0; DWORD rule = 0; _stscanf_s( buffer,_T("%x"),&crcName ); status = RegOpenKey( hKey,buffer,&hRuleKey ); if( status != ERROR_SUCCESS) { AfxMessageBox(_T("获取DNS规则失败(002)"),MB_OK | MB_ICONWARNING ); break; } cbSize = sizeof( buffer); status = RegQueryValueEx( hRuleKey, _T("name"), NULL, NULL, (LPBYTE)buffer, &cbSize ); if( status != ERROR_SUCCESS) { AfxMessageBox(_T("获取进程规则失败(003)"),MB_OK | MB_ICONWARNING ); CloseHandle( hRuleKey ); break; } cbSize = sizeof( DWORD); status = RegQueryValueEx( hRuleKey, _T("rule"), NULL, NULL, (LPBYTE)&rule, &cbSize ); ASSERT(cbSize==sizeof(DWORD)); if( status != ERROR_SUCCESS) { AfxMessageBox(_T("获取DNS规则失败(004)"),MB_OK | MB_ICONWARNING ); CloseHandle( hRuleKey ); break; } m_RuleList.InsertItem( i,buffer ); if( rule == 1 ) m_RuleList.SetItemText( i,1,_T("允许")); else m_RuleList.SetItemText( i,1,_T("禁止")); m_RuleList.SetItemData( i,crcName ); CloseHandle(hRuleKey ); cbSize = sizeof( buffer); } CButton *pBtn = (CButton *)GetDlgItem( IDC_RADIO_ALLOW ); pBtn->SetCheck( bOtherAccess ); pBtn = (CButton *)GetDlgItem( IDC_RADIO_DENY ); pBtn->SetCheck( !bOtherAccess ); pBtn = (CButton *)GetDlgItem( IDC_BUTTON_EDITRULE ); pBtn->EnableWindow( FALSE ); pBtn = (CButton *)GetDlgItem( IDC_BUTTON_DELRULE ); pBtn->EnableWindow( FALSE ); if( hKey != NULL) CloseHandle( hKey ); }
HINT APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, HINT nCmdShow) { INSTANCE_START //g_Mutex =::CreateMutex(NULL, TRUE, APP_CLASSNAME_TEST1); HINT nParam = 0; _stscanf_s(GetCommandLine(),_T("%d"),&nParam); nCmdShow = PARAM_SHOW_CMD(nParam); // HMI 初始化 if( !UIDevInit( SCREEN_WIDTH, SCREEN_HEIGHT, hInstance, const_cast<HCHAR*>(STR_PROCESSNAME_IPOD), const_cast<HCHAR*>(STR_PROCESSNAME_IPOD), 0,g_hIpodWnd) ) { return 0; } ::ShowWindow(g_hIpodWnd, nCmdShow); ::UpdateWindow(g_hIpodWnd); SetOwnerProc(MyProc); //注册回调 CEIPC_Regist(IPC_ID_IPOD, g_hIpodWnd, RecvIPCEvent); GetRESingleton()->ReLoadFont(FONT_MSYH_TTF); GetRESingleton()->ReLoadFont(FONT_QUARTZ_REGULAR_TTF); InitPopupSurface(GetHMIPath(_T("")).c_str()); // 获取配置信息 if( NULL != KCLastMemory::GetInstance() ) { // 读取SETUP配置文件 KCLastMemory::GetInstance()->GetSetupMemory(g_SetupSetting); } else { KCLastMemory::GetSetupMemoryDefault(g_SetupSetting); } #ifdef WINCE //::CeSetThreadPriority(GetCurrentThread(),/*251*/224); #endif //消息循环 MSG msg; int n = 0; s_pSong = new sSongInfo; memset(s_pSong,0,sizeof(sSongInfo)); g_pDlg = new CIpodDlg; if(g_pDlg != NULL) { g_pDlg->Create(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GetScreen()); g_pDlg->SetTransType(0); g_pDlg->ClearUpdateRect(); g_pDlg->ShowWindow(); g_pDlg->UpdateWindow(); } g_pDlg->SetMyHandle(g_hIpodWnd); g_Handle[0] = CreateEvent( NULL, false, FALSE, TEXT("_IPOD_UAC_CNNT_")); ////g_hIpodInsert = CreateEvent( NULL, false, FALSE, TEXT("_IPOD_UAC_CNNT_")); //if(g_Handle[0] == NULL) //{ // IPODDEBEGINFO(L"CreateEvent:_IPOD_UAC_CNNT_:Lasterror = %d",GetLastError()); //} //else //{ // IPODDEBEGINFO(L"CreateEvent:_IPOD_UAC_CNNT_:Sucess"); //} g_Handle[1] = CreateEvent( NULL, FALSE, FALSE, TEXT("_IPOD_UAC_EXIT_")); ////g_hIpodUnplug = CreateEvent( NULL, FALSE, FALSE, TEXT("_IPOD_UAC_EXIT_")); //if(g_Handle[1] == NULL) //{ // IPODDEBEGINFO(L"CreateEvent:_IPOD_UAC_EXIT_:Lasterror = %d",GetLastError()); //} //else //{ // IPODDEBEGINFO(L"CreateEvent:_IPOD_UAC_EXIT_:Sucess "); //} g_hMonitorIpodEventThread = CreateThread(NULL,0,((LPTHREAD_START_ROUTINE)MonitorIpodEventThread),NULL,0,NULL); if(g_hMonitorIpodEventThread == NULL) { IPODDEBEGINFO(L"CreateThread::MonitorIpodEventThread: error = %d",GetLastError()); } g_pDlg->ConectAndStartPlay(); /*UINT nretTime = SetTimer(g_hWnd,100,1000,UpDataMusicInfo); if(nretTime == 0) { IPODDEBEGINFO(L"SetTimer error: %d",GetLastError()); }*/ while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } // 注销IPC CEIPC_UnRegist(); if( ::IsWindow(g_hIpodWnd) ) { ::DestroyWindow(g_hIpodWnd); } UnInitPopupSurface(); //释放 UIDevRelease(); IPODDEBEGINFO(L"IPOD Quit"); g_bContiue = false; DWORD DD = WaitForSingleObject(g_hMonitorIpodEventThread,3000); switch(DD) { case WAIT_OBJECT_0: { } break; case WAIT_TIMEOUT: { } break; } CloseHandle(g_Handle[0]); CloseHandle(g_Handle[1]); CloseHandle(g_hMonitorIpodEventThread); // 通知Manage进程退出 HWND hServerWnd = ::FindWindow(STR_PROCESSNAME_MANAGE, STR_PROCESSNAME_MANAGE); if (hServerWnd) { ::PostMessage(hServerWnd, VWM_SERVER_SRC_CLOSE, IPC_ID_IPOD, NULL); } return 0; }
bool CFloatEdit::GetFloat(float& f) { CString s; GetWindowText(s); return(_stscanf_s(s, _T("%f"), &f) == 1); }
bool CHexEdit::GetDWORD(DWORD& dw) { CString s; GetWindowText(s); return(_stscanf_s(s, _T("%x"), &dw) == 1); }
BOOL CSubtitleUpDlg::OnInitDialog() { __super::OnInitDialog(); m_progress.SetParent(&m_status); m_progress.UpdateWindow(); int n = 0, curPos = 0; CArray<int> columnWidth; CString strColumnWidth(AfxGetApp()->GetProfileString(IDS_R_DLG_SUBTITLEUP, IDS_RS_DLG_SUBTITLEUP_COLWIDTH)); CString token(strColumnWidth.Tokenize(_T(","), curPos)); while (!token.IsEmpty()) { if (_stscanf_s(token, L"%d", &n) == 1) { columnWidth.Add(n); token = strColumnWidth.Tokenize(_T(","), curPos); } else { throw 1; } } m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP); m_list.SetImageList(&m_pMainFrame->m_pSubtitlesProviders->GetImageList(), LVSIL_SMALL); if (columnWidth.GetCount() != COL_TOTAL_COLUMNS) { // default sizes columnWidth.RemoveAll(); columnWidth.Add(120); columnWidth.Add(75); columnWidth.Add(250); } m_list.InsertColumn(COL_PROVIDER, ResStr(IDS_SUBDL_DLG_PROVIDER_COL), LVCFMT_LEFT, columnWidth[COL_PROVIDER]); m_list.InsertColumn(COL_USERNAME, ResStr(IDS_SUBUL_DLG_USERNAME_COL), LVCFMT_LEFT, columnWidth[COL_USERNAME]); m_list.InsertColumn(COL_STATUS, ResStr(IDS_SUBUL_DLG_STATUS_COL), LVCFMT_LEFT, columnWidth[COL_STATUS]); m_list.SetRedraw(FALSE); m_list.DeleteAllItems(); int i = 0; for (const auto& iter : m_pMainFrame->m_pSubtitlesProviders->Providers()) { if (iter->Flags(SPF_UPLOAD)) { int iItem = m_list.InsertItem((int)i++, CString(iter->Name().c_str()), iter->GetIconIndex()); m_list.SetItemText(iItem, COL_USERNAME, UTF8To16(iter->UserName().c_str())); m_list.SetItemText(iItem, COL_STATUS, ResStr(IDS_SUBUL_DLG_STATUS_READY)); m_list.SetCheck(iItem, iter->Enabled(SPF_UPLOAD)); m_list.SetItemData(iItem, (DWORD_PTR)(iter.get())); } } m_list.SetRedraw(TRUE); m_list.Invalidate(); m_list.UpdateWindow(); UpdateData(FALSE); AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT); AddAnchor(IDC_BUTTON1, BOTTOM_RIGHT); AddAnchor(IDC_BUTTON2, BOTTOM_RIGHT); AddAnchor(IDOK, BOTTOM_RIGHT); AddAnchor(IDC_STATUSBAR, BOTTOM_LEFT, BOTTOM_RIGHT); const CSize s(500, 250); SetMinTrackSize(s); EnableSaveRestore(IDS_R_DLG_SUBTITLEUP, TRUE); return TRUE; }
INT_PTR CALLBACK ControlDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { // These will be garbage in WM_INITDIALOG, but we're not using them there anyway, so who cares LPBLENDSETTINGS settings = (LPBLENDSETTINGS)GetWindowLongPtr(hDlg, GWLP_USERDATA); LPBLENDRESULT results = (LPBLENDRESULT)(settings + 1); HWND *imgWindows = (HWND*)(results + 1); switch (uMsg) { case WM_INITDIALOG: { // Check the serial radio button by default HWND hwndSerialRadioBtn = GetDlgItem(hDlg, IDC_RADIO_SERIAL); SendMessage(hwndSerialRadioBtn, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); // Allocate space for BLENDSETTINGS, BLENDRESULT and the HWNDs to display the images (one for the image, one for the kernel, and one for the blend result) LPVOID userData = (LPVOID)malloc(sizeof(BLENDSETTINGS) + sizeof(BLENDRESULT) + sizeof(HWND) * 3); // Allocate space for the file names LPBLENDSETTINGS blendSettings = (LPBLENDSETTINGS)userData; blendSettings->lpszImageFile = (TCHAR*)malloc(sizeof(TCHAR) * FILENAME_SIZE); blendSettings->lpszKernelFile = (TCHAR*)malloc(sizeof(TCHAR) * FILENAME_SIZE); LPBLENDRESULT blendResult = (LPBLENDRESULT)(blendSettings + 1); blendResult->hwndNotifyWindow = hDlg; blendResult->bufs[BLENDRESULT_IMAGE].pixels = NULL; blendResult->bufs[BLENDRESULT_KERNEL].pixels = NULL; blendResult->bufs[BLENDRESULT_BLENDED].pixels = NULL; // Initialise the display windows HWND *displayWindows = (HWND*)(blendResult + 1); displayWindows[0] = (HWND)INVALID_HANDLE_VALUE; displayWindows[1] = (HWND)INVALID_HANDLE_VALUE; displayWindows[2] = (HWND)INVALID_HANDLE_VALUE; SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)userData); return TRUE; } case WM_BLENDFINISHED: { DWORD dwError = wParam; switch (dwError) { case BLEND_GENERAL_FAILURE: MessageBox(NULL, TEXT("The images could not be blended for some reason. Please try again later."), TEXT("General Failure"), MB_ICONERROR); return TRUE; case BLEND_KERNEL_2LARGE: MessageBox(NULL, TEXT("The kernel image was too large. Its maximum dimensions must be those of the image to blend. Please select another kernel."), TEXT("Kernel Too Large"), MB_ICONERROR); return TRUE; } // Set the amount of time taken HWND hwndTimeMessage = GetDlgItem(hDlg, IDC_PROC_TIME_TXT); TCHAR buf[128] = { 0 }; _sntprintf_s(buf, _countof(buf), TEXT("Processing Time (ms): %.3f"), results->processTime); SetWindowText(hwndTimeMessage, buf); // Re-enable the start button EnableWindow(GetDlgItem(hDlg, IDSTART), TRUE); // Create the windows if we haven't already if (imgWindows[0] == (HWND)INVALID_HANDLE_VALUE) { HINSTANCE hInst = (HINSTANCE)GetWindowLongPtr(hDlg, GWLP_HINSTANCE); InitImageWindow(&imgWindows[BLENDRESULT_IMAGE], hDlg, hInst, TEXT("Original Image")); InitImageWindow(&imgWindows[BLENDRESULT_KERNEL], hDlg, hInst, TEXT("Kernel Image")); InitImageWindow(&imgWindows[BLENDRESULT_BLENDED], hDlg, hInst, TEXT("Blended Image")); for (int i = 0; i < 3; i++) { ShowWindow(imgWindows[i], SW_SHOW); } } for (int i = 0; i < 3; i++) { LPOFFSCREENBUFFER oldBuf = (LPOFFSCREENBUFFER)GetWindowLongPtr(imgWindows[i], IMG_GWLP_OFFSCREENBUFFER); LPOFFSCREENBUFFER newBuf = &results->bufs[i]; // Set the new pixels DWORD newSize = (DWORD)(DIB_WIDTHBYTES(newBuf->width * newBuf->bytesPerPixel * 8) * newBuf->height); oldBuf->pixels = realloc(oldBuf->pixels, newSize); memcpy(oldBuf->pixels, newBuf->pixels, newSize); // Copy over the new bitmap info memcpy(&oldBuf->info, &newBuf->info, sizeof(BITMAPINFO)); oldBuf->height = newBuf->height; oldBuf->width = newBuf->width; SetWindowPos(imgWindows[i], 0, 0, 0, newBuf->width, newBuf->height, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); UpdateWindow(imgWindows[i]); } return TRUE; } case WM_CLOSE: /* there are more things to go here, */ DestroyWindow(hDlg); return TRUE; case WM_DESTROY: // TODO: Destroy the child windows and tell them to free any memory they have // Free the settings object free(settings->lpszImageFile); free(settings->lpszKernelFile); // settings is actually the pointer to the whole buffer, so we need to free it last free(settings); PostQuitMessage(0); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_IMG_BROWSE: ChooseFile(hDlg, GetDlgItem(hDlg, IDC_IMAGE_EDIT)); return TRUE; case IDC_KERNEL_BROWSE: ChooseFile(hDlg, GetDlgItem(hDlg, IDC_KERNEL_EDIT)); return TRUE; case IDSTART: { TCHAR szBlendFactor[64] = { 0 }; BYTE blendType; BOOL bIsSerial = SendMessage(GetDlgItem(hDlg, IDC_RADIO_SERIAL), BM_GETCHECK, 0, 0) == BST_CHECKED; BOOL bIsMMX = SendMessage(GetDlgItem(hDlg, IDC_RADIO_MMX), BM_GETCHECK, 0, 0) == BST_CHECKED; // Try to get the blend factor GetWindowText(GetDlgItem(hDlg, IDC_BLEND), szBlendFactor, 64); if (_stscanf_s(szBlendFactor, TEXT("%lf"), &settings->blendFactor) != 1 || settings->blendFactor < 0 || settings->blendFactor > 1) { MessageBox(hDlg, TEXT("Blend factor must be between 0 and 1."), TEXT("Invalid Blend Factor"), MB_ICONERROR); return TRUE; } // Set the blend procedure if (bIsSerial) settings->blendType = BLEND_SERIAL; else if (bIsMMX) settings->blendType = BLEND_MMX; else settings->blendType = BLEND_SSE; // Get the file names and check to make sure they're valid GetWindowText(GetDlgItem(hDlg, IDC_IMAGE_EDIT), settings->lpszImageFile, FILENAME_SIZE); GetWindowText(GetDlgItem(hDlg, IDC_KERNEL_EDIT), settings->lpszKernelFile, FILENAME_SIZE); if (!IsValidImageFile(settings->lpszImageFile)) { MessageBox(hDlg, TEXT("Invalid image file. Please select an existing file file with one of the specified extensions."), TEXT("Invalid Image File"), MB_ICONERROR); return TRUE; } else if (!IsValidImageFile(settings->lpszKernelFile)) { MessageBox(hDlg, TEXT("Invalid kernel image file. Please select an existing file with one of the specified extensions."), TEXT("Invalid Kernel Image File"), MB_ICONERROR); return TRUE; } HWND startBtnHwnd = (HWND)lParam; EnableWindow(GetDlgItem(hDlg, IDSTART), FALSE); BlendImages(settings, results); return TRUE; } } default: return FALSE; } }