本文整理汇总了C++中GlobalSize函数的典型用法代码示例。如果您正苦于以下问题:C++ GlobalSize函数的具体用法?C++ GlobalSize怎么用?C++ GlobalSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GlobalSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}