void COXNetBrowseTree::Cleanup()
// --- In  :
// --- Out : 
// --- Returns :
// --- Effect : Clean up the internal structures
{
	// Clean up the association map between tree item handles and net resource infos
	POSITION pos;
	HTREEITEM hTreeItem;
	NETRESOURCE* pNetResource;
	pos = m_resourceMap.GetStartPosition();
	while (pos != NULL)
	{
		m_resourceMap.GetNextAssoc(pos, hTreeItem, pNetResource);
		// ... First delete the strings
		ASSERT(pNetResource->lpLocalName == NULL || AfxIsValidString(pNetResource->lpLocalName));
		ASSERT(pNetResource->lpRemoteName == NULL || AfxIsValidString(pNetResource->lpRemoteName));
		ASSERT(pNetResource->lpComment == NULL || AfxIsValidString(pNetResource->lpComment));
		ASSERT(pNetResource->lpProvider == NULL || AfxIsValidString(pNetResource->lpProvider));
		delete[] pNetResource->lpLocalName;
		delete[] pNetResource->lpRemoteName;
		delete[] pNetResource->lpComment;
		delete[] pNetResource->lpProvider;
		ASSERT(AfxIsValidAddress(pNetResource, sizeof(NETRESOURCE)));
		delete pNetResource;
	}
	m_resourceMap.RemoveAll();
}
Esempio n. 2
0
BOOL CTrayIcon::ShowBalloon(LPCTSTR szText, LPCTSTR szTitle, DWORD dwIcon, UINT uTimeout)
{
    // Verify input parameters.
	if (uTimeout <= 0)
		return FALSE;

    // The balloon tooltip text can be up to 255 chars long.
    ASSERT(AfxIsValidString(szText));
    ASSERT(lstrlen(szText) < 256);

    // The balloon title text can be up to 63 chars long.
    if (szTitle)
    {
        ASSERT(AfxIsValidString( szTitle));
        ASSERT(lstrlen(szTitle) < 64);
    }

    // dwBalloonIcon must be valid.
    ASSERT(NIIF_NONE == dwIcon    || NIIF_INFO == dwIcon ||
           NIIF_WARNING == dwIcon || NIIF_ERROR == dwIcon);

    // The timeout must be between 10 and 30 seconds.
    uTimeout = min(max(uTimeout, 10), 30);

	NOTIFYICONDATA_TI nid;

	nid.cbSize = sizeof(nid);
	nid.hWnd = GetSafeHwnd();
	nid.uID = GetDlgCtrlID();
	nid.uFlags = NIF_INFO;

//fabio_2005
#if _MSC_VER >= 1300
    _tcsncpy_s(nid.szInfo, szText, 256);

    if (szTitle)
        _tcsncpy_s(nid.szInfoTitle, szTitle, 64);
#else
    _tcsncpy(nid.szInfo, szText, 256);

    if (szTitle)
        _tcsncpy(nid.szInfoTitle, szTitle, 64);
#endif

    else
        nid.szInfoTitle[0] = _T('\0');

    nid.dwInfoFlags = dwIcon;
    nid.uTimeout = uTimeout * 1000;   // convert time to ms

	// if the icon is not showing then show it temporarily
	if (!m_bVisible)
	{
		m_bTemporaryIcon = TRUE;
		ShowTrayIcon(TRUE);
	}

    return Shell_NotifyIcon(NIM_MODIFY, (PNOTIFYICONDATA)&nid);
}
Esempio n. 3
0
bool CXTPTrayIcon::ShowBalloonTip(LPCTSTR lpszInfo, LPCTSTR lpszInfoTitle/*= NULL*/, DWORD dwInfoFlags/*= NIIF_NONE*/, UINT uTimeout/*= 10*/)
{
	bool bResult = false;

	if (IsShellVersion5() && lpszInfo)
	{
		// The balloon tooltip text can be up to 255 chars long.
		ASSERT(AfxIsValidString(lpszInfo));
		ASSERT(lstrlen(lpszInfo) < 256);

		// The balloon title text can be up to 63 chars long.
		if (lpszInfoTitle)
		{
			ASSERT(AfxIsValidString(lpszInfoTitle));
			ASSERT(lstrlen(lpszInfoTitle) < 64);
		}

		// dwInfoFlags must be valid.
		ASSERT(NIIF_NONE == dwInfoFlags ||
				NIIF_INFO == dwInfoFlags ||
				NIIF_WARNING == dwInfoFlags ||
				NIIF_ERROR == dwInfoFlags);

		// The timeout must be between 10 and 30 seconds.
		ASSERT(uTimeout >= 10 && uTimeout <= 30);

		m_niData.uFlags |= NIF_INFO;

		STRNCPY_S(m_niData.szInfo, _countof(m_niData.szInfo), lpszInfo, 255);

		if (lpszInfoTitle)
		{
			STRNCPY_S(m_niData.szInfoTitle, _countof(m_niData.szInfoTitle), lpszInfoTitle, 63);
		}
		else
		{
			m_niData.szInfoTitle[0] = _T('\0');
		}

		m_niData.uTimeout = (uTimeout * 1000); // convert time to millisecs
		m_niData.dwInfoFlags = dwInfoFlags;

		if (ShellNotify(NIM_MODIFY))
		{
			bResult = true;
		}

		// Zero out the balloon text string so that later operations won't redisplay
		// the balloon.
		m_niData.szInfo[0] = _T('\0');
	}

	return bResult;
}
Esempio n. 4
0
void CTag::AssertValid() const
{
	CObject::AssertValid();

	ASSERT( m_uType != 0 );
	ASSERT( m_uName != 0 && m_pszName == NULL || m_uName == 0 && m_pszName != NULL );
	ASSERT( m_pszName == NULL || AfxIsValidString(m_pszName) );
	if (IsStr())
		ASSERT( m_pstrVal != NULL && AfxIsValidString(*m_pstrVal) );
	else if (IsHash())
		ASSERT( m_pData != NULL && AfxIsValidAddress(m_pData, 16) );
	else if (IsBlob())
		ASSERT( m_pData != NULL && AfxIsValidAddress(m_pData, m_nBlobSize) );
}
BOOL COXRegistryValFile::Open(HKEY hkey, LPCTSTR lpszKey, LPCTSTR lpszValue, LONG& error)
	{
	ASSERT(AfxIsValidString(lpszKey));
	ASSERT(AfxIsValidString(lpszValue));
	m_value = lpszValue;

	error = ::RegCreateKey(hkey, lpszKey, &m_key);
	if (ERROR_SUCCESS != error)
		return FALSE;
	DWORD dwType;
	DWORD dwSize;
	if (ERROR_SUCCESS == ::RegQueryValueEx(m_key, m_value, NULL, &dwType, NULL, &dwSize))
		{
		// the value already exists, check the type
		if (dwType != REG_BINARY)
			{
			error = 0;		// wrong type exists
			return FALSE;
			}

		// the value exists and has the right type
		BYTE * pData = NULL;
		try
			{
			pData = new BYTE[dwSize];
			}
		catch(...)
			{
			error = 0;		// memory low
			return FALSE;
			}

		error = ::RegQueryValueEx(m_key, m_value, NULL, &dwType, pData, &dwSize);
		if (ERROR_SUCCESS != error)
			{
			delete [] pData;
			return FALSE;
			}

		Write(pData, dwSize);
		SeekToBegin();

		delete [] pData;
		return TRUE;
		}

	error = 0;
	return TRUE;
	}
Esempio n. 6
0
/*========================================================================
	Name:		连接到数据源.
	-----------------------------------------------------
	Params:		[lpszConnect]: 连接字符串, 包含连接信息.
				[lOptions]:	可选. 决定该方法是以同步还是异步的方式连接数据
						源. 可以是如下某个常量:
		[常量]					[说明] 
		----------------------------------
		adConnectUnspecified	(默认)同步方式打开连接. 
		adAsyncConnect			异步方式打开连接. Ado用 ConnectComplete 事
						件来通知已经完成连接. 
==========================================================================*/
BOOL CAdoConnection::Open(LPCTSTR lpszConnect, long lOptions)
{
	ASSERT(m_pConnection != NULL);
	ASSERT(AfxIsValidString(lpszConnect));
	
	if (strcmp(lpszConnect, _T("")) != 0)
	{
		m_strConnect = lpszConnect;
	}

	if (m_strConnect.IsEmpty())
	{
		ASSERT(FALSE);
		return FALSE;
	}

	if (IsOpen()) Close();

	try
	{
		// 连接数据库 ---------------------------------------------
		return (m_pConnection->Open(_bstr_t(LPCTSTR(m_strConnect)), "", "", lOptions) == S_OK);
	}
	catch (_com_error e)
	{
		TRACE(_T("Warning: 连接数据库发生异常. 错误信息: %s; 文件: %s; 行: %d\n"), e.ErrorMessage(), __FILE__, __LINE__);
		TRACE(_T("%s\r\n"), GetLastErrorText());
		return FALSE;
	} 
	catch (...)
	{
		TRACE(_T("Warning: 连接数据库时发生未知错误:"));
	}
	return FALSE;
}
Esempio n. 7
0
BOOL CPtrListExt :: AddRecord (COleVariant varBookmark, const char *pAbfallArt, BOOL bFirst/* = TRUE*/)
{
	ASSERT (NULL != pAbfallArt && AfxIsValidString (pAbfallArt));
	ASSERT (*pAbfallArt);

	try
	{
		CString strArt (pAbfallArt);
		CRecordInfo *pInfo = new CRecordInfo (strArt, varBookmark);
		AddTail (pInfo);					

	//	ggf. als 1. Satz setzen
		if (bFirst)
			return SetFirstRecord (varBookmark);

		return TRUE;
	}
	catch (CDaoException *e)
	{
		:: DisplayDaoException (e);
		e -> Delete ();
	}
	catch (CException *e)
	{
		e -> ReportError ();
		e -> Delete ();
	}

	return FALSE;
}
Esempio n. 8
0
COleClientItem* COleLinkingDoc::OnFindEmbeddedItem(LPCTSTR lpszItemName)
{
	ASSERT_VALID(this);
	ASSERT(AfxIsValidString(lpszItemName));

	// default implementation walks list of client items looking for
	//  a case sensitive match

	POSITION pos = GetStartPosition();
	COleClientItem* pItem;
	while ((pItem = GetNextClientItem(pos)) != NULL)
	{
		// a client item is running if there is a match in name
		//  and the m_lpObject is also running.
		TCHAR szItemName[OLE_MAXITEMNAME];
		pItem->GetItemName(szItemName, _countof(szItemName));
		if (lstrcmp(szItemName, lpszItemName) == 0)
			return pItem;
	}

	TRACE(traceOle, 1, "Warning: default COleLinkingDoc::OnFindEmbeddedItem\n");
	TRACE(traceOle, 1, _T("\timplementation failed to find item '%s'.\n"), lpszItemName);

	return NULL;    // no matching item found
}
Esempio n. 9
0
BOOL COleLinkingDoc::RegisterIfServerAttached(LPCTSTR lpszPathName, BOOL bMessage)
{
	ASSERT_VALID(this);
	ASSERT(lpszPathName == NULL || AfxIsValidString(lpszPathName));

	CDocTemplate* pTemplate = GetDocTemplate();
	ASSERT_VALID(pTemplate);

	COleObjectFactory* pFactory =
		(COleObjectFactory*)pTemplate->m_pAttachedFactory;
	if (pFactory != NULL)
	{
		// always attach the document to the server at this time
		ASSERT_KINDOF(COleObjectFactory, pFactory);
		m_pFactory = pFactory;

		// register with OLE Server
		if (!Register(pFactory, lpszPathName))
		{
			if (bMessage)
			{
				// only report error when message box allowed
				ReportSaveLoadException(lpszPathName, NULL, FALSE,
					AFX_IDP_FAILED_TO_NOTIFY);
			}
			return FALSE;
		}
	}
	return TRUE;
}
Esempio n. 10
0
const CFileName& CFileName::Append(LPCTSTR lpsz)
{
  ASSERT(lpsz == NULL || AfxIsValidString(lpsz));
  CString::ConcatInPlace(SafeStrlen(lpsz), lpsz);
  return *this;
  
}
Esempio n. 11
0
BOOL CNamedPipeException::GetErrorMessage(LPTSTR pstrError, UINT nMaxError, PUINT pnHelpContext)
{
  //Validate our parameters
	ASSERT(pstrError != NULL && AfxIsValidString(pstrError, nMaxError));

	if (pnHelpContext != NULL)
		*pnHelpContext = 0;

  //What will be the return value from this function (assume the worst)
  BOOL bSuccess = FALSE;

	LPTSTR lpBuffer;
	DWORD dwReturn = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
			                           NULL,  m_dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),
			                           reinterpret_cast<LPTSTR>(&lpBuffer), 0, NULL);
	if (dwReturn == 0)
		*pstrError = _T('\0');
	else
	{
    bSuccess = TRUE;
    Checked::tcsncpy_s(pstrError, nMaxError, lpBuffer, _TRUNCATE);
		LocalFree(lpBuffer);
	}

	return bSuccess;
}
Esempio n. 12
0
BOOL CDialog::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
	ASSERT(HIWORD(lpszTemplateName) == 0 ||
		AfxIsValidString(lpszTemplateName));

	m_lpszTemplateName = lpszTemplateName;  // used for help
	if (HIWORD(m_lpszTemplateName) == 0 && m_nIDHelp == 0)
		m_nIDHelp = LOWORD((DWORD)m_lpszTemplateName);

#ifdef _DEBUG
	if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE))
	{
		ASSERT(FALSE);          // invalid dialog template name
		PostNcDestroy();        // cleanup if Create fails too soon
		return FALSE;
	}
#endif //_DEBUG

	HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
	HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
	HGLOBAL hTemplate = LoadResource(hInst, hResource);
	BOOL bResult = CreateIndirect(hTemplate, pParentWnd, hInst);
	FreeResource(hTemplate);

	return bResult;
}
Esempio n. 13
0
COleObjectFactory::COleObjectFactory(REFCLSID clsid,
	CRuntimeClass* pRuntimeClass, BOOL bMultiInstance, LPCTSTR lpszProgID)
{
	ASSERT(pRuntimeClass == NULL ||
		pRuntimeClass->IsDerivedFrom(RUNTIME_CLASS(CCmdTarget)));
	ASSERT(AfxIsValidAddress(&clsid, sizeof(CLSID), FALSE));
	ASSERT(lpszProgID == NULL || AfxIsValidString(lpszProgID));

	// initialize to unregistered state
	m_dwRegister = 0;   // not registered yet
	m_bRegistered = FALSE;
	m_clsid = clsid;
	m_pRuntimeClass = pRuntimeClass;
	m_bMultiInstance = bMultiInstance;
	m_lpszProgID = lpszProgID;
	m_bOAT = (BYTE) OAT_UNKNOWN;

	// licensing information
	m_bLicenseChecked = FALSE;
	m_bLicenseValid = FALSE;

	// add this factory to the list of factories
	m_pNextFactory = NULL;
	AFX_MODULE_STATE* pModuleState = _AFX_CMDTARGET_GETSTATE();
	AfxLockGlobals(CRIT_OBJECTFACTORYLIST);
	pModuleState->m_factoryList.AddHead(this);
	AfxUnlockGlobals(CRIT_OBJECTFACTORYLIST);

	ASSERT_VALID(this);
}
Esempio n. 14
0
BOOL CxString :: Teilen( CString& h, CString& r, const char* pat, BOOL trimmen )
{
	CxString	head = h;
	CxString	rest = r;
	BOOL		result = FALSE;

	ASSERT( AfxIsValidString( pat ));
	if ( *pat == '\0' )
	{
		head = *this;
		rest = "";

		if ( trimmen )
		{
			head.TrimAll();
			rest.TrimAll();
		}
		h = head;
		r = rest;
		return TRUE;
	}
	if ( *(pat + 1 ) == '\0' )
		return Teilen( h, r, *pat, trimmen );

	int			i = Find( pat );
	int			len = lstrlen( pat );

	if ( len >= GetLength())
		return FALSE;

	if ( i >= 0 )
	{	if ( i == 0 )	// pat steht am Anfang
		{
			head.Empty();
			rest = Mid( len );
		}
		else
		{
			head = Left( i );
			if (( i + len ) < GetLength())
				rest = Mid( i + len );
			else
				rest = "";
			result = TRUE;
	}	}
	else
	{	// pat nicht gefunden!
		head = *this;
		rest.Empty();
	}

	if ( trimmen )
	{	head.TrimAll();
		rest.TrimAll();
	}

	h = head;
	r = rest;
	return result;
}	// Teilen
Esempio n. 15
0
BOOL COleException::GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
		PUINT pnHelpContext)
{
	ASSERT(lpszError != NULL && AfxIsValidString(lpszError, nMaxError));

	if (pnHelpContext != NULL)
		*pnHelpContext = 0;

	LPTSTR lpBuffer;
	if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
				FORMAT_MESSAGE_FROM_SYSTEM,
				NULL, m_sc,
				MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),
				(LPTSTR) &lpBuffer, 0, NULL) == 0)
	{
		*lpszError = '\0';
		return FALSE;
	}
	else
	{
		lstrcpyn(lpszError, lpBuffer, nMaxError);
		LocalFree(lpBuffer);
		return TRUE;
	}
}
BOOL CFolderDialog::GetRootFolder(IN OUT LPTSTR pszPath)
{
	ASSERT_VALID(this);
	ASSERT(AfxIsValidString(pszPath, MAX_PATH));

	return ::SHGetPathFromIDList(m_bi.pidlRoot, pszPath);
}
Esempio n. 17
0
BOOL COleClientItem::ActivateAs(LPCTSTR lpszUserType,
                                REFCLSID clsidOld, REFCLSID clsidNew)
{
    ASSERT_VALID(this);
    ASSERT(lpszUserType == NULL || AfxIsValidString(lpszUserType));
    ASSERT(m_lpObject != NULL);

    // enable activate as
    m_scLast = _AfxOleDoTreatAsClass(lpszUserType, clsidOld, clsidNew);
    if (FAILED(m_scLast))
        return FALSE;

    // reload all items in this doucment
    COleDocument* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    POSITION pos = pDoc->GetStartPosition();
    COleClientItem* pItem;
    while ((pItem = pDoc->GetNextClientItem(pos)) != NULL)
    {
        // reload it, so activate as works as appropriate
        pItem->Reload();
    }

    ASSERT_VALID(this);
    return TRUE;
}
Esempio n. 18
0
LPSTREAM AFXAPI _AfxLoadStreamFromPropset(CPropertySection& psec, LPCTSTR pszPropName,
	DWORD& vtType)
{
	ASSERT(AfxIsValidString(pszPropName));

	vtType = VT_EMPTY;

	DWORD dwPropID;
	CProperty* pprop = NULL;
	LPSTREAM pstm = NULL;

	if (psec.GetID(pszPropName, &dwPropID) &&
		((pprop = psec.GetProperty(dwPropID)) != NULL))
	{
		vtType = pprop->GetType();

		if ((vtType == VT_BLOB) || (vtType == VT_BLOB_PROPSET))
		{
			pstm = _AfxCreateMemoryStream();

			if (pstm != NULL)
			{
				if (!_AfxInitStreamDataFromBlobProp(pstm, pprop))
				{
					pstm->Release();
					pstm = NULL;
				}
			}
		}
	}

	return pstm;
}
Esempio n. 19
0
UINT AFXAPI AfxGetFileTitle(LPCTSTR lpszPathName, LPTSTR lpszTitle, UINT nMax)
{
	ASSERT(lpszTitle == NULL ||
		AfxIsValidAddress(lpszTitle, _MAX_FNAME));
	ASSERT(AfxIsValidString(lpszPathName, FALSE));

#ifndef _MAC
	// use a temporary to avoid bugs in ::GetFileTitle when lpszTitle is NULL
	TCHAR szTemp[_MAX_PATH];
	LPTSTR lpszTemp = lpszTitle;
	if (lpszTemp == NULL)
	{
		lpszTemp = szTemp;
		nMax = _countof(szTemp);
	}
	if (AfxDllGetFileTitle(lpszPathName, lpszTemp, (WORD)nMax) != 0)
	{
		// when ::GetFileTitle fails, use cheap imitation
		return AfxGetFileName(lpszPathName, lpszTitle, nMax);
	}
	return lpszTitle == NULL ? lstrlen(lpszTemp)+1 : 0;
#else
	return AfxDllGetFileTitle(lpszPathName, lpszTitle, (WORD)nMax);
#endif
}
Esempio n. 20
0
// nPointSize is actually scaled 10x
BOOL CxEditView::CMyFont::CreatePointFont(int nPointSize, LPCTSTR lpszFaceName, CDC* pDC)
{
   ASSERT(AfxIsValidString(lpszFaceName));

   LOGFONT logFont;
   memset(&logFont, 0, sizeof(LOGFONT));
   logFont.lfCharSet = DEFAULT_CHARSET;
   logFont.lfHeight = nPointSize;
   lstrcpyn(logFont.lfFaceName, lpszFaceName, _countof(logFont.lfFaceName));

   HDC hDC;
   if (pDC != NULL)
   {
      ASSERT_VALID(pDC);
      ASSERT(pDC->m_hAttribDC != NULL);
      hDC = pDC->m_hAttribDC;
   }
   else
      hDC = ::GetDC(NULL);

   // convert nPointSize to logical units based on pDC
   POINT pt;
   pt.y = ::GetDeviceCaps(hDC, LOGPIXELSY) * logFont.lfHeight;
   pt.y /= 720;    // 72 points/inch, 10 decipoints/point
   ::DPtoLP(hDC, &pt, 1);
   POINT ptOrg = { 0, 0 };
   ::DPtoLP(hDC, &ptOrg, 1);
   logFont.lfHeight = -abs(pt.y - ptOrg.y);

   if (pDC == NULL)
      ::ReleaseDC(NULL, hDC);

   return CreateFontIndirect(&logFont);

}
Esempio n. 21
0
CFolderDialog::CFolderDialog( IN LPCTSTR pszTitle	 /*NULL*/,
							  IN LPCTSTR pszSelPath	 /*NULL*/,
							  IN CWnd*	 pWndParent	 /*NULL*/,
							  IN UINT	 uFlags		 /*BIF_RETURNONLYFSDIRS*/ )
			 : CCommonDialog( pWndParent )
			 , m_hWnd( NULL )
{	
	ASSERT( AfxIsValidString( pszSelPath, MAX_PATH ) );
	
	::ZeroMemory( &m_bi, sizeof( BROWSEINFO ) );
	::ZeroMemory( m_szFolPath, MAX_PATH );
	::ZeroMemory( m_szSelPath, MAX_PATH );
	
	if( pszSelPath != NULL )
		SetSelectedFolder( pszSelPath );
	
	// Fill data	
	m_bi.hwndOwner	= pWndParent->GetSafeHwnd();
	m_bi.pidlRoot	= NULL;	
	m_bi.lpszTitle	= pszTitle;
	m_bi.ulFlags	= uFlags;
	m_bi.lpfn		= (BFFCALLBACK)BrowseCallbackProc;
	m_bi.lParam		= (LPARAM)this;

	// The size of this buffer is assumed to be MAX_PATH bytes:
	
	m_bi.pszDisplayName = new TCHAR[ MAX_PATH ];
	ASSERT( m_bi.pszDisplayName != NULL );

	::ZeroMemory( m_bi.pszDisplayName, ( MAX_PATH * sizeof( TCHAR ) ) );
}
Esempio n. 22
0
/////////////////////////////////////////////////////////////////////////////
// 输出
/////////////////////////////////////////////////////////////////////////////
void COutputCtrl::vsWrite(LPCTSTR lpszFormat, va_list argList)
{
	ASSERT(AfxIsValidString(lpszFormat, FALSE));

	if(!::IsWindow(m_hWnd))
	{
		return;
	}

	va_list argListSave = argList;
	// make a guess at the maximum length of the resulting string
	int nMaxLen = 0;
	for (LPCTSTR lpsz = lpszFormat; *lpsz != '\0'; lpsz = _tcsinc(lpsz)) {

		// handle '%' character, but watch out for '%%'
		if (*lpsz != '%' || *(lpsz = _tcsinc(lpsz)) == '%') {

			nMaxLen += _tclen(lpsz);
			continue;
		}

		int nItemLen = 0;
		// handle '%' character with format
		int nWidth = 0;
		for (; *lpsz != '\0'; lpsz = _tcsinc(lpsz)) {

			// check for valid flags
			if (*lpsz == '#')
				nMaxLen += 2;   // for '0x'
			else if (*lpsz == '*')
				nWidth = va_arg(argList, int);
			else if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' ||
				*lpsz == ' ')
				;
			else // hit non-flag character
				break;
		}
		// get width and skip it
		if (nWidth == 0) {

			// width indicated by
			nWidth = _ttoi(lpsz);
			for (; *lpsz != '\0' && _istdigit(*lpsz); lpsz = _tcsinc(lpsz))
				;
		}
		ASSERT(nWidth >= 0);

		int nPrecision = 0;
		if (*lpsz == '.') {

			// skip past '.' separator (width.precision)
			lpsz = _tcsinc(lpsz);

			// get precision and skip it
			if (*lpsz == '*') {

				nPrecision = va_arg(argList, int);
				lpsz = _tcsinc(lpsz);
			}
Esempio n. 23
0
CString AFXAPI operator+(LPCTSTR lpsz, const CString& string)
{
	ASSERT(lpsz == NULL || AfxIsValidString(lpsz, FALSE));
	CString s;
	s.ConcatCopy(CString::SafeStrlen(lpsz), lpsz, string.GetData()->nDataLength,
		string.m_pchData);
	return s;
}
Esempio n. 24
0
CFileName AFXAPI operator+(LPCTSTR lpsz, const CFileName& string)
{
  ASSERT(lpsz == NULL || AfxIsValidString(lpsz));
  CFileName s;
  s.ConcatCopy(CFileName::SafeStrlen(lpsz), lpsz, string.GetData()->nDataLength,
    string.m_pchData);
  return s;
}
Esempio n. 25
0
CFieldContentsDlg::CFieldContentsDlg(CWnd* pParent, CDatabase *pDatabase,
	const char *pTable, const char *pField)
: CDialog(CFieldContentsDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFieldContentsDlg)
	m_strFieldName = _T("");
	m_strFieldType = _T("");
	//}}AFX_DATA_INIT
	m_pDatabase = NULL;
	m_uiResID = 0;

	ASSERT (NULL != pDatabase && pDatabase -> IsOpen ());
	m_pDatabase = pDatabase;
	ASSERT (NULL != pTable && AfxIsValidString (pTable));
	ASSERT (NULL != pField && AfxIsValidString (pField));
	m_strTable = pTable;
	m_strField = pField;
}
Esempio n. 26
0
void CDocTemplateEx::AddToRecentFileList(LPCTSTR lpszPathName)
{
	ASSERT_VALID(this);
	ASSERT(lpszPathName != NULL);
	ASSERT(AfxIsValidString(lpszPathName));

	if (m_pRecentFileList != NULL)
		m_pRecentFileList->Add(lpszPathName);
}
Esempio n. 27
0
CNewPropertyPage::CNewPropertyPage(LPCTSTR lpszTemplateName, UINT nIDCaption, 	UINT nIDHeaderTitle, UINT nIDHeaderSubTitle, DWORD dwSize)
{
  free(m_pPSP);
  m_pPSP=NULL;
  
  ASSERT(AfxIsValidString(lpszTemplateName));
  AllocPSP(dwSize);
  CommonConstruct(lpszTemplateName, nIDCaption, nIDHeaderTitle, nIDHeaderSubTitle);
}
Esempio n. 28
0
CStdioFile::CStdioFile(LPCTSTR lpszFileName, UINT nOpenFlags)
{
	ASSERT(lpszFileName != NULL);
	ASSERT(AfxIsValidString(lpszFileName));

	CFileException e;
	if (!Open(lpszFileName, nOpenFlags, &e))
		AfxThrowFileException(e.m_cause, e.m_lOsError, e.m_strFileName);
}
Esempio n. 29
0
void CFolderDialog::SetExpanded( IN LPCTSTR pszPath )
{
	USES_CONVERSION;

	ASSERT( m_hWnd != NULL );
	ASSERT( AfxIsValidString( pszPath, MAX_PATH ) );
	
	::SendMessage( m_hWnd, BFFM_SETEXPANDED, (WPARAM)TRUE, (LPARAM)T2CW( pszPath ) );
}
Esempio n. 30
0
MBASEAPI void MIRACLEEXPORT logDebugVA(LPCTSTR lpszFormat,...)
{
	CString msg;
	ASSERT(AfxIsValidString(lpszFormat));
	va_list argList;
	va_start(argList, lpszFormat);
	msg.FormatV(lpszFormat, argList);
	va_end(argList);
	_logDebug(msg);
}