int ControllerProperty::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (BaseProperty::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here DebuggingProcessProp * process = (DebuggingProcessProp *)this->target; CString strMode; if (process->traceMode == DebuggingProcessProp::MODE_TRACE_GRAPH) strMode.SetString(L"display data"); else strMode.SetString(L"raw data"); CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("Trace Type"), strMode.GetBuffer(), _T("Specifies the trace type of the track bar")); pProp->AddOption(_T("display data")); pProp->AddOption(_T("raw data")); pProp->AllowEdit(FALSE); this->AddProperty(pProp); //pProp = new CMFCPropertyGridProperty( _T("Threshold"), (_variant_t) process->threshold, _T("Specifies the threshold for the channel circular buffer")); //this->AddProperty(pProp); return 0; }
//抽奖信息的绘制 void CLotteryDlg::_drawLotteryInfo(CDC* pDC) { pDC->SetBkMode(TRANSPARENT); CFont* pOldFont = pDC->SelectObject(&m_TitleFont); pDC->SetTextColor(RGB(255, 255, 255)); //绘制标题 CString str = L"天极传媒.上海2013迎春年会抽奖仪式---lgy"; str.SetString(m_uiInfo._title.c_str()); CSize size = pDC->GetTextExtent(str); pDC->TextOut(m_ClientRect.CenterPoint().x - size.cx/2, m_ClientRect.top + m_ClientRect.Height() / 8, str, str.GetLength()); pDC->SelectObject(pOldFont); if (m_bRollTimer) { pDC->SetTextColor(RGB(255,255,0)); pOldFont = pDC->SelectObject(&m_NormalFont); str = L"正在抽取"; int xPos = m_ClientRect.left + m_leftWidth; int yPos = m_ClientRect.bottom - m_ClientRect.Height()/10; pDC->TextOut(xPos, yPos - 5, str, str.GetLength()); xPos += pDC->GetTextExtent(str+L"123").cx; pDC->SelectObject(pOldFont); pOldFont = pDC->SelectObject(&m_KeyFont); str.SetString(m_uiInfo._curClass.c_str());//奖项 pDC->TextOut(xPos, yPos, str, str.GetLength()); str.SetString(m_uiInfo._curAward.c_str());//奖品 str = L"奖品 : " + str; pDC->TextOut(m_ClientRect.CenterPoint().x, yPos, str, str.GetLength()); pDC->SelectObject(pOldFont); } }
void CLotteryDlg::_readTheRandPartnerPic() { CString strFilePath; CPaintDC hDC(this); m_PicWidth = 0; m_PicHeight = 0; int index = 0; //一次读取生成的随机数对应的编号中的字符串 for (std::set<size_t>::iterator iter = m_RandNo.begin(); iter != m_RandNo.end(); ++iter) { strFilePath.SetString(m_PartnerPicPath[*iter].c_str());//设置读取的文件路径中的字符串 if (!_loadPic(strFilePath, &m_PartnerPicInfo[index])) { AfxMessageBox(_T("加载图片:") + strFilePath + _T("出错")); continue; } m_PartnerPicInfo[index]._width = MulDiv(m_PartnerPicInfo[index]._cx, GetDeviceCaps(hDC, LOGPIXELSX), 2540); m_PartnerPicInfo[index]._height = MulDiv(m_PartnerPicInfo[index]._cy, GetDeviceCaps(hDC, LOGPIXELSY), 2540); m_PicWidth += m_PartnerPicInfo[index]._width; if (m_PicHeight < m_PartnerPicInfo[index]._height) m_PicHeight = m_PartnerPicInfo[index]._height; index++; } m_PicWidth /= sizeof(m_PartnerPicInfo)/sizeof(m_PartnerPicInfo[0]); _calcMargin(); }
BOOL CVulEngine::_CheckDiskFreeSpace() { CString strDisk = _T("C:\\"); TCHAR szPath[MAX_PATH+1] = {0}; if( SHGetSpecialFolderPath(NULL, szPath, CSIDL_WINDOWS, FALSE) ) { strDisk.SetString(szPath, 3); } ULARGE_INTEGER lpuse = {0}; ULARGE_INTEGER lptotal = {0}; ULARGE_INTEGER lpfree = {0}; GetDiskFreeSpaceEx(strDisk,&lpuse,&lptotal,&lpfree); const int MEGA = 1024 * 1024; const int SPACE_LIMIT = MEGA * 100; if(lpfree.QuadPart<SPACE_LIMIT) { LPCTSTR szBtnClean = BkString::Get(IDS_VULFIX_5000); LPCTSTR szBtnCancel = BkString::Get(IDS_MSGBOX_CANCEL); LPCTSTR szMsgPrompt = BkString::Get(IDS_VULFIX_5001); CBkSafeMsgBox dlg; dlg.AddButton( szBtnClean, IDYES); dlg.AddButton( szBtnCancel, IDCANCEL); UINT nRet = dlg.ShowMsg(szMsgPrompt, NULL, MB_BK_CUSTOM_BUTTON|MB_ICONQUESTION, NULL); if(nRet==IDYES) { // C:\WINDOWS\\system32\\cleanmgr.exe LPCTSTR szCmd = _T("cleanmgr.exe"); ::ShellExecute(NULL,_T("open"), szCmd, NULL, NULL, SW_SHOW); return FALSE; } } return TRUE; }
void CAddTaskLinksEdit::RemoveLine(LPCTSTR lpszText) { if (NULL == lpszText || lpszText[0] == _T('\0')) return; CString strOldText; GetWindowText(strOldText); CONST TCHAR * pszURL = strOldText; CString url; CString result = _T(""); INT len = _tcslen(pszURL), i = 0, j = 0; for(i = 0, j = _tcscspn(pszURL + i, _T("\r\n")); i < len; i += j + 1, j = _tcscspn(pszURL + i, _T("\r\n"))) { if(j > 10) { url.SetString(pszURL + i, j); url = url.Trim(); if(url != _T("") && url != lpszText) result = result + url + _T("\r\n"); } } SetWindowText(result); }
BOOL _TransOfficeDir( LPCTSTR lpszSpecialFolder, CString& strPath ) { LPCTSTR szDot = _tcschr(lpszSpecialFolder, _T('.')); if(!szDot) return FALSE; ++szDot; INT nOfficeVersion = _tcstol(szDot, NULL, 10); for(int i=0; i<sizeof(_office_versions)/sizeof(_office_versions[0]); ++i) { if(nOfficeVersion!=_office_versions[i].nVerPub) continue; int nVerInternal = _office_versions[i].nVerInternal; ///> 检测是否针对visio的特殊路径 CString strSpecialFolder = lpszSpecialFolder; strSpecialFolder.MakeLower(); if ( -1 != strSpecialFolder.Find( _T("visio") ) ) { return _TransVisioDir( nVerInternal, strPath ); } CString strSubKey; CString strName; strName.SetString(lpszSpecialFolder, (int)(szDot-lpszSpecialFolder-1)); strSubKey.Format(_T("SOFTWARE\\Microsoft\\Office\\%d.0\\Common\\InstallRoot"), nVerInternal); return ReadRegString(HKEY_LOCAL_MACHINE, strSubKey, _T("Path"), strPath); } return FALSE; }
// 分析出下载的 hostname, query path, 以及下载的文件名 BOOL SplitDownloadUrl( LPCTSTR szUrl, CString &strHostname, CString &strPath, CString &strFilename ) { static LPCTSTR strProtocolHttp = _T("http://"); static LPCTSTR strProtocolHttps = _T("https://"); LPCTSTR p = NULL; if( _tcsnicmp(szUrl, strProtocolHttp, _tcslen(strProtocolHttp))==0 ) p = szUrl + _tcslen( strProtocolHttp ); else if( _tcsnicmp(szUrl, strProtocolHttps, _tcslen(strProtocolHttps))==0 ) p = szUrl + _tcslen( strProtocolHttps ); if(p) { LPCTSTR pslash = _tcschr(p, _T('/')); if( pslash ) { LPCTSTR pslashRight = _tcsrchr(pslash, _T('/') ); if(pslashRight) { strHostname.SetString( p, (int)(pslash-p) ); strPath = pslash; strFilename = pslashRight+1; return TRUE; } } } return FALSE; }
/*static*/ void CRtsSettingsWizDlg::UpdateScrlToolTip(CWnd* pParentWnd, CToolTipCtrl* pToolTips, UINT idFrom) { // Grab the string with that res ID CString csTip; if (! pToolTips) return; // If the string resource DNE if (! csTip.LoadString(idFrom)) { csTip.SetString(_T("")); } else { // Remove up to first new line int iOffset = csTip.Find(_T("\n")); if (iOffset < 0) { csTip.SetString(_T("")); } else { iOffset = csTip.GetLength() - (iOffset + 1); csTip.SetString( csTip.Right(iOffset) ); // Remove after second new line iOffset = csTip.Find(_T("\n")); if (iOffset >= 0) { csTip.SetString( csTip.Left(iOffset) ); } } } // Now add in the current value char cCurValue[500]; _itot(((CSliderCtrl*)pParentWnd->GetDlgItem(idFrom))->GetPos(), cCurValue, 10); csTip += _T(" ("); csTip += cCurValue; csTip += _T(")"); // Now insert the new text pToolTips->UpdateTipText(csTip, pParentWnd->GetDlgItem(idFrom)); pToolTips->Update(); }
CString CSZCommandLine::FindSubCommand(LPCTSTR lpszCmdLine, LPCWSTR* lppszSubCmdLine) { if (lppszSubCmdLine) *lppszSubCmdLine = lpszCmdLine; if (!lpszCmdLine) return _T(""); // trim white space while (*lpszCmdLine) { if (!IsWhiteSpace(*lpszCmdLine)) break; ++lpszCmdLine; } // find first word LPCWSTR lpNextWord = lpszCmdLine; while (*lpNextWord) { if (!IsAlpha(*lpNextWord)) break; ++lpNextWord; } // no word if (lpNextWord == lpszCmdLine) return _T(""); // get subcommand CString strSubCommand; strSubCommand.SetString(lpszCmdLine, int(lpNextWord - lpszCmdLine)); // trim white space while (*lpNextWord) { if (!IsWhiteSpace(*lpNextWord)) break; ++lpNextWord; } // return command line for sub command if (lppszSubCmdLine) *lppszSubCmdLine = lpNextWord; return strSubCommand; }
void ExpandFilePath( CString &strPath ) { int nOffset = strPath.Find( '\\' ); if( nOffset > 0 ) // 替换之前的路径 { CString strSpecial; strSpecial.SetString(strPath, nOffset); ParseSpecialFolder( strSpecial ); strPath.Format( _T("%s\\%s"),strSpecial, strPath.Mid( nOffset + 1 )); } else // ParseSpecialFolder( strPath ); }
void CEditView::GetSelectedText( CString &strResult ) const /*********************************************************/ { DWORD dwSelStart; DWORD dwSelEnd; ::SendMessage( m_hWnd, EM_GETSEL, (WPARAM)&dwSelStart, (LPARAM)&dwSelEnd ); if( dwSelEnd > dwSelStart ) { LPCTSTR lpszBuffer = LockBuffer(); strResult.SetString( lpszBuffer + dwSelStart, dwSelEnd - dwSelStart ); UnlockBuffer(); } else { strResult.Empty(); } }
BOOL _TransClsid( LPCTSTR lpszClsid, CString &strPath ) { CString strFilename; if( GetCLSIDFilename(lpszClsid, strFilename) ) { LPTSTR lpszFileName = PathFindFileName(strFilename); if(lpszFileName) { strPath.SetString(strFilename, (int)(lpszFileName-(LPCTSTR)strFilename) ); return TRUE; } } return FALSE; }
/* Low priority task checks if there's a message to be received from CONSIS and then sleeps for 200 msec */ DWORD WINAPI AsynchDialogueListenerThread(CPharmaRobot10Dlg* pdialog) { int MessageLength, MessagePSize = 114, MessageISize = 67, lisRobotItem; char buffer[MAX_CONSIS_MESSAGE_SIZE]; size_t retsize, convertedChars = 0;; pConsisRequestMessage * ppRequestMessage; PConsisPmsResponseMessage PResponseToConsis; iConsisRequestMessage * piRequestMessage; IConsisPmsResponseMessage IResponseToConsis; wchar_t description[256], wcstring[256]; for (;;) //Run forever { //Perform Message checking only if CONSIS is connected if (pdialog->Consis.ConnectionStarted == TRUE) { //Try to catch the Mutex for CONSIS Access //Protect with Mutex the CONSIS resource CSingleLock singleLock(&(pdialog->m_Mutex)); // Attempt to lock the shared resource if (singleLock.Lock(INFINITE)) { //log locking success } //clear buffer memset(buffer, 0, MAX_CONSIS_MESSAGE_SIZE); MessageLength = sizeof(buffer); pdialog->Consis.ReceiveConsisMessage(buffer, &MessageLength, 0 ); //no timeout //Check if we received a 'p' request and handle it if (buffer[0] == 'p') {//handle a 'p' message here mbstowcs_s(&convertedChars, wcstring, sizeof(pConsisRequestMessage) + 1, buffer, _TRUNCATE); wcstring[sizeof(pConsisRequestMessage)] = L'\0'; pdialog->m_listBoxMain.AddString(wcstring); ppRequestMessage = (pConsisRequestMessage *)buffer; //Extract Article ID wchar_t articleID[31]; articleID[30] = '\0'; mbstowcs_s(&retsize, articleID, sizeof(ppRequestMessage->ArticleId) + 1, ppRequestMessage->ArticleId, _TRUNCATE); //Clean leading zeroes CString cleanArticleID; cleanArticleID.SetString(articleID); cleanArticleID.TrimLeft(L' '); cleanArticleID.TrimLeft(L'0'); wsprintf(articleID,cleanArticleID.GetString()); //clean the message to CONSIS memset ((void*)&PResponseToConsis, '0',sizeof(PResponseToConsis)); memset (&(PResponseToConsis.ArticleName),' ',sizeof(PResponseToConsis.ArticleName)); //Get Description from Yarpa SQL if (pdialog->GetItemDescFromBarcode(articleID, description)) {//Got a description char DescriptionInChar[40]; wcstombs(DescriptionInChar, description, 39); sprintf(PResponseToConsis.ArticleName,DescriptionInChar); } else { sprintf(PResponseToConsis.ArticleName, "Name Missing"); } PResponseToConsis.RecordType = 'P'; memcpy(&(PResponseToConsis.ArticleId), ppRequestMessage->ArticleId, sizeof(PResponseToConsis.ArticleId)); mbstowcs_s(&convertedChars, wcstring, sizeof(PResponseToConsis) + 1, (char*)&PResponseToConsis, _TRUNCATE); wcstring[sizeof(PResponseToConsis)] = L'\0'; pdialog->m_listBoxMain.AddString(wcstring); //Send a response to CONSIS pdialog->Consis.SendConsisMessage((char*)&PResponseToConsis, MessagePSize); } //Check if we received an 'i' request and handle it if (buffer[0] == 'i') {//handle an 'i' message here mbstowcs_s(&convertedChars, wcstring, sizeof(iConsisRequestMessage) + 1, buffer, _TRUNCATE); wcstring[sizeof(iConsisRequestMessage)] = L'\0'; pdialog->m_listBoxMain.AddString(wcstring); piRequestMessage = (iConsisRequestMessage *)buffer; //Extract Article ID wchar_t articleID[31]; articleID[30] = '\0'; mbstowcs_s(&retsize, articleID, sizeof(piRequestMessage->ArticleId) + 1, piRequestMessage->ArticleId, _TRUNCATE); //Clean leading zeroes CString cleanArticleID; cleanArticleID.SetString(articleID); cleanArticleID.TrimLeft(L'0'); cleanArticleID.TrimLeft(L' '); wsprintf(articleID,cleanArticleID.GetString()); //clean the message to CONSIS //State will be set to '00' by this action memset ((void*)&IResponseToConsis, '0',sizeof(IResponseToConsis)); //check if message is '04-New article (return) '05-New article (goods receipt) type. if ((piRequestMessage->OrderState[1] == '4') || (piRequestMessage->OrderState[1] == '5')) { //Check if TA is 999 in Yarpa DB for this Barcode number if (pdialog->GetTaFromYarpaByBarcode(articleID, &lisRobotItem)) {//Got a TA from SQL if(lisRobotItem != 999) IResponseToConsis.State[1]='1';//Article may not be stored as its not a ROBOT item according to YARPA DB } else { IResponseToConsis.State[1]='1';//Article may not be stored as not found in YARPA DB } } IResponseToConsis.RecordType = 'I'; //Get Article ID from request memset((char*)(&(IResponseToConsis.ArticleId[0])), ' ', 30); memcpy(&(IResponseToConsis.ArticleId), piRequestMessage->ArticleId, sizeof(IResponseToConsis.ArticleId)); //Get Order number from request memcpy(&(IResponseToConsis.OrderNumber), piRequestMessage->OrderNumber, sizeof(IResponseToConsis.OrderNumber)); //Get Demanding Counetr ID from request memcpy(&(IResponseToConsis.DemandingCounterUnitId), piRequestMessage->DemandingCounterUnitId, sizeof(IResponseToConsis.DemandingCounterUnitId)); //IResponseToConsis.Text[3] = '/0'; //Null terminator at the end of no text string IResponseToConsis.Text[3] = ' '; mbstowcs_s(&convertedChars, wcstring, sizeof(IResponseToConsis) + 1, (char*)&IResponseToConsis, _TRUNCATE); wcstring[sizeof(IResponseToConsis)] = L'\0'; pdialog->m_listBoxMain.AddString(wcstring); //Send a response to CONSIS pdialog->Consis.SendConsisMessage((char*)&IResponseToConsis, MessageISize); } //Ignore all other messages singleLock.Unlock(); }//CONSIS connected if statement context Sleep(200); } // NOT REACHED return 0; }
/*static*/ BOOL CRtsSettingsWizDlg::InitToolTips(CWnd* pParentWnd, CToolTipCtrl*& hpToolTips) { if (! pParentWnd) return TRUE; // Load up all the tool tips if (! hpToolTips) hpToolTips = new CToolTipCtrl; if(! hpToolTips->Create(pParentWnd)) { AfxMessageBox(_T("Unable to load tool tips."), MB_OK | MB_ICONERROR); return TRUE; } // Tool tips are ready to be added else { // Get first child window CWnd* pChildWnd = pParentWnd->GetWindow(GW_CHILD); while (pChildWnd != NULL) { // Grab the string with that res ID CString csTip; // If the string resource DNE if (! csTip.LoadString(pChildWnd->GetDlgCtrlID())) { // Get the next child window in the list pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT); continue; } // If the resource exists else { // Remove up to first new line int iOffset = csTip.Find(_T("\n")); if (iOffset < 0) { // Get the next child window in the list pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT); continue; } iOffset = csTip.GetLength() - (iOffset + 1); csTip.SetString( csTip.Right(iOffset) ); // Remove after second new line iOffset = csTip.Find(_T("\n")); if (iOffset >= 0) { csTip.SetString( csTip.Left(iOffset) ); } } // Add the tool tip hpToolTips->AddTool(pChildWnd, csTip); // Get the next child window in the list pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT); } // Set the "max number of pixels" per line // (if a line doesn't contain spaces, it may be larger then this number hpToolTips->SetMaxTipWidth(300); // Set the length of time the tool tip window remains visible if the // pointer is stationary within a tool's bounding rectangle. hpToolTips->SetDelayTime(TTDT_AUTOPOP, 15/*s*/ * 1000/*milliseconds*/); // Set the length of time the pointer must remain stationary within a // tool's bounding rectangle before the tool tip window appears hpToolTips->SetDelayTime(TTDT_INITIAL, 50); // Set the length of time it takes for subsequent tool tip windows to // appear as the pointer moves from one tool to another. hpToolTips->SetDelayTime(TTDT_RESHOW, 50); // Turn the tips on hpToolTips->Activate(TRUE); } return 0; }
BOOL CSZCommandLine::Analyze(LPCTSTR lpszCmdLine) { BOOL bResult = FALSE; int nParamNamePos = 0; int nParamValuePos = 0; int nSubCommandPos = 0; CString strParamName; CString strSubCommand; BOOL bInQuotation = FALSE; EM_CMDLINE_STATUS nStatus = em_Cmd_New_Arg; m_mapParams.RemoveAll(); if (!lpszCmdLine) goto Exit0; for (int nPos = 0; 0 == nPos || lpszCmdLine[nPos - 1]; ++nPos) { TCHAR ch = lpszCmdLine[nPos]; switch (nStatus) { case em_Cmd_New_Arg: bInQuotation = FALSE; // no break; case em_Cmd_White_Space: if (IsWhiteSpace(ch)) { nStatus = em_Cmd_White_Space; } else if (IsArgNamePrefix(ch)) { nStatus = em_Cmd_Arg_Name_Prefix; } else if (IsAlpha(ch)) { // skip sub command nSubCommandPos = nPos; nStatus = em_Cmd_Sub_Command; } else if (IsQuotation(ch)) { bInQuotation = TRUE; nStatus = em_Cmd_White_Space; } else { goto Exit0; } break; case em_Cmd_Sub_Command: if (IsWhiteSpace(ch)) { strSubCommand.SetString(lpszCmdLine + nSubCommandPos, nPos - nSubCommandPos); AppendSubCommand(strSubCommand); nStatus = em_Cmd_New_Arg; } else if (IsAlpha(ch)) { // skip sub command nStatus = em_Cmd_Sub_Command; } else if (IsQuotation(ch)) { strSubCommand.SetString(lpszCmdLine + nSubCommandPos, nPos - nSubCommandPos); AppendSubCommand(strSubCommand); nStatus = em_Cmd_New_Arg; } else { goto Exit0; } break; case em_Cmd_Arg_Name_Prefix: if (IsWhiteSpace(ch)) { goto Exit0; } else if (IsArgNamePrefix(ch)) { // Á¬ÐøµÄǰ׺ nStatus = em_Cmd_Arg_Name_Prefix; } else { nParamNamePos = nPos; nStatus = em_Cmd_Arg_Name; } break; case em_Cmd_Arg_Name: if (IsWhiteSpace(ch)) { strParamName.SetString(lpszCmdLine + nParamNamePos, nPos - nParamNamePos); SetParam(strParamName, _T("")); nStatus = em_Cmd_New_Arg; } else if (IsArgValuePrefix(ch)) { strParamName.SetString(lpszCmdLine + nParamNamePos, nPos - nParamNamePos); nStatus = em_Cmd_Arg_Value_Prefix; } else if (IsQuotation(ch)) { strParamName.SetString(lpszCmdLine + nParamNamePos, nPos - nParamNamePos); SetParam(strParamName, _T("")); nStatus = em_Cmd_New_Arg; } else { nStatus = em_Cmd_Arg_Name; } break; case em_Cmd_Arg_Value_Prefix: if (IsWhiteSpace(ch)) { if (bInQuotation) { // treat quoted white space as arg-value nParamValuePos = nPos; nStatus = em_Cmd_Arg_Value; } else { SetParam(strParamName, _T("")); nStatus = em_Cmd_New_Arg; } } else if (IsQuotation(ch)) { nParamValuePos = nPos + 1; bInQuotation = TRUE; nStatus = em_Cmd_Arg_Value_Prefix; } else { nParamValuePos = nPos; nStatus = em_Cmd_Arg_Value; } break; case em_Cmd_Arg_Value: if (IsWhiteSpace(ch) && !bInQuotation) { SetParam(strParamName, lpszCmdLine + nParamValuePos, nPos - nParamValuePos); nStatus = em_Cmd_New_Arg; } else if (IsQuotation(ch)) { SetParam(strParamName, lpszCmdLine + nParamValuePos, nPos - nParamValuePos); nStatus = em_Cmd_New_Arg; } else { nStatus = em_Cmd_Arg_Value; } break; } } bResult = TRUE; Exit0: return bResult; }
/* ================ SpinFloatString ================ */ void SpinFloatString(CString &str, bool up) { int i, dotIndex = -1, digitIndex = -1; for (i = 0; str[i]; i++) { if (str[i] == '.') { if (dotIndex == -1) { dotIndex = i; } } else if (str[i] != '0') { if (digitIndex == -1) { digitIndex = i; } } } if (digitIndex == -1) { str.SetString("1"); return; } if (dotIndex != -1) { str.Delete(dotIndex, 1); if (digitIndex > dotIndex) { digitIndex--; } } else { dotIndex = i; } if (up) { if (str[digitIndex] == '9') { str.SetAt(digitIndex, '0'); if (digitIndex == 0) { str.Insert(0, '1'); dotIndex++; } else { str.SetAt(digitIndex-1, '1'); } } else { str.SetAt(digitIndex, str[digitIndex] + 1); } } else { if (str[digitIndex] == '1') { if (str[digitIndex+1] == '\0') { str.SetAt(digitIndex, '0'); str.AppendChar('9'); } else if (str[digitIndex+1] == '0') { str.SetAt(digitIndex, '0'); str.SetAt(digitIndex+1, '9'); } else { str.SetAt(digitIndex+1, str[digitIndex+1] - 1); } } else { str.SetAt(digitIndex, str[digitIndex] - 1); } } if (dotIndex < str.GetLength()) { str.Insert(dotIndex, '.'); // remove trailing zeros for (i = str.GetLength()-1; i >= 0; i--) { if (str[i] != '0' && str[i] != '.') { break; } } if (i < str.GetLength() - 1) { str.Delete(i+1, str.GetLength() - i); } } for (i = 0; str[i]; i++) { if (str[i] == '.') { if (i > 1) { str.Delete(0, i-1); } break; } if (str[i] != '0') { if (i > 0) { str.Delete(0, i); } break; } } }
// Puts the information on a particular file in the pInfo structure. // // Returns: // MDERR_OK when successful // MDERR_AFC_NOT_FOUND if the file couldn't be found (or is a broken link) // t_MachError CiPoTApi::GetFileInfo(char *remotePath, t_iPodFileInfo *pInfo, t_iPodExtraInfo *pExtra) { t_MachError ret; struct afc_dictionary *pDict; char *pKey, *pVal; CString filename; CMacPath MacPath; if (!remotePath) { // If remotePath is not specified, then create it filename.SetString(pInfo->remotePath); if (filename.Right(1).Compare("\\")) //[0] == '\\' filename += "\\"; filename += pInfo->findData.cFileName; remotePath = filename.GetBuffer(); } MacPath.SetWindowsPath(remotePath); memset(pInfo, 0, sizeof(FILETIME)*3 + sizeof(DWORD)*3); if (pExtra) memset(pExtra, 0, sizeof(t_iPodExtraInfo)); // if (pInfo->findData.cFileName[0] == '.') // pInfo->findData.dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN; if ((ret = AFCFileInfoOpen(m_iPodConnection, MacPath.GetBuffer(), &pDict)) != MDERR_OK) return ret; AFCKeyValueRead(pDict, &pKey, &pVal); while(pKey || pVal) { if (!strcmp(pKey, "st_ifmt")) { if (!strcmp(pVal, "S_IFIFO")) { // pipe pInfo->findData.dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM; if (pExtra) pExtra->iType = IPOD_IFIFO; } else if (!strcmp(pVal, "S_IFCHR")) { // character special pInfo->findData.dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM; if (pExtra) pExtra->iType = IPOD_IFCHR; } else if (!strcmp(pVal, "S_IFBLK")) { // block special pInfo->findData.dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM; if (pExtra) pExtra->iType = IPOD_IFBLK; } else if (!strcmp(pVal, "S_IFSOCK")) { // socket pInfo->findData.dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM; if (pExtra) pExtra->iType = IPOD_IFSOCK; } else if (!strcmp(pVal, "S_IFLNK")) { // symbolic link pInfo->findData.dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM; if (pExtra) pExtra->iType = IPOD_IFLNK; } else if (!strcmp(pVal, "S_IFDIR")) { // directory pInfo->findData.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY; if (pExtra) pExtra->iType = IPOD_IFDIR; } else if (!strcmp(pVal, "S_IFREG")) { // regular pInfo->findData.dwFileAttributes |= FILE_ATTRIBUTE_NORMAL; if (pExtra) pExtra->iType = IPOD_IFREG; } } else if (!strcmp(pKey, "st_size")) { pInfo->findData.nFileSizeLow = strtol(pVal, NULL, 10); if (pExtra) pExtra->iSize = pInfo->findData.nFileSizeLow; } else if (!strcmp(pKey, "st_blocks")) { if (pExtra) pExtra->iBlocks = atoi(pVal); } else if (!strcmp(pKey, "st_nlink")) { if (pExtra) pExtra->iLinks = atoi(pVal); } else if (!strcmp(pKey, "LinkTarget")) { if (pExtra) strcpy(pExtra->LinkTarget, pVal); // Acquire info about the link target. pExtra will contain link info, so leave it alone char cFullPath[MAX_PATH]; GetLinkTargetPath(remotePath, pVal, cFullPath); int iRet = GetFileInfo(cFullPath, pInfo, 0); pInfo->findData.dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM; if (iRet == MDERR_OK) break; else if (pExtra) pExtra->iType = IPOD_IFBLNK; } AFCKeyValueRead(pDict, &pKey, &pVal); } if (pInfo->findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) pInfo->findData.nFileSizeLow = 0; AFCKeyValueClose(pDict); return MDERR_OK; }
QUERYRESPONSE ProRbtDb::HandleCounterIdEntry(PRORBTCOUNTERSESSION * pCounterSession, CPharmaRobot10Dlg* pdialog) { QUERYRESPONSE returnvalue = Q_NOACK; size_t retsize, len, convertedChars; int MessageLength, NumTenBatches; char numart[3]; aConsisReplyHeader *paMesHeader; aConsisReplyDispensedOcc* aocc; REQUESTINTERMEIDATEDB InterMDb; CString StringFromProRbt, st; if (pCounterSession->ExpectedNumLines == pCounterSession->ReceivedNumLines) { if (pdialog->Consis.ConnectionStarted == FALSE) { if (pdialog->Consis.ConnectToConsis("ShorT", &(pdialog->m_listBoxMain), &(pdialog->m_CheckBoxRemoteSvr))) pdialog->EnableCondsisTab(); } if (pdialog->Consis.ConnectionStarted == TRUE) { //Clean intermideate database memset (&InterMDb, 0, sizeof(InterMDb)); InterMDb.firstIndexToStartfrom = INITIAL; int l = 0; //build intermediate database that agregates identical article IDs (barcodes) for (int j = 0 ; j < pCounterSession->ExpectedNumLines ; j++) { bool entryfound = false; while (InterMDb.Entry[l].NumReq != 0) //search for an empty entry indicating the last entry in database { if (wcscmp(InterMDb.Entry[l].ArctileIdRequested, pCounterSession->RbtParamLinesArr[j + 1].Barcode) == 0) { InterMDb.Entry[l].NumReq += _wtoi(pCounterSession->RbtParamLinesArr[j+1].Qty); //aggregate number of requested articles entryfound = true; } l++;//Check next entry in intermediate database } if(entryfound == false) {//barcode not found in any of the entries in the database. //Create new entry - copy Barcode number and requested quantity to inetrmediate database. StringFromProRbt = pCounterSession->RbtParamLinesArr[j + 1].Barcode; len = StringFromProRbt.GetLength(); memcpy(&(InterMDb.Entry[l].ArctileIdRequested),pCounterSession->RbtParamLinesArr[j+1].Barcode,len*sizeof(wchar_t)); InterMDb.Entry[l].ArctileIdRequested[len] = L'\0';//insure string ends with a null InterMDb.Entry[l].NumReq = _wtoi(&(pCounterSession->RbtParamLinesArr[j+1].Qty[0])); //insert numer of requested articles //Check if Item is in Stock char BarcodeString[31]; memset(BarcodeString, 0, 30); wcstombs(BarcodeString, InterMDb.Entry[l].ArctileIdRequested, len); int TotalStock; if (CheckAmountInStock(&TotalStock, BarcodeString, pdialog) == FALSE) { //Error with Consis, Init entire Database InitProRbtDb(); memset(ackemessage.Message, 0, ACK_MESSAGE_SIZE * sizeof(_TCHAR)); wsprintf(ackemessage.Message,L"תקלה בשליחת שאילתת כמות במלאי לשרת קונסיס"); return Q_ERROR; } if (TotalStock >= InterMDb.Entry[l].NumReq) { InterMDb.Entry[l].NumInStock = InterMDb.Entry[l].NumReq; } else { InterMDb.Entry[l].NumInStock = TotalStock; } //the Item is in stock and may be dispensed if (InterMDb.Entry[l].NumInStock > 0) { InterMDb.sizeInStock += 1; if (InterMDb.firstIndexToStartfrom == INITIAL) { InterMDb.firstIndexToStartfrom = l; } } } //record intermediate database size for all items inserted to it InterMDb.sizeRequested = l + 1; l = 0; } //Handling 'A' dialogue is done in a batches of 10 NumTenBatches = 1 + (InterMDb.sizeInStock / 10); //Try to catch the Mutex for CONSIS Access //Protect with Mutex the CONSIS resource CSingleLock singleLock(&(pdialog->m_MutexAMessage)); // Attempt to lock the shared resource if (singleLock.Lock(INFINITE)) { //log locking success } while (NumTenBatches !=0) { //Build 'A' Message with Barcode from RBT parameters only if there are items left to send if (InterMDb.sizeInStock > 0) { //This function will send the following 10 items in the database that are in stock if (BuildAndSendACommand(&InterMDb, pdialog, &(pCounterSession->RbtParamLinesArr[1])) == FALSE) { //Error with Consis, Init entire Database InitProRbtDb(); singleLock.Unlock(); memset(ackemessage.Message, 0, ACK_MESSAGE_SIZE * sizeof(_TCHAR)); wsprintf(ackemessage.Message,L"תקלה בשליחת בקשת ניפוק לשרת קונסיס"); return Q_ERROR; } if (InterMDb.sizeInStock >= 10) InterMDb.sizeInStock -= 10; //10 less in stock //Session state depends on the order state //Last message Should be '4' - Ready, but Server returns '5', so that's what we'll wait for char orderState[3]; memset(&(orderState[2]),'\0',1); memset(orderState,'0',2); //clear message buffer to be received from consis memset(pdialog->Consis.amessageBuffer, 0 ,sizeof(pdialog->Consis.amessageBuffer)); MessageLength = sizeof(pdialog->Consis.amessageBuffer); paMesHeader = (aConsisReplyHeader *)pdialog->Consis.amessageBuffer; do { /* Infinitly wait for the reply to arrive from CONSIS by means of AsynchDialogue listener*/ ::WaitForSingleObject(pdialog->Consis.aMessageEvent.m_hObject, INFINITE); pdialog->Consis.amessageBuffer[pdialog->Consis.aMessageLength] = '\0'; memcpy(orderState, paMesHeader->OrderState, sizeof(paMesHeader->OrderState)); orderState[2] = '\0'; //Print the reply of CONSIS 'a' to the dialog box size_t origsize = strlen(pdialog->Consis.amessageBuffer) + 1; wchar_t wcstring[1000]; mbstowcs_s(&convertedChars, wcstring, origsize, pdialog->Consis.amessageBuffer, _TRUNCATE); st = wcstring; pdialog->m_listBoxMain.AddString(st); }while ((paMesHeader->OrderState[1] != '4') && (paMesHeader->OrderState[1] != '3')); //If Cancelled stop all. if (paMesHeader->OrderState[1] == '3') {//We checked that all the items are in stock. If Cancelled somthing is wrong in CONSIS //Error with Consis, Init entire Database InitProRbtDb(); singleLock.Unlock(); memset(ackemessage.Message, 0, ACK_MESSAGE_SIZE * sizeof(_TCHAR)); wsprintf(ackemessage.Message,L"תקלה בקבלת תשובה לבקשת ניפוק לשרת קונסיס"); return Q_ERROR; } else//The 'A' request was not cancelled but finished, go through the reply { //Extract number of locations memcpy(numart, paMesHeader->NumberOfArticles, sizeof(paMesHeader->NumberOfArticles)); numart[2] = '\0'; int numArticles = atoi(numart); //TEMP RANM DEBUG wchar_t Stringnumdif1f[3]; _itow_s(numArticles,Stringnumdif1f,10); Stringnumdif1f[2] = '\0'; st = L"numArticles = "; st += Stringnumdif1f; pdialog->m_listBoxMain.AddString(st); //TEMP RANM DEBUG for (int i = 0 ; i < numArticles ; i++ ) { //Extract Article ID and Dispensed quantity from Occupancy entry in 'a' message occupany entry char* address = (char*)paMesHeader + sizeof(aConsisReplyHeader) + (i * 42); aocc = (aConsisReplyDispensedOcc*)address; //Get article ID from 'a' response wchar_t articleID[31]; articleID[30] = '\0'; mbstowcs_s(&retsize, articleID, sizeof(aocc->ArticleId) + 1, aocc->ArticleId, _TRUNCATE); //Clean leading zeroes CString cleanArticleID; cleanArticleID.SetString(articleID); cleanArticleID.TrimLeft(L'0'); cleanArticleID.TrimLeft(L' '); wsprintf(articleID,cleanArticleID.GetString()); articleID[cleanArticleID.GetLength()] = L'\0'; //find article ID in intermediate database int k = 0; while (InterMDb.Entry[k].NumReq != 0) { if (wcscmp(articleID, InterMDb.Entry[k].ArctileIdRequested) == 0) {//found the entry accoridng to barcode in intermedeate database //Dispensed quantity handling. Fill intermediate database for handling at the end. char dispenssedQuantity[6]; memcpy(dispenssedQuantity, aocc->DispensedQuantity, sizeof(aocc->DispensedQuantity)); dispenssedQuantity[5] = '\0'; InterMDb.Entry[k].NumDis += atoi(dispenssedQuantity); //IF NO CANCELLED STATE RECEIVED, THEN ALL ITEMS WERE DISPENSSED // InterMDb.Entry[k].NumDis = InterMDb.Entry[k].NumInStock; } k++;//serach for article ID in the intermediate database further } } } } NumTenBatches--; } singleLock.Unlock(); } else { //Error with Consis, Init entire Database InitProRbtDb(); memset(ackemessage.Message, 0, ACK_MESSAGE_SIZE * sizeof(_TCHAR)); wsprintf(ackemessage.Message,L"תקלה בתקשורת לשרת קונסיס"); return Q_ERROR; } //CONSIS Completed, Build Ack from intermediate database. Check if all entries in the aggregated database were dispensed. int m = 0; bool missingitems = false; CString AckedString = L"מבקשת הניפוק חסרים הפריטים הבאים"; AckedString += L":";AckedString += L"\n"; while (InterMDb.Entry[m].NumReq != 0) { if (InterMDb.Entry[m].NumReq != InterMDb.Entry[m].NumDis) { missingitems = true; wchar_t description[256]; //Get Description from Yarpa SQL. If failed publish back to Client the Barcode if (!pdialog->GetItemDescFromBarcode(InterMDb.Entry[m].ArctileIdRequested, description)) wsprintf(description, InterMDb.Entry[m].ArctileIdRequested); AckedString += L"סוג פריט"; AckedString += L":"; AckedString += L" "; AckedString += description; AckedString += L"\n"; AckedString += L"חסרים"; AckedString += L":"; AckedString += L" "; wchar_t Stringnumdiff[3]; _itow_s(InterMDb.Entry[m].NumReq - InterMDb.Entry[m].NumDis,Stringnumdiff,10); AckedString += Stringnumdiff; AckedString += L"\n\n"; } m++;//Go on to next item in intermediate databse. } if (missingitems) { memset(ackemessage.Message, 0, ACK_MESSAGE_SIZE * sizeof(_TCHAR)); memcpy(ackemessage.Message, AckedString.GetString(), AckedString.GetLength() * sizeof(wchar_t)); returnvalue = Q_SENDACK; } else { returnvalue = Q_NOACK; } //Prepare Database Line Entry for next Session pCounterSession->PreviousSessionId = pCounterSession->CurrentSessionId; pCounterSession->ExpectedNumLines = -1; pCounterSession->ReceivedNumLines = -1; pCounterSession->CurrentSessionId = -1; } return returnvalue; }
//-------------------------------------------------------------------------- // 버튼 색을 동적으로 변하게하는 함수 //-------------------------------------------------------------------------- void CDrawProperty::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) { UpdateData(); CDC dc; CRect rect; UINT state; ////////////////////////////////////////////////////////////////////////// // 버튼 그리기 작업 초기화 if (nIDCtl == IDC_BUTTON_LINECOLOR || nIDCtl == IDC_BUTTON_FILLCOLOR || nIDCtl == IDC_BUTTON_FILLCOLOR2) { dc.Attach(lpDrawItemStruct->hDC); rect = lpDrawItemStruct->rcItem; state = lpDrawItemStruct->itemState; } switch (nIDCtl) { ////////////////////////////////////////////////////////////////////////// // 라인색 버튼의 색 지정 case IDC_BUTTON_LINECOLOR: { dc.Draw3dRect(&rect, RGB(255,255,255), RGB(0,0,0)); if(state & ODS_DISABLED) dc.FillSolidRect(&rect, ::GetSysColor(COLOR_BTNFACE)); //비활성화색 else dc.FillSolidRect(&rect, CDrawPropertyValue::m_sLineColor); //버튼 색 지정 if(state & ODS_SELECTED) dc.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT); else dc.DrawEdge(&rect, EDGE_RAISED, BF_RECT); COLORREF invertColor = CDrawPropertyValue::m_sLineColor ^ 0x00FFFFFF; //색반전 dc.SetTextColor(invertColor); CString str = L"Line\n(Text)"; CRect textRect = rect; textRect.top += textRect.CenterPoint().y/2; dc.DrawText(str, textRect, DT_CENTER | DT_VCENTER | BS_MULTILINE | DT_NOCLIP); break; } ////////////////////////////////////////////////////////////////////////// // 채우기 색 버튼의 색 지정 case IDC_BUTTON_FILLCOLOR: { dc.Draw3dRect(&rect, RGB(255,255,255), RGB(0,0,0)); if(state & ODS_DISABLED) dc.FillSolidRect(&rect, ::GetSysColor(COLOR_BTNFACE)); //비활성화색 else dc.FillSolidRect(&rect, CDrawPropertyValue::m_sBrushColor); //버튼 색 지정 if(state & ODS_SELECTED) dc.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT); else dc.DrawEdge(&rect, EDGE_RAISED, BF_RECT); COLORREF invertColor = CDrawPropertyValue::m_sBrushColor ^ 0x00FFFFFF; //색반전 if(state & ODS_DISABLED) invertColor = ::GetSysColor(COLOR_GRAYTEXT); dc.SetTextColor(invertColor); CString str = L"Fill"; if(state & ODS_DISABLED) str.SetString(L"Not Use"); dc.DrawText(str, rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER); break; } ////////////////////////////////////////////////////////////////////////// // 그라디언트 끝 색 버튼의 색 지정 case IDC_BUTTON_FILLCOLOR2: { dc.Draw3dRect(&rect, RGB(255,255,255), RGB(0,0,0)); if(state & ODS_DISABLED) dc.FillSolidRect(&rect, ::GetSysColor(COLOR_BTNFACE)); //비활성화색 else dc.FillSolidRect(&rect, CDrawPropertyValue::m_sGradientEndColor); //버튼 색 지정 if(state & ODS_SELECTED) dc.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT); else dc.DrawEdge(&rect, EDGE_RAISED, BF_RECT); COLORREF invertColor = CDrawPropertyValue::m_sGradientEndColor ^ 0x00FFFFFF; //색반전 if(state & ODS_DISABLED) invertColor = ::GetSysColor(COLOR_GRAYTEXT); dc.SetTextColor(invertColor); CString str = L"Grd End"; if(state & ODS_DISABLED) str.SetString(L"Not Use"); dc.DrawText(str, rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER); break; } ////////////////////////////////////////////////////////////////////////// // 라인 패턴 그리기 case IDC_LINEPATTERN: if(m_sLinePtnCombo.GetSafeHwnd()) m_sLinePtnCombo.DrawItem(lpDrawItemStruct); break; ////////////////////////////////////////////////////////////////////////// // 채우기 패턴(HATCH STYLE) 그리기 case IDC_FILLPATTERN: if(m_sFillPtnCombo.GetSafeHwnd()) m_sFillPtnCombo.DrawItem(lpDrawItemStruct); break; ////////////////////////////////////////////////////////////////////////// // 그라디언트 패턴 그리기 case IDC_COMBO_GRADIENT: if(m_sGradientCombo.GetSafeHwnd()) m_sGradientCombo.DrawItem(lpDrawItemStruct); break; } dc.Detach(); // CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct); }