本文整理汇总了C++中GetHandleSize函数的典型用法代码示例。如果您正苦于以下问题:C++ GetHandleSize函数的具体用法?C++ GetHandleSize怎么用?C++ GetHandleSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetHandleSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: validhandle
boolean validhandle (Handle h) {
if (h == nil)
return (true);
#ifdef MACVERSION
if (GetHandleSize (h) < 0) /*negative length never valid*/
return (false);
return (MemError () == noErr);
#endif
#ifdef WIN95VERSION
if (GlobalSize (h) <= 0)
return (false);
return (true);
#endif
} /*validhandle*/
示例2: CheckStack
/*
** CheckStack checks the size of the search stack (array) to see if there's
** room to push another LevelRec. If not, CheckStack grows the stack by
** another kAdditionalLevelRecs elements.
*/
static OSErr CheckStack(unsigned short stackDepth,
LevelRecHandle searchStack,
Size *searchStackSize)
{
OSErr result;
if ( (*searchStackSize / sizeof(LevelRec)) == (stackDepth + 1) )
{
/* Time to grow stack */
SetHandleSize((Handle)searchStack, *searchStackSize + (kAdditionalLevelRecs * sizeof(LevelRec)));
result = MemError(); /* should be noErr */
*searchStackSize = GetHandleSize((Handle)searchStack);
}
else
{
result = noErr;
}
return ( result );
}
示例3: ParseMacrosFromHandle
// RAB BetterTelnet 2.0b5
// handle should be locked and detached
void ParseMacrosFromHandle(NewMacroInfo *macrost, Handle theHandle)
{
Ptr macroPtr;
long macroLength;
macroPtr = *theHandle;
macroLength = GetHandleSize(theHandle) - 2;
// format and sanity checks follow
if ((macroLength < 1) || (*macroPtr != '!') || (*(macroPtr + 1) != '\015')) {
DisposeHandle(theHandle);
setupNewMacros(macrost);
return;
} // bah
BlockMoveData(macroPtr + 2, macroPtr, macroLength); // get rid of !CR
HUnlock(theHandle);
SetHandleSize(theHandle, macroLength);
HLock(theHandle);
// now invoke the actual parser
parseNewMacros2(macrost, theHandle);
}
示例4: _GetResource
bool VMacResFile::GetResource( const VString& inType, sLONG inID, VBlob& outData) const
{
outData.Clear();
bool ok = false;
Handle data = NULL;
VError error = _GetResource( inType, inID, &data);
if (error == VE_OK)
{
::LoadResource(data);
OSErr macError = ::ResError();
if (testAssert(macError == noErr))
{
assert(*data != NULL);
::HLock(data);
ok = outData.PutData( *data, GetHandleSize( data)) == VE_OK;
::HUnlock(data);
data = NULL;
}
}
return ok;
}
示例5: setmessageverb
static pascal OSErr setmessageverb (const AppleEvent *event, AppleEvent *reply, long refcon) {
#pragma unused (refcon)
OSErr ec;
AEDesc result;
Str255 s;
Handle htext;
long lentext;
Boolean fl;
ec = AEGetParamDesc (event, keyDirectObject, typeChar, &result);
if (ec != noErr)
return (ec);
htext = result.dataHandle;
if (htext == nil)
return (noErr);
lentext = GetHandleSize (htext);
if (lentext > 255)
lentext = 255;
s [0] = (unsigned char) lentext;
BlockMove (*htext, &s [1], lentext);
AEDisposeDesc (&result);
setwindowmessage (s);
fl = true;
ec = AEPutParamPtr (reply, keyDirectObject, typeBoolean, (Ptr) &fl, sizeof (Boolean));
return (ec);
} /*setmessageverb*/
示例6: read_setting_filename
int read_setting_filename(void *handle, const char *key, Filename *result)
{
int fd;
AliasHandle h;
Boolean changed;
OSErr err;
Str255 pkey;
if (handle == NULL) goto out;
fd = *(int *)handle;
UseResFile(fd);
if (ResError() != noErr) goto out;
c2pstrcpy(pkey, key);
h = (AliasHandle)Get1NamedResource(rAliasType, pkey);
if (h == NULL) goto out;
if ((*h)->userType == 'pTTY' && (*h)->aliasSize == sizeof(**h))
memset(result, 0, sizeof(*result));
else {
err = ResolveAlias(NULL, h, &result->fss, &changed);
if (err != noErr && err != fnfErr) goto out;
if ((*h)->userType == 'pTTY') {
long dirid;
StrFileName fname;
/* Tail of record is pascal string contaning leafname */
if (FSpGetDirID(&result->fss, &dirid, FALSE) != noErr) goto out;
memcpy(fname, (char *)*h + (*h)->aliasSize,
GetHandleSize((Handle)h) - (*h)->aliasSize);
err = FSMakeFSSpec(result->fss.vRefNum, dirid, fname,
&result->fss);
if (err != noErr && err != fnfErr) goto out;
}
}
ReleaseResource((Handle)h);
if (ResError() != noErr) goto out;
return 1;
out:
return 0;
}
示例7: NewPoolListSlot
static PoolHandlePtr NewPoolListSlot()
{ // Find or make an empty slot in the list.
// WARNING: returns a pointer to data in an unlocked handle.
PoolHandlePtr p, q;
long count;
const int kInitialSlots = 4;
const int kIncreaseBySlots = 4;
// Initialize the pool list if necessary
if ( poolList == 0 ) {
poolList = (PoolListHandle)NewHandleClear(kInitialSlots*sizeof(Handle));
assert( poolList != 0 );
}
// Find an empty slot in the poolList (if there is one)
count = GetHandleSize( (Handle)poolList )/sizeof(PoolHandle);
p = *poolList;
q = p + count;
while (p<q) {
if ( *p == 0 )
return p;
p++;
}
// Couldn't find and empty slot. Make some.
SetHandleSize( (Handle)poolList, sizeof(PoolHandle) * ( count + kIncreaseBySlots) );
assert( MemError() == noErr );
// Note: poolList might have moved, so we *must* rebuild p and q.
p = *poolList + count;
q = p + kIncreaseBySlots;
while ( p<q ) {
*(p++) = 0;
}
return *poolList + count;
}
示例8: defined
ODSize
RealShape::Purge( ODSize )
{
if( fQDRegion ) {
#if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
ODSize size = 0;
fQDRegion.DisposeRgn();
#else
ODSize size = GetHandleSize( (Handle)fQDRegion );
DisposeRgn( fQDRegion );
#endif // IBM Platforms
fQDRegion = kODNULL;
return size;
} else
return 0;
}
示例9: parseNewMacros2
void parseNewMacros2(NewMacroInfo *macrost, Handle macroHandle)
{
Ptr macroPtr, pos;
long macroLength, len;
short i, flag;
macroLength = GetHandleSize(macroHandle);
macroPtr = *macroHandle;
len = macroLength;
pos = macroPtr;
i = 1; // first index is obviously always zero, so we use it as length (see below)
flag = 0;
while (len) {
if (*pos == 13) *pos = 0; // for strlen
pos++;
len--;
}
len = macroLength;
pos = macroPtr;
while ((i < NUM_MACROS) && (len > 1)) { // if len = 1, this is the last char;
// then the index points out of the handle!
if (*pos == 0) {
macrost->index[i] = (pos - macroPtr + 1);
i++;
}
pos++;
len--;
}
macrost->handle = macroHandle;
macrost->index[0] = macroLength; // first index is length of whole shebang
HUnlock(macroHandle);
fixMacros(macrost); // make sure there's an entry for each macro
}
示例10: SpriteUtils_AddPICTImageToKeyFrameSample
OSErr SpriteUtils_AddPICTImageToKeyFrameSample (QTAtomContainer theKeySample, short thePictID, RGBColor *theKeyColor, QTAtomID theID, FixedPoint *theRegistrationPoint, StringPtr theImageName)
{
PicHandle myPicture = NULL;
Handle myCompressedPicture = NULL;
ImageDescriptionHandle myImageDesc = NULL;
OSErr myErr = noErr;
// get picture from resource
myPicture = (PicHandle)GetPicture(thePictID);
if (myPicture == NULL)
myErr = resNotFound;
if (myErr != noErr)
goto bail;
DetachResource((Handle)myPicture);
// convert it to image data compressed by the animation compressor
myErr = ICUtils_RecompressPictureWithTransparency(myPicture, theKeyColor, NULL, &myImageDesc, &myCompressedPicture);
if (myErr != noErr)
goto bail;
// add it to the key sample
HLock(myCompressedPicture);
myErr = SpriteUtils_AddCompressedImageToKeyFrameSample(theKeySample, myImageDesc, GetHandleSize(myCompressedPicture), *myCompressedPicture, theID, theRegistrationPoint, theImageName);
bail:
if (myPicture != NULL)
KillPicture(myPicture);
if (myCompressedPicture != NULL)
DisposeHandle(myCompressedPicture);
if (myImageDesc != NULL)
DisposeHandle((Handle)myImageDesc);
return(myErr);
}
示例11: indexNthWord
static short indexNthWord (Handle htext, short n, short *wordcount) {
short i;
short ctchars;
Boolean inwhite = true;
Boolean thischarwhite;
*wordcount = 0;
ctchars = GetHandleSize (htext);
if (ctchars == 0)
return (0);
for (i = 0; i < ctchars; i++) {
thischarwhite = iswhite ((*htext) [i]);
if (inwhite) {
if (!thischarwhite) {
(*wordcount)++;
if (*wordcount >= n)
return (i + 1); /*returned value is 1-based*/
inwhite = false;
}
}
else {
if (thischarwhite)
inwhite = true;
}
} /*indexNthWord*/
return (0); /*aren't that many words*/
} /*indexNthWord*/
示例12: size
void CRectTracker::DrawTrackerRect(
LPCRECT lpRect, CWnd* pWndClipTo, CDC* pDC, CWnd* pWnd)
{
// first, normalize the rectangle for drawing
CRect rect = *lpRect;
rect.NormalizeRect();
// convert to client coordinates
if (pWndClipTo != NULL)
{
pWnd->ClientToScreen(&rect);
pWndClipTo->ScreenToClient(&rect);
}
CSize size(0, 0);
if (!m_bFinalErase)
{
// otherwise, size depends on the style
if (m_nStyle & hatchedBorder)
{
size.cx = size.cy = max(1, GetHandleSize(rect)-1);
rect.InflateRect(size);
}
else
{
size.cx = CX_BORDER;
size.cy = CY_BORDER;
}
}
// and draw it
if (m_bFinalErase || !m_bErase)
pDC->DrawDragRect(rect, size, m_rectLast, m_sizeLast);
// remember last rectangles
m_rectLast = rect;
m_sizeLast = size;
}
示例13: QTUtils_FindUserDataItemWithPrefix
static long QTUtils_FindUserDataItemWithPrefix (UserData theUserData, OSType theType, char *thePrefix)
{
Handle myData = NULL;
long myCount = 0;
long myIndex = 0;
long myItemIndex = 0;
OSErr myErr = noErr;
// make sure we've got some valid user data
if (theUserData == NULL)
goto bail;
// allocate a handle for GetUserData
myData = NewHandle(0);
if (myData == NULL)
goto bail;
myCount = CountUserDataType(theUserData, theType);
for (myIndex = 1; myIndex <= myCount; myIndex++) {
myErr = GetUserData(theUserData, myData, theType, myIndex);
if (myErr == noErr) {
if (GetHandleSize(myData) < strlen(thePrefix))
continue;
// see if the user data begins with the specified prefix (IdenticalText is case-insensitive)
if (IdenticalText(*myData, thePrefix, strlen(thePrefix), strlen(thePrefix), NULL) == 0) {
myItemIndex = myIndex;
goto bail;
}
}
}
bail:
if (myData != NULL)
DisposeHandle(myData);
return(myItemIndex);
}
示例14:
/*e*/
TClut &TClut::operator=(const TClut ©Me)
{
if (copyMe.ctab)
{
Size size=GetHandleSize((Handle)copyMe.ctab);
if (ctab)
BetterSetHandleSize((Handle)ctab,size,0);
else
{
ctab=(CTabHandle)NewHandle(size);
ThrowIfMemFull_(ctab);
}
BlockMove(*copyMe.ctab,*ctab,size);
}
else
{
if (ctab)
DisposeHandle((Handle)ctab);
ctab=0L;
}
return *this;
}
示例15: UnRef
void wxMetafile::SetHMETAFILE(WXHMETAFILE mf)
{
UnRef() ;
m_refData = new wxMetafileRefData;
M_METAFILEDATA->m_metafile = (PicHandle) mf;
#if wxMAC_USE_CORE_GRAPHICS
size_t sz = GetHandleSize( (Handle) M_METAFILEDATA->m_metafile ) ;
wxMemoryBuffer* membuf = new wxMemoryBuffer( sz ) ;
void * data = membuf->GetWriteBuf(sz) ;
memcpy( data , *M_METAFILEDATA->m_metafile , sz ) ;
membuf->UngetWriteBuf(sz) ;
CGDataProviderRef provider = CGDataProviderCreateWithData( membuf , data , sz ,
wxMacMemoryBufferReleaseProc ) ;
M_METAFILEDATA->m_qdPictRef = NULL ;
if ( provider != NULL )
{
M_METAFILEDATA->m_qdPictRef = QDPictCreateWithProvider( provider ) ;
CGDataProviderRelease( provider ) ;
}
#endif
}