Exemplo n.º 1
0
void CDataCeneter::GetMailServer(BYTE bOperation, LPVOID VarData)
{
	struMail *pMailData = (struMail*)VarData;

	TCHAR szData[1024] = {0};
	ULONG ulChars = 1024;
	CRegKey regKey;

	if( regKey.Open(HKEY_LOCAL_MACHINE, GetRegFolder()) == ERROR_SUCCESS)
	{
		regKey.QueryStringValue(_T("SMTPSETTING"), szData,&ulChars);
	}
	regKey.Close();

	CString csSMTPSecure, csSMTPServer, csSMTPPort, csSMTPAccount, csSMTPPassword;
	AfxExtractSubString(csSMTPSecure, szData, 0, ';');
	AfxExtractSubString(csSMTPServer, szData, 1, ';');
	AfxExtractSubString(csSMTPPort, szData, 2, ';');
	AfxExtractSubString(csSMTPAccount, szData, 3, ';');
	AfxExtractSubString(csSMTPPassword, szData, 4, ';');

	pMailData->SMTPSecure = (SMTP_SECURE)_ttoi(csSMTPSecure);
	pMailData->SMTPServer = csSMTPServer;
	pMailData->SMTPPort = csSMTPPort;
	pMailData->SMTPAccount = csSMTPAccount;
	pMailData->SMTPPassword = csSMTPPassword;
}
Exemplo n.º 2
0
/* extract CSV items using undocumented 'AfxExtractSubString()' to speed up (maybe) */
bool	CCsvFile::GetItem(CStringW &item, const CStringW &line, WORD &index)
{
	CStringW last_item;
	bool	ret = false;

	last_item.Empty();
	if(!AfxExtractSubString(item,line,index,','))
		return false;

	if(item.Left(1) == _T("\""))
	{
		do
		{
			if(item.Right(1) == _T("\""))
			{
				if(!last_item.IsEmpty())
					item = last_item + item;
				item.Trim(_T("\""));
				ret = true;
				break;
			}
			last_item += item + _T(",");
		}
		while(AfxExtractSubString(item,line,++index,','));
	}
	else
		ret = true;
	return ret;
}
Exemplo n.º 3
0
BOOL CDialogCheckUpdate::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  在此添加额外的初始化
	CString strLatestVersionInfo = GetLatestVersionInfo(UIDESIGNER_VERSION_CHECK_URL);
	CString strLastestVersion;
	CString strUpdateURL;
	AfxExtractSubString(strLastestVersion,strLatestVersionInfo, 0, '|');
	AfxExtractSubString(strUpdateURL,strLatestVersionInfo, 1, '|');
	this->GetDlgItem(IDC_STATIC_CURRENT_VERSION)->SetWindowText(UIDESIGNER_VERSION);
	this->GetDlgItem(IDC_STATIC_LATEST_VERSION)->SetWindowText(strLastestVersion);
	CWnd* pWndInfo = this->GetDlgItem(IDC_STATIC_UPDATE_INFO);
	if(strLatestVersionInfo.IsEmpty())
		pWndInfo->SetWindowText(_T("检查新版本失败!"));
	else if(strLastestVersion == UIDESIGNER_VERSION)
		pWndInfo->SetWindowText(_T("您的版本已经是最新!"));
	else
	{
		m_btnUpdateURL.SetURL(strUpdateURL);
		m_btnUpdateURL.SetTooltip(_T("下载最新版本"));
		m_btnUpdateURL.SizeToContent();
		m_btnUpdateURL.ShowWindow(SW_SHOW);
		pWndInfo->SetWindowText(_T("新版本可供下载!"));
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}
//******************************************************************************
void CBCGPRadialMenuItem::UpdateToolTip()
{
	CString strText;
	if (!strText.LoadString (m_nID))
	{
		return;
	}

	m_strToolTip.Empty ();
	m_strDescription.Empty ();

	if (strText.IsEmpty ())
	{
		return;
	}

	AfxExtractSubString (m_strDescription, strText, 0);
	AfxExtractSubString (m_strToolTip, strText, 1, '\n');

	const CString strDummyAmpSeq = _T("\001\001");

	m_strToolTip.Replace (_T("&&"), strDummyAmpSeq);
	m_strToolTip.Remove (_T('&'));
	m_strToolTip.Replace (strDummyAmpSeq, _T("&"));
}
Exemplo n.º 5
0
void CMainDlg::OnBnClickedBtRescan()
{
	CStringList ports;
	CString str, port, name;
	int ix, num, sel=0;
	
	m_comPorts.ResetContent();

	MgpEnumerateSystemPorts(_T("Ports"), _T("COM"), &ports);

	POSITION pos = ports.GetHeadPosition();

	while(pos)
	{
		str = ports.GetNext(pos);
		AfxExtractSubString(port, str, 0, '\n');
		AfxExtractSubString(name, str, 1, '\n');

		if(_stscanf(port, _T("COM%i"), &num) == 1)
		{
			ix = m_comPorts.AddString(name);
			m_comPorts.SetItemData(ix, (LPARAM) num);

			if(name.Find(_T("Bootloader")) >= 0)
			{
				sel = ix;
			}
		}
	}

	m_comPorts.SetCurSel(sel);
}
BOOL CConnectRemoteMachineWindow::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	m_port.SetWindowTextW(L"20099");

	loadHistory();

	int i = 0;
	std::deque<CString>::iterator iter = m_historyCommand.begin();
	for(; iter != m_historyCommand.end(); iter++)
	{
		if(i == 0)
		{
			CString output = L"";
			CString output1 = L"";
			AfxExtractSubString(output, (*iter), 0, _T(':'));
			AfxExtractSubString(output1, (*iter), 1, _T(':'));

			char* ip = KBEngine::strutil::wchar2char(output.GetBuffer(0));
			m_ip.SetAddress(ntohl(inet_addr(ip)));
			free(ip);

			m_port.SetWindowTextW(output1);
		}

		i++;
		m_log.AddString((*iter));
	}

	return TRUE;  // return TRUE  unless you set the focus to a control
}
Exemplo n.º 7
0
void AfxUnregisterShellFileTypes()
{
	CString strPathName, strTemp;

	AfxGetModuleShortFileName(AfxGetInstanceHandle(), strPathName);

	CString	strMainFrame;
	VERIFY(strMainFrame.LoadString( IDR_MAINFRAME ));

	CString strFilterExt, strFileTypeId, strFileTypeName;
	if (AfxExtractSubString( strFileTypeId,strMainFrame,
	   CDocTemplate::regFileTypeId) && !strFileTypeId.IsEmpty())
	{
		// enough info to register it
		if (!AfxExtractSubString( strFileTypeName, strMainFrame,
		   CDocTemplate::regFileTypeName))
			strFileTypeName = strFileTypeId;    // use id name

		ASSERT(strFileTypeId.Find(' ') == -1);  // no spaces allowed

		strTemp.Format(_afxDefaultIconFmt, (LPCTSTR)strFileTypeId);
		AfxDeleteRegKey(strTemp);

		// path\shell\open\command = path filename
		strTemp.Format(_afxShellOpenFmt, (LPCTSTR)strFileTypeId,
			(LPCTSTR)_afxCommand);
		AfxDeleteRegKey(strTemp);

		// path\shell\print\command = path /p filename
		strTemp.Format(_afxShellPrintFmt, (LPCTSTR)strFileTypeId,
			(LPCTSTR)_afxCommand);
		AfxDeleteRegKey(strTemp);

		// path\shell\printto\command = path /pt filename printer driver port
		strTemp.Format(_afxShellPrintToFmt, (LPCTSTR)strFileTypeId,
			(LPCTSTR)_afxCommand);
		AfxDeleteRegKey(strTemp);

		AfxExtractSubString( strFilterExt, strMainFrame, CDocTemplate::filterExt);
		if (!strFilterExt.IsEmpty())
		{
			ASSERT(strFilterExt[0] == '.');

			LONG lSize = _MAX_PATH * 2;
			LONG lResult = ::RegQueryValue(HKEY_CLASSES_ROOT, strFilterExt,
				strTemp.GetBuffer(lSize), &lSize);
			strTemp.ReleaseBuffer();

			if (lResult != ERROR_SUCCESS || strTemp.IsEmpty() ||
				strTemp == strFileTypeId)
			{
				strTemp.Format(_afxShellNewFmt, (LPCTSTR)strFilterExt);
				AfxDeleteRegKey(strTemp);

				// no association for that suffix
				AfxDeleteRegKey(strFilterExt);
			}
		}
	}
}
Exemplo n.º 8
0
AFX_STATIC void AFXAPI _AfxAppendFilterSuffix(CString& filter, OPENFILENAME& ofn,
											  CString *pstrDefaultExt)
{
	CString	strMainFrame;
	VERIFY(strMainFrame.LoadString( IDR_MAINFRAME ));

	CString strFilterExt, strFilterName;
	if (AfxExtractSubString(strFilterExt, strMainFrame, CDocTemplate::filterExt) &&
	 !strFilterExt.IsEmpty() &&
	 AfxExtractSubString(strFilterName, strMainFrame, CDocTemplate::filterName) &&
	 !strFilterName.IsEmpty())
	{
		// a file based document template - add to filter list
		ASSERT(strFilterExt[0] == '.');
		if (pstrDefaultExt != NULL)
		{
			// set the default extension
			*pstrDefaultExt = ((LPCTSTR)strFilterExt) + 1;  // skip the '.'
			ofn.lpstrDefExt = (LPTSTR)(LPCTSTR)(*pstrDefaultExt);
			ofn.nFilterIndex = ofn.nMaxCustFilter + 1;  // 1 based number
		}

		// add to filter
		filter += strFilterName;
		ASSERT(!filter.IsEmpty());  // must have a file type name
		filter += (TCHAR)'\0';  // next string please
		filter += (TCHAR)'*';
		filter += strFilterExt;
		filter += (TCHAR)'\0';  // next string please
		ofn.nMaxCustFilter++;
	}
}
CSize CXTPPropertyGridItemSize::StringToSize(LPCTSTR str)
{
	CString strWidth, strHeight;

	AfxExtractSubString(strWidth, str, 0, ';');
	AfxExtractSubString(strHeight, str, 1, ';');

	return CSize(_ttoi(strWidth), _ttoi(strHeight));
}
Exemplo n.º 10
0
void CEditListEditor::OpenFile(LPCTSTR lpFileName)
{
    CString strLine;
    CStdioFile editListFile;
    CString strUser;
    CString strHotFolders;

    CloseFile();
    m_strFileName.Format(_T("%s.edl"), lpFileName);

    if (editListFile.Open(m_strFileName, CFile::modeRead)) {
        m_bFileOpen = true;
        while (editListFile.ReadString(strLine)) {
            //int nPos = 0;
            CString strIn;      //  = strLine.Tokenize(_T(" \t"), nPos);
            CString strOut;     //  = strLine.Tokenize(_T(" \t"), nPos);
            CString strName;    //  = strLine.Tokenize(_T(" \t"), nPos);

            AfxExtractSubString(strIn, strLine, 0, _T('\t'));
            AfxExtractSubString(strOut, strLine, 1, _T('\t'));
            AfxExtractSubString(strName, strLine, 2, _T('\t'));
            if (strUser.IsEmpty()) {
                AfxExtractSubString(strUser, strLine, 3, _T('\t'));
                SelectCombo(strUser, m_cbUsers);
            }
            if (strHotFolders.IsEmpty()) {
                AfxExtractSubString(strHotFolders, strLine, 4, _T('\t'));
                SelectCombo(strHotFolders, m_cbHotFolders);
            }

            if (!strIn.IsEmpty() && !strOut.IsEmpty()) {
                CClip NewClip;
                NewClip.SetIn(strIn);
                NewClip.SetOut(strOut);
                NewClip.SetName(strName);

                InsertClip(nullptr, NewClip);
            }
        }

        editListFile.Close();
    } else {
        m_bFileOpen = false;
    }

    if (m_nameList.IsEmpty()) {
        CStdioFile nameFile;
        CString str;
        if (nameFile.Open(_T("EditListNames.txt"), CFile::modeRead)) {
            while (nameFile.ReadString(str)) {
                m_nameList.Add(str);
            }
            nameFile.Close();
        }
    }
}
Exemplo n.º 11
0
// Get current setting for a file or the default settings if not yet set
// This now handles an index of -1 to get the default setting
CString CHexFileList::GetData(int index, param_num param) const
{
	ASSERT(index < int(name_.size()));

	CString retval;
	if (index > - 1)
		AfxExtractSubString(retval, data_[index], param, '|');
	if (retval.IsEmpty())
		AfxExtractSubString(retval, default_data_, param, '|');
	return retval;
}
Exemplo n.º 12
0
void CAddDevice::GetNetMask(CJason& jason, ec_Camera& camObj)
{
	CString csNetmask;
	jason.GetValuebyKey(_T("netmask"),csNetmask);
	LPCTSTR lpszFullString = csNetmask.GetBuffer();
	AfxExtractSubString(camObj.subnet_mask1, lpszFullString, 0, '.');
	AfxExtractSubString(camObj.subnet_mask2, lpszFullString, 1, '.');
	AfxExtractSubString(camObj.subnet_mask3, lpszFullString, 2, '.');
	AfxExtractSubString(camObj.subnet_mask4, lpszFullString, 3, '.');
	csNetmask.ReleaseBuffer();
}
Exemplo n.º 13
0
CMDIChildWnd* CMDIFrameWnd::CreateNewChild(CRuntimeClass* pClass,
		UINT nResources, HMENU hMenu /* = NULL */, HACCEL hAccel /* = NULL */)
{
	ASSERT(pClass != NULL);
	CMDIChildWnd* pFrame = (CMDIChildWnd*) pClass->CreateObject();
	ASSERT_KINDOF(CMDIChildWnd, pFrame);

	// load the frame
	CCreateContext context;
	context.m_pCurrentFrame = this;

	pFrame->SetHandles(hMenu, hAccel);
	if (!pFrame->LoadFrame(nResources,
			WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, &context))
	{
		TRACE(traceAppMsg, 0, "Couldn't load frame window.\n");
		return NULL;
	}

	CString strFullString, strTitle;
	if (strFullString.LoadString(nResources))
		AfxExtractSubString(strTitle, strFullString, CDocTemplate::docName);

	// redraw the frame and parent
	pFrame->SetTitle(strTitle);
	pFrame->InitialUpdateFrame(NULL, TRUE);

	return pFrame;
}
Exemplo n.º 14
0
void CFireView:: ParseToIp(CString str)
{
	// Your code, please pay attention to the form of IP address and port!
	//把每一行的字符串根据逗号分隔开
	CString strTmp[8];
	for(int i = 0; i < 8; i ++){
		AfxExtractSubString(strTmp[i], (LPCTSTR)str, i, ',');
	}
	//将每行数据添加在Item列表里的首行(第0行)
	AddItem(0,0,(LPCTSTR)strTmp[0]);
	AddItem(0,1,(LPCTSTR)strTmp[1]);
	AddItem(0,2,(LPCTSTR)strTmp[2]);
	AddItem(0,3,(LPCTSTR)strTmp[3]);
	AddItem(0,4,(LPCTSTR)strTmp[4]);
	AddItem(0,5,(LPCTSTR)strTmp[5]);
	int	_proto = atoi((LPCTSTR)strTmp[6]);
	CString	proto;
	if(_proto == 0)
		proto = "ANY";
	else if(_proto == 1)
		proto = "ICMP";
	else if(_proto == 6)
		proto = "TCP";
	else if(_proto == 17)
		proto = "UDP";
	AddItem(0,6,((LPCTSTR)proto));
	int _action = atoi((LPCTSTR)strTmp[7]);
	if(_action == 0)
		AddItem(0,7,"ALLOW");
	if(_action == 1)
		AddItem(0,7,"DENY");
	//对应行数增加1
	_rows ++;
	
}
Exemplo n.º 15
0
BOOL CSetupWnd::LoadWndParameter(CString& strParameter)
{
	CStringArray arData;

	if (!m_edPath)
		return FALSE;

	CString sToken = _T("");
	int i = 0;
	while (AfxExtractSubString(sToken, strParameter, i, ','))
	{
		arData.Add(sToken);
		i++;
	}

	if (arData.GetCount() != $VALUE_MAX)
		return FALSE;
		
	m_btnEnable->SetCheck(_tstoi(arData.GetAt($VALUE_ENABLE)));

	CString strTemp(arData.GetAt($VALUE_PATH));
	strTemp.Replace(L"\\", L"\\\\");
	m_edPath->SetWindowText(strTemp);


	return TRUE;
}
void CBCGPRibbonBackstagePagePrint::OnPageChanged() 
{
	if (m_wndPreview->GetSafeHwnd () != NULL)
	{
		CPrintInfo* pPrintInfo = m_wndPreview->GetPrintInfo ();

		CString strPage;
		CString strFmt;
		if (!AfxExtractSubString (strFmt, pPrintInfo->m_strPageDesc, 0))
		{
			strFmt = _T("%d");
		}

		strPage.Format(strFmt, m_wndPreview->GetCurrentPage ());

		m_wndPageNum.SetWindowText (strPage);

		m_btnPrev.EnableWindow (m_wndPreview->GetCurrentPage () > pPrintInfo->GetMinPage ());
		m_btnNext.EnableWindow (m_wndPreview->GetCurrentPage () < pPrintInfo->GetMaxPage ());
	}
	else
	{
		m_btnPrev.EnableWindow (FALSE);
		m_btnNext.EnableWindow (FALSE);

		m_wndPageNum.SetWindowText (_T(""));
		m_wndPageNum.EnableWindow (FALSE);
	}
}
Exemplo n.º 17
0
void CSizableReBar::LoadState( LPCTSTR lpszProfileName )
{
    // This function restores index, width and style from the registry for
    // each band in the rebar.

    CString strValue = AfxGetApp()->GetProfileString( lpszProfileName,
        m_lpszStateInfoEntry );
    if ( !strValue.IsEmpty() )
    {
        REBARBANDINFO rbbi;
        rbbi.cbSize = sizeof( rbbi );
        rbbi.fMask  = RBBIM_STYLE | RBBIM_SIZE | RBBIM_ID;

        CReBarCtrl& rbCtrl = m_wndReBar.GetReBarCtrl();
        for ( UINT nBand = 0; nBand < rbCtrl.GetBandCount(); nBand++ )
        {
            CString strBandState;
            VERIFY( AfxExtractSubString( strBandState, strValue, nBand, _T('\n') ) );

            UINT nID, cx, nStyle;
            int nResult = _stscanf( strBandState, m_lpszStateInfoFormat, &nID, &cx, &nStyle );
            ASSERT( nResult == 3 );

            rbCtrl.MoveBand( rbCtrl.IDToIndex( nID ), nBand );
            VERIFY( rbCtrl.GetBandInfo( nBand, &rbbi ) );
            rbbi.cx     = cx;
            rbbi.fStyle = ( rbbi.fStyle & ~( RBBS_HIDDEN | RBBS_BREAK ) ) | nStyle;
            VERIFY( rbCtrl.SetBandInfo( nBand, &rbbi ) );
        }
    }
}
Exemplo n.º 18
0
BOOL CGuiFrameWnd::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) 
{
	// only do this once
	ASSERT_VALID_IDR(nIDResource);
	ASSERT(m_nIDHelp == 0 || m_nIDHelp == nIDResource);

	m_nIDHelp = nIDResource; // ID for help context (+HID_BASE_RESOURCE)

	CString strFullString;
	if (strFullString.LoadString(nIDResource))
		AfxExtractSubString(m_strTitle, strFullString, 0); // first sub-string

	VERIFY(AfxDeferRegisterClass(AFX_WNDFRAMEORVIEW_REG));

	// attempt to create the window
	LPCTSTR lpszClass = GetIconWndClass(dwDefaultStyle, nIDResource);
	LPCTSTR lpszTitle = m_strTitle;
	if (!Create(lpszClass, lpszTitle, dwDefaultStyle, rectDefault,pParentWnd, NULL, 0L, pContext))
	{
		return FALSE; // will self destruct on failure normally
	}

	// save the default menu handle
	ASSERT(m_hWnd != NULL);
	m_hMenuDefault = ::GetMenu(m_hWnd);

	// load accelerator resource
	LoadAccelTable(MAKEINTRESOURCE(nIDResource));

	if (pContext == NULL) // send initial update
		SendMessageToDescendants(WM_INITIALUPDATE, 0, 0, TRUE, TRUE);

	return TRUE;
}
Exemplo n.º 19
0
void CFrameWnd::GetMessageString( UINT nID, CString &rString ) const
/******************************************************************/
{
    CString strTemp;
    strTemp.LoadString( nID );
    AfxExtractSubString( rString, strTemp, 0 );
}
Exemplo n.º 20
0
BOOL CALLBACK EnumWindowsProc(HWND hwnd, DWORD lParam) 
{
  // 窗口是否可视
    if (!IsWindowVisible(hwnd))
        return TRUE;
 
    // 窗口是否可激活
    if (!IsWindowEnabled(hwnd))
        return TRUE;
	
	int length = ::GetWindowTextLength(hwnd);
	// 窗口是否有标题,无标题则无法判断
	if(length <1) 
		return TRUE;

	char *buffer = new char[length+2];
	::GetWindowText(hwnd,buffer,length+2);

	CString str_Title = buffer;
	CString keywords = *((CString*)lParam);

	CString temp;

	int i=0;
	while(AfxExtractSubString(temp,(LPCTSTR)keywords,i++,'%'))
	{
		if(temp.GetLength()>0 && str_Title.Find(temp,0) != -1)  //看窗口标题中是否包含关键字,若有,则发送关闭消息使其关闭
			::PostMessage(hwnd,WM_CLOSE,0,0);
	}

    return TRUE;
}
Exemplo n.º 21
0
BOOL CModelessMain::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
{
	ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW);

	// allow top level routing frame to handle the message
	if (GetRoutingFrame() != NULL)
		return FALSE;

	// need to handle both ANSI and UNICODE versions of the message
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
	TCHAR szFullText[256];
	CString strTipText;
	UINT_PTR nID = (UINT_PTR)pNMHDR->idFrom;
	if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
		pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
	{
		// idFrom is actually the HWND of the tool
		nID = ((UINT_PTR)(WORD)::GetDlgCtrlID((HWND)nID));
	}

	if (nID != 0) // will be zero on a separator
	{
		AfxLoadString((UINT)nID, szFullText);
			// this is the command id, not the button index
		AfxExtractSubString(strTipText, szFullText, 1, '\n');
	}
#ifndef _UNICODE
	if (pNMHDR->code == TTN_NEEDTEXTA)
		_tcsncpy_s(pTTTA->szText, (sizeof(pTTTA->szText)/sizeof(pTTTA->szText[0])),
			strTipText, _TRUNCATE);
	else
	{
		int n = MultiByteToWideChar(CP_ACP, 0, strTipText, -1, pTTTW->szText, 
			sizeof(pTTTW->szText)/sizeof(pTTTW->szText[0]));
		if (n > 0)
			pTTTW->szText[n-1] = 0;
	}
#else
	if (pNMHDR->code == TTN_NEEDTEXTA)
	{
		int n = WideCharToMultiByte(CP_ACP, 0, strTipText, -1, 
			pTTTA->szText, sizeof(pTTTA->szText)/sizeof(pTTTA->szText[0]),
			NULL, NULL);
		if (n > 0)
			pTTTA->szText[n-1] = 0;
	}
	else
		_tcsncpy_s(pTTTW->szText, (sizeof(pTTTW->szText)/sizeof(pTTTW->szText[0])),
			strTipText, _TRUNCATE);
#endif
	*pResult = 0;

	// bring the tooltip window above other popup windows
	::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0,
		SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE);

	return TRUE;    // message was handled
}
Exemplo n.º 22
0
void CConnectRemoteMachineWindow::OnLbnDblclkList1()
{
	// TODO: Add your control notification handler code here
	CString str;
	m_log.GetText(m_log.GetCurSel(), str);
	
	CString output = L"";
	CString output1 = L"";
	AfxExtractSubString(output, str, 0, _T(':'));
	AfxExtractSubString(output1, str, 1, _T(':'));

	char* ip = KBEngine::strutil::wchar2char(output.GetBuffer(0));
	m_ip.SetAddress(ntohl(inet_addr(ip)));
	free(ip);

	m_port.SetWindowTextW(output1);
}
Exemplo n.º 23
0
CString	AfxGetApplicationName( )
{
	CString	strMainFrame;
	strMainFrame.LoadString( IDR_MAINFRAME );
	CString strName;
	VERIFY( AfxExtractSubString( strName, strMainFrame,CDocTemplate::windowTitle) );
	return strName;
}
Exemplo n.º 24
0
HRESULT CPatchDlg::ParseServerCfg(CString cfgPath)
{
	BKIni::Document ini;
	int nFileCount=100;
	HRESULT hr=S_OK;
	BKIni::Section section;

	if (FAILED(hr))
		return hr;
    ini.LoadFile(cfgPath);
	if (!ini.HasSection(L"config"))
		return E_FAIL;
    section=ini[L"config"];
	//初始化
	nFileCount=section[L"maxFileCount"].GetValueDWORD();
	sBaseAddress=section[_T("baseAddress")].GetValueString();
	section=ini[L"file"];
	m_mapSvrFileVersion.RemoveAll();
	Log(_T("分析服务端的文件列表,基址%s,最大文件数%d\r\n"),sBaseAddress,nFileCount);
	for (int i=1; i<nFileCount; ++i)
	{
		wchar_t szItem[10] = {0};
		wsprintf(szItem, L"f%d", i);
		CString 
			str,
			sFile,
			sVer,
			sTmp;
		DWORD dwCrc=0;
		if (!section.HasKey(szItem))
			break;
        str=section[szItem].GetValueString();
		PFILEUPDATESVRDATA pData=new FILEUPDATESVRDATA();
	    AfxExtractSubString(sFile,str,0,L',');
		AfxExtractSubString(pData->sFilePath,str,1,L',');
        AfxExtractSubString(sVer,str,2,L',');
		AfxExtractSubString(sTmp,str,3,L',');
		_stscanf_s(sTmp.GetString(),_T("%x"),&dwCrc);
		pData->sFileName=sFile;
		pData->sVersion=sVer;
		pData->nCrc32=dwCrc;
		m_mapSvrFileVersion.SetAt(sFile.MakeUpper(),pData);
		//Log(_T("服务端文件:%-25s,版本:%10s\r\n"),pData->sFileName,pData->sVersion);
	}
	return S_OK;
}
Exemplo n.º 25
0
HICON ShellIcons::ExtractIcon(SHELLICON nIndex, bool bLarge)
{
	HICON hIcon = NULL;

	// Shell icons can be customized by the registry:
	// HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons
	// "<ShellIconIndex>" = "<Filename>,<IconIndex>"
	// E.g.
	// "3" = "c:\MyFolderIcon.ico,1"
	HKEY hkeyShellIcons;

	if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), 0, KEY_READ, &hkeyShellIcons) == ERROR_SUCCESS)
	{
		TCHAR szBuffer[ MAX_PATH * sizeof TCHAR];
		DWORD dwSize = MAX_PATH * sizeof TCHAR;

		TCHAR szIndex[6] = {0};
		_stprintf (szIndex, _T("%d"), nIndex);

		if (RegQueryValueEx (hkeyShellIcons, szIndex, NULL, NULL, (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS)
		{
			CString strFileName, strIndex;
			VERIFY (AfxExtractSubString (strFileName, szBuffer, 0, _T(',')));
			VERIFY (AfxExtractSubString (strIndex, szBuffer, 1, _T(',')));

			if (bLarge)
				ExtractIconEx(strFileName, _ttoi(strIndex), &hIcon, NULL, 1);
			else
				ExtractIconEx(strFileName, _ttoi(strIndex), NULL, &hIcon, 1);
		}

		RegCloseKey( hkeyShellIcons );
	}

	// Not customized? Then get the original icon from shell23.dll
	if (!hIcon)
	{
		if (bLarge)
			ExtractIconEx(_T("SHELL32.DLL"), nIndex, &hIcon, NULL, 1);
		else
			ExtractIconEx(_T("SHELL32.DLL"), nIndex, NULL, &hIcon, 1);
	}

	return hIcon;
}
Exemplo n.º 26
0
// xxx TBD handle whitespace including CR/LF
// Takes a string in the form of an C/C++ enum content such as "{NONE, RED=2, GREEN}"
// and returns a vector of name/value (Eg NONE/0, RED/2, GREEN/3).
// If any errors are found in the string false is returned and the vector is empty.
bool get_enum(LPCTSTR pp, std::vector<enum_entry> &retval)
{
	retval.clear();

	// Make sure the enum string starts with the flag character {
	if (pp[0] != '{') return false;

	// Get rid of the trailing } so we just have the enum strings
	const char *pend = strchr(pp, '}');
	if (pend == NULL) return false;

	CString ss(pp+1, pend-pp-1);

	__int64 enum_val = 0;
	for (int ii = 0; ; ++ii)
	{
		CString entry;                  // One enum entry (comma separated)
		enum_entry ee;                  // Entry to add to the returned vector
		int eq_pos;                     // Posn of equals sign in the entry

		// Get a single enum entry and break from loop if no more
		if (!AfxExtractSubString(entry, ss, ii, ','))
			break;

		entry.TrimLeft();
		entry.TrimRight();
		if ((eq_pos = entry.Find('=')) == -1)
		{
			if (!valid_id(entry))
			{
				retval.clear();
				return false;
			}
			ee.name = entry;
		}
		else
		{
			// Get separate name and value
			ee.name = entry.Left(eq_pos);
			ee.name.TrimRight();
			if (!valid_id(ee.name))
			{
				retval.clear();
				return false;
			}
			enum_val = _atoi64(entry.Mid(eq_pos + 1));
		}

		ee.value = enum_val;
		retval.push_back(ee);
		//TRACE2("ENUM: %s=%ld\n", ee.name, long(enum_val));

		++enum_val;
	}

	return true;
}
Exemplo n.º 27
0
CString	AfxGetStrategyFileExt( )
{
	CString	strMainFrame;
	strMainFrame.LoadString( IDR_MAINFRAME );
	CString strExt;
	VERIFY( AfxExtractSubString( strExt, strMainFrame,CDocTemplate::filterExt) );
	ASSERT( !strExt.IsEmpty() && strExt[0] == '.');
	return strExt;
}
BOOL CXTPSyntaxEditSectionManager::SplitString(CString& csLeft, CString& csRight, const CString& csBuffer, TCHAR chSep)
{
	if (!AfxExtractSubString(csLeft, csBuffer, 0, chSep))
		return FALSE;

	// trim whitespace from string.
	csLeft.TrimLeft();
	csLeft.TrimRight();

	if (!AfxExtractSubString(csRight, csBuffer, 1, chSep))
		return FALSE;

	// trim whitespace from string.
	csRight.TrimLeft();
	csRight.TrimRight();

	return TRUE;
}
Exemplo n.º 29
0
void CMyListCtrlTool::InsertRecord(CListCtrl &ctrl, CString &strRecord)
{
    int nItems = 0;
    /*nItems = m_ProcessListCtrl.GetHeaderCtrl()->GetItemCount();*/
    
#define  USE_AFXSUB
#ifdef USE_AFXSUB
    
    CString strSub;
    AfxExtractSubString(strSub, strRecord, 0, '|');
    int nItem = ctrl.InsertItem(nItems, strSub);
    
    for (int i = 1; ; i++)
    {
        if (!AfxExtractSubString(strSub, strRecord, i, '|'))
        {
            break;
        }
        ctrl.SetItemText(nItem, i, strSub);
    }
    
#else
    
    TCHAR *pszTaskInfo = strRecord.GetBuffer(0);
    TCHAR seps[] = TEXT("|");
    TCHAR *token = NULL;
    
    // 插入第1列
    token = _tcstok(pszTaskInfo, seps);
    if (token != NULL)
    {
        ctrl.InsertItem(nItems, token);
        token = _tcstok(NULL, seps);
    }
    
    //后续各列插入
    int nSub = 1;
    while (token != NULL)
    {
        ctrl.SetItemText(nItems, nSub++, token);        
        token = _tcstok( NULL, seps );
    } 
#endif
}
Exemplo n.º 30
0
void CBookmarkDlg::InitColumnHeadings()
{
	static char *heading[] =
	{
		"Name",
		"File",
		"Folder",
		"Byte No",
		"Modified",
		"Accessed",
		NULL
	};

	ASSERT(sizeof(heading)/sizeof(*heading) == COL_LAST + 1);

	CString strWidths = theApp.GetProfileString("File-Settings", 
												"BookmarkDialogColumns",
												"80,80,,60,,138");
	int curr_col = grid_.GetFixedColumnCount();
	bool all_hidden = true;

	for (int ii = 0; ii < COL_LAST; ++ii)
	{
		CString ss;

		AfxExtractSubString(ss, strWidths, ii, ',');
		int width = atoi(ss);
		if (width != 0) all_hidden = false;                  // we found a visible column

		ASSERT(heading[ii] != NULL);
		grid_.SetColumnCount(curr_col + 1);
		if (width == 0)
			grid_.SetColumnWidth(curr_col, 0);              // make column hidden
		else
			grid_.SetUserColumnWidth(curr_col, width);      // set user specified size (or -1 to indicate fit to cells)

		// Set column heading text (centred).  Also set item data so we know what goes in this column
		GV_ITEM item;
		item.row = 0;                                       // top row is header
		item.col = curr_col;                                // column we are changing
		item.mask = GVIF_PARAM|GVIF_FORMAT|GVIF_TEXT;       // change data+centered+text
		item.lParam = ii;                                   // data that says what's in this column
		item.nFormat = DT_CENTER|DT_VCENTER|DT_SINGLELINE;  // centre the heading
		item.strText = heading[ii];                         // text of the heading
		grid_.SetItem(&item);

		++curr_col;
	}

	// Show at least one column
	if (all_hidden)
	{
		grid_.SetColumnWidth(grid_.GetFixedColumnCount(), 1);
		grid_.AutoSizeColumn(grid_.GetFixedColumnCount(), GVS_BOTH);
	}
}