本文整理汇总了C++中HLock函数的典型用法代码示例。如果您正苦于以下问题:C++ HLock函数的具体用法?C++ HLock怎么用?C++ HLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HLock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawImage
void DrawImage( void )
{
OSErr err = noErr;
Handle hOpenTypeList = NewHandle(0);
long numTypes = 0;
FSSpec theFSSpec;
Rect bounds;
GraphicsImportComponent importer = 0;
BuildGraphicsImporterValidFileTypes( hOpenTypeList, &numTypes );
HLock( hOpenTypeList );
err = GetOneFileWithPreview(numTypes, (OSTypePtr)*hOpenTypeList, &theFSSpec, NULL);
DisposeHandle( hOpenTypeList );
if ( err ) return;
// locate and open a graphics importer component which can be used to draw the
// selected file. If a suitable importer is not found the ComponentInstance
// is set to NULL.
err = GetGraphicsImporterForFile( &theFSSpec, // specifies the file to be drawn
&importer ); // pointer to the returned GraphicsImporterComponent
// get the native size of the image associated with the importer
err = GraphicsImportGetNaturalBounds( importer, // importer instance
&bounds ); // returned bounds
OffsetRect( &bounds, 10, 45 );
window = NewCWindow( NULL, &bounds, "\pDraw Image", true, documentProc, (WindowPtr)-1, true, 0);
// set the graphics port for drawing
err = GraphicsImportSetGWorld( importer, // importer instance
GetWindowPort( window ), // destination graphics port or GWorld
NULL ); // destination GDevice, set to NULL uses GWorlds device
// draw the image
err = GraphicsImportDraw( importer );
// close the importer instance
CloseComponent( importer );
}
示例2: P0
P0(PUBLIC pascal trap, LONGINT, UnloadScrap)
{
OSErr retval;
INTEGER f;
LONGINT l = Cx(ScrapSize);
if (Cx(ScrapState) > 0) {
retval = cropen(&f);
if (retval != noErr)
/*-->*/ return(retval);
HLock(MR(ScrapHandle));
retval = FSWriteAll(f, &l, STARH(MR(ScrapHandle)));
HUnlock(MR(ScrapHandle));
if (retval != noErr)
/*-->*/ return(retval);
retval = FSClose(f);
if (retval != noErr)
/*-->*/ return(retval);
ScrapState = 0;
}
return noErr;
}
示例3: CurResFile
//_______________________________________________________________________________
OSErr WriteRsrc (Handle rsrc, ResType type, short ID, short resFile)
{
OSErr err; Handle h;
short saved;
saved = CurResFile();
UseResFile( resFile);
if ((err= ResError())!=noErr) return err;
h= GetResource (type, ID);
if (h) RemoveResource (h);
HLock (rsrc);
AddResource( rsrc, type, ID, "\p");
err= ResError();
if( err== noErr) {
UpdateResFile( resFile);
err= ResError();
}
HUnlock( rsrc);
UseResFile( saved);
return err;
}
示例4: GetAEDataHandle
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥ GetAEDataHandle /*e*/
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// Returns the AE data handle from the desc. You have to dispose of this handle.
Handle GetAEDataHandle(
const AEDesc &inDesc)
{
Size size;
size=::AEGetDescDataSize(&inDesc);
Handle h=::NewHandle(size);
ThrowIfMemFull_(h);
HLock(h);
OSErr err=::AEGetDescData(&inDesc,*h,size);
HUnlock(h);
if (err)
{
DisposeHandle(h);
Throw_(err);
}
return h;
}
示例5: GetUserName
static char *
GetUserName()
{
static char buf[33];
short refnum;
Handle h;
refnum = CurResFile();
UseResFile(0);
h = GetResource('STR ', -16096);
UseResFile(refnum);
if (h == NULL) {
return NULL;
}
HLock(h);
strncpy(buf, (*h)+1, **h);
buf[**h] = '\0';
HUnlock(h);
ReleaseResource(h);
return(buf[0] ? buf : NULL);
}
示例6: 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);
}
示例7: Printer_postScript_printf
int Printer_postScript_printf (void *stream, const char *format, ... ) {
#if defined (_WIN32)
static union { char chars [3002]; short shorts [1501]; } theLine;
#elif cocoa
#elif defined (macintosh)
static Handle theLine;
#endif
int length;
va_list args;
va_start (args, format);
(void) stream;
#if cocoa
#elif defined (_WIN32)
vsprintf (theLine.chars + 2, format, args);
length = strlen (theLine.chars + 2);
theLine.shorts [0] = length;
if (length > 0 && theLine.chars [length + 1] == '\n') {
theLine.chars [length + 1] = '\r';
theLine.chars [length + 2] = '\n';
theLine.chars [length + 3] = '\0';
length ++;
}
Escape (theWinDC, POSTSCRIPT_PASSTHROUGH, length + 2, theLine.chars, nullptr);
#elif defined (macintosh)
if (! theLine) {
theLine = NewHandle (3000);
HLock (theLine);
}
vsprintf (*theLine, format, args);
length = strlen (*theLine);
if (length > 0 && (*theLine) [length - 1] == '\n')
(*theLine) [length - 1] = '\r';
SetPort (theMacPort);
PMSessionPostScriptData (theMacPrintSession, *theLine, strlen (*theLine));
#endif
va_end (args);
return 1;
}
示例8: setupNewMacros
void setupNewMacros(NewMacroInfo *macrost) // RAB BetterTelnet 2.0b5
{
Handle macroHandle;
Ptr pos;
long len;
short i;
len = NUM_MACROS;
macrost->handle = macroHandle = myNewHandle(len);
HLock(macroHandle);
pos = *macroHandle;
while (len) {
*pos = 0;
pos++;
len--;
}
for (i = 0; i < NUM_MACROS; i++)
macrost->index[i] = i;
HUnlock(macroHandle);
}
示例9: ProgressMsgInit
void
ProgressMsgInit()
{
Rect r;
if (gControls->tw->allProgressMsg)
{
HLock((Handle)gControls->tw->allProgressMsg);
SetRect(&r, (*gControls->tw->allProgressMsg)->viewRect.left,
(*gControls->tw->allProgressMsg)->viewRect.top,
(*gControls->tw->allProgressMsg)->viewRect.right,
(*gControls->tw->allProgressMsg)->viewRect.bottom );
HUnlock((Handle)gControls->tw->allProgressMsg);
TESetText("", 0, gControls->tw->allProgressMsg);
EraseRect(&r);
}
bProgMsgInit = true;
return;
}
示例10: MakeXIconWithIPIcon
/* create icns(icon for MacOS X) with IPIcon */
OSErr MakeXIconWithIPIcon(const FSSpec *theFile,const IPIconRec *ipIcon)
{
OSErr err;
FInfo fndrInfo;
short refNum;
IconFamilyHandle iconFamily;
long count;
if (!isIconServicesAvailable) return -1;
/* convert IPIcon to icns */
err=IPIconToIconFamily(ipIcon,&iconFamily);
if (err!=noErr) return err;
/* create a file */
err=FSpGetFInfo(theFile,&fndrInfo);
if (err==fnfErr)
err=FSpCreate(theFile,kIconPartyCreator,kXIconFileType,smSystemScript);
if (err!=noErr) return err;
/* open the file */
err=FSpOpenDF(theFile,fsWrPerm,&refNum);
if (err!=noErr) return err;
/* save icns */
HLock((Handle)iconFamily);
count=GetHandleSize((Handle)iconFamily);
err=FSWrite(refNum,&count,*iconFamily);
err=SetEOF(refNum,count);
HUnlock((Handle)iconFamily);
DisposeHandle((Handle)iconFamily);
/* close the file */
err=FSClose(refNum);
return noErr;
}
示例11: CleanupExtractedFiles
OSErr
CleanupExtractedFiles(short tgtVRefNum, long tgtDirID)
{
OSErr err = noErr;
FSSpec coreDirFSp;
StringPtr pcoreDir = nil;
short i = 0;
HLock(gControls->cfg->coreDir);
if (*gControls->cfg->coreDir != NULL && **gControls->cfg->coreDir != NULL)
{
// just need to delete the core dir and its contents
pcoreDir = CToPascal(*gControls->cfg->coreDir);
err = FSMakeFSSpec(tgtVRefNum, tgtDirID, pcoreDir, &coreDirFSp);
if (err == noErr)
{
err = FSpDelete( &coreDirFSp );
}
HUnlock(gControls->cfg->coreDir);
goto aurevoir;
}
HUnlock(gControls->cfg->coreDir);
// otherwise iterate through coreFileList deleteing each individually
for (i=0; i<currCoreFile+1; i++)
{
FSpDelete( &coreFileList[i] );
}
aurevoir:
if (pcoreDir)
DisposePtr((Ptr) pcoreDir);
return err;
}
示例12: FT_New_Face_From_SFNT
/* Create a new FT_Face from an SFNT resource, specified by res ID. */
static
FT_Error FT_New_Face_From_SFNT( FT_Library library,
short sfnt_id,
FT_Long face_index,
FT_Face* aface )
{
Handle sfnt = NULL;
FT_Byte* sfnt_data;
size_t sfnt_size;
FT_Stream stream = NULL;
FT_Error error = 0;
FT_Memory memory = library->memory;
sfnt = GetResource( 'sfnt', sfnt_id );
if ( ResError() )
return FT_Err_Invalid_Handle;
sfnt_size = (FT_ULong)GetHandleSize( sfnt );
if ( ALLOC( sfnt_data, (FT_Long)sfnt_size ) )
{
ReleaseResource( sfnt );
return error;
}
HLock( sfnt );
memcpy( sfnt_data, *sfnt, sfnt_size );
HUnlock( sfnt );
ReleaseResource( sfnt );
return open_face_from_buffer( library,
sfnt_data,
sfnt_size,
face_index,
"truetype",
aface );
}
示例13: MakeTintMapShifted
// This routine takes a CTab and generates a mapping array which will map one colour onto the best
// tinted colour in the palette. It makes no attempt to change the colours in the palette, they
// are mapped to the closest match.
void MakeTintMapShifted(CTabHandle theClut,TintPtr theTint,long rShift,long gShift,long bShift)
{
char origState=HGetState((Handle)theClut);
RGBColor theCol;
short count,index;
Boolean openedWorld=false;
HLock((Handle)theClut);
CTabChanged(theClut); // important, otherwise the remapping goes : "fsd;jhgflkasrhgflkdsavbn.asdkjrhvliuabhdv.kjhopsd; jrg;osnalkgvsa;rlfjhlkhbeoirlh"
if (!gBL_TintWorld)
{
OpenTintWorld(theClut);
openedWorld=true;
}
if (gBL_TintWorld)
{
for(count=0; count<=(**theClut).ctSize; count++)
{
theCol=(**theClut).ctTable[count].rgb;
ShiftColour(&theCol,rShift,gShift,bShift);
index=RGB2IndexGW(theClut,&theCol);
if (index!=-1) // if a match could not be found then put the original colour in
theTint[count]=index;
else
theTint[count]=count;
}
if (openedWorld)
CloseTintWorld();
}
HSetState((Handle)theClut,origState);
}
示例14: ResObj_set_data
static int ResObj_set_data(ResourceObject *self, PyObject *v, void *closure)
{
char *data;
long size;
if ( v == NULL )
return -1;
if ( !PyString_Check(v) )
return -1;
size = PyString_Size(v);
data = PyString_AsString(v);
/* XXXX Do I need the GetState/SetState calls? */
SetHandleSize(self->ob_itself, size);
if ( MemError())
return -1;
HLock(self->ob_itself);
memcpy((char *)*self->ob_itself, data, size);
HUnlock(self->ob_itself);
/* XXXX Should I do the Changed call immedeately? */
return 0;
return 0;
}
示例15: PAS_decodeResource
OSErr PAS_decodeResource(PASEntry *entry, FSSpec *outFile, short inRefNum)
{
OSErr err = noErr;
short outRefNum;
PASResFork info;
SInt32 infoSize;
short oldResFile;
PASResource pasRes;
SInt32 pasResSize;
long bufSize;
Handle buffer;
long counter=0;
infoSize = sizeof(PASResFork);
err = SetFPos(inRefNum, fsFromStart, (*entry).entryOffset );
if (err != noErr) return err;
err = FSRead( inRefNum, &infoSize, &info);
if (err != noErr) return err;
if(infoSize != sizeof(PASResFork))
{
err = -1;
goto error;
}
oldResFile=CurResFile();
outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);
if (outRefNum < noErr) return outRefNum;
UseResFile(outRefNum);
while (1)
{
pasResSize = sizeof(PASResource);
err = FSRead( inRefNum, &pasResSize, &pasRes);
if (err != noErr)
{
if(err == eofErr)
err = noErr;
break;
}
bufSize = pasRes.length;
buffer = NewHandle(bufSize);
HLock(buffer);
if(buffer == NULL)
{
/* if we did not get our memory, try updateresfile */
HUnlock(buffer);
UpdateResFile(outRefNum);
counter=0;
buffer = NewHandle(bufSize);
HLock(buffer);
if(buffer == NULL)
{
err = memFullErr;
break;
}
}
err = FSRead( inRefNum, &bufSize, &(**buffer));
if (err != noErr && err != eofErr) break;
AddResource(buffer, pasRes.attrType, pasRes.attrID, pasRes.attrName);
WriteResource(buffer);
SetResAttrs(buffer, pasRes.attr);
ChangedResource(buffer);
WriteResource(buffer);
ReleaseResource(buffer);
if (counter++ > 100)
{
UpdateResFile(outRefNum);
counter=0;
}
}
error:
UseResFile(oldResFile);
CloseResFile(outRefNum);
return err;
//.........这里部分代码省略.........