本文整理匯總了C++中AfxIsValidString函數的典型用法代碼示例。如果您正苦於以下問題:C++ AfxIsValidString函數的具體用法?C++ AfxIsValidString怎麽用?C++ AfxIsValidString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AfxIsValidString函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: while
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();
}
示例2: ASSERT
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);
}
示例3: ASSERT
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;
}
示例4: ASSERT
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) );
}
示例5: ASSERT
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;
}
示例6: AddRecord
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;
}
示例7: ASSERT_VALID
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
}
示例8: ASSERT
const CFileName& CFileName::Append(LPCTSTR lpsz)
{
ASSERT(lpsz == NULL || AfxIsValidString(lpsz));
CString::ConcatInPlace(SafeStrlen(lpsz), lpsz);
return *this;
}
示例9: ASSERT
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;
}
示例10: ASSERT
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;
}
示例11: ASSERT
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);
}
示例12: Teilen
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
示例13: ASSERT
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;
}
}
示例14: ASSERT_VALID
BOOL CFolderDialog::GetRootFolder(IN OUT LPTSTR pszPath)
{
ASSERT_VALID(this);
ASSERT(AfxIsValidString(pszPath, MAX_PATH));
return ::SHGetPathFromIDList(m_bi.pidlRoot, pszPath);
}
示例15: ASSERT_VALID
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;
}