Пример #1
0
/**
 * @brief Get text of specified lines (ghost lines will not contribute to text).
 * 
 * @param nCrlfStyle determines the EOL type in the returned buffer.
 * If nCrlfStyle equals CRLF_STYLE_AUTOMATIC, we read the EOL from the line buffer
 * 
 * @note This function has its base in CrystalTextBuffer
 * CrystalTextBuffer::GetTextWithoutEmptys() is for a buffer with no ghost lines.
 * CrystalTextBuffer::GetText() returns text including ghost lines.
 * These two base functions never read the EOL from the line buffer, they
 * use CRLF_STYLE_DOS when nCrlfStyle equals CRLF_STYLE_AUTOMATIC.
 */
void CGhostTextBuffer::			/* virtual override */
GetTextWithoutEmptys(int nStartLine, int nStartChar, 
                 int nEndLine, int nEndChar, 
                 CString &text, CRLFSTYLE nCrlfStyle /*= CRLF_STYLE_AUTOMATIC */,
                 bool bExcludeInvisibleLines /*= true*/) const
{
	const size_t lines = m_aLines.size();
	ASSERT(nStartLine >= 0 && nStartLine < static_cast<intptr_t>(lines));
	ASSERT(nStartChar >= 0 && nStartChar <= GetLineLength(nStartLine));
	ASSERT(nEndLine >= 0 && nEndLine < static_cast<intptr_t>(lines));
	ASSERT(nEndChar >= 0 && nEndChar <= GetFullLineLength(nEndLine));
	ASSERT(nStartLine < nEndLine || nStartLine == nEndLine && nStartChar <= nEndChar);
	// some edit functions (copy...) should do nothing when there is no selection.
	// assert to be sure to catch these 'do nothing' cases.
//	ASSERT(nStartLine != nEndLine || nStartChar != nEndChar);

	// estimate size (upper bound)
	int nBufSize = 0;
	int i = 0;
	for (i = nStartLine; i <= nEndLine; ++i)
		nBufSize += (GetFullLineLength(i) + 2); // in case we insert EOLs
	LPTSTR pszBuf = text.GetBuffer(nBufSize);

	if (nCrlfStyle != CRLF_STYLE_AUTOMATIC)
	{
		// we must copy this EOL type only
		const CString sEol = GetStringEol (nCrlfStyle);

		for (i = nStartLine; i <= nEndLine; ++i)
		{
			// exclude ghost lines
			if ((GetLineFlags(i) & LF_GHOST) || (bExcludeInvisibleLines && (GetLineFlags(i) & LF_INVISIBLE)))
				continue;

			// copy the line, excluding the EOL
			int soffset = (i == nStartLine ? nStartChar : 0);
			int eoffset = (i == nEndLine ? nEndChar : GetLineLength(i));
			int chars = eoffset - soffset;
			LPCTSTR szLine = m_aLines[i].GetLine(soffset);
			CopyMemory(pszBuf, szLine, chars * sizeof(TCHAR));
			pszBuf += chars;

			// copy the EOL of the requested type
			if (i != ApparentLastRealLine())
			{
				CopyMemory(pszBuf, sEol, sEol.GetLength() * sizeof(TCHAR));
				pszBuf += sEol.GetLength();
			}
		}
	} 
	else 
	{
		for (i = nStartLine; i <= nEndLine; ++i)
		{
			// exclude ghost lines
			if ((GetLineFlags(i) & LF_GHOST) || (bExcludeInvisibleLines && GetLineFlags(i) & LF_INVISIBLE))
				continue;

			// copy the line including the EOL
			int soffset = (i == nStartLine ? nStartChar : 0);
			int eoffset = (i == nEndLine ? nEndChar : GetFullLineLength(i));
			int chars = eoffset - soffset;
			LPCTSTR szLine = m_aLines[i].GetLine(soffset);
			CopyMemory(pszBuf, szLine, chars * sizeof(TCHAR));
			pszBuf += chars;

			// check that we really have an EOL
			if (i != ApparentLastRealLine() && GetLineLength(i) == GetFullLineLength(i))
			{
				// Oops, real line lacks EOL
				// (If this happens, editor probably has bug)
				ASSERT(false);
				CString sEol = GetStringEol (nCrlfStyle);
				CopyMemory(pszBuf, sEol, sEol.GetLength() * sizeof(TCHAR));
				pszBuf += sEol.GetLength();
			}
		}
	}
	text.ReleaseBuffer(static_cast<int>(pszBuf - text));
	text.FreeExtra();
}
Пример #2
0
//通过字符串获取双色球
sShuangSeQiu CDataManageCenter::GetShuangSeQiuByStr(CString& StrData)
{
	sShuangSeQiu ShuangSeQiu;

	int StartPos = 0;
	int EndPos   = 0;
	int Index = 0;
	int Count=0;
	while(EndPos != -1)
	{
		EndPos=StrData.Find(_T(" "),StartPos);
		if(EndPos == -1)
			break;

		if(Index == 0)
		{
			ShuangSeQiu.m_QiShu = StrData.Mid(StartPos,EndPos-StartPos);
		}
		else if(Index == 7)
		{
			CString Temp = StrData.Mid(StartPos,EndPos-StartPos);
			ShuangSeQiu.m_LanQiu = atoi(Temp.GetBuffer());
			Temp.ReleaseBuffer();
		}
		else
		{
			if(Index > QIU_XUN)
				continue;
			CString Temp = StrData.Mid(StartPos,EndPos-StartPos);
			ShuangSeQiu.m_HongQiu[Index-1]= atoi(Temp.GetBuffer());
			Temp.ReleaseBuffer();
			Count+=ShuangSeQiu.m_HongQiu[Index-1];
			if( ShuangSeQiu.m_HongQiu[Index-1] <= 11)
				ShuangSeQiu.m_QuJian[0]++;
			else if(ShuangSeQiu.m_HongQiu[Index-1] > 11 && ShuangSeQiu.m_HongQiu[Index-1] <= 22)
				ShuangSeQiu.m_QuJian[1]++;
			else
				ShuangSeQiu.m_QuJian[2]++;
		}

		Index++;
		StartPos = EndPos+1;
	}

	ShuangSeQiu.m_HongQiuSum = Count;
	m_ShuangSeQiuChuHaoList.push_back(ShuangSeQiu);
	for(int i = 0; i < QIU_XUN; i++)
	{
		for(int Index = 0 ; Index < QIU_XUN; Index++)
		{
			if(ShuangSeQiu.m_HongQiu[i] < ShuangSeQiu.m_HongQiu[Index])
			{
				int Temp1 = ShuangSeQiu.m_HongQiu[Index];
				ShuangSeQiu.m_HongQiu[Index]=ShuangSeQiu.m_HongQiu[i];
				ShuangSeQiu.m_HongQiu[i] = Temp1;
			}	
		}
	}

	return ShuangSeQiu;
}
Пример #3
0
BOOL CPrssrApp::InitInstance() {
	LOG0(1, "CPrssrApp::InitInstance()");

	LoadSSL();
	// init win sock
	WSADATA wsaData;
	WSAStartup(0x0101, &wsaData);

	// Change the registry key under which our settings are stored.
	SetRegistryKey(_T("DaProfik"));

	// register wnd class
	WNDCLASS wc = { 0 };
	wc.lpfnWndProc = ::DefWindowProc;
	wc.hInstance = AfxGetInstanceHandle();
	wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = PRSSR_CLASS_NAME;
	if (!AfxRegisterClass(&wc))
		return FALSE;

	CFeedView::Register();
	CGroupView::Register();
	CTextProgressCtrl::Register();
	CInfoBar::Register();

	// get DPI
	HDC hdcScreen = ::GetDC(NULL);
	int nSystemDPI = ::GetDeviceCaps(hdcScreen, LOGPIXELSX);
	::ReleaseDC(NULL, hdcScreen);

	// load the resource library according to the system DPI
	CString resLibName;
	resLibName.Format(_T("res.%03d.dll"), nSystemDPI);
	m_hResDLL = LoadLibrary(resLibName);
	if (m_hResDLL == NULL) return Error(IDS_INTERNAL_ERROR, 0x00000002);

	if (!InitHTMLControl(AfxGetInstanceHandle()))
		return 0;

	// Initialize the control
	INITCOMMONCONTROLSEX icce;
	icce.dwSize = sizeof(icce);
	icce.dwICC = ICC_DATE_CLASSES | ICC_LISTVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_UPDOWN_CLASS | ICC_TREEVIEW_CLASSES | ICC_TOOLTIP_CLASSES | ICC_TAB_CLASSES;
	InitCommonControlsEx(&icce);

	SHInitExtraControls();

	// frame
	CMainFrame* pFrame = new CMainFrame();
	m_pMainWnd = pFrame;

	// create and load the frame with its resources
	pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW, NULL, NULL);

	// process cmd line
	CString strCmdLine = m_lpCmdLine;

	// minimized ?
	if (strCmdLine.Find(_T("/minimized")) != -1) {
		pFrame->ShowWindow(SW_MINIMIZE);
	}
	else {
		pFrame->ShowWindow(m_nCmdShow);
		pFrame->UpdateWindow();
	}

	if (strCmdLine.Find(_T("/updateall")) != -1) {
		pFrame->PostMessage(UWM_UPDATE_ALL);
	}

	int npos;
	if ((npos = strCmdLine.Find(_T("/opensite"))) != -1) {
		CString strSite = strCmdLine.Mid(npos + 10);
		int site;
		if (swscanf(strSite.GetBuffer(strSite.GetLength()), _T("%d"), &site) == 1) {
			// after sites are loaded, site with this value is opened
			pFrame->PostMessage(UWM_OPEN_SITE, site, 0);
		}
	}

	if ((npos = strCmdLine.Find(_T("/openitem"))) != -1) {
		CString sPar = strCmdLine.Mid(npos + 10);

		int site, feedIdx;
		if (swscanf(sPar.GetBuffer(sPar.GetLength()), _T("%d %d"), &site, &feedIdx) == 2) {
			pFrame->PostMessage(UWM_OPEN_FEEDITEM, site, (LPARAM) feedIdx);
		}
		sPar.ReleaseBuffer();
	}

	return TRUE;
}
Пример #4
0
bool CCacheDlg::GetStatusFromRemoteCache(const CTGitPath& Path, bool bRecursive)
{
	if(!EnsurePipeOpen())
	{
		STARTUPINFO startup = { 0 };
		PROCESS_INFORMATION process = { 0 };
		startup.cb = sizeof(startup);

		CString sCachePath = L"TGitCache.exe";
		if (CreateProcess(sCachePath.GetBuffer(sCachePath.GetLength() + 1), L"", nullptr, nullptr, FALSE, 0, nullptr, nullptr, &startup, &process) == 0)
		{
			// It's not appropriate to do a message box here, because there may be hundreds of calls
			sCachePath.ReleaseBuffer();
			ATLTRACE("Failed to start cache\n");
			return false;
		}
		sCachePath.ReleaseBuffer();

		// Wait for the cache to open
		ULONGLONG endTime = GetTickCount64()+1000;
		while(!EnsurePipeOpen())
		{
			if((GetTickCount64() - endTime) > 0)
			{
				return false;
			}
		}
	}


	DWORD nBytesRead;
	TGITCacheRequest request;
	request.flags = TGITCACHE_FLAGS_NONOTIFICATIONS;
	if(bRecursive)
	{
		request.flags |= TGITCACHE_FLAGS_RECUSIVE_STATUS;
	}
	wcsncpy_s(request.path, Path.GetWinPath(), MAX_PATH);
	SecureZeroMemory(&m_Overlapped, sizeof(OVERLAPPED));
	m_Overlapped.hEvent = m_hEvent;
	// Do the transaction in overlapped mode.
	// That way, if anything happens which might block this call
	// we still can get out of it. We NEVER MUST BLOCK THE SHELL!
	// A blocked shell is a very bad user impression, because users
	// who don't know why it's blocked might find the only solution
	// to such a problem is a reboot and therefore they might loose
	// valuable data.
	// Sure, it would be better to have no situations where the shell
	// even can get blocked, but the timeout of 5 seconds is long enough
	// so that users still recognize that something might be wrong and
	// report back to us so we can investigate further.

	TGITCacheResponse ReturnedStatus;
	BOOL fSuccess = TransactNamedPipe(m_hPipe,
		&request, sizeof(request),
		&ReturnedStatus, sizeof(ReturnedStatus),
		&nBytesRead, &m_Overlapped);

	if (!fSuccess)
	{
		if (GetLastError()!=ERROR_IO_PENDING)
		{
			ClosePipe();
			return false;
		}

		// TransactNamedPipe is working in an overlapped operation.
		// Wait for it to finish
		DWORD dwWait = WaitForSingleObject(m_hEvent, INFINITE);
		if (dwWait == WAIT_OBJECT_0)
		{
			fSuccess = GetOverlappedResult(m_hPipe, &m_Overlapped, &nBytesRead, FALSE);
			return TRUE;
		}
		else
			fSuccess = FALSE;
	}

	ClosePipe();
	return false;
}
Пример #5
0
	// The message loop of Mozilla does not handle accelertor keys.
	// IOleInplaceActivateObject requires MSG be filtered by its TranslateAccellerator() method.
	// So we install a hook to do the dirty hack.
	// Mozilla message loop is here:
	// http://mxr.mozilla.org/mozilla-central/source/widget/src/windows/nsAppShell.cpp
	// bool nsAppShell::ProcessNextNativeEvent(bool mayWait)
	// It does PeekMessage, TranslateMessage, and then pass the result directly
	// to DispatchMessage.
	// Just before PeekMessage returns, our hook procedure is called.
	LRESULT CALLBACK WindowMessageHook::GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam) 
	{ 
		if (nCode >= 0 && wParam == PM_REMOVE && lParam)
		{
			MSG * pMsg = reinterpret_cast<MSG *>(lParam);
			HWND hwnd = pMsg->hwnd;

			// 只处理键盘消息
			if (pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST || hwnd == NULL)
			{
				goto Exit;
			}

			// 只处理IE窗口消息,通过检查窗口类名过滤非IE窗口
			CString strClassName;
			GetClassName(hwnd, strClassName.GetBuffer(MAX_PATH), MAX_PATH);
			strClassName.ReleaseBuffer(); 
			if (WM_KEYDOWN == pMsg->message && VK_TAB == pMsg->wParam && strClassName == _T("Internet Explorer_TridentCmboBx"))
			{
				hwnd = ::GetParent(hwnd);
				GetClassName(hwnd, strClassName.GetBuffer(MAX_PATH), MAX_PATH);
				strClassName.ReleaseBuffer(); 
			}
			if (strClassName != _T("Internet Explorer_Server"))
			{
				goto Exit;
			}

			// 获取CIEHostWindow对象
			CIEHostWindow* pIEHostWindow = CIEHostWindow::FromInternetExplorerServer(hwnd);
			if (pIEHostWindow == NULL) 
			{
				goto Exit;
			}

			if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN || pMsg->message == WM_SYSKEYUP)
			{
				BOOL bAltPressed = HIBYTE(GetKeyState(VK_MENU)) != 0;
				BOOL bCtrlPressed = HIBYTE(GetKeyState(VK_CONTROL)) != 0;
				BOOL bShiftPressed = HIBYTE(GetKeyState(VK_SHIFT))  != 0;

				// 当Alt键释放时,也向Firefox窗口转发按钮消息。否则无法通过Alt键选中主菜单。
				if (pMsg->message == WM_SYSKEYUP && pMsg->wParam == VK_MENU) 
				{
					bAltPressed = TRUE;
				}

				TRACE(_T("WindowMessageHook::GetMsgProc MSG: %x wParam: %x, lPara: %x\n"), pMsg->message, pMsg->wParam, pMsg->lParam);
				if (bCtrlPressed || bAltPressed || (pMsg->wParam >= VK_F1 && pMsg->wParam <= VK_F24))
				{
					int nKeyCode = static_cast<int>(pMsg->wParam);
					if (FilterFirefoxKey(nKeyCode, bAltPressed, bCtrlPressed, bShiftPressed))
					{
						HWND hwndMessageTarget = GetTopMozillaWindowClassWindow(pIEHostWindow->GetSafeHwnd());
						if (hwndMessageTarget)
						{
							::SetFocus(hwndMessageTarget);
							::PostMessage(hwndMessageTarget, pMsg->message, pMsg->wParam, pMsg->lParam);
							pMsg->message = WM_NULL;
							goto Exit;
						}
					}
				}
			}

			if (pIEHostWindow->m_ie.TranslateAccelerator(pMsg) == S_OK)
			{
				pMsg->message = WM_NULL;
			}
		}
Exit:
		return CallNextHookEx(s_hhookGetMessage, nCode, wParam, lParam); 
	}
Пример #6
0
//插入字串
bool CSkinRichEdit::InsertString(LPCTSTR pszString, CHARFORMAT2 & CharFormat)
{
	//变量定义
	bool bResumeSelect;
	CHARRANGE CharRange;

	//保存状态
	GetSel(CharRange.cpMin,CharRange.cpMax);
	bResumeSelect=(CharRange.cpMax!=CharRange.cpMin);

	//搜索变量
	LPCTSTR pszHttp=TEXT("http://");
	const INT nHttpLength=lstrlen(pszHttp);
	const INT nStringLength=lstrlen(pszString);

	//索引定义
	INT nStringStart=0;
	INT nStringPause=0;

	//字符解释
	for (INT i=0;i<nStringLength;i++)
	{
		//变量定义
		INT nUrlPause=i;

		//地址判断
		if (((i+nHttpLength)<nStringLength)&&(memcmp(&pszString[i],pszHttp,nHttpLength*sizeof(TCHAR))==0))
		{
			//设置索引
			nUrlPause=i+nHttpLength;

			//地址搜索
			while (nUrlPause<nStringLength)
			{
				//字符判断
				if (EfficacyUrlChar(pszString[nUrlPause])==true)
				{
					nUrlPause++;
					continue;
				}

				break;
			}
		}

		//终止字符
		if (nUrlPause<=(i+nHttpLength)) nStringPause=(i+1);

		//插入字符
		if ((i==(nStringLength-1))||(nUrlPause>(i+nHttpLength)))
		{
			//普通字符
			if (nStringPause>nStringStart)
			{
				//获取缓冲
				CString strNormalString;
				LPTSTR pszNormalString=strNormalString.GetBuffer(nStringPause-nStringStart+1);

				//拷贝字符
				pszNormalString[nStringPause-nStringStart]=0;
				CopyMemory(pszNormalString,&pszString[nStringStart],(nStringPause-nStringStart)*sizeof(TCHAR));

				//释放缓冲
				strNormalString.ReleaseBuffer();

				//插入消息
				SetSel(-1L,-1L);
				SetWordCharFormat(CharFormat);
				ReplaceSel((LPCTSTR)strNormalString);
			}

			//连接地址
			if (nUrlPause>(i+nHttpLength))
			{
				//获取缓冲
				CString strUrlString;
				LPTSTR pszUrlString=strUrlString.GetBuffer((nUrlPause-i)+1);

				//拷贝字符
				pszUrlString[nUrlPause-i]=0;
				CopyMemory(pszUrlString,&pszString[i],(nUrlPause-i)*sizeof(TCHAR));

				//释放缓冲
				strUrlString.ReleaseBuffer();

				//构造格式
				CHARFORMAT2 CharFormatHyper;
				CharFormatHyper=CharFormat;

				//效验地址
				if (EfficacyUrlString(strUrlString)==true)
				{
					CharFormatHyper.dwMask|=CFM_LINK;
					CharFormatHyper.dwEffects|=CFE_LINK;
				}

				//插入消息
				SetSel(-1L,-1L);
				SetWordCharFormat(CharFormatHyper);
				ReplaceSel((LPCTSTR)strUrlString);
			}

			//设置索引
			nStringStart=__max(i,nUrlPause);
		}

		//设置索引
		i+=(nUrlPause-i);
	}

	//状态设置
	if (bResumeSelect==true) SetSel(CharRange);
	else PostMessage(WM_VSCROLL,SB_BOTTOM,0);

	return true;
}
Пример #7
0
///////////////////////////////////////////////////////////////////////////////
//
// 函数功能描述:标准日志打印
// 输入:日志级别、类型、源文件名、代码行,格式字串
// 输出:向窗口或文件写日志
// 返回值:
// 其它说明:
//
///////////////////////////////////////////////////////////////////////////////
void CLogTrace::Trace(BYTE cLevel, BYTE cType, const TCHAR * pszSourceFile,
           DWORD dwLine, LPCTSTR lpszFormat, ...)
{
	if (! IsLogFileEnable()) return;
    //指定类型级别以下的日志不打印;
    if ( m_nOutLogLevel < cType )
    {
        return;
    }

    //合法性检测
    if (!pszSourceFile || !lpszFormat)
    {
        OutputDebugString(_T("Error: pszSourceFile or lpszFormat is NULL\r\n"));
        return;
    }

    //读取参数
    va_list args;
    va_start(args, lpszFormat);

    CLocalLock localLock(&m_lock); //锁
    
    //打入字串
	m_szBuffer[0][0] = 0;
	int nBuf = -1;
	if(cType == LOGT_COMPRESS)      //对打印的日志进行压缩
	{
		TCHAR *tmp = new TCHAR[200000];
		memset(tmp,0,200000 * sizeof(TCHAR));
		int nBuf = _vsntprintf(tmp,200000-1,lpszFormat,args);
		CString strSource,strZipData;
		strSource.Format(_T("%s"),tmp);
		if (strSource.GetLength() < 100)
		{
			strZipData = strSource;
		}
		else
		{
			ZipEecodeStdString(strSource,strZipData);
		}
		_tcsncpy(m_szBuffer[0],strZipData.GetBuffer(strZipData.GetLength()),MAX_LEN_OF_LOG_LINE-128);
		strZipData.ReleaseBuffer();
		delete []tmp;
	}
	else
	{
		nBuf = _vsntprintf(m_szBuffer[0], MAX_LEN_OF_LOG_LINE - 128, lpszFormat, args);
	}
    va_end(args);		

    if (nBuf < 0) //出错
    {
		//有可能是字符串太长
        m_szBuffer[0][MAX_LEN_OF_LOG_LINE - 128] = 0;
    }
    
    //取系统日期、时间
    TCHAR szData[12], szTime[12];
    _tstrdate(szData);
    _tstrtime(szTime);

    //类型字串及颜色
	CString strType;
    DWORD dwColor = 0;

	//获取日志的类型文本及颜色
	GetLogType(strType,dwColor,cType);

    //源文件名缩短处理
    TCHAR * pszSourceShort = NULL;
    TCHAR szSourceShort[MAX_PATH];
    WORD wSourceNameLen = lstrlen(pszSourceFile);

    if (wSourceNameLen > LEN_SHORT_SOURCEFILE_NAME) //太长
    {
        wsprintf(szSourceShort, _T("...%s"),
            pszSourceFile + (wSourceNameLen - LEN_SHORT_SOURCEFILE_NAME));
        pszSourceShort = szSourceShort;
    }
    else
    {
        pszSourceShort = (TCHAR *)pszSourceFile;
    }

    //形成结果字串
    nBuf = _sntprintf(m_szBuffer[1], MAX_LEN_OF_LOG_LINE,
        _T("%s %s [%d]%s: %s at %d in %s\r\n"), szData, szTime, GetCurrentThreadId(), strType.GetBuffer(),
        m_szBuffer[0], dwLine, pszSourceShort);
    if (nBuf < 0) //出错
    {
        //有可能是字符串太长
        m_szBuffer[1][MAX_LEN_OF_LOG_LINE - 1] = 0;
    }

	strType.ReleaseBuffer();
    //打印
    TraceColor(cLevel, dwColor);
}
Пример #8
0
BOOL CChromClean::ScanChromePass()
{	
	if (!_CheckChromeExist())
	{
		g_vsNoinstallapp.Add(CHROME_PASSWORD);
		return TRUE;
	}
	CSimpleArray<CString> vec_file;
	CString strPath; 

	g_fnScanFile(g_pMain,BEGINPROC(CHROME_PASSWORD),0,0,0);

	std::wstring str;
	std::vector<std::wstring>::iterator it;
	for (it = g_listProcessName.begin(); it != g_listProcessName.end(); it++ )
	{
		str = *it;
		transform(str.begin(), str.end(), str.begin(), towlower);
		if (str == L"chrome.exe")
		{
			str = L"正在运行,跳过";
			goto _exit_;
		}
	}
	str = L"";
	if (m_bScan ==TRUE)
	{
        TCHAR szBuffer[MAX_PATH] = {0};

        ::SHGetSpecialFolderPath( NULL, szBuffer, CSIDL_LOCAL_APPDATA, FALSE);

        strPath = szBuffer;
        strPath += _T("\\Google\\Chrome\\User Data\\Default");
        sqlite3* pDB = NULL;
        sqlite3_stmt* sspStart = NULL;

        CString strDbPath = L"";
        strPath += L"\\";
        FindFileInDirectory(strPath.GetBuffer(),strDbPath,_T("Web Data"));
		strPath.ReleaseBuffer();

        if (strDbPath.GetLength()>=0)
        {
            KW2UTF8  szDataPath(strDbPath.GetBuffer());
            int nResult = sqlite3_open(szDataPath, &pDB);
            if (nResult != SQLITE_OK)
            {
                goto _exit_1;
            }
            nResult = sqlite3_prepare(pDB, "select * from logins", -1, &sspStart, 0);
            if (nResult != SQLITE_OK)
            {
                goto _exit_1;
            }

            nResult = sqlite3_step(sspStart);

            if(nResult == SQLITE_ROW)
            {
                CString strOutPut = strDbPath;
                strOutPut += L"|logins";
                g_fnScanFile(g_pMain, CHROME_PASSWORD, strOutPut, 0, 0);

            }
_exit_1:
            
            if (sspStart)
            {
                sqlite3_finalize(sspStart);
                sspStart = NULL;
            }

            if (pDB)
            {
                sqlite3_close(pDB);
                pDB = NULL;
            }

        }   

		strDbPath = L"";
		FindFileInDirectory(strPath.GetBuffer(),strDbPath,_T("Login Data"));
		strPath.ReleaseBuffer();

		if (strDbPath.GetLength()>=0)
		{
			KW2UTF8  szDataPath(strDbPath.GetBuffer());
			strDbPath.ReleaseBuffer();
			int nResult = sqlite3_open(szDataPath, &pDB);
			if (nResult != SQLITE_OK)
			{
				goto _exit_2;
			}
			nResult = sqlite3_prepare(pDB, "select * from logins", -1, &sspStart, 0);
			if (nResult != SQLITE_OK)
			{
				goto _exit_2;
			}

			nResult = sqlite3_step(sspStart);

			if(nResult == SQLITE_ROW)
			{
				CString strOutPut = strDbPath;
				strOutPut += L"|logins";
				g_fnScanFile(g_pMain, CHROME_PASSWORD, strOutPut, 0, 0);

			}
_exit_2:

			if (sspStart)
			{
				sqlite3_finalize(sspStart);
				sspStart = NULL;
			}

			if (pDB)
			{
				sqlite3_close(pDB);
				pDB = NULL;
			}

		}   
	}
_exit_:
	g_fnScanFile(g_pMain,ENDPROC(CHROME_PASSWORD),str.c_str(),0,0);

	return TRUE;		
}
Пример #9
0
BOOL CChromClean::CleanChromePass(CString& strInPath)
{	
    sqlite3* pDB = NULL;

    BOOL bRet = TRUE;

	if (strInPath.Find(L'|')==-1)
	{
		bRet = FALSE;
		return bRet;
	}

    TCHAR szBuffer[MAX_PATH] = {0};

    ::SHGetSpecialFolderPath( NULL, szBuffer, CSIDL_LOCAL_APPDATA, FALSE);

    CString strPath = szBuffer;

	strPath += _T("\\Google\\Chrome\\User Data\\Default");

    CString strDbPath = L"";

    strPath += L"\\";
    FindFileInDirectory(strPath.GetBuffer(),strDbPath,_T("Web Data"));
	strPath.ReleaseBuffer();

    if (strDbPath.GetLength()>=0)
    {
        KW2UTF8  szDataPath(strDbPath.GetBuffer());
		strDbPath.ReleaseBuffer();
        char* szError = NULL;
        char szSql[MAX_PATH] = {0};

        int nResult = sqlite3_open(szDataPath, &pDB);
        if (nResult != SQLITE_OK)
        {
            goto _exit_1;
        }


        sprintf_s(szSql, MAX_PATH - 1, "delete from logins");

        nResult = sqlite3_exec(pDB, szSql, 0, 0, &szError);

        if(nResult != SQLITE_OK)
        {
           
        }
_exit_1:

        if (pDB)
        {
            sqlite3_close(pDB);
            pDB = NULL;
        }

    }   

	strDbPath = L"";
	FindFileInDirectory(strPath.GetBuffer(),strDbPath,_T("Login Data"));
	strPath.ReleaseBuffer();

	if (strDbPath.GetLength()>=0)
	{
		KW2UTF8  szDataPath(strDbPath.GetBuffer());
		strDbPath.ReleaseBuffer();
		char* szError = NULL;
		char szSql[MAX_PATH] = {0};

		int nResult = sqlite3_open(szDataPath, &pDB);
		if (nResult != SQLITE_OK)
		{
			bRet = FALSE;
			goto _exit_2;
		}


		sprintf_s(szSql, MAX_PATH - 1, "delete from logins");

		nResult = sqlite3_exec(pDB, szSql, 0, 0, &szError);

		if(nResult != SQLITE_OK)
		{
			
		}
_exit_2:

		if (pDB)
		{
			sqlite3_close(pDB);
			pDB = NULL;
		}

	}   

	bRet = TRUE;


    return TRUE;

}	
Пример #10
0
void CDlgBatteryParam::WirteBatteryParameters()
{
    bool bIsRun=true;
    ::SendMessage((HWND)g_msgHwnd,WM_TEST_RUNNING,0,(LPARAM)&bIsRun);
    if (!bIsRun)
    {
             
        CString strInfo;
        if (!PathFileExists(strResourceDtsPath))
        {
            GetPrivateProfileStringW(_T("Prompt"),_T("ERROR_NOFOUND_RESOURCE"),_T("ERROR_NOFOUND_RESOURCE"),
                strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
            MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
            strInfo.ReleaseBuffer(MAX_LENGTH);
            return;
        }

		if(BatteryParamReadFile(strResourceDtsPath)<0)
		{
			GetPrivateProfileStringW(_T("Prompt"),_T("ERROR_READ_DTS_FILE"),_T("ERROR_READ_DTS_FILE"),
                strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
            MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
            strInfo.ReleaseBuffer(MAX_LENGTH);
            return;

		}

        STRUCT_BATTERY_PARAM param;
        if (!GetParamFromInterface(&param))
        {
            GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_INVALID_PARAM"),_T("IDS_ERROR_INVALID_PARAM"),
                strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
            MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
            return;
        }
        int iRet;
        iRet = WriteBatteryParam(strResourceDtsPath,&param);
        if (iRet==0)
        {
            GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_INFO_WRITE_OK"),_T("IDS_INFO_WRITE_OK"),
                strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
            MessageBox(strInfo,m_strMsgBoxTitle);
            return;
        }
        else
        {
            if (iRet==-2)
            {
                GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_INVALID_RESOURCE"),_T("IDS_ERROR_INVALID_RESOURCE"),
                strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
            }
            else{
                GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_NO_PARAM"),_T("IDS_ERROR_NO_PARAM"),
                strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
            }
        
            MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
            return;
        }
        
    }
}
Пример #11
0
BOOL CChromClean::ScanChrome()
{	
	//文件部分
	if (!_CheckChromeExist())
	{
		g_vsNoinstallapp.Add(BROWSERSCLEAN_CHROME);
		return TRUE;
	}
	CSimpleArray<CString> vec_file;
	CString strPath; 
	std::wstring str;
	g_fnScanFile(g_pMain,BEGINPROC(BROWSERSCLEAN_CHROME),0,0,0);
	
	std::vector<std::wstring>::iterator it;
	for (it = g_listProcessName.begin(); it != g_listProcessName.end(); it++ )
	{
		str = *it;
		transform(str.begin(), str.end(), str.begin(), towlower);
		if (str == L"chrome.exe")
		{
			str = L"正在运行,跳过";
			goto _exit_;
		}
	}
	str = L"";
	if (m_bScan ==TRUE)
	{
        TCHAR szBuffer[MAX_PATH] = {0};
		
        ::SHGetSpecialFolderPath( NULL, szBuffer, CSIDL_LOCAL_APPDATA, FALSE);

        strPath = szBuffer;
        strPath += _T("\\Google\\Chrome\\User Data\\Default\\Cache");
		m_appHistory.CommfunFile(BROWSERSCLEAN_CHROME,strPath,vec_file);
		
        strPath = szBuffer;
		strPath += _T("\\Google\\Chrome\\User Data\\Default\\Media Cache");
		m_appHistory.CommfunFile(BROWSERSCLEAN_CHROME,strPath,vec_file);

		//vec_file.Add(_T("Cookies"));
		//vec_file.Add(_T("Extension Cookies"));
		vec_file.Add(_T("Archived History"));
		//vec_file.Add(_T("History"));
		//vec_file.Add(_T("History-journal"));
		//vec_file.Add(_T("Thumbnails"));
		//vec_file.Add(_T("Thumbnails-journal"));
		vec_file.Add(_T("Current Tabs"));
		vec_file.Add(_T("Current Session"));
		vec_file.Add(_T("Last Tabs"));
		vec_file.Add(_T("Last Session"));
		vec_file.Add(_T("Safe Browsing Bloom"));
		vec_file.Add(_T("History Index*"));
		vec_file.Add(_T("Visited Links"));

		//vec_file.Add(_T("Extension Cookies"));
        strPath = szBuffer;
		strPath += _T("\\Google\\Chrome\\User Data\\Default");
		m_appHistory.CommfunFile(BROWSERSCLEAN_CHROME,strPath,vec_file);
		vec_file.RemoveAll();

        sqlite3* pDB = NULL;
        sqlite3_stmt* sspStart = NULL;

        CString strDbPath = L"";
        strPath += L"\\";
        FindFileInDirectory(strPath.GetBuffer(),strDbPath,_T("History"));
		strPath.ReleaseBuffer();

        if (strDbPath.GetLength()>=0)
        {
            KW2UTF8  szDataPath(strDbPath.GetBuffer());
			strDbPath.ReleaseBuffer();
            int nResult = sqlite3_open(szDataPath, &pDB);
            if (nResult != SQLITE_OK)
            {
                goto _exit_1;
            }
            nResult = sqlite3_prepare(pDB, "select * from segments", -1, &sspStart, 0);
            if (nResult != SQLITE_OK)
            {
                goto _exit_1;
            }

            nResult = sqlite3_step(sspStart);

            if(nResult == SQLITE_ROW)
            {
                CString strOutPut = strDbPath;
                strOutPut += L"|segments";
                g_fnScanFile(g_pMain, BROWSERSCLEAN_CHROME, strOutPut, 0, 0);
            }
        _exit_1:
			if (sspStart)
			{
				sqlite3_finalize(sspStart);
				sspStart = NULL;
			}

			if (pDB)
			{
				sqlite3_close(pDB);
				pDB = NULL;
			}

			nResult = sqlite3_open(szDataPath, &pDB);
			if (nResult != SQLITE_OK)
			{
				goto _exit_2;
			}

            nResult = sqlite3_prepare(pDB, "select * from visits", -1, &sspStart, 0);
            if (nResult != SQLITE_OK)
            {
                goto _exit_2;
            }

            nResult = sqlite3_step(sspStart);

            if(nResult == SQLITE_ROW)
            {
                CString strOutPut = strDbPath;
                strOutPut += L"|visits";
                g_fnScanFile(g_pMain, BROWSERSCLEAN_CHROME, strOutPut, 0, 0);

            }

        _exit_2:
            if (sspStart)
            {
                sqlite3_finalize(sspStart);
                sspStart = NULL;
            }
            if (pDB)
            {
                sqlite3_close(pDB);
                pDB = NULL;
            }

        }   

	}
	
_exit_:
	g_fnScanFile(g_pMain,ENDPROC(BROWSERSCLEAN_CHROME),str.c_str(),0,0);
	
	return TRUE;
}
Пример #12
0
void CDlgBatteryParam::ReadBatteryParameters()
{
    bool bIsRun=true;
    ::SendMessage((HWND)g_msgHwnd,WM_TEST_RUNNING,0,(LPARAM)&bIsRun);
    if (!bIsRun)
    {
        char szDir[MAX_PATH];
        memset(szDir,0,MAX_PATH);
        ::SendMessage((HWND)g_msgHwnd,WM_GET_DIR,(WPARAM)EmMsg_Root_key,(LPARAM)szDir);
        if (strlen(szDir)>0)
        {
            BOOL bRet = FALSE;
            LPWSTR lpDir = NULL;
            int nSize = 0;
            bRet = AnsiToUnicode(lpDir,nSize,szDir);
            if (bRet)
            {
                CString strInfo;
                CString strKernelPath=lpDir;
                delete []lpDir;
                lpDir = NULL;
                strKernelPath += _T("\\Image\\kernel.img");
                if (!PathFileExists(strKernelPath))
                {
                    GetPrivateProfileStringW(_T("Prompt"),_T("ERROR_NOFOUND_KERNEL"),_T("ERROR_NOFOUND_KERNEL"),
                        strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
                    MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
                    strInfo.ReleaseBuffer(MAX_LENGTH);
                    return;
                }
                STRUCT_BATTERY_PARAM param;
                int iRet;
                iRet = ReadBatteryParam(strKernelPath,&param);
                if (iRet==0)
                {
                    UpdateParamToInterface(&param);
                    return;
                }
                else
                {
                    ClearParamInterface();
                    if (iRet==-4)
                    {
                        GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_INVALID_KERNEL"),_T("IDS_ERROR_INVALID_KERNEL"),
                            strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
                    }
                    else if (iRet==-5)
                    {
                        GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_NO_PARAM"),_T("IDS_ERROR_NO_PARAM"),
                            strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
                    }
                    else
                        GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_READ_FAIL"),_T("IDS_ERROR_READ_FAIL"),
                        strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
                    MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
                    strInfo.ReleaseBuffer(MAX_LENGTH);
                    return;
                }
                
            }
            
        }
	}
}
Пример #13
0
void CMainFrame::OnFileSave() 
{
CFileDialog dlg(
		FALSE,
		_T("UI state"),
		_T(".\\Default.UI state"),
		OFN_ENABLESIZING|OFN_EXPLORER
			|OFN_LONGNAMES|OFN_PATHMUSTEXIST
			|OFN_NOCHANGEDIR|OFN_NODEREFERENCELINKS
			,
		_T("UI state files (*.UI state)|*.UI state|All files (*.*)|*.*||"),
		this
		);
	dlg.m_ofn.lpstrTitle = _T("Save UI state to file");
	if( dlg.DoModal() != IDOK )
		return;
	ASSERT( dlg.m_ofn.lpstrFile != NULL );
	try
	{
		CFile _file(
			dlg.m_ofn.lpstrFile,
			CFile::modeCreate|CFile::modeWrite|CFile::shareExclusive
			);
		CArchive ar( &_file, CArchive::store);

		CWinApp * pApp = ::AfxGetApp();
		ASSERT( pApp != NULL );
		ASSERT( pApp->m_pszRegistryKey != NULL );
		ASSERT( pApp->m_pszRegistryKey[0] != _T('\0') );
		ASSERT( pApp->m_pszProfileName != NULL );
		ASSERT( pApp->m_pszProfileName[0] != _T('\0') );

		VERIFY(
			CExtControlBar::ProfileBarStateSerialize(
				ar,
				this
				)
			);
		VERIFY(
			g_CmdManager->SerializeState(
				pApp->m_pszProfileName,
				ar
				)
			);
	} // try
	catch( CException * pXept )
	{
		CString sErrorDescription;
		VERIFY(
			pXept->GetErrorMessage(
				sErrorDescription.GetBuffer(8192), 8192
				)
			);
		sErrorDescription.ReleaseBuffer();
		ASSERT( !sErrorDescription.IsEmpty() );
		pXept->Delete();
		MessageBox(
			LPCTSTR(sErrorDescription),
			_T("State save failed"),
			MB_ICONERROR
			);
	} // catch( CException * pXept )
	catch( ... )
	{
		MessageBox(
			_T("Unknown exception caught"),
			_T("State save failed"),
			MB_ICONERROR
			);
	} // catch( ... )
}
Пример #14
0
int CPayment::GetMacData(CIso8583Package *package,char *sAccount)
{
	//打开串口
	int iCode = ZT_EPP_OpenCom(atoi(szZTComPort.GetBuffer()), atoi(szZTComBaud.GetBuffer()));
	if (iCode != 0)
	{
		//LogManager.WriteLog(LogFile.Error , " 任务出错: 打开金属密码键盘串口出错,端口被占用!" + "\r\n");
		return -1;
	}

	char cBuf[50];

	if (strcmp(szPinMode.GetBuffer(),"0") == 0) //前加密
	{
		//(1)激活PIN运算时使用的密钥号 -- 取PIN值,前加密
		if (strcmp(szKeyMode.GetBuffer(),"SAM") == 0)
		{
			//(1)设置卡座,卡座1,CPU卡
			iCode = ZT_EPP_SetICType(1, 0x88);
			if (iCode != 0)
			{
				//LogManager.WriteLog(LogFile.Error , " 任务出错: 设置卡座出错," + iCode + "\r\n");
				ZT_EPP_CloseCom();
				return -1;
			}
			//(2)上电
			iCode = ZT_EPP_ICOnPower(cBuf);
			if (iCode != 0)
			{
				//LogManager.WriteLog(LogFile.Error , " 任务出错: IC卡上电出错," + iCode + "\r\n");
				ZT_EPP_CloseCom();
				return -1;
			}
			//(3)设置算法参数
			iCode = ZT_EPP_SetDesPara(0, 0x30);
			if (iCode != 0)
			{
				//LogManager.WriteLog(LogFile.Error , " 任务出错: 设置算法参数出错," + iCode + "\r\n");
				ZT_EPP_CloseCom();
				return -1;
			}
		}

		iCode = ZT_EPP_SetDesPara(1, 0x30);
		if (iCode != 0)
		{
			//LogManager.WriteLog(LogFile.Error , " 任务出错: 设置算法参数出错," + iCode + "\r\n");
			ZT_EPP_CloseCom();
			return -1;
		}

		//(1)激活工作密钥
		iCode = ZT_EPP_ActivWorkPin(0, 0);
		if (iCode != 0)
		{
			//LogManager.WriteLog(LogFile.Error , " 任务出错: 激活工作密钥," + iCode + "\r\n");
			ZT_EPP_CloseCom();
			return -1;
		}

		//(2)设置卡号
		char cAccount[13] ={'\0'};
		int offset = strlen(sAccount) - 13;
		memcpy(cAccount,sAccount + offset,12);
		iCode = ZT_EPP_PinLoadCardNo(cAccount);
		if (iCode != 0)
		{
			//LogManager.WriteLog(LogFile.Error , " 任务出错: 无法设置卡号!" + "\r\n");
			ZT_EPP_CloseCom();
			return -1;
		}

		//(3)关闭键盘且打开按键声音
		iCode = ZT_EPP_OpenKeyVoic(2);

		if (strcmp(szKeyMode.GetBuffer(),"IC") == 0)
		{
			//键盘输入PIN采用内置3DES-2key密码算法,工作密钥加密
			iCode = ZT_EPP_SetDesPara(1, 0x30); 
		}

		//键盘输入PIN短时,用<F>值填充PIN右边直至8字节
		iCode = ZT_EPP_SetDesPara(2, 0xFF);

		//(4)启动密码键盘加密
		iCode = ZT_EPP_PinStartAdd(6, 1, 1, 0, 30);   

		AllowInput = true;
		//(5)循环获取使用者按键键值
		ZtPwdEncryptInput();
		AllowInput = false;

		//(6)最后接收取PIN密文
		unsigned char cPin[20]={'\0'};
		iCode = ZT_EPP_PinReadPin(0, cPin);
		if (iCode != 0)
		{
			//LogManager.WriteLog(LogFile.Error , " 任务出错: 取PIN密文出错," + iCode + "\r\n");
			ZT_EPP_CloseCom();
			return -1;
		}
		package->SetFieldData(52,8,cPin);
	}
	else if (strcmp(szPinMode.GetBuffer(),"1") == 0)
	{
		//(2)关闭键盘且打开按键声音
		iCode = ZT_EPP_OpenKeyVoic(2);

		////键盘输入PIN采用内置3DES-2key密码算法,工作密钥加密
		//iCode = ZT_EPP_SetDesPara(1, 0x30);

		//iCode = ZT_EPP_SetDesPara(2, 0xFF);

		//(3)启动密码键盘加密
		iCode = ZT_EPP_PinStartAdd(6, 1, 0, 0, 30);

		AllowInput = true;
		//(4)循环获取使用者按键键值
		ZtPwdEncryptInput();
		AllowInput = false;

		//(5)激活PIN运算时使用的密钥号 -- 取PIN值,前加密
		if (strcmp(szKeyMode.GetBuffer(),"IC") == 0)
			iCode = ZT_EPP_ActivWorkPin(0, 0);
		else if (strcmp(szKeyMode.GetBuffer(),"SAM") == 0)
			iCode = ZT_EPP_ActivWorkPin(0, 0x40);

		////键盘输入PIN采用内置3DES-2key密码算法,工作密钥加密
		//iCode = ZT_EPP_SetDesPara(1, 0x30);
		////键盘输入PIN短时,用<F>值填充PIN右边直至8字节
		//iCode = ZT_EPP_SetDesPara(2, 0xFF);

		iCode = ZT_EPP_SetDesPara(4, 0x10);

		//(6)设置卡号
		char cAccount[13] ={'\0'};
		int offset = strlen(sAccount) - 13;
		memcpy(cAccount,sAccount + offset,12);
		iCode = ZT_EPP_PinLoadCardNo(cAccount);
		if (iCode != 0)
		{
			//LogManager.WriteLog(LogFile.Error , " 任务出错: 无法设置卡号!" + "\r\n");
			ZT_EPP_CloseCom();
			return -1;
		}

		//(7)最后接收取PIN密文
		unsigned char cPin[20]={'\0'};
		iCode = ZT_EPP_PinReadPin(2, cPin);
		if (iCode != 0)
		{
			//LogManager.WriteLog(LogFile.Error , " 任务出错: 取PIN密文出错," + iCode + "\r\n");
			ZT_EPP_CloseCom();
			return -1;
		}
		package->SetFieldData(52,8,cPin);
	}
	//(7) 关闭金属键盘
	ZT_EPP_OpenKeyVoic(0);
	if (strcmp(szKeyMode.GetBuffer(),"SAM") == 0)
	{
		iCode = ZT_EPP_SetDesPara(0, 0x30);
		if (iCode != 0)
		{
			//LogManager.WriteLog(LogFile.Error , " 任务出错: 设置算法参数出错," + iCode + "\r\n");
			ZT_EPP_CloseCom();
			return -1;
		}
		iCode = ZT_EPP_SetDesPara(1, 0x30);
		if (iCode != 0)
		{
			//LogManager.WriteLog(LogFile.Error , " 任务出错: 设置算法参数出错," + iCode + "\r\n");
			ZT_EPP_CloseCom();
			return -1;
		}
	}
	//激活工作密钥 - MAC
	iCode = ZT_EPP_ActivWorkPin(0, 1);

	//取需要进行MAC计算的数据
	BYTE cData[1024];
	memset(cData,0,1024);
	BYTE cType[] ={0x02,0x00};
	int nLen = package->GetData(cData,1024,cType,2,true);
	int nGroup = 0;
	if( nLen % 8 == 0)
		nGroup = nLen / 8;
	else
		nGroup = nLen / 8 + 1;
	CString sMacData = Convert2Hex((char *)cData,nGroup * 8);

	//MAC加密运算
	char cMac[17]={'\0'};
	iCode = ZT_EPP_PinCalMAC(1, 4, /*cMacData*/sMacData.GetBuffer(), cMac);
	if (iCode != 0)
	{
		//LogManager.WriteLog(LogFile.Error , " 任务出错: MAC加密运算出错," + iCode + "\r\n");
		ZT_EPP_CloseCom();
		return -1;
	}

	sMacData.ReleaseBuffer();

	//关闭串口
	iCode = ZT_EPP_CloseCom();

	package->SetFieldData(64,8,(BYTE*)cMac);

	return 0;
}
Пример #15
0
/*
 * This function is called when the remote connection, whant to send a file.  
 *
 */  
void MyIOCP::PackageFileTransfer(CIOCPBuffer *pOverlapBuff,int nSize,ClientContext *pContext)
{
#ifdef TRANSFERFILEFUNCTIONALITY
	
	CString sFileName="";
	UINT	iMaxFileSize=0;
	BYTE dummy=0;
	if(pOverlapBuff->GetPackageInfo(dummy,iMaxFileSize,sFileName))
	{
		// Get The Current Path name and application name.
		CString sFilePath="";		
		char drive[_MAX_DRIVE];
		char dir[_MAX_DIR];
		char fname[_MAX_FNAME];
		char ext[_MAX_EXT];
		CString strTemp;
		GetModuleFileName(NULL,strTemp.GetBuffer(MAX_PATH),MAX_PATH);
		strTemp.ReleaseBuffer();
		_splitpath( strTemp, drive, dir, fname, ext );
		sFilePath=drive; //Drive
		sFilePath+=dir; //dir
		sFilePath+=sFileName; //name.. 
		TRACE("Incoming File >%s.\r\n",sFilePath);
		// Perpare for Receive
	
		if(PrepareReceiveFile(pContext->m_Socket,sFilePath,iMaxFileSize))
		{
			// Send start file transfer.. 
			CIOCPBuffer *pOverlapBuff=AllocateBuffer(IOWrite);
			if(pOverlapBuff)
			{
				if(pOverlapBuff->CreatePackage(Job_StartFileTransfer))
			     ASend(pContext,pOverlapBuff);

			}
		}else
		{
		   // Abort Transfer. 
			CIOCPBuffer *pOverlapBuff=AllocateBuffer(IOWrite);
			if(pOverlapBuff)
			{
				if(pOverlapBuff->CreatePackage(Job_AbortFileTransfer))
			     ASend(pContext,pOverlapBuff);

			}
		}
		
		// to be sure that pcontext Suddenly does not dissapear.. 
		m_ContextMapLock.Lock();
		pContext->m_ContextLock.Lock();
		pContext->m_sReceived=sFilePath;
		// Update that we have data
		pContext->m_iNumberOfReceivedMsg++;
		pContext->m_ContextLock.Unlock();
		m_ContextMapLock.Unlock();

		// Update Statistics. 
		m_StatusLock.Lock();
		m_iNumberOfMsg++;
		m_StatusLock.Unlock();
	}
#endif
}
//-------------------------------------------------------
// LOAD SAVED STATS
//-------------------------------------------------------
void CCalcDlg::OnloadButton( ) 
{
	CCalcDlg::Onreset( );
	
	//which position in the list box the user click on
	int sel = m_loadList.GetCurSel( );
	
	CString str;
	int n;
	
	//convert the string in the list box to a CString
	n = m_loadList.GetTextLen( sel );
    m_loadList.GetText( sel, str.GetBuffer( n ) );
    str.ReleaseBuffer( );
	
	//change the save input to the file name to be loaded
	m_saveIn.SetWindowText( str );
	
	FILE* in;
	in = fopen( str+".dat", "r" );
	
	if ( in != NULL )
	{
		int s[6];
		int j[6];
		
		//read the .dat file and save the info
		fscanf( in, "%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i",
			&classNumber, &lvl, &statArray[0], &statArray[1], &statArray[2], &statArray[3],
			&statArray[4], &shrineArray[0], &shrineArray[1], &shrineArray[2], &shrineArray[3],
			&shrineArray[4], &s[0], &s[1], &s[2], &s[3], &s[4], &s[5], &j[0], &j[1], &j[2],
			&j[3], &j[4], &j[5], &hpBaseArray[0], &hpBaseArray[1], &hpBaseArray[2], &hpBaseArray[3],
			&hpBaseArray[4], &hpBaseArray[5], &mpBaseArray[0], &mpBaseArray[1], &mpBaseArray[2],
			&mpBaseArray[3], &mpBaseArray[4], &mpBaseArray[5] );

		//human skills
		if ( mpBaseArray[5] == 6 ) { m_mphuman.SetCheck( 1 ); }
		if ( hpBaseArray[5] == 6 ) { m_hphuman.SetCheck( 1 ); }
		
		//check the shrines
		m_ghShrine.SetCheck( s[0] );
		m_strengthShrine.SetCheck( s[1] );
		m_agilityShrine.SetCheck( s[2] );
		m_constitutionShrine.SetCheck( s[3] );
		m_intelligenceShrine.SetCheck( s[4] );
		m_wisdomShrine.SetCheck( s[5] );
		
		//check and call the jeloc functions
		if ( j[0] == TRUE )
		{
			//sixth is checked, so check all the jeloc shrines too
			m_sixthJeloc.SetCheck( TRUE );
			CCalcDlg::OnsixthJeloc( );
			
			//calling the 6th jeloc function will add an extra 7 points not needed
			statArray[0]-=7; shrineArray[0]-=7;
			statArray[1]-=7; shrineArray[1]-=7;
			statArray[2]-=7; shrineArray[2]-=7;
			statArray[3]-=7; shrineArray[3]-=7;
			statArray[4]-=7; shrineArray[4]-=7;
		}
		else
		{
			//sixth was not checked, so only check the ones that were
			m_strengthJeloc.SetCheck( j[1] );
			m_agilityJeloc.SetCheck( j[2] );
			m_constitutionJeloc.SetCheck( j[3] );
			m_intelligenceJeloc.SetCheck( j[4] );
			m_wisdomJeloc.SetCheck( j[5] );
		}
		
		
		fclose( in );
		CCalcDlg::redo( );
	}
}
Пример #17
0
//左键双击
void __cdecl CPlazaViewItem::OnTreeLeftDBClick(CListItem *pListItem, 
											   HTREEITEM hTreeItem, 
											   CTreeCtrl *pTreeCtrl)
{
	//效验参数
	if(pListItem==NULL) 
	{
		return ;
	}


	//消息处理
	switch (pListItem->GetItemGenre())
	{
		//游戏类型
	case ItemGenre_Kind:	
		{
			CListKind *pListKind	= (CListKind *)pListItem;
			tagGameKind *pGameKind	= pListKind->GetItemInfo();
			//Add by doctor 20071014
			//大类型ID
			int gameTypeInt = pGameKind->wTypeID ;
			CString gameExeStr;
			gameExeStr.Format("%s", pGameKind->szProcessName );

			if ( IsTimeOut())
			{}
			else
			{
				//是否为单机,FLASH游戏
				switch (gameTypeInt)
				{
					//单机游戏
				case 5:
					{
						CString lpszFileName ;
						CString  gamePath;
						CString applicationPath;
						CFileFind  fFind;


						//获得应用程序路径
						int nPos;
						GetModuleFileName(NULL,applicationPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
						applicationPath.ReleaseBuffer();
						nPos = applicationPath.ReverseFind('\\');
						applicationPath = applicationPath.Left(nPos);

						gamePath = applicationPath + "\\LocalGame";
						lpszFileName = gamePath +"\\"+gameExeStr;//这里修改成你的调用应用程序的文件名称
						//启动单机游戏
						if(!fFind.FindFile(lpszFileName))
						{

							AfxMessageBox("没有找到调用的应用程序!"+ lpszFileName); 
							return ;
						}
						else
						{
							CString cmdLine;
							cmdLine.Format("-%s", "FlyGame2007");
							//	ShellExecute(NULL,"open", gameExeStr, cmdLine ,NULL,SW_SHOW);	
							ShellExecute(NULL,"open", gameExeStr, cmdLine ,gamePath,SW_SHOW);	
							//						ShellExecute(NULL,NULL,_T(gameExeStr),NULL, gamePath,NULL); 
						}

						return;
					}
					break;
					//flash游戏
				case 6:
					{
						//启动FLASH游戏
						//连接规则
						TCHAR szRuleUrl[256]=TEXT("");
						_snprintf(szRuleUrl,sizeof(szRuleUrl),TEXT("%sPlayGame.asp?KindID=%ld"), Glb().m_MainHomeUrl, pGameKind->wKindID);

						WebBrowse(szRuleUrl,true);

						return;
					}
					break;
				default:
					{}
				}
				//End add
			}//End if

			//安装判断
			if (pListKind->m_bInstall==false)
			{
				TCHAR szBuffer[512]=TEXT("");
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("【%s】还没有安装,现在是否下载?"),pGameKind->szKindName);
				int nResult = ShowMessageBox(szBuffer,
					MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1);
				if(nResult == IDYES)	
				{
					g_GlobalAttemper.DownLoadClient(pGameKind->szKindName,
						pGameKind->wKindID,
						true);
				}
			}

			return;
		}

		//进程类型
	case ItemGenre_Process:	
		{
			CListProcess *pListProcess	= (CListProcess *)pListItem;
			tagGameProcess *pGameProcess= pListProcess->GetItemInfo();

			//构造命令行
			CString strCommonLine;
			tagGlobalUserData & UserData=g_GlobalUnits.GetGolbalUserData();
			strCommonLine.Format(TEXT("%s /UserToken:%ld#%s#%s /KindID:%ld /WndPlaza:%ld"),
				pGameProcess->szProcessName,
				UserData.dwUserID,
				UserData.szAccounts,
				UserData.szPassWord,
				pGameProcess->wKindID,
				m_hWnd);

			//启动游戏客户端
			STARTUPINFO			StartInfo;
			PROCESS_INFORMATION ProcessInfo;

			memset(&StartInfo,0,sizeof(StartInfo));
			memset(&ProcessInfo,0,sizeof(ProcessInfo));

			StartInfo.cb=sizeof(StartInfo);
			StartInfo.wShowWindow=SW_SHOWMAXIMIZED;
			BOOL bSuccess=CreateProcess(NULL,strCommonLine.GetBuffer(),NULL,NULL,FALSE,CREATE_DEFAULT_ERROR_MODE,NULL,NULL,&StartInfo,&ProcessInfo);
			strCommonLine.ReleaseBuffer();
			if(bSuccess == FALSE)
			{
				//下载询问
				TCHAR szBuffer[512]=TEXT("");
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("【%s】还没有安装,现在是否下载?"),pGameProcess->szKindName);
				int nResult=ShowMessageBox(szBuffer,MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1);
				if (nResult==IDYES)	g_GlobalAttemper.DownLoadClient(pGameProcess->szKindName,pGameProcess->wKindID,true);
			}
			else
			{
				CloseHandle(ProcessInfo.hThread);
				CloseHandle(ProcessInfo.hProcess);
			}

			return;
		}

		//游戏房间
	case ItemGenre_Server:	
		{
			CListServer * pListServer=(CListServer *)pListItem;
			g_pControlBar->CreateRoomViewItem(pListServer);
			return;
		}
	}//End switch (pListItem->GetItemGenre())

	return;
}
Пример #18
0
// 设置当前账号
void SetCurrentUser(LPCTSTR userName)
{
	// 保存当前账号配置
	if (g_currentUser != _T(""))
		SaveCurrentUserProfile();

	// 设置配置路径
	g_currentUser = userName;
	CURRENT_USER_PATH = USERS_PATH + userName;
	USER_PROFILE_PATH = CURRENT_USER_PATH + _T("\\options.tb");
	COOKIE_PATH = CURRENT_USER_PATH + _T("\\ck.tb");
	CACHE_PATH = CURRENT_USER_PATH + _T("\\cache.tb");

	// 读取设置
	TCHAR buffer[260];
	// 方案
	GetPrivateProfileString(_T("Setting"), _T("Option"), _T("默认"), g_currentOption.GetBuffer(MAX_PATH), MAX_PATH, USER_PROFILE_PATH);
	g_currentOption.ReleaseBuffer();
	ReadOptions(OPTIONS_PATH + g_currentOption + _T(".tb"));
	// 贴吧名
	GetPrivateProfileString(_T("Setting"), _T("ForumName"), _T(""), buffer, _countof(buffer), USER_PROFILE_PATH);
	((CTiebaManagerDlg*)AfxGetApp()->m_pMainWnd)->m_forumNameEdit.SetWindowText(buffer);
	// Cookie
	gzFile f = gzopen_w(COOKIE_PATH, "rb");
	if (f != NULL)
	{
		ReadText(f, g_cookie);
		gzclose(f);
	}

	// 历史回复、忽略ID等
	f = gzopen_w(CACHE_PATH, "rb");
	if (f != NULL)
	{
		int size;
		// 历史回复
		if (gzread(f, &size, sizeof(int)) == sizeof(int) && 0 < size && size < 100000) // 长度
		{
			__int64 tid;
			int reply;
			for (int i = 0; i < size; i++)
			{
				gzread(f, &tid, sizeof(__int64));
				gzread(f, &reply, sizeof(int));
				g_reply[tid] = reply;
			}
		}
		// 忽略ID
		ReadIDSet(f, g_initIgnoredTID);
		g_ignoredTID = g_initIgnoredTID;
		ReadIDSet(f, g_initIgnoredPID);
		g_ignoredPID = g_initIgnoredPID;
		ReadIDSet(f, g_initIgnoredLZLID);
		g_ignoredLZLID = g_initIgnoredLZLID;
		// 违规次数
		if (gzread(f, &size, sizeof(int)) == sizeof(int) && 0 < size && size < 100000) // 长度
		{
			CString userName;
			int count;
			for (int i = 0; i < size; i++)
			{
				ReadText(f, userName);
				gzread(f, &count, sizeof(int));
				g_userTrigCount[userName] = count;
			}
		}
		// 拉黑用户
		ReadTextSet(f, g_defriendedUser);
		gzclose(f);
	}
}
Пример #19
0
void CDetailInfo::UpdateInfo(CPartFile* pFile, DWORD dwMask)
{
	try
	{
		m_ListDetail.DeleteAllItems();

		if (NULL == pFile || 0 == dwMask)
			return;

		m_pCurFile = pFile;
		m_dwCurMask = dwMask;

		int	iItem;
		CString	str;
		CPartFile	*lpPartFile = pFile;//DYNAMIC_DOWNCAST(CPartFile, pFile);

		iItem = 0;

		if (IM_FILENAME & dwMask)
		{
			str = pFile->GetFileName();
			m_ListDetail.InsertItem(iItem, GetResString(IDS_DL_FILENAME));
			m_ListDetail.SetItemText(iItem, 1, str);
			iItem++;
		}
		if (IM_FILESIZE & dwMask)
		{
			str = CastItoXBytes(pFile->GetFileSize(), false, false);
			m_ListDetail.InsertItem(iItem, GetResString(IDS_DL_SIZE));
			if(!str.IsEmpty())
			    m_ListDetail.SetItemText(iItem, 1, str);
			else
				m_ListDetail.SetItemText(iItem, 1, GetResString(IDS_UNKNOWN));
			iItem++;
		}
		if (IM_FILETYPE & dwMask)
		{
			str = pFile->GetFileTypeDisplayStr();
			m_ListDetail.InsertItem(iItem, GetResString(IDS_TYPE));
			if(!str.IsEmpty())
			    m_ListDetail.SetItemText(iItem, 1, str);
			else
				m_ListDetail.SetItemText(iItem, 1, GetResString(IDS_UNKNOWN));
			iItem++;
		}
		
		if (IM_LINK & dwMask)
		{   
			str = GetLink(pFile);
			bool bRefer = false;
			if(str.Left(7).CompareNoCase(_T("http://")) == 0)
			{  
				if(str.Find(_T('<'))>0)
				{   
					bRefer = true;
					str = str.Left(str.Find(_T('<')));
				}
				if(str.Find(_T('#'))>0)
					str = str.Left(str.Find(_T('#')));
			}
			if(!str.IsEmpty())
			{
				m_ListDetail.InsertItem(iItem, GetResString(IDS_DOWNLOAD_LINK));
				m_ListDetail.SetItemText(iItem, 1, str);
				iItem++;
			}
			if(bRefer)
			{
				
				CString refer = GetLink(pFile);
				refer = refer.Right(refer.GetLength() - 1 - refer.Find(_T('=')));
				if(refer.Find(_T('>')) > 0)
					refer.Remove(_T('>'));
				m_ListDetail.InsertItem(iItem,GetResString(IDS_REFER_LINK));
				m_ListDetail.SetItemText(iItem,1,refer);
				iItem++;
			}
		}
		if (IM_SOURCEURL & dwMask)
		{
			str = pFile->GetPartFileURL();
			bool bRefer = false;
			if(str.Find(_T('<'))>0)
			{   
				bRefer = true;
				str = str.Left(str.Find(_T('<')));
			}
			if(str.Find(_T('#'))>0)
				str = str.Left(str.Find(_T('#')));
			if(!str.IsEmpty())
			{
		       m_ListDetail.InsertItem(iItem, GetResString(IDS_URL_LINK));
		       m_ListDetail.SetItemText(iItem, 1, str);
			   iItem++;
			}
			if(bRefer)
			{   
			   CString strRefer = pFile->GetPartFileURL();
			   strRefer = strRefer.Right(strRefer.GetLength() -1 - strRefer.Find(_T('=')  ));
			   if(strRefer.Find(_T('>'))>0)
				   strRefer.Remove(_T('>'));
				m_ListDetail.InsertItem(iItem,GetResString(IDS_REFER_LINK));
				m_ListDetail.SetItemText(iItem,1,strRefer);
				iItem++;
			}
		}
		if (IM_PRIORITY & dwMask)
		{ 
			if(dwMask == CDetailInfo::IM_COMBINE_DOWNLOAD)
			      str = PriorityToString(pFile->GetDownPriority(), pFile->IsAutoDownPriority());
			if(dwMask == CDetailInfo::IM_COMBINE_SHARE)
				str = PriorityToString(pFile->GetUpPriority(),pFile->IsAutoUpPriority());
			m_ListDetail.InsertItem(iItem, GetResString(IDS_PRIORITY));
			m_ListDetail.SetItemText(iItem, 1, str);
			iItem++;
		}
		if (IM_FILEHASH & dwMask)
		{
			if (pFile->HasNullHash())
			{
				str = _T("-");
			}
			else
			{
				str = md4str(pFile->GetFileHash());
			}
			
			m_ListDetail.InsertItem(iItem, GetResString(IDS_FILEID));
			m_ListDetail.SetItemText(iItem, 1, str);
			iItem++;
		}
		if (IM_REQUEST & dwMask)
		{
			str.Format(_T("%u (%u)"), pFile->statistic.GetRequests(), pFile->statistic.GetAllTimeRequests());
			m_ListDetail.InsertItem(iItem, GetResString(IDS_SF_REQUESTS));
			m_ListDetail.SetItemText(iItem, 1, str);
			iItem++;
		}
		if (IM_TRANSFERED & dwMask)
		{
			str.Format(_T("%s (%s)"), CastItoXBytes(pFile->statistic.GetTransferred(), false, false), CastItoXBytes(pFile->statistic.GetAllTimeTransferred(), false, false));
			m_ListDetail.InsertItem(iItem, GetResString(IDS_SF_TRANSFERRED));
			m_ListDetail.SetItemText(iItem, 1, str);
			iItem++;
		}
		if (IM_FILEPATH & dwMask)
		{
			str = pFile->GetPath();
			PathRemoveBackslash(str.GetBuffer());
			str.ReleaseBuffer();
			m_ListDetail.InsertItem(iItem, GetResString(IDS_FOLDER));
			m_ListDetail.SetItemText(iItem, 1, str);
			iItem++;
		}
		if (IM_ACCEPT & dwMask)
		{
			str.Format(_T("%u (%u)"), pFile->statistic.GetAccepts(), pFile->statistic.GetAllTimeAccepts());
			m_ListDetail.InsertItem(iItem, GetResString(IDS_SF_ACCEPTS));
			m_ListDetail.SetItemText(iItem, 1, str);
			iItem++;
		}
		if (IM_SOURCE & dwMask)
		{
			str.Format(_T("%u - %u"), pFile->m_nCompleteSourcesCountLo, pFile->m_nCompleteSourcesCountHi);
			m_ListDetail.InsertItem(iItem, GetResString(IDS_COMPLSOURCES));
			m_ListDetail.SetItemText(iItem, 1, str);
			iItem++;
		}
		if (IM_REMAIN & dwMask)
		{
			if (NULL != lpPartFile)
			{
				str.Empty();
				if (lpPartFile->GetStatus() != PS_COMPLETING && lpPartFile->GetStatus() != PS_COMPLETE )
				{
					// time 
					time_t restTime;
					if (!thePrefs.UseSimpleTimeRemainingComputation())
						restTime = lpPartFile->getTimeRemaining();
					else
						restTime = lpPartFile->getTimeRemainingSimple();

					str.Format(_T("%s (%s)"), CastSecondsToHM(restTime), CastItoXBytes((lpPartFile->GetFileSize() - lpPartFile->GetCompletedSize()), false, false));
				}
				else
				{
					str.Format(_T("%s (%s)"), _T("0"), CastItoXBytes((lpPartFile->GetFileSize() - lpPartFile->GetCompletedSize()), false, false));
				}
				m_ListDetail.InsertItem(iItem, GetResString(IDS_DL_REMAINS));
				if(!str.IsEmpty())
				   m_ListDetail.SetItemText(iItem, 1, str);
				else
					m_ListDetail.SetItemText(iItem,1,GetResString(IDS_UNKNOWN));
				iItem++;
			}

		}
		if (IM_LASTCOMPLETE & dwMask)
		{
			if (NULL != lpPartFile)
			{
//				CString tempbuffer;
//				if (lpPartFile->m_nCompleteSourcesCountLo == 0)
//				{
//					tempbuffer.Format(_T("< %u"), lpPartFile->m_nCompleteSourcesCountHi);
//				}
//				else if (lpPartFile->m_nCompleteSourcesCountLo == lpPartFile->m_nCompleteSourcesCountHi)
//				{
//					tempbuffer.Format(_T("%u"), lpPartFile->m_nCompleteSourcesCountLo);
//				}
//				else
//				{
//					tempbuffer.Format(_T("%u - %u"), lpPartFile->m_nCompleteSourcesCountLo, lpPartFile->m_nCompleteSourcesCountHi);
//				}
				if (lpPartFile->lastseencomplete==NULL)
					str.Format(_T("%s" /*(%s)*/),GetResString(IDS_NEVER)/*,tempbuffer*/);
				else
					str.Format(_T("%s" /*(%s)*/),lpPartFile->lastseencomplete.Format( thePrefs.GetDateTimeFormat())/*,tempbuffer*/);

				m_ListDetail.InsertItem(iItem, GetResString(IDS_LASTSEENCOMPL));
				m_ListDetail.SetItemText(iItem, 1, str);
				iItem++;
			}

		}
		if (IM_LASTRECV & dwMask)
		{
			if (NULL != lpPartFile)
			{
				if(lpPartFile->GetFileDate()!=NULL && lpPartFile->GetRealFileSize()/*GetCompletedSize() */> (uint64)0)
					str = lpPartFile->GetCFileDate().Format( thePrefs.GetDateTimeFormat());
				else
					str.Format(_T("%s"),GetResString(IDS_NEVER));

				m_ListDetail.InsertItem(iItem, GetResString(IDS_FD_LASTCHANGE));
				m_ListDetail.SetItemText(iItem, 1, str);
				iItem++;
			}
		}
		if (IM_CATEGORY & dwMask)
		{
			if (NULL != lpPartFile)
			{
				str = (lpPartFile->GetCategory()!=0) ? thePrefs.GetCategory(lpPartFile->GetCategory())->strTitle:_T("");

				m_ListDetail.InsertItem(iItem, GetResString(IDS_CAT));
				m_ListDetail.SetItemText(iItem, 1, str);
				iItem++;
			}
		}
	}
	catch(...)
	{
	}
}
Пример #20
0
HTREEITEM CDirectoryTreeCtrl::AddChildItem(HTREEITEM hRoot, CString strText)
{
	CString strPath = GetFullPath(hRoot);
	if (hRoot != NULL && strPath.Right(1) != _T("\\"))
		strPath += _T("\\");
	CString strDir = strPath + strText;
	TV_INSERTSTRUCT itInsert = {0};
	
	// START: changed by FoRcHa /////
	WORD wWinVer = thePrefs.GetWindowsVersion();
	if(wWinVer == _WINVER_2K_ || wWinVer == _WINVER_XP_ || wWinVer == _WINVER_ME_)		
	{
		itInsert.item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_TEXT |
							TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
		itInsert.item.stateMask = TVIS_BOLD | TVIS_STATEIMAGEMASK;
	}
	else
	{
		itInsert.item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_TEXT | TVIF_STATE;
		itInsert.item.stateMask = TVIS_BOLD;
	}
	// END: changed by FoRcHa ///////
	
	if (HasSharedSubdirectory(strDir))
		itInsert.item.state = TVIS_BOLD;
	else
		itInsert.item.state = 0;
	if (HasSubdirectories(strDir))
		itInsert.item.cChildren = I_CHILDRENCALLBACK;		// used to display the + symbol next to each item
	else
		itInsert.item.cChildren = 0;

	itInsert.item.pszText = const_cast<LPTSTR>((LPCTSTR)strText);
	itInsert.hInsertAfter = hRoot ? TVI_SORT : TVI_LAST;
	itInsert.hParent = hRoot;
	
	// START: added by FoRcHa ////////////////
	if(wWinVer == _WINVER_2K_ || wWinVer == _WINVER_XP_ || wWinVer == _WINVER_ME_)		
	{
		CString strTemp = strDir;
		if(strTemp.Right(1) != _T("\\"))
			strTemp += _T("\\");
		
		UINT nType = GetDriveType(strTemp);
		if(DRIVE_REMOVABLE <= nType && nType <= DRIVE_RAMDISK)
			itInsert.item.iImage = nType;
	
		SHFILEINFO shFinfo;
		shFinfo.szDisplayName[0] = _T('\0');
		if(!SHGetFileInfo(strTemp, 0, &shFinfo,	sizeof(shFinfo),
						SHGFI_ICON | SHGFI_SMALLICON | SHGFI_DISPLAYNAME))
		{
			TRACE(_T("Error Gettting SystemFileInfo!"));
			itInsert.itemex.iImage = 0; // :(
		}
		else
		{
			itInsert.itemex.iImage = shFinfo.iIcon;
			DestroyIcon(shFinfo.hIcon);
			if (hRoot == NULL && shFinfo.szDisplayName[0] != _T('\0'))
			{
				STreeItem* pti = new STreeItem;
				pti->strPath = strText;
				strText = shFinfo.szDisplayName;
				itInsert.item.pszText = const_cast<LPTSTR>((LPCTSTR)strText);
				itInsert.item.mask |= TVIF_PARAM;
				itInsert.item.lParam = (LPARAM)pti;
			}
		}

		if(!SHGetFileInfo(strTemp, 0, &shFinfo, sizeof(shFinfo),
							SHGFI_ICON | SHGFI_OPENICON | SHGFI_SMALLICON))
		{
			TRACE(_T("Error Gettting SystemFileInfo!"));
			itInsert.itemex.iImage = 0;
		}
		else
		{
			itInsert.itemex.iSelectedImage = shFinfo.iIcon;
			DestroyIcon(shFinfo.hIcon);
		}
	}
	// END: added by FoRcHa //////////////

	HTREEITEM hItem = InsertItem(&itInsert);
	if (IsShared(strDir))
		SetCheck(hItem);
	strText.ReleaseBuffer();

	return hItem;
}
Пример #21
0
//
// PreloadPBNFile()
//
// - preload the PBN file and strip comments
//
int CEasyBDoc::PreloadPBNFile(CArchive& ar, CStringArray& strLines)
{
	int numLinesRead = 0;
	strLines.RemoveAll();

	// read in the file
	CString strBuf;
	int nSize = ar.GetFile()->GetLength();
	PBYTE pBuf = (PBYTE) strBuf.GetBuffer(nSize);
	int numBytesRead = ar.Read(pBuf, nSize);
	ASSERT(numBytesRead == nSize);
	strBuf.ReleaseBuffer(nSize);

	// check for export tag
	int nPos = strBuf.Find(_T("% EXPORT"));
	if (nPos < 0)   // NCR_PBNI allow as first line (was < 1)
	{
		AfxMessageBox("The Files is not in PBN Export format.");
//		AfxThrowFileException(CFileException::generic);
		isExportFile = false;  // NCR_PBNI Not export file - fewer tags required
	}

	// remove comments
	nPos = strBuf.Find(_T('{'));
	while(nPos >= 0)
	{
		// see if this comment started a new line
		bool bNewLine = false;
		if ((nPos > 0) && ((strBuf[nPos-1] == _T('\n')) || (strBuf[nPos-1] == _T('\r'))))
			bNewLine = true;

		// find the end of the comment section
		CString strMid = strBuf.Mid(nPos);
		int nEnd = strMid.Find(_T('}'));
		ASSERT(nEnd >= 0);

		// search for the next nonspace character
		nEnd++;
		int nLen = strMid.GetLength();
		// NCR test if comment at end of file
		if(nLen == nEnd)
			break;		// NCR exit if at end
		while ((nEnd < nLen) && (_istspace(strMid[nEnd])))
			nEnd++;

		// and trim and re-combine
		if ((nEnd < nLen) && (strMid[nEnd] == _T('[')) && !bNewLine)
			strBuf = strBuf.Left(nPos) + _T('\n') + strMid.Mid(nEnd);
		else
			strBuf = strBuf.Left(nPos) + strMid.Mid(nEnd);
		nPos = strBuf.Find(_T('{'));
	} // end while() removing comment

	// remove '!' suffixes
	strBuf.Remove(_T('!'));

	// remove any question marks that are not preceded by a quote character
	// '?' characters may be used in tag values as well as used for quality ratings
	for(int i=0;i<strBuf.GetLength();i++)
	{
		if ((i > 0) && (strBuf[i] == _T('?')) && (strBuf[i-1] != _T('\"')))
		{
			strBuf = strBuf.Left(i) + strBuf.Mid(i+1);
			i--;
		}
	}

	// organize into lines
	int nLen, nIndex = -1;
	BOOL bEmptyLineAdded = FALSE;
	do
	{
		// locate the end of the current line
		nLen = strBuf.GetLength();
		nIndex = -1;
		for(int i=0;i<nLen;i++)
		{
			if ((strBuf[i] == _T('\r')) || (strBuf[i] == _T('\n')))
			{
				nIndex = i;
				break;
			}
		}
		// add the line if not empty
		if (nIndex >= 0)
		{
			// add the string if it's not a comment
			if (strBuf[0] != _T('%'))
			{
				// test for an empty line by removing whitespace
				CString strTest = strBuf.Left(nIndex);
				strTest.TrimLeft();
				if (strTest.IsEmpty())
				{
					if (!bEmptyLineAdded)
					{
						strLines.Add(_T(""));
						bEmptyLineAdded = TRUE;
						numLinesRead++;
					}
				}
				else
				{
					// it's a nonblank line
					// trim any rest-of-line comments
					int nPos = strTest.Find(_T(';'));
					if (nPos >= 0)
						strTest = strTest.Left(nPos);

					// and add the line
					strLines.Add(strTest);
					bEmptyLineAdded = FALSE;
					numLinesRead++;
				}
			}

			// and skip over the CF/LF pair
			int nCharCount = 0;
			while ( (nIndex < nLen) && ((strBuf[nIndex] == _T('\r')) || (strBuf[nIndex] == _T('\n'))) )
			{
				nIndex++;
				nCharCount++;
			}

			// if more than one CR/LF pair (or two LF's) was found, add an empty line
			if ( ( (nCharCount > 2) || ((nIndex >= 2) && (strBuf[nIndex-1] == _T('\n')) && (strBuf[nIndex-2] == _T('\n'))) ) && 
				   (!bEmptyLineAdded))
			{
				strLines.Add(_T(""));
				numLinesRead++;
				bEmptyLineAdded = TRUE;
			}

			// chop off the part of the string that was read
			if (nIndex < nLen)
			{
				strBuf = strBuf.Mid(nIndex);
			}
			else
			{
				// reached the end of file
				strBuf.Empty();
				// add an empty line just to make sure
				strLines.Add(_T(""));
				numLinesRead++;
				bEmptyLineAdded = TRUE;
			}
		}
	}
	while ((nIndex >= 0) && !strBuf.IsEmpty());

	// done
	return numLinesRead;
}
Пример #22
0
// handle model dep and put lang item name to array
bool ConvDictPass1(WCHAR* SrcFile, WCHAR* DstPath, WCHAR* ModelName)
{
	bool RetVal = true;
	CString DstFile = DstPath;
#ifdef WIN32
	DstFile = DstFile + L"\\";
#else
	DstFile = DstFile + L"/";
#endif	
	DstFile = DstFile + SrcFile;
	//DstFile = DstFile + L".dict";
	DstFile = L"temp.dict";
	WCHAR CompareBuf[MAX_LINE_BUF];
	WCHAR NewSrcFile[MAX_PATH];

	wcscpy(NewSrcFile,m_SrcFolder);
	wcscat(NewSrcFile,SrcFile);
	wcscat(NewSrcFile,L".dict");
#ifdef WIN32
	CTextFileRead myfile(NewSrcFile);
	CTextFileWrite myfile2(DstFile, CTextFileWrite::UTF_8);	
#else	
	char TmpNewSrcFile[256];
	char TmpDstFile[256];
	wcstombs(TmpNewSrcFile,NewSrcFile,256);
	CTextFileRead myfile(TmpNewSrcFile);
	wcstombs(TmpDstFile,DstFile,256);	
	CTextFileWrite myfile2(TmpDstFile, CTextFileWrite::UTF_8);	
#endif	
	if (!myfile.IsOpen()) mywprintf(L"Src File Fail");
	if (!myfile2.IsOpen()) mywprintf(L"Dst File Fail");

	if (myfile.IsOpen() && myfile2.IsOpen())
	{
		while(!myfile.Eof())
		{
			CString line;
			myfile.ReadLine(line);
			line = line.Trim();
			if (line != L"")
			{
				BOOL SectionHit = FALSE;
				int ModelDepLen = wcslen(L"[###MODEL_DEP###]");
				if (line.Left(ModelDepLen) == L"[###MODEL_DEP###]")
				{
					line = line.Right(line.GetLength() - ModelDepLen);
					CString line2;
					line2 = line.Trim();
					BOOL SectionHit = FALSE;
					while (1)
					{
						if (line2.GetLength() > 2)
						{
							if (line2.Left(1) == L"[")
							{
								for (int LenIdx=1; LenIdx < line2.GetLength() - 1; LenIdx++)
								{
									if (line2.Mid(LenIdx,1) == L"]")
									{
										CString line3;
										// get modem name without mid bracket
										line3 = line2.Mid(1,LenIdx-1);
										// get reminder part
										line2 = line2.Mid(LenIdx+1,line2.GetLength()-LenIdx-1);
#ifdef WIN32
										if (line3 == ModelName)
#else	
										WCHAR TmpModelName[256];
										wcscpy_x(TmpModelName, line3);
										if (wcscmp(TmpModelName,ModelName)==0)
#endif	
										{
											SectionHit = TRUE;
										}
									}
								}
							}
							else
							{
								if (SectionHit)
								{
									line2 = line2.Trim();
									line2.Replace(L"ZVMODELVZ", ModelName);
									TextFileWrite(myfile2,line2);
									myfile2 << '\n';
									break;
								}
								break;
							}
						}
						else
						{
							break;
						}
					}
				}
			}
		}
	}
	else
	{
		//mywprintf(L"\n!!!!\n");
		RetVal = false;
	}

	myfile.Close();
	myfile2.Close();

	// put lang item name to array

	int NumStrModelDep = 0;
	WCHAR* DstFileOutputPtr;
	DstFileOutputPtr = DstFile.GetBuffer(DstFile.GetLength());
	mywprintf(L"get modem_dep lang item name to array\n");	
	mywprintf(DstFileOutputPtr);	
	mywprintf(L"\n");
	DstFile.ReleaseBuffer();
#ifdef WIN32
	CTextFileRead myfile3(DstFile);
#else	
	char TmpDstFile3[256];
	wcstombs(TmpDstFile3,DstFile,256);	
	CTextFileRead myfile3(TmpDstFile3);
#endif	
	while(!myfile3.Eof())
	{
		CString StrTest;
		myfile3.ReadLine(StrTest);
		CString StrTestTrim = StrTest.Trim();
		if (StrTestTrim.Left(1) == L"[" && StrTestTrim.Right(1) == L"]")
		{
			// skip
		}
		else if (StrTestTrim == L"")
		{
			// skip
		}
		else
		{
			WCHAR StrContentBuf[MAX_LINE_BUF];
			wcscpy_x(StrContentBuf,StrTestTrim);
			scanner_set(StrContentBuf, wcslen(StrContentBuf));
			token tok;
			WCHAR* pRespStr;
			while (1)
			{
				tok = scanner();
				if (tok == TOKEN_EOF)
				{
					break;
				}
				if (tok == TOKEN_STRING)
				{
					if (NumStrModelDep < MAX_MODEL_DEP)
					{
						pRespStr = scanner_get_str();
						wcscpy(StrModelDep[NumStrModelDep],pRespStr);
						NumStrModelDep++;
						token tok2 = scanner();
						if (tok2 != TOKEN_EQUAL)
						{
							mywprintf(L"No equal : %ls\n",StrContentBuf);
						}
					}
					else
					{
						mywprintf(L"No free buffer\n");
					}
					break;
				}
			}
		}
	}


	myfile3.Close();

	mywprintf(L"Pass 1 - Model dep strings : %d\n",NumStrModelDep);

	m_NumStrModelDep = NumStrModelDep;

	return RetVal;
}
Пример #23
0
LRESULT CDlgProveedores::OnEnKillfocusEditlabel(WPARAM, LPARAM lParam)
{
	HRESULT hErr = 0;

	// Si el foco va a la primera columna y es una fila vacía
	if (m_lstProve.m_ptEditting.y == 0 && m_lstProve.m_ptEditting.x == m_iNumProve)
	{
		CString strCodProve;
		/* Se coge el código del artículo */
		int len = m_lstProve.GetEditControl()->LineLength(m_lstProve.GetEditControl()->LineIndex(0));
		if (len > 0)
		{
			m_lstProve.GetEditControl()->GetLine(0, strCodProve.GetBuffer(len), len);
			strCodProve.ReleaseBuffer(len);
			if (!strCodProve.IsEmpty())
				BuscaProve(strCodProve);
		}
	}	

	// Se obtiene lo que contiene la primera columna
	CString strCod = m_lstProve.GetItemText(m_lstProve.m_ptEditting.x, 0);

	// En las columnas que deben estar inactivas se pone el textbox a readonly
	if (m_lstProve.m_ptEditting.y == 1 || (m_lstProve.m_ptEditting.y == 0 && !strCod.IsEmpty()))
		m_lstProve.GetEditControl()->SetReadOnly(TRUE);
	else
		m_lstProve.GetEditControl()->SetReadOnly(FALSE);

	// Si estamos en la columna de Tarifas o de Descuento hay que comprobar si es un número
	if (m_lstProve.m_ptEditting.y == 3 || m_lstProve.m_ptEditting.y == 4)
	{
		CString strNumero;
		int len = m_lstProve.GetEditControl()->LineLength(m_lstProve.GetEditControl()->LineIndex(0));
		if (len > 0)
		{
			m_lstProve.GetEditControl()->GetLine(0, strNumero.GetBuffer(len), len);
			strNumero.ReleaseBuffer(len);

			if (!strNumero.IsEmpty())
			{
				if (m_lstProve.m_ptEditting.y == 3)
				{
					if (!(EsNum(strNumero)))
						m_lstProve.SetItemTextCB(m_lstProve.m_ptEditting.x, 3, m_strOldTarifa);
					else
					{
						m_lstProve.SetItemTextCB(m_lstProve.m_ptEditting.x, 3, strNumero);
						m_strOldTarifa = strNumero;
					}
				}
				if (m_lstProve.m_ptEditting.y == 4)
				{
					if (!(EsNum(strNumero)))
						m_lstProve.SetItemTextCB(m_lstProve.m_ptEditting.x, 4, m_strOldDescuento);
					else
					{
						m_lstProve.SetItemTextCB(m_lstProve.m_ptEditting.x, 4, strNumero);
						m_strOldDescuento = strNumero;
					}
				}
			}
		}
	}

	return hErr;
}
Пример #24
0
bool ConvDict(WCHAR* SrcFile, WCHAR* DstPath, WCHAR* ModelName)
{
	bool RetVal = true;
	CString DstFile = DstPath;
#ifdef WIN32
	DstFile = DstFile + L"\\";
#else
	DstFile = DstFile + L"/";
#endif	
	DstFile = DstFile + SrcFile;
	DstFile = DstFile + L".dict";

	WCHAR CompareBuf[MAX_LINE_BUF];
	WCHAR NewSrcFile[MAX_PATH];

	wcscpy(NewSrcFile,m_SrcFolder);
	wcscat(NewSrcFile,SrcFile);
	wcscat(NewSrcFile,L".dict");

#ifdef WIN32	
	WCHAR TempDstFileFn[MAX_PATH];
	wcscpy(TempDstFileFn,m_ToolDir);
	wcscat(TempDstFileFn,L"\\temp_");
	wcscat(TempDstFileFn,SrcFile);
	wcscat(TempDstFileFn,L".dict");
#else	
	char TempDstFileFn[MAX_PATH];
	strcpy(TempDstFileFn,m_ToolDir);
	strcat(TempDstFileFn,"/temp_");
	char TempSrcFile[256];
	wcstombs(TempSrcFile,SrcFile,256);	
	strcat(TempDstFileFn,TempSrcFile);
	strcat(TempDstFileFn,".dict");
/*	
	{
	WCHAR tmp2[128];
	CString tmp = TempDstFileFn;
	wcscpy_x(tmp2,tmp);
	wprintf(L"\n\n%ls\n\n",tmp2);
	}
*/	
#endif	

#ifdef WIN32
	CTextFileRead myfile(NewSrcFile);
	CTextFileWrite myfile2(TempDstFileFn, CTextFileWrite::UTF_8);	
#else	
	char TmpNewSrcFile[256];
	char TmpDstFile[256];
	wcstombs(TmpNewSrcFile,NewSrcFile,256);
	CTextFileRead myfile(TmpNewSrcFile);
	CTextFileWrite myfile2(TempDstFileFn, CTextFileWrite::UTF_8);	
#endif	


	if (!myfile.IsOpen()) mywprintf(L"Src File Fail");
	if (!myfile2.IsOpen()) mywprintf(L"Dst File Fail");

	// add header
	for (int IdxDictHdr = 0; IdxDictHdr < m_NumDictHdrLang; IdxDictHdr++)
	{
		// fix for linux
		// linux only could use CString to output UNICODE
		myfile2 << "LANG_";
		TextFileWrite(myfile2,StrDictHdrLang[IdxDictHdr]);
		myfile2 << "\n";
	}

	if (myfile.IsOpen() && myfile2.IsOpen())
	{
		while(!myfile.Eof())
		{
			CString line;
			myfile.ReadLine(line);
			line = line.Trim();
			if (line != L"")
			{
				BOOL SectionHit = FALSE;
				int ModelDepLen = wcslen(L"[###MODEL_DEP###]");
				if (line.Left(ModelDepLen) == L"[###MODEL_DEP###]")
				{
					// skip
				}
				else
				{
					if (line.Left(1) == L"[" && line.Right(1) == L"]")
					{
						// skip
					}
					else
					{
						WCHAR StrContentBuf[MAX_LINE_BUF];
						wcscpy_x(StrContentBuf,line);
						scanner_set(StrContentBuf, wcslen(StrContentBuf));
						token tok;
						WCHAR* pRespStr;
						bool ModelDepStrFound = false;
						while (1)
						{
							tok = scanner();
							if (tok == TOKEN_EOF)
							{
								break;
							}
							if (tok == TOKEN_STRING)
							{
								pRespStr = scanner_get_str();

								for (int IdxMdep = 0; IdxMdep < m_NumStrModelDep; IdxMdep++)
								{
									if (!wcscmp(StrModelDep[IdxMdep],pRespStr))
									{
										// same, skip
										ModelDepStrFound = true;
										break;
									}
								}
							}
							if (ModelDepStrFound) break;
						}

						if (ModelDepStrFound == false)
						{
							line.Replace(L"[###UNTRANSLATED###]",L"");
							line.Replace(L"ZVMODELVZ", ModelName);
							//myfile2 << (LPTSTR)(LPCTSTR)line;
							TextFileWrite(myfile2,line);
							myfile2 << '\n';
						}
					}
				}
			}
		}
	}
	else
	{
		//mywprintf(L"\n!!!!\n");
		RetVal = false;
	}

	myfile.Close();

	// add model_dep strings
#ifdef WIN32	
	CTextFileRead myfile4(L"temp.dict");
#else
	CTextFileRead myfile4("temp.dict");
#endif	

	if (!myfile4.IsOpen())
	{
		mywprintf(L"temp.dict fail");
	}
	else
	{
/*
		CString StrTitle;
		StrTitle = L"[model dep strings]";
		TextFileWrite(myfile2,StrTitle);
		myfile2 << '\n';
*/
		while(!myfile4.Eof())
		{
			CString StrTest;
			myfile4.ReadLine(StrTest);
			TextFileWrite(myfile2,StrTest);
			myfile2 << '\n';
		}
	}

	myfile4.Close();

	myfile2.Close();

	int NumStrValiddate = 0;
	int GenerateEnum = 0;
	WCHAR* DstFileOutputPtr;
	DstFileOutputPtr = DstFile.GetBuffer(DstFile.GetLength());
	if (!wcscmp(SrcFile,L"EN"))
	{
		GenerateEnum = 1;
		mywprintf(L"It is EN.dict and will generate enum list\n");	
	}
	mywprintf(L"Check duplicated strang and empty line\n");	
	mywprintf(L"**** Validating ****  ");	
	mywprintf(DstFileOutputPtr);	
	mywprintf(L"\n");
	DstFile.ReleaseBuffer();
#ifdef WIN32
	CTextFileRead myfile3(TempDstFileFn);
#else	
	char TmpDstFile2[256];
	CTextFileRead myfile3(TempDstFileFn);
#endif	
	while(!myfile3.Eof())
	{
		CString StrTest;
		myfile3.ReadLine(StrTest);
		CString StrTestTrim = StrTest.Trim();
		if (StrTestTrim.Left(1) == L"[" && StrTestTrim.Right(1) == L"]")
		{
			// skip
		}
		else if (StrTestTrim == L"")
		{
			// skip
		}
		else
		{
			WCHAR StrContentBuf[MAX_LINE_BUF];
			wcscpy_x(StrContentBuf,StrTestTrim);
			scanner_set(StrContentBuf, wcslen(StrContentBuf));
			token tok;
			WCHAR* pRespStr;
			while (1)
			{
				tok = scanner();
				if (tok == TOKEN_EOF)
				{
					break;
				}
				if (tok == TOKEN_STRING)
				{
					if (NumStrValiddate < MAX_VALIDATE)
					{
						pRespStr = scanner_get_str();
						wcscpy(StrValidate[NumStrValiddate],pRespStr);
						NumStrValiddate++;
						token tok2 = scanner();
						if (tok2 != TOKEN_EQUAL)
						{
							mywprintf(L"No equal : %ls\n",StrContentBuf);
						}
					}
					else
					{
						mywprintf(L"No free buffer\n");
					}
					break;
				}
			}
		}
	}

	myfile3.Close();

	FILE* fp;

	if (GenerateEnum)
	{
#ifdef WIN32
		fp = _wfopen(m_EnumFile,L"w");
#else
		fp = fopen(m_EnumFile,"w");
#endif	
	}


	int ii;
	int jj;

	for (jj = 0; jj<NumStrValiddate; jj++)
	{
		bDuplicated[jj] = false;
	}

	int EnumCounter = 0;
	for (ii = 0; ii<NumStrValiddate; ii++)
	{
		//if (dup) break;
		bool dup = false;
		if (wcscmp(StrValidate[ii],L"")==0)
		{
			mywprintf(L"empty line : %d\n",ii+1);
		}
		for (jj = 0; jj<NumStrValiddate; jj++)
		{
			if (ii!=jj)
			{
				if (wcscmp(StrValidate[ii],StrValidate[jj])==0)
				{
					mywprintf(L"Duplicated name : %ls\n",StrValidate[ii]);
					dup = true;
					break;
				}
			}
		}

		if (GenerateEnum)
		{
			if (dup)
			{
				if (bDuplicated[jj] == false)
				{
					bDuplicated[jj] = true;
					fwprintf(fp, L"%d=%ls\n", EnumCounter, StrValidate[ii]);
					EnumCounter++;
				}
			}
			else
			{
				fwprintf(fp, L"%d=%ls\n", EnumCounter, StrValidate[ii]);
				EnumCounter++;
			}
		}
	}

	if (GenerateEnum)
	{
		fclose(fp);		
	}


	// final dest file handling
	LoadDict(m_EnumFile);


#ifdef WIN32
	CTextFileRead myfile5(TempDstFileFn);
	CTextFileWrite myfile6(DstFile, CTextFileWrite::UTF_8);	
#else	
	CTextFileRead myfile5(TempDstFileFn);	
	char TmpDstFile6[256];
	wcstombs(TmpDstFile6,DstFile,256);	
	CTextFileWrite myfile6(TmpDstFile6, CTextFileWrite::UTF_8);	
#endif	

	while(!myfile5.Eof())
	{
		CString StrTest;
		myfile5.ReadLine(StrTest);
		CString StrTestTrim = StrTest.Trim();
		if (StrTestTrim.Left(1) == L"[" && StrTestTrim.Right(1) == L"]")
		{
			// skip
		}
		else if (StrTestTrim == L"")
		{
			// skip
		}
		else
		{
			WCHAR StrContentBuf[MAX_LINE_BUF];
			wcscpy_x(StrContentBuf,StrTestTrim);
			scanner_set(StrContentBuf, wcslen(StrContentBuf));
			token tok;
			WCHAR* pRespStr;
			while (1)
			{
				tok = scanner();
				if (tok == TOKEN_EOF)
				{
					break;
				}
				if (tok == TOKEN_STRING)
				{
					if (NumStrValiddate < MAX_VALIDATE)
					{
						pRespStr = scanner_get_str();
						WCHAR StrContentBuf2[MAX_LINE_BUF];
						wcscpy(StrContentBuf2,pRespStr);
						token tok2 = scanner();
						if (tok2 == TOKEN_EQUAL)
						{
							WCHAR* RetDict = GetDictContent(StrContentBuf2);
							if (NULL == RetDict)
							{
								mywprintf(L"No found : %ls\n",StrContentBuf);
							}
							else
							{
								token tok3 = scanner_get_rest();
								if (TOKEN_STRING == tok3)
								{
									//int DestVarLoc = _wtoi(RetDict);
									int DestVarLoc = wcstol(RetDict, NULL, 10);
									pRespStr = scanner_get_str();
									wcscpy(m_DictNameTblDest[DestVarLoc].Content,pRespStr);
								}
								else
								{
									mywprintf(L"No string : %ls\n",StrContentBuf);
								}
							}
						}
						else
						{
							mywprintf(L"No equal : %ls\n",StrContentBuf);
						}
					}
					else
					{
						mywprintf(L"No free buffer\n");
					}
					break;
				}
			}
		}
	}

	myfile5.Close();

	for (jj = 0; jj<NumStrValiddate; jj++)
	{
		myfile6 << m_DictNameTblDest[jj].Content;
		myfile6 << '\n';
	}

	myfile6.Close();



	return RetVal;
}
Пример #25
0
LRESULT CMainWindow::DoCommand(int id, LPARAM lParam)
{
    switch (id)
    {
    case ID_FILE_OPEN:
        {
            if (OpenDialog())
            {
                picWindow1.SetPic(leftpicpath, L"", true);
                picWindow2.SetPic(rightpicpath, L"", false);
                if (bOverlap)
                {
                    picWindow1.SetSecondPic(picWindow2.GetPic(), rightpictitle, rightpicpath);
                }
                else
                {
                    picWindow1.SetSecondPic();
                }
                RECT rect;
                GetClientRect(*this, &rect);
                PositionChildren(&rect);
                picWindow1.FitImageInWindow();
                picWindow2.FitImageInWindow();
            }
        }
        break;
    case ID_VIEW_IMAGEINFO:
        {
            bShowInfo = !bShowInfo;
            HMENU hMenu = GetMenu(*this);
            UINT uCheck = MF_BYCOMMAND;
            uCheck |= bShowInfo ? MF_CHECKED : MF_UNCHECKED;
            CheckMenuItem(hMenu, ID_VIEW_IMAGEINFO, uCheck);

            picWindow1.ShowInfo(bShowInfo);
            picWindow2.ShowInfo(bShowInfo);
            picWindow3.ShowInfo(bShowInfo);

            // change the state of the toolbar button
            TBBUTTONINFO tbi;
            tbi.cbSize = sizeof(TBBUTTONINFO);
            tbi.dwMask = TBIF_STATE;
            tbi.fsState = bShowInfo ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED;
            SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_IMAGEINFO, (LPARAM)&tbi);
        }
        break;
    case ID_VIEW_OVERLAPIMAGES:
        {
            bOverlap = !bOverlap;
            HMENU hMenu = GetMenu(*this);
            UINT uCheck = MF_BYCOMMAND;
            uCheck |= bOverlap ? MF_CHECKED : MF_UNCHECKED;
            CheckMenuItem(hMenu, ID_VIEW_OVERLAPIMAGES, uCheck);
            uCheck |= ((m_BlendType == CPicWindow::BLEND_ALPHA) && bOverlap) ? MF_CHECKED : MF_UNCHECKED;
            CheckMenuItem(hMenu, ID_VIEW_BLENDALPHA, uCheck);
            UINT uEnabled = MF_BYCOMMAND;
            uEnabled |= bOverlap ? MF_ENABLED : MF_DISABLED | MF_GRAYED;
            EnableMenuItem(hMenu, ID_VIEW_BLENDALPHA, uEnabled);

            // change the state of the toolbar button
            TBBUTTONINFO tbi;
            tbi.cbSize = sizeof(TBBUTTONINFO);
            tbi.dwMask = TBIF_STATE;
            tbi.fsState = bOverlap ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED;
            SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_OVERLAPIMAGES, (LPARAM)&tbi);

            tbi.fsState = ((m_BlendType == CPicWindow::BLEND_ALPHA) && bOverlap) ? TBSTATE_CHECKED : 0;
            if (bOverlap)
                tbi.fsState |= TBSTATE_ENABLED;
            else
                tbi.fsState = 0;
            SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_BLENDALPHA, (LPARAM)&tbi);

            if (bOverlap)
                tbi.fsState = 0;
            else
                tbi.fsState = bVertical ? TBSTATE_ENABLED | TBSTATE_CHECKED : TBSTATE_ENABLED;
            SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_ARRANGEVERTICAL, (LPARAM)&tbi);

            if (bOverlap)
            {
                bLinkedPositions = true;
                picWindow1.LinkPositions(bLinkedPositions);
                picWindow2.LinkPositions(bLinkedPositions);
                tbi.fsState = TBSTATE_CHECKED;
            }
            else
                tbi.fsState = bLinkedPositions ? TBSTATE_ENABLED | TBSTATE_CHECKED : TBSTATE_ENABLED;
            SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_LINKIMAGESTOGETHER, (LPARAM)&tbi);

            ShowWindow(picWindow2, bOverlap ? SW_HIDE : SW_SHOW);

            if (bOverlap)
            {
                picWindow1.StopTimer();
                picWindow2.StopTimer();
                picWindow1.SetSecondPic(picWindow2.GetPic(), rightpictitle, rightpicpath,
                    picWindow2.GetHPos(), picWindow2.GetVPos());
                picWindow1.SetBlendAlpha(m_BlendType, 0.5f);
            }
            else
            {
                picWindow1.SetSecondPic();
            }
            picWindow1.SetOverlapMode(bOverlap);
            picWindow2.SetOverlapMode(bOverlap);


            RECT rect;
            GetClientRect(*this, &rect);
            PositionChildren(&rect);

            return 0;
        }
        break;
    case ID_VIEW_BLENDALPHA:
        {
            if (m_BlendType == CPicWindow::BLEND_ALPHA)
                m_BlendType = CPicWindow::BLEND_XOR;
            else
                m_BlendType = CPicWindow::BLEND_ALPHA;

            HMENU hMenu = GetMenu(*this);
            UINT uCheck = MF_BYCOMMAND;
            uCheck |= ((m_BlendType == CPicWindow::BLEND_ALPHA) && bOverlap) ? MF_CHECKED : MF_UNCHECKED;
            CheckMenuItem(hMenu, ID_VIEW_BLENDALPHA, uCheck);
            UINT uEnabled = MF_BYCOMMAND;
            uEnabled |= bOverlap ? MF_ENABLED : MF_DISABLED | MF_GRAYED;
            EnableMenuItem(hMenu, ID_VIEW_BLENDALPHA, uEnabled);

            // change the state of the toolbar button
            TBBUTTONINFO tbi;
            tbi.cbSize = sizeof(TBBUTTONINFO);
            tbi.dwMask = TBIF_STATE;
            tbi.fsState = ((m_BlendType == CPicWindow::BLEND_ALPHA) && bOverlap) ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED;
            SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_BLENDALPHA, (LPARAM)&tbi);
            picWindow1.SetBlendAlpha(m_BlendType, picWindow1.GetBlendAlpha());
            PositionChildren();
        }
        break;
    case ID_VIEW_TRANSPARENTCOLOR:
        {
            static COLORREF customColors[16] = {0};
            CHOOSECOLOR ccDlg = { 0 };
            ccDlg.lStructSize = sizeof(ccDlg);
            ccDlg.hwndOwner = m_hwnd;
            ccDlg.rgbResult = transparentColor;
            ccDlg.lpCustColors = customColors;
            ccDlg.Flags = CC_RGBINIT | CC_FULLOPEN;
            if(ChooseColor(&ccDlg))
            {
                transparentColor = ccDlg.rgbResult;
                picWindow1.SetTransparentColor(transparentColor);
                picWindow2.SetTransparentColor(transparentColor);
                picWindow3.SetTransparentColor(transparentColor);
                // The color picker takes the focus and we don't get it back.
                ::SetFocus(picWindow1);
            }
        }
        break;
    case ID_VIEW_FITIMAGEWIDTHS:
        {
            bFitWidths = !bFitWidths;
            picWindow1.FitWidths(bFitWidths);
            picWindow2.FitWidths(bFitWidths);
            picWindow3.FitWidths(bFitWidths);

            HMENU hMenu = GetMenu(*this);
            UINT uCheck = MF_BYCOMMAND;
            uCheck |= bFitWidths ? MF_CHECKED : MF_UNCHECKED;
            CheckMenuItem(hMenu, ID_VIEW_FITIMAGEWIDTHS, uCheck);

            // change the state of the toolbar button
            TBBUTTONINFO tbi;
            tbi.cbSize = sizeof(TBBUTTONINFO);
            tbi.dwMask = TBIF_STATE;
            tbi.fsState = bFitWidths ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED;
            SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_FITIMAGEWIDTHS, (LPARAM)&tbi);
        }
        break;
    case ID_VIEW_FITIMAGEHEIGHTS:
        {
            bFitHeights = !bFitHeights;
            picWindow1.FitHeights(bFitHeights);
            picWindow2.FitHeights(bFitHeights);
            picWindow3.FitHeights(bFitHeights);

            HMENU hMenu = GetMenu(*this);
            UINT uCheck = MF_BYCOMMAND;
            uCheck |= bFitHeights ? MF_CHECKED : MF_UNCHECKED;
            CheckMenuItem(hMenu, ID_VIEW_FITIMAGEHEIGHTS, uCheck);

            // change the state of the toolbar button
            TBBUTTONINFO tbi;
            tbi.cbSize = sizeof(TBBUTTONINFO);
            tbi.dwMask = TBIF_STATE;
            tbi.fsState = bFitHeights ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED;
            SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_FITIMAGEHEIGHTS, (LPARAM)&tbi);
        }
        break;
    case ID_VIEW_LINKIMAGESTOGETHER:
        {
            bLinkedPositions = !bLinkedPositions;
            picWindow1.LinkPositions(bLinkedPositions);
            picWindow2.LinkPositions(bLinkedPositions);
            picWindow3.LinkPositions(bLinkedPositions);

            HMENU hMenu = GetMenu(*this);
            UINT uCheck = MF_BYCOMMAND;
            uCheck |= bLinkedPositions ? MF_CHECKED : MF_UNCHECKED;
            CheckMenuItem(hMenu, ID_VIEW_LINKIMAGESTOGETHER, uCheck);

            // change the state of the toolbar button
            TBBUTTONINFO tbi;
            tbi.cbSize = sizeof(TBBUTTONINFO);
            tbi.dwMask = TBIF_STATE;
            tbi.fsState = bLinkedPositions ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED;
            SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_LINKIMAGESTOGETHER, (LPARAM)&tbi);
        }
        break;
    case ID_VIEW_ALPHA0:
        picWindow1.SetBlendAlpha(m_BlendType, 0.0f);
        break;
    case ID_VIEW_ALPHA255:
        picWindow1.SetBlendAlpha(m_BlendType, 1.0f);
        break;
    case ID_VIEW_ALPHA127:
        picWindow1.SetBlendAlpha(m_BlendType, 0.5f);
        break;
    case ID_VIEW_ALPHATOGGLE:
        picWindow1.ToggleAlpha();
        break;
    case ID_VIEW_FITIMAGESINWINDOW:
        {
            picWindow1.FitImageInWindow();
            picWindow2.FitImageInWindow();
            picWindow3.FitImageInWindow();
        }
        break;
    case ID_VIEW_ORININALSIZE:
        {
            picWindow1.SetZoom(100, false);
            picWindow2.SetZoom(100, false);
            picWindow3.SetZoom(100, false);
            picWindow1.CenterImage();
            picWindow2.CenterImage();
            picWindow3.CenterImage();
        }
        break;
    case ID_VIEW_ZOOMIN:
        {
            picWindow1.Zoom(true, false);
            if ((!(bFitWidths || bFitHeights))&&(!bOverlap))
            {
                picWindow2.Zoom(true, false);
                picWindow3.Zoom(true, false);
            }
        }
        break;
    case ID_VIEW_ZOOMOUT:
        {
            picWindow1.Zoom(false, false);
            if ((!(bFitWidths || bFitHeights))&&(!bOverlap))
            {
                picWindow2.Zoom(false, false);
                picWindow3.Zoom(false, false);
            }
        }
        break;
    case ID_VIEW_ARRANGEVERTICAL:
        {
            bVertical = !bVertical;
            RECT rect;
            GetClientRect(*this, &rect);
            if (bVertical)
            {
                RECT tbRect;
                GetWindowRect(hwndTB, &tbRect);
                LONG tbHeight = tbRect.bottom-tbRect.top-1;
                if (selectionPaths.size() != 3)
                {
                    nSplitterPos = (rect.bottom-rect.top)/2+tbHeight;
                    nSplitterPos2 = 0;
                }
                else
                {
                    nSplitterPos = (rect.bottom-rect.top)/3+tbHeight;
                    nSplitterPos2 = (rect.bottom-rect.top)*2/3+tbHeight;
                }
            }
            else
            {
                if (selectionPaths.size() != 3)
                {
                    nSplitterPos = (rect.right-rect.left)/2;
                    nSplitterPos2 = 0;
                }
                else
                {
                    nSplitterPos = (rect.right-rect.left)/3;
                    nSplitterPos2 = (rect.right-rect.left)*2/3;
                }
            }
            HMENU hMenu = GetMenu(*this);
            UINT uCheck = MF_BYCOMMAND;
            uCheck |= bVertical ? MF_CHECKED : MF_UNCHECKED;
            CheckMenuItem(hMenu, ID_VIEW_ARRANGEVERTICAL, uCheck);
            // change the state of the toolbar button
            TBBUTTONINFO tbi;
            tbi.cbSize = sizeof(TBBUTTONINFO);
            tbi.dwMask = TBIF_STATE;
            tbi.fsState = bVertical ? TBSTATE_CHECKED | TBSTATE_ENABLED : TBSTATE_ENABLED;
            SendMessage(hwndTB, TB_SETBUTTONINFO, ID_VIEW_ARRANGEVERTICAL, (LPARAM)&tbi);

            PositionChildren(&rect);
        }
        break;
    case ID_ABOUT:
        {
            CAboutDlg dlg(*this);
            dlg.DoModal(hInst, IDD_ABOUT, *this);
        }
        break;
    case SELECTBUTTON_ID:
        {
            HWND hSource = (HWND)lParam;
            FileType resolveWith;
            if (picWindow1 == hSource)
                resolveWith = FileTypeMine;
            else if (picWindow2 == hSource)
                resolveWith = FileTypeBase;
            else if (picWindow3 == hSource)
                resolveWith = FileTypeTheirs;
            else
                break;

            if (selectionResult.empty())
            {
                PostQuitMessage(resolveWith);
                break;
            }

            CopyFile(selectionPaths[resolveWith].c_str(), selectionResult.c_str(), FALSE);

            CAutoBuf projectRoot;
            if (git_repository_discover(projectRoot, CUnicodeUtils::GetUTF8(selectionResult.c_str()), FALSE, nullptr) < 0 && strstr(projectRoot->ptr, "/.git/"))
            {
                PostQuitMessage(resolveWith);
                break;
            }

            CAutoRepository repository(projectRoot->ptr);
            if (!repository)
            {
                PostQuitMessage(resolveWith);
                break;
            }

            CStringA subpath = CUnicodeUtils::GetUTF8(selectionResult.c_str()).Mid((int)strlen(git_repository_workdir(repository)));

            CAutoIndex index;
            if (git_repository_index(index.GetPointer(), repository) || (git_index_get_bypath(index, subpath, 1) == nullptr && git_index_get_bypath(index, subpath, 2) == nullptr))
            {
                PostQuitMessage(resolveWith);
                break;
            }

            CString sTemp;
            sTemp.Format(ResString(hResource, IDS_MARKASRESOLVED), (LPCTSTR)CPathUtils::GetFileNameFromPath(selectionResult.c_str()));
            if (MessageBox(m_hwnd, sTemp, L"TortoiseGitMerge", MB_YESNO | MB_ICONQUESTION) != IDYES)
                break;

            CString cmd;
            cmd.Format(L"\"%sTortoiseGitProc.exe\" /command:resolve /path:\"%s\" /closeonend:1 /noquestion /skipcheck /silent", (LPCTSTR)CPathUtils::GetAppDirectory(), selectionResult.c_str());
            if (resolveMsgWnd)
                cmd.AppendFormat(L" /resolvemsghwnd:%I64d /resolvemsgwparam:%I64d /resolvemsglparam:%I64d", (__int64)resolveMsgWnd, (__int64)resolveMsgWParam, (__int64)resolveMsgLParam);

            STARTUPINFO startup = { 0 };
            PROCESS_INFORMATION process = { 0 };
            startup.cb = sizeof(startup);

            if (!CreateProcess(nullptr, cmd.GetBuffer(), nullptr, nullptr, FALSE, CREATE_UNICODE_ENVIRONMENT, nullptr, nullptr, &startup, &process))
            {
                cmd.ReleaseBuffer();
                PostQuitMessage(resolveWith);
                break;
            }
            cmd.ReleaseBuffer();

            AllowSetForegroundWindow(process.dwProcessId);

            CloseHandle(process.hThread);
            CloseHandle(process.hProcess);

            PostQuitMessage(resolveWith);
        }
        break;
    case IDM_EXIT:
        ::PostQuitMessage(0);
        return 0;
        break;
    default:
        break;
    };
    return 1;
}
Пример #26
0
void TabDoc::DecodeHTML(const char* filename, int scheme)
{
  // Open the file
  CFile htmlFile;
  if (htmlFile.Open(filename,CFile::modeRead) == 0)
    return;

  // Read it into memory
  CString htmlText;
  int len = (int)htmlFile.GetLength();
  htmlFile.Read(htmlText.GetBuffer(len),len);
  htmlText.ReleaseBuffer(len);

  // Convert from UTF-8 to Unicode
  CStringW html = TextFormat::UTF8ToUnicode(htmlText);

  // Get the body text
  int body1 = html.Find(L"<body");
  if (body1 == -1)
    return;
  body1 = html.Find(L">",body1);
  if (body1 == -1)
    return;
  int body2 = html.Find(L"</body>");
  if (body2 <= body1)
    return;
  CStringW bodyHtml = html.Mid(body1+1,body2-body1-1);

  // Create a DocText instance for this file
  DocText* mainDocText = new DocText();
  mainDocText->file = filename;
  mainDocText->colourScheme = scheme;
  m_docTexts.Add(mainDocText);

  // Reserve space for the main text
  len = bodyHtml.GetLength();
  mainDocText->body.Preallocate(len);

  // Scan the text, removing markup
  DocText* docText = mainDocText;
  bool ignore = false;
  bool white = false;
  const wchar_t* p1 = bodyHtml;
  const wchar_t* p2 = p1+len;
  while (p1 < p2)
  {
    // Look for a markup element
    if ((*p1 == L'<') && (iswalpha(*(p1+1)) || (*(p1+1) == L'/')))
    {
      // Check for a closing markup element
      bool closing = false;
      if (*(p1+1) == L'/')
      {
        closing = true;
        p1++;
      }

      // Scan for a known markup element
      bool found = false;
      int i = 0;
      while (!found && (i < sizeof tags / sizeof tags[0]))
      {
        if (wcsncmp(p1+1,tags[i].name,tags[i].len) == 0)
          found = true;
        if (!found)
          i++;
      }
      ASSERT(found);

      // Remove the markup
      if (found && tags[i].remove)
      {
        ASSERT(!closing);

        // Remove everything until the closing element
        CStringW search;
        search.Format(L"</%s>",tags[i].name);
        p1 = wcsstr(p1,search);
        if (p1 != NULL)
          p1 += search.GetLength()-1;
        else
          p1 = p2;
      }
      else
      {
        // Remove just the element
        while ((p1 < p2) && (*p1 != L'>'))
          p1++;
      }
      ASSERT(*p1 == L'>');

      // Add a carriage return for appropriate markup
      if (found && !closing && tags[i].cr && !ignore)
        docText->AddToBody(L'\n');
      white = false;
    }
    else if ((*p1 == L'<') && (*(p1+1) == L'!'))
    {
      // Extract metadata from comments
      wchar_t meta1[256], meta2[256];
      if (swscanf(p1,L"<!-- SEARCH TITLE \"%[^\"]",meta1) == 1)
        docText->title = meta1;
      else if (swscanf(p1,L"<!-- SEARCH SECTION \"%[^\"]",meta1) == 1)
        docText->section = meta1;
      else if (swscanf(p1,L"<!-- SEARCH SORT \"%[^\"]",meta1) == 1)
        docText->sort = meta1;
      else if (swscanf(p1,L"<!-- START EXAMPLE \"%[^\"]\" \"%[^\"]",meta1,meta2) == 2)
      {
        docText = new DocText();
        docText->file = mainDocText->file + "#" + CStringA(meta2);
        docText->colourScheme = mainDocText->colourScheme;
        docText->title = "Example " + CStringA(meta1);
        docText->section = mainDocText->section;
        docText->sort = mainDocText->sort;
        docText->body.Preallocate(len/2);
        m_docTexts.Add(docText);
      }
      else if (wcsncmp(p1,L"<!-- END EXAMPLE -->",20) == 0)
        docText = mainDocText;
      else if (wcsncmp(p1,L"<!-- START IGNORE ",18) == 0)
        ignore = true;
      else if (wcsncmp(p1,L"<!-- END IGNORE -->",19) == 0)
        ignore = false;

      p1 = wcsstr(p1,L"-->");
      if (p1 != NULL)
        p1 += 2;
      else
        p1 = p2;
    }
    else if (*p1 == L'&')
    {
      // Scan for a known literal
      bool found = false;
      int i = 0;
      while (!found && (i < sizeof literals / sizeof literals[0]))
      {
        if (wcsncmp(p1+1,literals[i].name,literals[i].len) == 0)
          found = true;
        if (!found)
          i++;
      }

      // Replace the literal
      if (found)
      {
        if (!ignore)
          docText->AddToBody(literals[i].replace);
        p1 += literals[i].len;
      }
      else
      {
        ASSERT(FALSE);
        if (!ignore)
          docText->AddToBody(*p1);
      }
      white = false;
    }
    else if (iswspace(*p1))
    {
      if (!white && !ignore)
        docText->AddToBody(L' ');
      white = true;
    }
    else
    {
      if (!ignore)
        docText->AddToBody(*p1);
      white = false;
    }
    p1++;
  }

/*
  CString bodyA(docText->body);
  AfxMessageBox(bodyA);
*/
}
Пример #27
0
void CTreePropSheet::RefillPageTree()
{
	if (!IsWindow(m_hWnd))
		return;

	m_pwndPageTree->DeleteAllItems();

	CTabCtrl	*pTabCtrl = GetTabControl();
	if (!IsWindow(pTabCtrl->GetSafeHwnd()))
	{
		ASSERT(FALSE);
		return;
	}

	const int	nPageCount = pTabCtrl->GetItemCount();

	// rebuild image list
	if (m_bTreeImages)
	{
		for (int i = m_Images.GetImageCount()-1; i >= 0; --i)
			m_Images.Remove(i);

		// add page images
		CImageList	*pPageImages = pTabCtrl->GetImageList();
		if (pPageImages)
		{
			for (int nImage = 0; nImage < pPageImages->GetImageCount(); ++nImage)
			{
				HICON	hIcon = pPageImages->ExtractIcon(nImage);
				m_Images.Add(hIcon);
				DestroyIcon(hIcon);
			}
		}

		// add default images
		if (m_DefaultImages.GetSafeHandle())
		{	
			HICON	hIcon;

			// add default images
			hIcon = m_DefaultImages.ExtractIcon(0);
			if (hIcon)
			{
				m_Images.Add(hIcon);
				DestroyIcon(hIcon);
			}
			hIcon = m_DefaultImages.ExtractIcon(1);
			{
				m_Images.Add(hIcon);
				DestroyIcon(hIcon);
			}
		}
	}

	// insert tree items
	for (int nPage = 0; nPage < nPageCount; ++nPage)
	{
		// Get title and image of the page
		CString	strPagePath;

		TCITEM	ti;
		ZeroMemory(&ti, sizeof(ti));
		ti.mask = TCIF_TEXT|TCIF_IMAGE;
		ti.cchTextMax = MAX_PATH;
		ti.pszText = strPagePath.GetBuffer(ti.cchTextMax);
		ASSERT(ti.pszText);
		if (!ti.pszText)
			return;

		pTabCtrl->GetItem(nPage, &ti);
		strPagePath.ReleaseBuffer();

		// Create an item in the tree for the page
		HTREEITEM	hItem = CreatePageTreeItem(ti.pszText);
		ASSERT(hItem);
		if (hItem)
		{
			m_pwndPageTree->SetItemData(hItem, nPage);

			// set image
			if (m_bTreeImages)
			{
				int	nImage = ti.iImage;
				if (nImage < 0 || nImage >= m_Images.GetImageCount())
					nImage = m_DefaultImages.GetSafeHandle()? m_Images.GetImageCount()-1 : -1;

				m_pwndPageTree->SetItemImage(hItem, nImage, nImage);
			}
		}
	}
}
Пример #28
0
/////////////////////////////////////////////////////////////////////////////
// 加载DockingPane
// nID = -1表示加载所有自动加载的
/////////////////////////////////////////////////////////////////////////////
BOOL CPlugIn::LoadDockingPane(int nID, BOOL bProjectLoad)
{
	CMainFrame* pMainFrame = (CMainFrame*)(AfxGetMainWnd());
	if(nID == -1)
	{
		// 2007-09-09修改,不需要事先加载OWM,在窗口要显示时候会自动加载
		// 此段代码取消--如果组件尚未加载就先加载--
		//if((m_arDockingPane.GetSize() > 0) && (m_pVciObj == NULL))
		//{
		//	LoadOwmPlugIn();
		//}

		for(int i=0; i<m_arDockingPane.GetSize(); i++)
		{
			CXTPDockingPane* pPane = pMainFrame->GetPaneManager()->FindPane(m_arDockingPane[i].m_nId);
			// 如果需要自动创建,或者工程打开时创建(并且工程正在打开),或者Pane已经存在,则执行创建动作
			if(m_arDockingPane[i].m_bAutoCreate || (m_arDockingPane[i].m_bProjectCreate && bProjectLoad) || pPane)
			{
				CString strIconPath = m_arDockingPane[i].m_strIcon;
				if(strIconPath.Find(":") == -1)
				{
					strIconPath = m_strPath+"\\"+m_arDockingPane[i].m_strIcon;
				}
				WORD wIndex = 0;
				HICON hIcon = ::ExtractAssociatedIcon(theApp.m_hInstance,
					strIconPath.GetBuffer(0), &wIndex);
				strIconPath.ReleaseBuffer();
				if(m_arDockingPane[i].m_bAutoCreate || (m_arDockingPane[i].m_bProjectCreate && bProjectLoad))
				{
					pMainFrame->CreateDockingBar(m_arDockingPane[i].m_nId,
						m_arDockingPane[i].m_nDirection, hIcon);
				}else
				if(hIcon)
				{
					pMainFrame->GetPaneManager()->SetIcon(m_arDockingPane[i].m_nId,
						CXTPImageManagerIconHandle(hIcon));
				}
			}
		}
	}else
	{
		for(int i=0; i<m_arDockingPane.GetSize(); i++)
		{
			if(m_arDockingPane[i].m_nId == nID)
			{
				if(m_pVciObj == NULL)
				{
					LoadOwmPlugIn();
				}

				CString strIconPath = m_arDockingPane[i].m_strIcon;
				if(strIconPath.Find(":") == -1)
				{
					strIconPath = m_strPath+"\\"+m_arDockingPane[i].m_strIcon;
				}
				WORD wIndex = 0;
				HICON hIcon = ::ExtractAssociatedIcon(theApp.m_hInstance,
					strIconPath.GetBuffer(0), &wIndex);
				strIconPath.ReleaseBuffer();
				pMainFrame->CreateDockingBar(m_arDockingPane[i].m_nId,
					m_arDockingPane[i].m_nDirection, hIcon);
				return TRUE;
			}
		}
	}
	return TRUE;
}
Пример #29
0
UINT ShowMessageBox (UINT Id, UINT Button, UINT Help, ...) {

    CString temp;
    TCHAR *pszstring, 
    *pszpaste, 
    *pszcut, 
    *pszdone,
    *pszconvert;
    TCHAR chread;
    va_list params;
    int x;

    pszconvert = new TCHAR[255];    	
    va_start(params, Help);
    LoadString (temp, Id);
    pszstring = temp.GetBuffer(512);
    _tcscpy(pszstring,pszstring);
    temp.ReleaseBuffer();
    // Look and see - is there a need to insert chars (95% of the time, there won't)
    if (!_tcsstr(pszstring, _T("%"))) {
	delete pszconvert;
	return AfxMessageBox(pszstring, Button, Help);
    }   

    x = _tcscspn(pszstring, _T("%"));
    pszdone = new TCHAR[512];
    pszcut = new TCHAR[512];
    pszpaste = new TCHAR[512];
    _tcscpy(pszcut, &pszstring[x+2]);
    _tcsncpy(pszpaste, pszstring, x);
    pszpaste[x] = _T('\0');
    chread = pszstring[x+1];

    for ( ; ; ) {

	switch (chread) { 
	case	_T('i') :
	case	_T('d') :
	{ 	    
	    int anint = va_arg(params, int);
	    _itot( anint, pszconvert, 10);
	    break;
	}
	case	_T('u') :
	{	
	    UINT anuint = va_arg(params, UINT);
	    _itot( anuint, pszconvert, 10);
	    break;
	}

	case	_T('x') :
	case	_T('X') :   
	{
	    int ahex = va_arg(params, int);
	    _itot( ahex, pszconvert, 16);
	    break;
	}
	case	_T('g') :
	case	_T('f') :
	case	_T('e') :   
	{
	    double adbl = va_arg(params, double);
            _stprintf(pszconvert, _T("%g"), adbl);
	    break;
	}
	case	_T('s') :	
	{
	    TCHAR *pStr = va_arg(params, TCHAR*);
	    ASSERT(_tcslen(pStr) <= 255);
	    _tcscpy(pszconvert, pStr);
	    break;
	}
	case	_T('l') :	
	{
	    chread = pszdone[x+2];
	    switch(chread) {
	    case	_T('x')	:
	    {
		long int alhex = va_arg(params, long int);
		_ltot(alhex, pszconvert, 16);
		_tcscpy(pszcut, &pszcut[1]);
		break;
	    }
	    case 	_T('d')	:
		default 	:
		{
		    long int along = va_arg(params, long int);
		    _ltot( along, pszconvert, 10);
		    // For the L, there will be one character after it,
		    //   so move ahead another letter
		    _tcscpy(pszcut, &pszcut[1]);
		    break;
		}
	    }
	    break;
	}

	case	_T('c') :	
	{
	    int letter = va_arg(params, int);
	    pszconvert[0] = (TCHAR)letter;
	    pszconvert[1] = '\0'; 
	    break;
	}
	case 	_T('a')	:
	{
	    CString zeta;
	    TCHAR* lsc;
	    UINT ls = va_arg(params, UINT);
	    LoadString (zeta, ls);
	    lsc = zeta.GetBuffer(255);
	    _tcscpy(pszconvert, lsc);
	    zeta.ReleaseBuffer();
	    break;
	}
	case	_T('o')	:
	{
	    CString get = va_arg(params, CString);
	    TCHAR* ex = get.GetBuffer(255);
	    _tcscpy(pszconvert,ex);
	    get.ReleaseBuffer();
	    break;
	}
	    default 	:
	    {	
		_tcscpy(pszconvert, _T(" Could not load message. Invalid %type in string table entry. "));
		delete pszdone;
		pszdone = new TCHAR[_tcslen(pszpaste)+_tcslen(pszcut)+_tcslen(pszconvert)+5];
		_tcscpy(pszdone, pszpaste);
		_tcscat(pszdone, pszconvert);
		_tcscat(pszdone, pszcut);
		AfxMessageBox(pszdone, Button, Help);
		delete pszcut;
		delete pszpaste;
		delete pszconvert;
		delete pszdone;
		ASSERT(FALSE);
		return 0;
	    }		
	} // case

	delete pszdone;
	pszdone = new TCHAR[_tcslen(pszpaste)+_tcslen(pszcut)+_tcslen(pszconvert)+5];
	_tcscpy(pszdone, pszpaste);
	_tcscat(pszdone, pszconvert);
	_tcscat(pszdone, pszcut);
	// Now pszdone holds the entire message.
	// Check to see if there are more insertions to be made or not
	
	if (!_tcsstr(pszdone, _T("%")))	{
	    UINT rt_type = AfxMessageBox(pszdone, Button, Help);
	    delete pszcut;
	    delete pszpaste;
	    delete pszconvert;
	    delete pszdone;
	    return rt_type;
	} // if

	// there are more insertions to make, prepare the strings to use.
	x = _tcscspn(pszdone, _T("%"));
	_tcscpy(pszcut, &pszdone[x+2]);
	_tcsncpy(pszpaste, pszdone, x); 
	pszpaste[x] = _T('\0');
	chread = pszdone[x+1];
	
    } // for
    ASSERT(FALSE);		
    return 0;

} // ShowMessageBox
Пример #30
0
void COutputTabView::AddFileToListCtrl3(CString sPath, CString sFileName, CString sFileSize, CString sFileDate)
{
	LANGID dwLanguageID = GetSystemLanguagePrimaryID();
	LVITEM Item;
	int iBufferSize = 128;
	int iCount = 0;
	int iType = 2;
	
	TCHAR buffer[1024];
	
		
	
	CString sPos = _itot(g_fcurrentPos, buffer, 10);
	CString sLine = _itot(g_currentLine + 1, buffer, 10);

	
	LPTSTR lpszLine			= sLine.GetBuffer(iBufferSize);
	LPTSTR lpszPos			=  sPos.GetBuffer(iBufferSize);
	LPTSTR lpszFilePath	= (LPTSTR)sPath.GetBuffer(iBufferSize);
	LPTSTR lpszFileName	= (LPTSTR)sFileName.GetBuffer(iBufferSize);
	LPTSTR lpszFileSize	= (LPTSTR)sFileSize.GetBuffer(iBufferSize);
	LPTSTR lpszFileDate	= (LPTSTR)sFileDate.GetBuffer(iBufferSize); 
	LPTSTR lpszText			= (LPTSTR)g_fText.GetBuffer(iBufferSize);


	sFileSize.ReleaseBuffer();
	sFileDate.ReleaseBuffer();
	sPath.ReleaseBuffer();
	sFileName.ReleaseBuffer();   
	sPos.ReleaseBuffer();
	sLine.ReleaseBuffer();
	g_fText.ReleaseBuffer();


	//Handle Internationational
	switch(dwLanguageID)
	{
		case LANG_SPANISH:
			Item = AddListItem3(0, 0, _T(""), iType );
			break;
		default:
			Item = AddListItem3(0, 0, _T(""), iType );
		break;
	}
			
	
	AddListSubItem3(Item, 0, 1,lpszLine);
	AddListSubItem3(Item, 0, 2,lpszPos);
	AddListSubItem3(Item, 0, 3,lpszFilePath);
	AddListSubItem3(Item, 0, 4,lpszFileName);
	AddListSubItem3(Item, 0, 5,lpszFileSize);
	AddListSubItem3(Item, 0, 6,lpszFileDate);
	AddListSubItem3(Item, 0, 7,lpszText);

	iCount = m_listCtrl3.GetItemCount();
	CString strCount = _itot(iCount, buffer, 10);
	LPTSTR lpszCount = _T("0");

	LVCOLUMN lvcol;

	switch(dwLanguageID)
	{
		case LANG_SPANISH:
			strCount = _T("Contenido     *** ") + strCount + _T("  fichero(s) encontrado(s) de la búsqueda. ***");
			lpszCount = strCount.GetBuffer(iBufferSize);
			
			lvcol.pszText = lpszCount;
			m_listCtrl3.SetColumn(7, &lvcol);
			break;
		default:
			strCount = _T("Content     *** ")+ strCount + _T("  ocurrence(s) have been found. ***");
			lpszCount = strCount.GetBuffer(iBufferSize);
			
			lvcol.pszText = lpszCount;
			m_listCtrl3.SetColumn(7, &lvcol);
			break;
	}

	
}