Example #1
0
static void sendOpenFileMessage(HWND window) {
	_TCHAR* id;
	UINT msg;
	int index = 0;
	int size = 0;
	DWORD wParam;
#ifdef WIN64
	DWORDLONG lParam;
#else
	DWORD lParam;
#endif

	/* what's the longest path? */
	while (openFilePath[index] != NULL) {
		int length = _tcslen(openFilePath[index++]);
		if (size <= length)
			size = length + 1;
	}

	createSharedData(&id, size * sizeof(_TCHAR));
	_stscanf(id, _T_ECLIPSE("%lx_%lx"), &wParam, &lParam);
	msg = RegisterWindowMessage(_T("SWT_OPENDOC"));

	index = 0;
	for(index = 0; openFilePath[index] != NULL; index++) {
		/* SendMessage does not return until the message has been processed */
		setSharedData(id, openFilePath[index]);
		SendMessage(window, msg, wParam, lParam);
	}
	destroySharedData(id);
	free(id);
	SetForegroundWindow(window);
}
Example #2
0
//-----------------------------------------------------------------------------
// Name: StringToDouble
// Object: convert string to double
// Parameters :
//     in  : TCHAR* strValue
//     out : double* pValue
//     return : TRUE on success
//-----------------------------------------------------------------------------
BOOL CStringConverter::StringToDouble(TCHAR* strValue,double* pValue)
{
    *pValue=0;
    CTrimString::TrimString(strValue);

    return (_stscanf(strValue,_T("%g"),pValue)==1);
}
Example #3
0
int CWebWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (WEB_WINDOW_PARENT::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// Get IE version
	CString str;
	McRegGetString(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Internet Explorer"), _T("Version"), str, NULL);
	long nMajor=0, nMinor=0;
	if(!str.IsEmpty())
		_stscanf((LPCTSTR)str, _T("%d.%d"), &nMajor, &nMinor);
	m_nIEVersion = nMajor * 100 + nMinor;
	
	if(!m_bChild)
		AddWindowToClose(this);
	
//	m_browser.Create(NULL, WS_VISIBLE|WS_CHILD, CRect(0,0,0,0), this, ID_DHTML_CTRL);
	
	HRESULT hr = m_pWebCustomizer.CreateInstance(CLSID_MpaWebCustomizer);
	if(FAILED(hr))
		return -1;
	
//	LPUNKNOWN pDispatch = m_browser.GetControlUnknown();
//	m_pWebCustomizer->PutRefWebBrowser((LPDISPATCH)pDispatch);

	m_MpaWebEvent.m_pParent = this;
	InitMpaWebEvent();
	
	return 0;
}
BOOL CSchemaMember::LoadType(CXMLElement* pType)
{
	CString strName = pType->GetName();

	if ( strName.CompareNoCase( _T("simpleType") ) &&
		 strName.CompareNoCase( _T("complexType") ) ) return FALSE;

	m_sType = pType->GetAttributeValue( _T("base"), _T("") );
	CharLower( m_sType.GetBuffer() );
	m_sType.ReleaseBuffer();
	m_bNumeric = ( m_sType == _T("short") || m_sType == _T("int") || m_sType == _T("decimal") );
	
	for ( POSITION pos = pType->GetElementIterator() ; pos ; )
	{
		CXMLElement* pElement	= pType->GetNextElement( pos );
		CString strElement		= pElement->GetName();

		if ( strElement.CompareNoCase( _T("enumeration") ) == 0 )
		{
			CString strValue = pElement->GetAttributeValue( _T("value"), _T("") );
			if ( strValue.GetLength() ) m_pItems.AddTail( strValue );
		}
		else if ( strElement.CompareNoCase( _T("maxInclusive") ) == 0 )
		{
			CString strValue = pElement->GetAttributeValue( _T("value"), _T("0") );
			_stscanf( strValue, _T("%i"), &m_nMaxLength );
		}
	}

	return TRUE;
}
void EditTextWithFormat(CDataExchange* pDX, int nIDC, HTREEITEM hItem, LPCTSTR lpszFormat, UINT nIDPrompt, ...)
	// only supports windows output formats - no floating point
{
	va_list pData;
	va_start(pData, nIDPrompt);

	HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC);
	ASSERT( hWndCtrl != NULL );
	CTreeOptionsCtrl* pCtrlTreeOptions = (CTreeOptionsCtrl*) CWnd::FromHandlePermanent(hWndCtrl);
	ASSERT(pCtrlTreeOptions);
	ASSERT(pCtrlTreeOptions->IsKindOf(RUNTIME_CLASS(CTreeOptionsCtrl)));

	if (pDX->m_bSaveAndValidate)
	{
		void* pResult;

		pResult = va_arg( pData, void* );
		// the following works for %d, %u, %ld, %lu
		//::GetWindowText(hWndCtrl, szT, _countof(szT));
		CString sText(pCtrlTreeOptions->GetEditText(hItem));
		if (_stscanf(sText, lpszFormat, pResult) != 1)
		{
			AfxMessageBox(nIDPrompt);
			pDX->Fail();        // throws exception
		}
	}
void EditTextFloatFormat(CDataExchange* pDX, int nIDC, HTREEITEM hItem, void* pData, double value, int nSizeGcvt)
{
	ASSERT(pData != NULL);

	pDX->PrepareEditCtrl(nIDC);
	HWND hWndCtrl;
	pDX->m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl);
	CTreeOptionsCtrl* pCtrlTreeOptions = (CTreeOptionsCtrl*) CWnd::FromHandlePermanent(hWndCtrl);
	ASSERT(pCtrlTreeOptions);
	ASSERT(pCtrlTreeOptions->IsKindOf(RUNTIME_CLASS(CTreeOptionsCtrl)));
	
	if (pDX->m_bSaveAndValidate)
	{
		//::GetWindowText(hWndCtrl, szBuffer, _countof(szBuffer));
		CString sText(pCtrlTreeOptions->GetEditText(hItem));
		double d;
		if (_stscanf(sText, _T("%lf"), &d) != 1)
		{
			AfxMessageBox(AFX_IDP_PARSE_REAL);
			pDX->Fail();            // throws exception
		}
		if (nSizeGcvt == FLT_DIG)
			*((float*)pData) = (float)d;
		else
			*((double*)pData) = d;
	}
	else
	{
		TCHAR szBuffer[400];
		_stprintf(szBuffer, _T("%.*g"), nSizeGcvt, value);
		//AfxSetWindowText(hWndCtrl, szBuffer);
		pCtrlTreeOptions->SetEditText(hItem, szBuffer);
	}
}
BOOL CRichDocument::LoadXMLStyles(CXMLElement* pParent)
{
	for ( POSITION pos = pParent->GetElementIterator() ; pos ; )
	{
		CXMLElement* pXML = pParent->GetNextElement( pos );
		if ( ! pXML->IsNamed( _T("style") ) ) continue;
		
		CString strName = pXML->GetAttributeValue( _T("name") );
		CharLower( strName.GetBuffer() );
		strName.ReleaseBuffer();
		
		CString strFontFace = theApp.m_sDefaultFont;
		int nFontSize = theApp.m_nDefaultFontSize + 1;
		int nFontWeight = FW_BOLD;
		
		if ( CXMLElement* pFont = pXML->GetElementByName( _T("font") ) )
		{
			strFontFace = pFont->GetAttributeValue( _T("face") );
			CString strTemp = pFont->GetAttributeValue( _T("size") );
			_stscanf( strTemp, _T("%i"), &nFontSize );
			strTemp = pFont->GetAttributeValue( _T("weight") );
			_stscanf( strTemp, _T("%i"), &nFontWeight );
		}
		
		CXMLElement* pColours = pXML->GetElementByName( _T("colours") );
		if ( pColours == NULL ) pColours = pXML;
		
		if ( strName == _T("default") || strName.IsEmpty() )
		{
			LoadXMLColour( pColours, _T("text"), &m_crText );
			LoadXMLColour( pColours, _T("link"), &m_crLink );
			LoadXMLColour( pColours, _T("hover"), &m_crHover );
			CreateFonts( strFontFace, nFontSize );
		}
		else if ( strName == _T("heading") )
		{
			LoadXMLColour( pColours, _T("text"), &m_crHeading );
			
			if ( m_fntHeading.m_hObject ) m_fntHeading.DeleteObject();
			m_fntHeading.CreateFont( -nFontSize, 0, 0, 0, nFontWeight, FALSE, FALSE, FALSE,
				DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
				DEFAULT_PITCH|FF_DONTCARE, strFontFace );
		}
	}
	
	return TRUE;
}
Example #8
0
void DayModelHandler::createEntry(ISAXAttributes *pattr)
{
    unsigned __int64 taskID = 0, start = 0, stop = 0, entryID = 0, mod = 0, created = 0;
	int len = 0;
	StringBuffer sbOwner(256);

	TCHAR *pAttrStr = getAttributeString(pattr, _T("taskid"), &len);
    taskID = ModelUtils::fromHexString(pAttrStr, len);

	pAttrStr = getAttributeString(pattr, _T("entryid"), &len);
    entryID = ModelUtils::fromHexString(pAttrStr, len);
    
	pAttrStr = getAttributeString(pattr, _T("start"), &len);
	start = ModelUtils::fromHexString(pAttrStr, len);
    
	pAttrStr = getAttributeString(pattr,_T("stop"), &len);
	stop = ModelUtils::fromHexString(pAttrStr, len);

	pAttrStr = getAttributeString(pattr, _T("owner"), &len);
	if(pAttrStr && len > 0)
	{
		sbOwner.append(pAttrStr, len);
		m_pDataManager->GetUserManagerInstance()->GetUser(sbOwner);
	}

	pAttrStr = getAttributeString(pattr, _T("created"), &len);
	if(pAttrStr && len > 0)created = ModelUtils::fromHexString(pAttrStr, len);

	pAttrStr = getAttributeString(pattr, _T("modified"), &len);
	if(pAttrStr && len > 0)mod = ModelUtils::fromHexString(pAttrStr, len);

    m_pEntry = m_pDataManager->createTimeEntry(entryID, taskID, start, stop, sbOwner, created, mod);
    int percent = -1;
	pAttrStr = getAttributeString(pattr, _T("percent"), &len);
	if(pAttrStr)
	{
		_stscanf(pAttrStr, _T("%d"), &percent);
		m_pEntry->setPercentComplete(percent);
	}

	pAttrStr = getAttributeString(pattr, _T("type"), &len);
	if(pAttrStr)
	{
		_stscanf(pAttrStr, _T("%d"), &percent);
		m_pEntry->SetEntryType(static_cast<TimeEntry::EntryType>(percent));
	}
}
Example #9
0
int _tmain(int argc, TCHAR **argv) {
  try {
    bool   highPriority = false;
    bool   specialTest  = false;
#ifdef _DEBUG
    int    threadCount  = getDebuggerPresent() ? 1 : 0;
#else
    int    threadCount  = 0;
#endif _DEBUG
    TCHAR *cp;
    for(argv++; *argv && *(cp = *argv) == '-'; argv++) {
      for(cp++; *cp; cp++) {
        switch(*cp) {
        case 'p': highPriority = true;
                  continue;
        case 's': specialTest  = true;
                  continue;
        case 't': if((_stscanf(cp+1, _T("%lu"), &threadCount) != 1) || (threadCount == 0)) {
                    usage();
                  }
                  break;
        default : usage();
        }
        break;
      }
    }

    if(highPriority) {
      BigRealResourcePool::setPriority(THREAD_PRIORITY_ABOVE_NORMAL);
      BigRealResourcePool::setPriorityBoost(true);

      if(!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL)) {
        throwLastErrorOnSysCallException(_T("SetThreadPriority"));
      }
      if(!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS)) {
        throwLastErrorOnSysCallException(_T("SetPriorityClass"));
      }
      if(!SetThreadPriorityBoost(GetCurrentThread(), TRUE)) {
        throwLastErrorOnSysCallException(_T("SetThreadPriorityBoost"));
      }
    }
    if(BigReal::hasPow2CacheFile()) {
      BigReal::loadPow2Cache();
    }
    if(specialTest) {
      SpecialTestClass stc;
      stc.runTest();
    } else {
      testBigReal(threadCount);
    }
    if(BigReal::pow2CacheChanged()) {
      BigReal::savePow2Cache();
    }
  } catch(Exception e) {
    tcout << _T("\nException:") << e.what() << _T("\n");
    return -1;
  }
  return 0;
}
Example #10
0
CRect CIni::GetRect(LPCTSTR strEntry, CRect rectDefault, LPCTSTR strSection)
{
	CRect rectReturn=rectDefault;

	CString strDefault;
	//old version :strDefault.Format("(%d,%d,%d,%d)",rectDefault.top,rectDefault.left,rectDefault.bottom,rectDefault.right);
	strDefault.Format(_T("%d,%d,%d,%d"),rectDefault.left,rectDefault.top,rectDefault.right,rectDefault.bottom);

	CString strRect = GetString(strEntry,strDefault);

	//new Version found
	if( 4==_stscanf(strRect,_T("%d,%d,%d,%d"),&rectDefault.left,&rectDefault.top,&rectDefault.right,&rectDefault.bottom))
		return rectReturn;
	//old Version found
	_stscanf(strRect,_T("(%d,%d,%d,%d)"), &rectReturn.top,&rectReturn.left,&rectReturn.bottom,&rectReturn.right);
	return rectReturn;
}
Example #11
0
DWORD CGProfile::GetPackedGPS() const
{
	if ( const CXMLElement* pLocation = m_pXML->GetElementByName( L"location" ) )
	{
		if ( const CXMLElement* pCoordinates = pLocation->GetElementByName( L"coordinates" ) )
		{
			float nLatitude = 0, nLongitude = 0;
			if ( _stscanf( pCoordinates->GetAttributeValue( L"latitude" ),  L"%f", &nLatitude ) == 1 &&
				 _stscanf( pCoordinates->GetAttributeValue( L"longitude" ), L"%f", &nLongitude ) == 1 )
			{
				return ( (DWORD)WORDLIM( ( nLatitude  + 90.0f )  * 65535.0f / 180.0f ) << 16 ) +
						 (DWORD)WORDLIM( ( nLongitude + 180.0f ) * 65535.0f / 360.0f );
			}
		}
	}
	return 0;
}
Example #12
0
unsigned __int64 Tokenizer::getUint64(bool hex) {
  String s = next();
  unsigned __int64 result;
  if(_stscanf(s.cstr(), hex ? _T("%I64x") : _T("%I64u"), &result) != 1) {
    throwException(_T("%s:Expected unsigned __int64:<%s>"), __TFUNCTION__, s.cstr());
  }
  return result;
}
Example #13
0
UINT Tokenizer::getUint(bool hex) {
  String s = next();
  UINT result;
  if(_stscanf(s.cstr(), hex ? _T("%x") : _T("%lu"), &result) != 1) {
    throwException(_T("%s:Expected unsigned int:<%s>"), __TFUNCTION__, s.cstr());
  }
  return result;
}
Example #14
0
double Tokenizer::getDouble() {
  String s = next();
  double result;
  if(_stscanf(s.cstr(), _T("%le"), &result) != 1) {
    throwException(_T("%s:Expected double:<%s>"), __TFUNCTION__, s.cstr());
  }
  return result;
}
Example #15
0
bool bgParserASE::ReadScene()
{
	bool hr = true;

	IF_FALSE_RETURN(FindWord(_T("*SCENE_FIRSTFRAME")));
	_stscanf(m_szLine, _T("%s %d"), m_szWord, &m_pModel->m_Scene.iFirstFrame);
	IF_FALSE_RETURN(FindWord(_T("*SCENE_LASTFRAME")));
	_stscanf(m_szLine, _T("%s %d"), m_szWord, &m_pModel->m_Scene.iLastFrame);
	IF_FALSE_RETURN(FindWord(_T("*SCENE_FRAMESPEED")));
	_stscanf(m_szLine, _T("%s %d"), m_szWord, &m_pModel->m_Scene.iFrameSpeed);
	IF_FALSE_RETURN(FindWord(_T("*SCENE_TICKSPERFRAME")));
	_stscanf(m_szLine, _T("%s %d"), m_szWord, &m_pModel->m_Scene.iTicksPerFrame);

	IF_FALSE_RETURN(FindWord(_T("}"))); // SCENE 탈출

	return hr;
}
Example #16
0
float GetDlgItemFloat(HWND hWnd, WORD ID)
{
	TCHAR buf[256];
	float val = 0;
	GetDlgItemText(hWnd, ID, buf, ARRAYSIZE(buf) - 1);
	_stscanf(buf, TEXT("%f"), &val);
	return val;
}
Example #17
0
void CConvertChapDlg::OnUpdateOK(CCmdUI* pCmdUI)
{
	CString str;
	GetDlgItem(IDC_EDIT1)->GetWindowText(str);
	int i;
	pCmdUI->Enable(3 == _stscanf(str, _T("%d:%d:%d"), &i, &i, &i)
		&& GetDlgItem(IDC_EDIT2)->GetWindowTextLength() > 0);
}
Example #18
0
long FlarmId::GetId() 
{ 
  unsigned int res;

  _stscanf(id, TEXT("%6x"), &res);

  return res;
};
Example #19
0
void CDebugger::AssembleJAL()
{
	Framework::Win32::CInputBox InputTarget(_T("Assemble JAL"), _T("Enter jump target:"), _T("00000000"));
	Framework::Win32::CInputBox InputAssemble(_T("Assemble JAL"), _T("Enter address to assemble JAL to:"), _T("00000000"));

	const TCHAR* sTarget = InputTarget.GetValue(m_hWnd);
	if(sTarget == NULL) return;

	const TCHAR* sAssemble = InputAssemble.GetValue(m_hWnd);
	if(sAssemble == NULL) return;

	uint32 nValueTarget = 0, nValueAssemble = 0;
	_stscanf(sTarget, _T("%x"), &nValueTarget);
	_stscanf(sAssemble, _T("%x"), &nValueAssemble);

	*(uint32*)&m_virtualMachine.m_ee->m_ram[nValueAssemble] = 0x0C000000 | (nValueTarget / 4);
}
Example #20
0
void GBDisassemble::OnGo()
{
  CString buffer;

  m_address.GetWindowText(buffer);
  _stscanf(buffer, _T("%hx"), &address);
  refresh();
}
Example #21
0
BOOL CSkin::LoadCommandImages(CXMLElement* pBase, const CString& strPath)
{
	for ( POSITION pos = pBase->GetElementIterator() ; pos ; )
	{
		CXMLElement* pXML = pBase->GetNextElement( pos );
		
		if ( pXML->IsNamed( _T("icon") ) )
		{
			UINT nID = LookupCommandID( pXML );
			if ( nID == 0 ) continue;
			
			CString strFile = strPath;
			strFile += pXML->GetAttributeValue( _T("res") );
			strFile += pXML->GetAttributeValue( _T("path") );
			
			int nPos = strFile.Find( '$' );
			HICON hIcon = NULL;
			
			if ( nPos < 0 )
			{
				if ( ExtractIconEx( strFile, 0, NULL, &hIcon, 1 ) != NULL && hIcon != NULL )
				{
					CoolInterface.AddIcon( nID, hIcon );
				}
			}
			else
			{
				HINSTANCE hInstance = NULL;
				UINT nIconID = 0;
				
				if ( _stscanf( strFile.Left( nPos ), _T("%lu"), &hInstance ) != 1 ) return TRUE;
				if ( _stscanf( strFile.Mid( nPos + 1 ), _T("%lu"), &nIconID ) != 1 ) return TRUE;
				
				hIcon = (HICON)LoadImage( hInstance, MAKEINTRESOURCE(nIconID), IMAGE_ICON, 16, 16, 0 );
				if ( hIcon != NULL ) CoolInterface.AddIcon( nID, hIcon );
			}
		}
		else if ( pXML->IsNamed( _T("bitmap") ) )
		{
			if ( ! LoadCommandBitmap( pXML, strPath ) ) return FALSE;
		}
	}
	
	return TRUE;
}
Example #22
0
BOOL CSecureRule::FromGnucleusString(CString& str)
{
	int x[4] = {};

	int nPos = str.Find( L':' );
	if ( nPos < 1 ) return FALSE;

	CString strAddress = str.Left( nPos );
	str = str.Mid( nPos + 1 );

	if ( _stscanf( strAddress, L"%i.%i.%i.%i", &x[0], &x[1], &x[2], &x[3] ) != 4 )
		return FALSE;

	m_nIP[0] = (BYTE)x[0]; m_nIP[1] = (BYTE)x[1];
	m_nIP[2] = (BYTE)x[2]; m_nIP[3] = (BYTE)x[3];

	nPos = strAddress.Find( L'-' );

	if ( nPos >= 0 )
	{
		strAddress = strAddress.Mid( nPos + 1 );

		if ( _stscanf( strAddress, L"%i.%i.%i.%i", &x[0], &x[1], &x[2], &x[3] ) != 4 )
			return FALSE;

		for ( int nByte = 0; nByte < 4; nByte++ )
		{
			BYTE nTop = (BYTE)x[ nByte ], nBase = (BYTE)x[ nByte ];

			for ( BYTE nValue = m_nIP[ nByte ]; nValue < nTop; nValue++ )
			{
				m_nMask[ nByte ] &= ~( nValue ^ nBase );
			}
		}
	}

	m_nType		= srAddress;
	m_nAction	= srDeny;
	m_nExpire	= srIndefinite;
	m_sComment	= str.SpanExcluding( L":" );

	MaskFix();

	return TRUE;
}
Example #23
0
static BOOL ProcessCommandLine()
{
	if( __argc == 1 )
		return FALSE;

	DWORD dwPid = 0;
	HANDLE hEvent = NULL;

	if( (__argc != 3) || (_stscanf( __targv[1], _T("-p:%d"), &dwPid ) != 1)
		|| (_stscanf( __targv[2], _T("-e:%d"), &hEvent ) != 1) )
	{
		MessageBoxV( NULL, IDS_CMDLINE_ERROR, MB_OK | MB_ICONHAND );
		return TRUE;
	}

	DumpAeDebug( dwPid, hEvent );
	return TRUE;
}
Example #24
0
bool CGridDlg::getUintEmptyZero(int id, UINT &value) {
  const String str = getWindowText(this, id).trim();
  if(str.length() == 0) {
    value = 0;
    return true;
  } else {
    return _stscanf(str.cstr(), _T("%u"), &value) == 1;
  }
}
void CDownloadWithSources::Serialize(CArchive& ar, int nVersion)	// DOWNLOAD_SER_VERSION
{
	CDownloadBase::Serialize( ar, nVersion );

	CQuickLock pLock( Transfers.m_pSection );

	if ( ar.IsStoring() )
	{
		DWORD_PTR nSources = GetCount();
		if ( nSources > Settings.Downloads.SourcesWanted )
			nSources = Settings.Downloads.SourcesWanted;
		ar.WriteCount( nSources );

		for ( POSITION posSource = GetIterator() ; posSource && nSources ; nSources-- )
		{
			CDownloadSource* pSource = GetNext( posSource );

			pSource->Serialize( ar, nVersion );
		}

		ar.WriteCount( m_pXML != NULL ? 1 : 0 );
		if ( m_pXML ) m_pXML->Serialize( ar );
	}
	else // Loading
	{
		for ( DWORD_PTR nSources = ar.ReadCount() ; nSources ; nSources-- )
		{
			// Create new source
			//CDownloadSource* pSource = new CDownloadSource( (CDownload*)this );
			CAutoPtr< CDownloadSource > pSource( new CDownloadSource( static_cast< CDownload* >( this ) ) );
			if ( ! pSource )
				AfxThrowMemoryException();

			// Load details from disk
			pSource->Serialize( ar, nVersion );

			// Extract ed2k client ID from url (m_pAddress) because it wasn't saved
			if ( ! pSource->m_nPort && _tcsnicmp( pSource->m_sURL, _T("ed2kftp://"), 10 ) == 0 )
			{
				CString strURL = pSource->m_sURL.Mid(10);
				if ( ! strURL.IsEmpty() )
					_stscanf( strURL, _T("%lu"), &pSource->m_pAddress.S_un.S_addr );
			}

			InternalAdd( pSource.Detach() );
		}

		if ( ar.ReadCount() )
		{
			m_pXML = new CXMLElement();
			if ( ! m_pXML )
				AfxThrowMemoryException();

			m_pXML->Serialize( ar );
		}
	}
}
Example #26
0
 void SPropertyItemColor::SetString( const SStringT & strValue )
 {
     int r,g,b,a;
     if(_stscanf(strValue,m_strFormat,&r,&g,&b,&a)==4)
     {
         m_crValue = RGBA(r,g,b,a);
         OnValueChanged();
     }
 }
void CDownloadWithSources::Serialize(CArchive& ar, int nVersion)
{
	CDownloadBase::Serialize( ar, nVersion );
	
	if ( ar.IsStoring() )
	{
		ar.WriteCount( GetSourceCount() );
		
		for ( CDownloadSource* pSource = GetFirstSource() ; pSource ; pSource = pSource->m_pNext )
		{
			pSource->Serialize( ar, nVersion );
		}
		
		ar.WriteCount( m_pXML != NULL ? 1 : 0 );
		if ( m_pXML ) m_pXML->Serialize( ar );
	}
	else
	{
		for ( int nSources = ar.ReadCount() ; nSources ; nSources-- )
		{
			// Create new source
			CDownloadSource* pSource = new CDownloadSource( (CDownload*)this );
			
			// Add to the list
			m_nSourceCount ++;
			pSource->m_pPrev = m_pSourceLast;
			pSource->m_pNext = NULL;
			
			if ( m_pSourceLast != NULL )
			{
				m_pSourceLast->m_pNext = pSource;
				m_pSourceLast = pSource;
			}
			else
			{
				m_pSourceFirst = m_pSourceLast = pSource;
			}

			// Load details from disk
			pSource->Serialize( ar, nVersion );

			// Extract ed2k client ID from url (m_pAddress) because it wasn't saved
			if ( ( !pSource->m_nPort ) && ( _tcsnicmp( pSource->m_sURL, _T("ed2kftp://"), 10 ) == 0 )  )
			{
				CString strURL = pSource->m_sURL.Mid(10);
				if ( strURL.GetLength())
					_stscanf( strURL, _T("%lu"), &pSource->m_pAddress.S_un.S_addr );
			}
		}
		
		if ( ar.ReadCount() )
		{
			m_pXML = new CXMLElement();
			m_pXML->Serialize( ar );
		}
	}
}
Example #28
0
/**
 * @brief Copy the bytes.
 * @param [in] hDlg Handle to the dialog.
 * @return TRUE if bytes were copied, FALSE otherwise.
 */
BOOL CopyDlg::Apply(HWindow* pDlg)
{
	const int bufSize = 64;
	TCHAR buf[bufSize + 1] = {0};
	int iOffset;
	int iNumberOfBytes;
	if (pDlg->GetDlgItemText(IDC_COPY_STARTOFFSET, buf, bufSize) &&
		!offset_parse(buf, iOffset))
	{
		MessageBox(pDlg, GetLangString(IDS_OFFSET_START_ERROR), MB_ICONERROR);
		return FALSE;
	}
	if (pDlg->IsDlgButtonChecked(IDC_COPY_OFFSET))
	{
		if (pDlg->GetDlgItemText(IDC_COPY_OFFSETEDIT, buf, bufSize) &&
			!offset_parse(buf, iNumberOfBytes))
		{
			MessageBox(pDlg, GetLangString(IDS_OFFSET_END_ERROR), MB_ICONERROR);
			return FALSE;
		}
		iNumberOfBytes = iNumberOfBytes - iOffset + 1;
	}
	else
	{// Get number of bytes.
		if (pDlg->GetDlgItemText(IDC_COPY_BYTECOUNT, buf, bufSize) &&
			_stscanf(buf, _T("%d"), &iNumberOfBytes) == 0)
		{
			MessageBox(pDlg, GetLangString(IDS_BYTES_NOT_KNOWN), MB_ICONERROR);
			return FALSE;
		}
	}
	// Can requested number be cut?
	// DataArray.GetLength ()-iCutOffset = number of bytes from current pos. to end.
	if (m_dataArray.GetLength() - iOffset < iNumberOfBytes)
	{
		MessageBox(pDlg, GetLangString(IDS_COPY_TOO_MANY), MB_ICONERROR);
		return FALSE;
	}
	// Transfer to clipboard.
	int destlen = Text2BinTranslator::iBytes2BytecodeDestLen(&m_dataArray[iOffset], iNumberOfBytes);
	HGLOBAL hGlobal = GlobalAlloc(GHND, destlen);
	if (hGlobal == 0)
	{
		// Not enough memory for clipboard.
		MessageBox(pDlg, GetLangString(IDS_COPY_NO_MEM), MB_ICONERROR);
		return FALSE;
	}
	WaitCursor wc;
	char* pd = (char *)GlobalLock(hGlobal);
	Text2BinTranslator::iTranslateBytesToBC(pd, &m_dataArray[iOffset], iNumberOfBytes);
	GlobalUnlock(hGlobal);
	pwnd->OpenClipboard();
	EmptyClipboard();
	SetClipboardData(CF_TEXT, hGlobal);
	CloseClipboard();
	return TRUE;
}
Example #29
0
xpr_bool_t StringToLogFont(const xpr_tchar_t *aFontText, LOGFONT &aLogFont)
{
    if (XPR_IS_NULL(aFontText))
        return XPR_FALSE;

    xpr_tchar_t sFontText[0xff] = {0};
    _tcscpy(sFontText, aFontText);

    memset(&aLogFont, 0, sizeof(LOGFONT));

    xpr_sint_t i;
    xpr_tchar_t *sSplit = sFontText;
    xpr_tchar_t *sSplit2;
    for (i = 0; i <= 5; ++i)
    {
        if (*sSplit == XPR_STRING_LITERAL('\0'))
            break;

        sSplit2 = _tcschr(sSplit, XPR_STRING_LITERAL(','));
        if (XPR_IS_NOT_NULL(sSplit2))
            *sSplit2 = XPR_STRING_LITERAL('\0');

        switch (i)
        {
        case 0: _tcscpy(aLogFont.lfFaceName, sSplit);                               break;
        case 1: _stscanf(sSplit, XPR_STRING_LITERAL("%d"), &aLogFont.lfHeight);     break;
        case 2: _stscanf(sSplit, XPR_STRING_LITERAL("%d"), &aLogFont.lfWeight);     break;
        case 3: _stscanf(sSplit, XPR_STRING_LITERAL("%d"), &aLogFont.lfItalic);     break;
        case 4: _stscanf(sSplit, XPR_STRING_LITERAL("%d"), &aLogFont.lfStrikeOut);  break;
        case 5: _stscanf(sSplit, XPR_STRING_LITERAL("%d"), &aLogFont.lfUnderline);  break;
        }

        sSplit += _tcslen(sSplit) + 1;
    }

    CClientDC sClientDC(CWnd::GetDesktopWindow());
    aLogFont.lfCharSet = DEFAULT_CHARSET;
    aLogFont.lfHeight  = -MulDiv(aLogFont.lfHeight, sClientDC.GetDeviceCaps(LOGPIXELSY), 72);
    if (aLogFont.lfWeight    == 1) aLogFont.lfWeight    = FW_BOLD;
    if (aLogFont.lfStrikeOut != 0) aLogFont.lfStrikeOut = XPR_TRUE;
    if (aLogFont.lfUnderline != 0) aLogFont.lfUnderline = XPR_TRUE;

    return XPR_TRUE;
}
Example #30
0
BOOL CWizardProfilePage::OnSetActive()
{
	SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );

	m_sNick = MyProfile.GetNick();

	if ( m_sNick.IsEmpty() )
	{
		TCHAR pBuffer[64];
		DWORD nSize = 64;
		if ( GetUserNameW( pBuffer, &nSize ) ) m_sNick = pBuffer;
	}

	if ( CXMLElement* pVitals = MyProfile.GetXML( _T("vitals") ) )
	{
		CString strGender	= pVitals->GetAttributeValue( _T("gender") );
		CString strAge		= pVitals->GetAttributeValue( _T("age") );

		if ( strGender.CompareNoCase( _T("male") ) == 0 )
		{
			m_nGender = 1;
		}
		else if ( strGender.CompareNoCase( _T("female") ) == 0 )
		{
			m_nGender = 2;
		}

		int nAge = 0;
		_stscanf( strAge, _T("%i"), &nAge );

		for ( int nAgeItem = 0 ; nAgeItem < m_wndAge.GetCount() ; nAgeItem ++ )
		{
			if ( m_wndAge.GetItemData( nAgeItem ) == DWORD( nAge ) )
			{
				m_nAge = nAgeItem;
				break;
			}
		}
	}

	if ( CXMLElement* pLocation = MyProfile.GetXML( _T("location") ) )
	{
		if ( CXMLElement* pPolitical = pLocation->GetElementByName( _T("political") ) )
		{
			m_sLocCountry	= pPolitical->GetAttributeValue( _T("country") );
			m_sLocCity		= pPolitical->GetAttributeValue( _T("city") ) + _T(", ")
							+ pPolitical->GetAttributeValue( _T("state") );
		}
	}

	UpdateData( FALSE );

	OnSelChangeCountry();

	return CWizardPage::OnSetActive();
}