当前位置: 首页>>代码示例>>C++>>正文


C++ GlobalReAlloc函数代码示例

本文整理汇总了C++中GlobalReAlloc函数的典型用法代码示例。如果您正苦于以下问题:C++ GlobalReAlloc函数的具体用法?C++ GlobalReAlloc怎么用?C++ GlobalReAlloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GlobalReAlloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SelPrinter

void SelPrinter(HWND hDlg){
  PRINTDLG pd;
  ZeroMemory(&pd,sizeof(PRINTDLG));
  pd.lStructSize = sizeof(PRINTDLG);
  pd.hwndOwner = hDlg;

  HGLOBAL hNewDevMode = NULL;
  HGLOBAL hNewDevNames = NULL;
  if(hDevMode != NULL && hDevNames != NULL){
    int size = GetSizeOfDevMode(hDevMode);
    hNewDevMode = GlobalAlloc(GHND,size);
    GlobalCpy(hNewDevMode,hDevMode,size);
    size = GetSizeOfDevNames(hDevNames);
    hNewDevNames = GlobalAlloc(GHND,size);
    GlobalCpy(hNewDevNames,hDevNames,size);
  }
  pd.hDevMode = hNewDevMode;
  pd.hDevNames = hNewDevNames;
  pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC | 
             PD_NOPAGENUMS | PD_NOSELECTION | PD_HIDEPRINTTOFILE;
  pd.nCopies = GetCurrentPrinterCopies();
  pd.nFromPage = 1;
  pd.nToPage = 1;
  pd.nMinPage = 1;
  pd.nMaxPage = 1;

  if(PrintDlg(&pd)){
    if(hPrintDC != NULL){
      DeleteDC(hPrintDC);
    }
    hPrintDC = pd.hDC;

    int size = GetSizeOfDevMode(pd.hDevMode);
    if(hDevMode != NULL){
      GlobalReAlloc(hDevMode,size,0);
    }else{
      hDevMode = GlobalAlloc(GHND,size);
    }
    GlobalCpy(hDevMode,pd.hDevMode,size);
    
    size = GetSizeOfDevNames(pd.hDevNames);
    if(hDevNames != NULL){
      GlobalReAlloc(hDevNames,size,0);
    }else{
      hDevNames = GlobalAlloc(GHND,size);
    }
    GlobalCpy(hDevNames,pd.hDevNames,size);

  }
  SetCurrentDirectoryToExePath();

  if(pd.hDevMode != NULL){
    GlobalFree(pd.hDevMode);
  }

  if(pd.hDevMode != NULL){
    GlobalFree(pd.hDevMode);
  }
}
开发者ID:pjmtdw,项目名称:kazesomiso,代码行数:59,代码来源:myprint_proc.cpp

示例2: GlobalUnlock

UBOOL AfoDetectResize
    (LPAFODETECT_STR lpafoDetectStr)

{
    // If there is no more room, ...
    if (lpafoDetectStr->uLineStrCnt EQ lpafoDetectStr->uLineStrNxt)
    {
        HGLOBAL hGlbLineStr;

        // Unlock the global memory handle so we may resize it
        GlobalUnlock (lpafoDetectStr->hGlbLineStr);

        // Reallocate the AFOLINE_STR
        //   moving the old data to the new location, and
        //   freeing the old global memory
        hGlbLineStr =
          GlobalReAlloc (lpafoDetectStr->hGlbLineStr,
                          (lpafoDetectStr->uLineStrCnt + AFOLINESTR_INCR) * sizeof (AFOLINE_STR),
                          GMEM_MOVEABLE);
        // Check for error
        if (hGlbLineStr EQ NULL)
            return FALSE;

        // Save (possibly new) handle
        lpafoDetectStr->hGlbLineStr  = hGlbLineStr;
        lpafoDetectStr->lpafoLineStr = GlobalLock (hGlbLineStr);

        return TRUE;
    } else
        return TRUE;
} // End AfoDetectResize
开发者ID:PlanetAPL,项目名称:nars2000,代码行数:31,代码来源:afofns.c

示例3: HGLOBALStreamImpl_SetSize

/***
 * This method is part of the IStream interface.
 *
 * It will change the size of a stream.
 *
 * TODO: Switch from small blocks to big blocks and vice versa.
 *
 * See the documentation of IStream for more info.
 */
static HRESULT WINAPI HGLOBALStreamImpl_SetSize(
				     IStream*      iface,
				     ULARGE_INTEGER  libNewSize)   /* [in] */
{
  HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
  HGLOBAL supportHandle;

  TRACE("(%p, %d)\n", iface, libNewSize.u.LowPart);

  /*
   * HighPart is ignored as shown in tests
   */

  if (This->streamSize.u.LowPart == libNewSize.u.LowPart)
    return S_OK;

  /*
   * Re allocate the HGlobal to fit the new size of the stream.
   */
  supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.u.LowPart, 0);

  if (supportHandle == 0)
    return E_OUTOFMEMORY;

  This->supportHandle = supportHandle;
  This->streamSize.u.LowPart = libNewSize.u.LowPart;

  return S_OK;
}
开发者ID:MichaelMcDonnell,项目名称:wine,代码行数:38,代码来源:hglobalstream.c

示例4: sizeof

long	UPSF::xxxx_To_UClr(
	HGLOBAL&	hUniv,
	long&			univSize,
	long			natv,
	void*			natvPtr,
	long			natvLen)

	{
	univSize = sizeof(short)*3L;
	if(!(hUniv = GlobalReAlloc(hUniv, univSize, MEMFLAGS)))
		return AUPSF_MEMORYERROR;

	short*	univPtr = (short*)GlobalLock(hUniv);
	if(!univPtr)
		return AUPSF_MEMORYERROR;

  long	retValue;

	if(natv==AUPSF_NATV_RGBCOLOR)
		{
		if(natvLen != sizeof(COLORREF))
			retValue = AUPSF_SIZEERROR;
    else
			retValue = RGBColor_To_UClr(univPtr, *(COLORREF*)natvPtr);
    }
	else
		retValue = AUPSF_CANTCONVERT;

	GlobalUnlock(hUniv);
	return retValue;
	}
开发者ID:benbucksch,项目名称:AppWare,代码行数:31,代码来源:NAT2UNIV.CPP

示例5: add_message

static void add_message(const struct message *msg)
{
    if (!sequence) {
        sequence_size = 10;
        sequence =
            (struct message *) GlobalAlloc(GMEM_DISCARDABLE,
                                           sequence_size *
                                           sizeof(struct message));
    }
    if (sequence_cnt == sequence_size) {
        sequence_size *= 2;
        sequence =
            (struct message *) GlobalReAlloc((char NEAR *) sequence,
                                             sequence_size *
                                             sizeof(struct message)
                                             , GMEM_DISCARDABLE);
    }
    assert(sequence);

    sequence[sequence_cnt].message = msg->message;
    sequence[sequence_cnt].flags = msg->flags;
    sequence[sequence_cnt].wParam = msg->wParam;
    sequence[sequence_cnt].lParam = msg->lParam;
    sequence_cnt++;
}
开发者ID:BackupGGCode,项目名称:win16test,代码行数:25,代码来源:msg.c

示例6: defined

/*
 * MemReAlloc - allocate some memory
 */
void *MemReAlloc( void *ptr, unsigned size )
{
    void *x;
#ifndef __OS2_PM__
#if defined( DEBUGMEM )
    GLOBALHANDLE        h;

    h = GlobalHandle( FP_SEG( ptr ) );
    GlobalUnlock( h );
    x = GlobalLock( GlobalReAlloc( h, size, GMEM_ZEROINIT | GMEM_MOVEABLE ) );
#else
    x = realloc( ptr, size );
#endif
#else
    x = realloc( ptr, size );
#endif
#if defined( WANT_MSGS )
    if( x == NULL ) {
        MessageBox( HWND_DESKTOP, "AUUGH, Null Pointer", "Memory Allocation",
                    MB_OK | MB_ICONHAND | MB_SYSTEMMODAL );
    }
#endif
    return( x );

} /* MemReAlloc */
开发者ID:hubei,项目名称:open-watcom,代码行数:28,代码来源:mem.c

示例7:

long	UPSF::xxxx_To_UFon(
	HGLOBAL&	hUniv,
	long&			univSize,
	long			natv,
	void*			natvPtr,
	long			natvLen)

	{
	univSize = natvLen;
	if(!(hUniv = GlobalReAlloc(hUniv, univSize, MEMFLAGS)))
		return AUPSF_MEMORYERROR;

	long*	univPtr = (long*)GlobalLock(hUniv);
	if(!univPtr)
		return AUPSF_MEMORYERROR;

	long	retValue = AUPSF_NOERROR;

	if(natv==AUPSF_NATV_FONT)
		{
		// just store the font name--each platform will convert on import
		// the attributes will be stored separately
		hmemcpy(univPtr, natvPtr, natvLen);
		}
	else
		retValue = AUPSF_CANTCONVERT;

	GlobalUnlock(hUniv);
	return retValue;
	}
开发者ID:benbucksch,项目名称:AppWare,代码行数:30,代码来源:NAT2UNIV.CPP

示例8: SetHandleSize

void SetHandleSize (Handle handle, size_t newSize)
{
	Ptr p;
	HANDLE hMem;


	memError = noErr;

	if (handle)
	{
		p = *handle;

		if (p)
		{
			GlobalUnlockPtr (p);
			hMem = GlobalReAlloc (GlobalPtrHandle (p), newSize, GHND);	
			if (hMem)
				p = (Ptr)GlobalLock (hMem);
			else
				p = NULL;
		}
 
		if (p)

			*handle = p;
		else

			memError = memFullErr;
	}

	else

		memError = memWZErr;

}
开发者ID:jxfengzi,项目名称:AirPhoto,代码行数:35,代码来源:PIUtilitiesWin.cpp

示例9: HGLOBALLockBytesImpl_SetSize

/******************************************************************************
 * This method is part of the ILockBytes interface.
 *
 * It will change the size of the byte array.
 *
 * See the documentation of ILockBytes for more info.
 */
static HRESULT WINAPI HGLOBALLockBytesImpl_SetSize(
      ILockBytes*     iface,
      ULARGE_INTEGER  libNewSize)   /* [in] */
{
  HGLOBALLockBytesImpl* const This=(HGLOBALLockBytesImpl*)iface;
  HGLOBAL supportHandle;

  /*
   * As documented.
   */
  if (libNewSize.u.HighPart != 0)
    return STG_E_INVALIDFUNCTION;

  if (This->byteArraySize.u.LowPart == libNewSize.u.LowPart)
    return S_OK;

  /*
   * Re allocate the HGlobal to fit the new size of the stream.
   */
  supportHandle = GlobalReAlloc(This->supportHandle, libNewSize.u.LowPart, 0);

  if (supportHandle == 0)
    return STG_E_MEDIUMFULL;

  This->supportHandle = supportHandle;
  This->byteArraySize.u.LowPart = libNewSize.u.LowPart;

  return S_OK;
}
开发者ID:howard5888,项目名称:wineT,代码行数:36,代码来源:memlockbytes.c

示例10: AllocRoomForDIB

HANDLE AllocRoomForDIB(BITMAPINFOHEADER bi, HBITMAP hBitmap)
{
    DWORD               dwLen;
    HANDLE              hDIB;
    HDC                 hDC;
    LPBITMAPINFOHEADER  lpbi;
    HANDLE              hTemp;

    // Figure out the size needed to hold the BITMAPINFO structure
    // (which includes the BITMAPINFOHEADER and the color table).

    dwLen = bi.biSize + PaletteSize((LPSTR) &bi);
    hDIB  = GlobalAlloc(GHND,dwLen);

    // Check that DIB handle is valid

    if (!hDIB)
        return NULL;

    // Set up the BITMAPINFOHEADER in the newly allocated global memory,
    // then call GetDIBits() with lpBits = NULL to have it fill in the
    // biSizeImage field for us.

    lpbi  = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
    *lpbi = bi;

    hDC   = GetDC(NULL);

    GetDIBits(hDC, hBitmap, 0, (UINT) bi.biHeight, NULL, (LPBITMAPINFO)lpbi,
            DIB_RGB_COLORS);
    ReleaseDC(NULL, hDC);

    // If the driver did not fill in the biSizeImage field,
    // fill it in -- NOTE: this is a bug in the driver!
    
    if (lpbi->biSizeImage == 0)
        lpbi->biSizeImage = WIDTHBYTES((DWORD)lpbi->biWidth *
                lpbi->biBitCount) * lpbi->biHeight;

    // Get the size of the memory block we need

    dwLen = lpbi->biSize + PaletteSize((LPSTR) &bi) + lpbi->biSizeImage;

    // Unlock the memory block

    GlobalUnlock(hDIB);

    // ReAlloc the buffer big enough to hold all the bits 

    if (hTemp = GlobalReAlloc(hDIB,dwLen,0))
        return hTemp;
    else
    {
        // Else free memory block and return failure

        GlobalFree(hDIB);
        return NULL;
    }
}
开发者ID:CyberShadow,项目名称:Ditto,代码行数:59,代码来源:DIBUTIL.CPP

示例11: MyReAlloc

//********************************************************************
Handle MyReAlloc(Handle hMem,
				uint32_t dwSize,
				uint32_t dwFlag)
{
	return CFIO_ReAlloc?
		CFIO_ReAlloc(hMem, dwSize, dwFlag):
		GlobalReAlloc(hMem, dwSize, dwFlag);
}
开发者ID:PauloMigAlmeida,项目名称:cuneiform,代码行数:9,代码来源:rout_dll.cpp

示例12: My_GlobalReAlloc

BOOL My_GlobalReAlloc()
{
	HGLOBAL hMem=NULL;
	SIZE_T dwBytes=NULL;
	UINT uFlags=NULL;
	HGLOBAL returnVal_Real = NULL;
	HGLOBAL returnVal_Intercepted = NULL;

	DWORD error_Real = 0;
	DWORD error_Intercepted = 0;
	__try{
	disableInterception();
	returnVal_Real = GlobalReAlloc (hMem,dwBytes,uFlags);
	error_Real = GetLastError();
	enableInterception();
	returnVal_Intercepted = GlobalReAlloc (hMem,dwBytes,uFlags);
	error_Intercepted = GetLastError();
	}__except(puts("in filter"), 1){puts("exception caught");}
	return ((returnVal_Real == returnVal_Intercepted) && (error_Real == error_Intercepted));
}
开发者ID:IFGHou,项目名称:Holodeck,代码行数:20,代码来源:GlobalReAlloc.cpp

示例13: gmem_realloc

static HGLOBAL gmem_realloc(HGLOBAL *hg, unsigned size)
{
 HGLOBAL hn;
 if (hn = *hg? GlobalReAlloc(*hg, size, loGMEM_FLAG):
               GlobalAlloc(loGMEM_FLAG, size)) *hg = hn;
/* else
   {
    UL_WARNING((LOGID, "%!L gmem_alloc(%u) FAILED", size));
   }*/
 return hn;
}
开发者ID:Nerovi,项目名称:LightOPC,代码行数:11,代码来源:dopack.cpp

示例14: GlobalAlloc

void CMenuSpawn::AddImageItem(const int idx, WORD cmd)
{
	if (iImageItem == 0)
		pImageItem = (ImageItem *) GlobalAlloc(GPTR, sizeof(ImageItem));
	else
		pImageItem = (ImageItem *) GlobalReAlloc((HGLOBAL) pImageItem, sizeof(ImageItem) * (iImageItem + 1), GMEM_MOVEABLE|GMEM_ZEROINIT);
	
	ASSERT(pImageItem);
	pImageItem[iImageItem].iCmd = (int) cmd;
	pImageItem[iImageItem].iImageIdx = idx;
	iImageItem ++;
}
开发者ID:axxapp,项目名称:winxgui,代码行数:12,代码来源:CMenuSpawn.cpp

示例15: _TIFFrealloc

tdata_t
_TIFFrealloc(tdata_t p, tsize_t s)
{
	void* pvTmp;
	if ((pvTmp = GlobalReAlloc(p, s, 0)) == NULL) {
		if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) {
			CopyMemory(pvTmp, p, GlobalSize(p));
			GlobalFree(p);
		}
	}
	return ((tdata_t)pvTmp);
}
开发者ID:shivshankardayal,项目名称:Universal-C-C--,代码行数:12,代码来源:tif_win32.c


注:本文中的GlobalReAlloc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。