• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GlobalSize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GlobalSize

// WriteDIB		- Writes a DIB to file
// Returns		- TRUE on success
// szFile		- Name of file to write to
// hDIB			- Handle of the DIB
BOOL CClientCapture::WriteDIB( CString csFile)
{
	BITMAPFILEHEADER	hdr;
	LPBITMAPINFOHEADER	lpbi;

	if (!hDIB)
		return FALSE;

	CFile file;
	if( !file.Open( csFile, CFile::modeWrite|CFile::modeCreate) )
		return FALSE;

	lpbi = (LPBITMAPINFOHEADER)hDIB;

	int nColors = 1 << lpbi->biBitCount;
	if( nColors > 256 ) 
		nColors = 0;

	// Fill in the fields of the file header 
	hdr.bfType		= ((WORD) ('M' << 8) | 'B');	// is always "BM"
	hdr.bfSize		= GlobalSize (hDIB) + sizeof( hdr );
	hdr.bfReserved1 	= 0;
	hdr.bfReserved2 	= 0;
	hdr.bfOffBits		= (DWORD) (sizeof( hdr ) + lpbi->biSize +
						nColors * sizeof(RGBQUAD));

	// Write the file header 
	file.Write( &hdr, sizeof(hdr) );

	// Write the DIB header and the bits 
	file.Write( lpbi, GlobalSize(hDIB) );

	return TRUE;
}
开发者ID:fallen2stealth,项目名称:GraphCalc-Update,代码行数:38,代码来源:ClientCapture.cpp


示例2: OpenClipboard

void CSemanticStrView::PasteClipboard() 
{
	OpenClipboard();
    HGLOBAL hMem = ::GetClipboardData(CF_UNICODETEXT );
    if (!hMem) {        
        CloseClipboard();        
        return;    
    }

	wchar_t s  [5000];
	if ( GlobalSize(hMem) > 4999) 
	{
		AfxMessageBox (" Text is too big!");
	};

	CopyMemory( s, hMem, GlobalSize(hMem));
	s[GlobalSize(hMem)] = 0;
    CString Q = s;
	char cmd[5200];
	strcpy (cmd, "$main.controls.mainEntry insert 0.0 \"");
    for (size_t i=0; i < Q.GetLength();i++)
		if (s[i] == '"')
			strcat (cmd, "\\\"");
		else
		{   size_t l = strlen(cmd);
			cmd[l] = Q[i];
			cmd[l+1] = 0; };

    strcat (cmd, "\"");
    if (Tcl_Eval(theInterp,cmd)!=0)
		AfxMessageBox ("Cannot set value");
	CloseClipboard();

}
开发者ID:deNULL,项目名称:seman,代码行数:34,代码来源:SemanticStrView.cpp


示例3: Z_Malloc

/*
================
Sys_GetClipboardData
================
*/
char *Sys_GetClipboardData( clipboard_t clip )
{
	char *data = NULL;
	char *cliptext;

	if ( OpenClipboard( NULL ) != 0 )
	{
		HANDLE hClipboardData;

		if ( ( hClipboardData = GetClipboardData( CF_TEXT ) ) != 0 )
		{
			if ( ( cliptext = GlobalLock( hClipboardData ) ) != 0 )
			{
				data = Z_Malloc( GlobalSize( hClipboardData ) + 1 );
				Q_strncpyz( data, cliptext, GlobalSize( hClipboardData ) );
				GlobalUnlock( hClipboardData );

				strtok( data, "\n\r\b" );
			}
		}

		CloseClipboard();
	}

	return data;
}
开发者ID:alhirzel,项目名称:Unvanquished,代码行数:31,代码来源:sys_win32.c


示例4: GlobalLock

void COleClipSource::DoUpperLowerCase(CClip &clip, bool upper)
{
	IClipFormat *unicodeTextFormat = clip.m_Formats.FindFormatEx(CF_UNICODETEXT);
	if (unicodeTextFormat != NULL)
	{
		HGLOBAL data = unicodeTextFormat->Data();
		wchar_t * stringData = (wchar_t *) GlobalLock(data);
		int size = (int) GlobalSize(data);
		CString cs(stringData);
		GlobalUnlock(data);

		//free the old text we are going to replace it below with an upper case version
		unicodeTextFormat->Free();

		CString val;
		if (upper)
		{
			val = cs.MakeUpper();
		}
		else
		{
			val = cs.MakeLower();
		}
		
		long lLen = val.GetLength();
		HGLOBAL hGlobal = NewGlobalP(val.GetBuffer(), ((lLen+1) * sizeof(wchar_t)));
		val.ReleaseBuffer();

		unicodeTextFormat->Data(hGlobal);		
	}

	IClipFormat *asciiTextFormat = clip.m_Formats.FindFormatEx(CF_TEXT);
	if (asciiTextFormat != NULL)
	{
		HGLOBAL data = asciiTextFormat->Data();
		char * stringData = (char *) GlobalLock(data);
		int size = (int) GlobalSize(data);
		CStringA cs(stringData);
		GlobalUnlock(data);

		//free the old text we are going to replace it below with an upper case version
		asciiTextFormat->Free();
		
		CString val;
		if (upper)
		{
			val = cs.MakeUpper();
		}
		else
		{
			val = cs.MakeLower();
		}

		long lLen = val.GetLength();
		HGLOBAL hGlobal = NewGlobalP(val.GetBuffer(lLen), lLen + sizeof(char));
		val.ReleaseBuffer();

		asciiTextFormat->Data(hGlobal);
	}
}
开发者ID:erdincay,项目名称:ditto-clipboard,代码行数:60,代码来源:OleClipSource.cpp


示例5: win_pr2_copy_check

static void
win_pr2_copy_check(gx_device_win_pr2 * wdev)
{
    HGLOBAL hdevmode = wdev->win32_hdevmode;
    HGLOBAL hdevnames = wdev->win32_hdevnames;
    DWORD devmode_len = (hdevmode) ? GlobalSize(hdevmode) : 0;
    DWORD devnames_len = (hdevnames) ? GlobalSize(hdevnames) : 0;

    if (wdev->original_device == wdev)
	return;

    wdev->hdcprn = NULL;
    wdev->win32_hdevmode = NULL;
    wdev->win32_hdevnames = NULL;

    wdev->original_device = wdev;

    if (devmode_len) {
	wdev->win32_hdevmode = GlobalAlloc(0, devmode_len);
	if (wdev->win32_hdevmode) {
	    memcpy(GlobalLock(wdev->win32_hdevmode), GlobalLock(hdevmode), devmode_len);
	    GlobalUnlock(wdev->win32_hdevmode);
	    GlobalUnlock(hdevmode);
	}
    }

    if (devnames_len) {
	wdev->win32_hdevnames = GlobalAlloc(0, devnames_len);
	if (wdev->win32_hdevnames) {
	    memcpy(GlobalLock(wdev->win32_hdevnames), GlobalLock(hdevnames), devnames_len);
	    GlobalUnlock(wdev->win32_hdevnames);
	    GlobalUnlock(hdevnames);
	}
    }
}
开发者ID:ststeiger,项目名称:ghostsvg,代码行数:35,代码来源:gdevwpr2.c


示例6: IsClipboardFormatAvailable

void TABLE::tPaste()

  {
  if(TABLE_ATTRIBUTES::AutoFill())
    return;

  BOOL  available = IsClipboardFormatAvailable(CF_TEXT);
  if(!available)
    return;

  DestroyAllEditControls();

  OpenClipboard(hParentWnd);
  HGLOBAL hClipboard = GetClipboardData(CF_TEXT);
  if(!hClipboard)
    {
    CloseClipboard();
    return;
    }

  HGLOBAL hCopy = GlobalAlloc(GHND, GlobalSize(hClipboard));
  if(!hCopy)
    {
    CloseClipboard();
    return;
    }

  char* copy = (char*)GlobalLock(hCopy);
  char* clip = (char*)GlobalLock(hClipboard);
  hmemcpy(copy, clip, GlobalSize(hClipboard));
  GlobalUnlock(hClipboard);
  CloseClipboard();

  RUNTIMEINFO*  rtime = (RUNTIMEINFO*)AObjGetRuntimeInfo(theObject);
  ROW*          row = rtime->GetRow();
  long          first = row->FirstSelection();
  char*         token = (char*)myStrtok((char huge*)copy);
  while(token)
    {
    row->AddRow(first, token, TABLE_ATTRIBUTES::NumColumns(), FALSE);
    token = (char*)myStrtok(NULL);
    first++;
    }
  GlobalUnlock(hCopy);
  GlobalFree(hCopy);

  row->DeleteSelectedRows();
  PostObjectChanged(CHANGED_NUMROWS);
  }
开发者ID:benbucksch,项目名称:AppWare,代码行数:49,代码来源:TABLE3.CPP


示例7: winclipreceive

void winclipreceive(void)
{
    HGLOBAL rmem;
    wchar_t *rptr;
    int i, rlen;

    if(OpenClipboard(NULL)) {
        rmem = GetClipboardData(CF_UNICODETEXT);
        if (rmem && (rptr = GlobalLock(rmem))) {
            rlen = GlobalSize(rmem) / sizeof(wchar_t);
            for (i=0; i < rlen; i++) {
                if (rptr[i] == '\0')
                    break;
                else if (rptr[i] == '\r' || rptr[i] == '\n')
                    continue;
                else if (rptr[i] == '\b' || rptr[i] == '\t')
                    continue;
                else if (rptr[i] != 27)
                    gli_input_handle_key(rptr[i]);
            }
            GlobalUnlock(rmem);
        }
        CloseClipboard(); 
    }
}
开发者ID:BPaden,项目名称:garglk,代码行数:25,代码来源:syswin.c


示例8: QueryGetData

STDMETHODIMP QOleDataObject::GetDataHere( FORMATETC *pformatetc, STGMEDIUM *pmedium )
{
    // is data is in our format?
    HRESULT hr = QueryGetData( pformatetc );
    if ( hr != S_OK )
        return hr;

    if ( pmedium->tymed != TYMED_HGLOBAL )
        return DV_E_TYMED;

    if ( !pmedium->hGlobal )
        return STG_E_MEDIUMFULL;

    HGLOBAL hGlobal = pmedium->hGlobal;
    uint size = GlobalSize( hGlobal );

    int cf = pformatetc->cfFormat;
    QPtrList<QWindowsMime> all = QWindowsMime::all();
    for ( QWindowsMime * c = all.first(); c ; c = all.next() ) {
        const char * mime = c->mimeFor( cf );
        if ( mime && m_dragObj->provides( mime ) ) {
            QByteArray ba = m_dragObj->encodedData( mime );
            if ( ba.size() > size )
                return STG_E_MEDIUMFULL;
            memcpy ( GlobalLock ( hGlobal ), ba.data(), ba.size() );
            GlobalUnlock ( hGlobal );
            return S_OK;
        }
    }
    return E_UNEXPECTED;
}
开发者ID:Miguel-J,项目名称:eneboo-core,代码行数:31,代码来源:qdnd_win.cpp


示例9: BeginWaitCursor

bool CModDoc::PasteEnvelope(INSTRUMENTINDEX nIns, EnvelopeType nEnv)
//----------------------------------------------------------------------
{
	CMainFrame *pMainFrm = CMainFrame::GetMainFrame();
	if (nIns < 1 || nIns > m_SndFile.m_nInstruments || !m_SndFile.Instruments[nIns] || !pMainFrm) return false;
	BeginWaitCursor();
	if (!pMainFrm->OpenClipboard())
	{
		EndWaitCursor();
		return false;
	}
	HGLOBAL hCpy = ::GetClipboardData(CF_TEXT);
	LPCSTR p;
	bool result = false;
	if ((hCpy) && ((p = (LPSTR)GlobalLock(hCpy)) != nullptr))
	{
		std::string data(p, p + GlobalSize(hCpy));
		GlobalUnlock(hCpy);
		CloseClipboard();

		result = StringToEnvelope(data, m_SndFile.Instruments[nIns]->GetEnvelope(nEnv), m_SndFile.GetModSpecifications());
	}
	EndWaitCursor();
	return result;
}
开发者ID:Sappharad,项目名称:modizer,代码行数:25,代码来源:Modedit.cpp


示例10: SkinMe

BOOL CDownloadDlg::OnInitDialog()
{
	CSkinDialog::OnInitDialog();

	SkinMe( NULL, IDR_DOWNLOADSFRAME );

	if ( OpenClipboard() )
	{
		if ( HGLOBAL hData = GetClipboardData( CF_UNICODETEXT ) )
		{
			size_t nData = GlobalSize( hData );
			LPVOID pData = GlobalLock( hData );

			LPTSTR pszData = m_sURL.GetBuffer( (int)( nData + 1 ) / 2 + 1 );
			CopyMemory( pszData, pData, nData );
			pszData[ ( nData + 1 ) / 2 ] = 0;
			m_sURL.ReleaseBuffer();
			GlobalUnlock( hData );
		}

		CloseClipboard();
	}

	m_sURL.Trim( _T(" \t\r\n") );

	CShareazaURL pURL;
	if ( !pURL.Parse( m_sURL, m_pURLs ) )
		m_sURL.Empty();

	UpdateData( FALSE );
	OnChangeURL();

	return TRUE;
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:34,代码来源:DlgDownload.cpp


示例11: SAFE_DELETE_ARRAY

bool CMemFileAccessor::CopyFromClipBroad(UINT ClipFormat)
{
	if(OpenClipboard(NULL))
	{
		HGLOBAL hClip=NULL;

		if( hClip=GetClipboardData(ClipFormat) )
		{
			
			char *pBuff = (char *)GlobalLock(hClip);				
			if(pBuff)
			{				
				SAFE_DELETE_ARRAY(m_Buffer);
				m_BufferSize=GlobalSize(hClip);
				m_DataPtr=0;
				m_WriteSize=0;
				m_Buffer=new char[m_BufferSize];
				memcpy(m_Buffer,pBuff,m_BufferSize);
				GlobalUnlock(hClip);
				CloseClipboard();
				return true;
			}							
		}
		CloseClipboard();		
	}
	return false;
}
开发者ID:EnoroF,项目名称:easygamelibs,代码行数:27,代码来源:MemFileAccessor.cpp


示例12: _TIFFrealloc

tdata_t
_TIFFrealloc(tdata_t p, tsize_t s)
{
    void    *pvTmp;
    tsize_t old;

    if (p == NULL)
        return ((tdata_t)GlobalAlloc(GMEM_FIXED, s));

    old = GlobalSize(p);

    if (old >= s)
    {
        if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL)
        {
            CopyMemory(pvTmp, p, s);
            GlobalFree(p);
        }
    }
    else
    {
        if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL)
        {
            CopyMemory(pvTmp, p, old);
            GlobalFree(p);
        }
    }

    return ((tdata_t)pvTmp);
}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:30,代码来源:tif_win32.c


示例13: GetClipboardData

String SystemClipboard::getTextFromClipboard()
{
    String result;

    if (OpenClipboard (0) != 0)
    {
        HANDLE bufH = GetClipboardData (CF_UNICODETEXT);

        if (bufH != 0)
        {
            const WCHAR* const data = (const WCHAR*) GlobalLock (bufH);

            if (data != nullptr)
            {
                result = String (data, (int) (GlobalSize (bufH) / sizeof (WCHAR)));

                GlobalUnlock (bufH);
            }
        }

        CloseClipboard();
    }

    return result;
}
开发者ID:baeksanchang,项目名称:juce,代码行数:25,代码来源:juce_win32_Misc.cpp


示例14: GlobalFreeP

HGLOBAL
GlobalFreeP(
   HGLOBAL hglbMem
)
{
   HGLOBAL hReturn;
   DWORD   dwSize;

   // get size of block before freeing it
   dwSize = (DWORD) GlobalSize(hglbMem);
   if (dwSize > 0)
   {
      // size was obtained OK so free the block
      hReturn = GlobalFree(hglbMem);
      if (hReturn == NULL)
      {
         // memory was freed
         if (pAppData != NULL)
         {
            // update call count
            pAppData->dwFreeCalls ++;
            pAppData->dwApplicationBytes -= dwSize;
         }
      }
      else
      {
         // memory was not freed so don't change data
      }
   }
   else
   {
      // unable to read memory size
   }
   return hReturn;
}
开发者ID:SatishSara,项目名称:zxlooong,代码行数:35,代码来源:AppMema.c


示例15: GetClipboardData

void CScreenManager::SendLocalClipboard()
{
	if (!::OpenClipboard(NULL))
	{
		return;
	}

	HGLOBAL hglb = GetClipboardData(CF_TEXT);
	if (!hglb)
	{
		::CloseClipboard();
		return;
	}

	int	nPacketLen = (int)GlobalSize(hglb) + 1;

	LPBYTE	lpData = new(std::nothrow) BYTE[nPacketLen];
	if (!lpData)
	{
		return;
	}
	
	LPSTR lpstr = (LPSTR)GlobalLock(hglb);
	lpData[0] = TOKEN_CLIPBOARD_TEXT;
	memcpy(lpData + 1, lpstr, nPacketLen - 1);

	::GlobalUnlock(hglb);
	::CloseClipboard();
	
	Send(lpData, nPacketLen);
	delete[] lpData;
}
开发者ID:chenboo,项目名称:ScreenMonitor,代码行数:32,代码来源:ScreenManager.cpp


示例16: PLUGINFUNCTIONSHORT

PLUGINFUNCTIONEND

PLUGINFUNCTIONSHORT(Copy)
{
    int size = 0;
    HANDLE source, dest;
    char *str;
    // Get the string
    if ((str = system_popstring()) == NULL) return;

    // Check for size option
    if (str[0] == '/')
    {
        size = (int) myatoi64(str+1);
        dest = (HANDLE) popint64();
    }
    else dest = (HANDLE) myatoi64(str);
    source = (HANDLE) popint64();

    // Ok, check the size
    if (size == 0) size = (int) GlobalSize(source);
    // and the destinantion
    if ((int) dest == 0) 
    {
        dest = GlobalAlloc((GPTR), size);
        system_pushint((int) dest);
    }

    // COPY!
    copymem(dest, source, size);

    GlobalFree(str);
}
开发者ID:Mobivity,项目名称:nsis-logset-on-debian,代码行数:33,代码来源:Buffers.c


示例17: GetHGlobalFromStream

HRESULT
CSite::HrStreamToFile(LPSTREAM pStream, LPCTSTR fileName)
{
	HRESULT hr = S_OK;
	HGLOBAL hMem = NULL;
	LPVOID memBuf = NULL;
	DWORD memSize = 0;
	CFile file;

	if (file.Open(fileName, CFile::modeCreate | CFile::modeReadWrite, NULL) == FALSE)
		return E_FAIL;

	hr = GetHGlobalFromStream(pStream, &hMem);

	ASSERT(SUCCEEDED(hr));

	memSize = GlobalSize(hMem);
	VERIFY(memBuf = GlobalLock(hMem));

	file.Write(memBuf, memSize);

	// Reference count of hMem not checked here
	// since we can't assume how many times the
	// Stream has locked it

	GlobalUnlock(hMem); 
	file.Close();

	return hr;
}
开发者ID:0anion0,项目名称:IBN,代码行数:30,代码来源:trifiltr.cpp


示例18: WSizeBuffer

size_t WSizeBuffer(LPSTR ptr)
{
	HANDLE	hand;

	hand = GlobalPtrHandle(ptr);
	return GlobalSize(hand);
}
开发者ID:jxfengzi,项目名称:AirPhoto,代码行数:7,代码来源:PIUtilitiesWin.cpp


示例19: GetClipboardData

bool UClipBoard::getFromClipboard(TCHAR *buf)
{

    if (OpenClipboard (0) != 0)
    {
        HANDLE bufH = GetClipboardData (CF_TEXT);

        if (bufH != 0)
        {
            const char* const data = (const char*) GlobalLock (bufH);

            if (data != 0)
            {
                ::memcpy(buf, data, (int) (GlobalSize (bufH) / sizeof(char)));

                GlobalUnlock (bufH);
            }
        }

        CloseClipboard();
    }



    return false;
}
开发者ID:Budskii,项目名称:ulib-win,代码行数:26,代码来源:uclipboard.cpp


示例20: GetClipboardText

// @return INFO::OK iff text has been assigned a pointer (which the
// caller must free via sys_clipboard_free) to the clipboard text.
static Status GetClipboardText(wchar_t*& text)
{
	// NB: Windows NT/2000+ auto convert CF_UNICODETEXT <-> CF_TEXT.

	if(!IsClipboardFormatAvailable(CF_UNICODETEXT))
		return INFO::CANNOT_HANDLE;

	HGLOBAL hMem = GetClipboardData(CF_UNICODETEXT);
	if(!hMem)
		WARN_RETURN(ERR::FAIL);

	const wchar_t* lockedText = (const wchar_t*)GlobalLock(hMem);
	if(!lockedText)
		WARN_RETURN(ERR::NO_MEM);

	const size_t size = GlobalSize(hMem);
	text = (wchar_t*)malloc(size);
	if(!text)
		WARN_RETURN(ERR::NO_MEM);
	wcscpy_s(text, size/sizeof(wchar_t), lockedText);

	(void)GlobalUnlock(hMem);

	return INFO::OK;
}
开发者ID:2asoft,项目名称:0ad,代码行数:27,代码来源:wclipboard.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GlobalToLocal函数代码示例发布时间:2022-05-30
下一篇:
C++ GlobalSelectionSystem函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap