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


C++ GlobalUnlock函数代码示例

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


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

示例1: DdeMessageWindow

static LRESULT CALLBACK DdeMessageWindow(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_DDE_INITIATE:
		{
			ATOM hSzApp = LOWORD(lParam); /* no UnpackDDElParam() here */
			ATOM hSzTopic = HIWORD(lParam);
			if ((hSzApp == GlobalFindAtom(DDEAPP) && hSzTopic == GlobalFindAtom(DDETOPIC)) || !hSzApp) {
				hSzApp = GlobalAddAtom(DDEAPP);
				hSzTopic = GlobalAddAtom(DDETOPIC);
				if (hSzApp && hSzTopic)
					/* PackDDElParam() only for posted msgs */
					SendMessage((HWND)wParam, WM_DDE_ACK, (WPARAM)hwnd, MAKELPARAM(hSzApp, hSzTopic));
				if (hSzApp) GlobalDeleteAtom(hSzApp);
				if (hSzTopic) GlobalDeleteAtom(hSzTopic);
			}
		}
		return 0;

	case WM_DDE_EXECUTE: /* posted message */
		HGLOBAL hCommand;
		if (UnpackDDElParam(msg, lParam, NULL, (PUINT_PTR)&hCommand)) {
			/* ANSI execute command can't happen for shell */
			if (IsWindowUnicode((HWND)wParam)) {
				TCHAR *pszCommand = (TCHAR*)GlobalLock(hCommand);
				if (pszCommand != NULL) {
					TCHAR *pszAction = GetExecuteParam(&pszCommand);
					TCHAR *pszArg = GetExecuteParam(&pszCommand);
					if (pszArg != NULL) {
						/* we are inside miranda here, we make it async so the shell does
							* not timeout regardless what the plugins try to do. */
						if (!mir_tstrcmpi(pszAction, _T("file")))
							CallFunctionAsync(FileActionAsync, mir_tstrdup(pszArg));
						else if (!mir_tstrcmpi(pszAction, _T("url")))
							CallFunctionAsync(UrlActionAsync, mir_tstrdup(pszArg));
					}
					GlobalUnlock(hCommand);
				}
			}

			DDEACK ack;
			memset(&ack, 0, sizeof(ack));
			lParam = ReuseDDElParam(lParam, msg, WM_DDE_ACK, *(PUINT)&ack, (UINT_PTR)hCommand);
			if (!PostMessage((HWND)wParam, WM_DDE_ACK, (WPARAM)hwnd, lParam)) {
				GlobalFree(hCommand);
				FreeDDElParam(WM_DDE_ACK, lParam);
			}
		}
		return 0;

	case WM_DDE_TERMINATE:
		PostMessage((HWND)wParam, msg, (WPARAM)hwnd, 0); /* ack reply */
		return 0;

	case WM_DDE_REQUEST:
	case WM_DDE_ADVISE:
	case WM_DDE_UNADVISE:
	case WM_DDE_POKE:
		/* fail safely for those to avoid memory leak in lParam */
		{
			ATOM hSzItem;
			DDEACK ack;
			memset(&ack, 0, sizeof(ack));
			if (UnpackDDElParam(msg, lParam, NULL, (PUINT_PTR)&hSzItem)) {
				lParam = ReuseDDElParam(lParam, msg, WM_DDE_ACK, *(PUINT)&ack, (UINT)hSzItem);
				if (!PostMessage((HWND)wParam, WM_DDE_ACK, (WPARAM)hwnd, lParam)) {
					if (hSzItem) GlobalDeleteAtom(hSzItem);
					FreeDDElParam(WM_DDE_ACK, lParam);
				}
			}
			return 0;
		}
	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
开发者ID:kxepal,项目名称:miranda-ng,代码行数:75,代码来源:dde.cpp

示例2: vd_printf

// If handle_clipboard_request() fails, its caller sends VD_AGENT_CLIPBOARD message with type
// VD_AGENT_CLIPBOARD_NONE and no data, so the client will know the request failed.
bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_request)
{
    VDAgentMessage* msg;
    uint32_t msg_size;
    UINT format;
    HANDLE clip_data;
    uint8_t* new_data = NULL;
    long new_size = 0;
    size_t len = 0;
    CxImage image;
    VDAgentClipboard* clipboard = NULL;

    if (_clipboard_owner != owner_guest) {
        vd_printf("Received clipboard request from client while clipboard is not owned by guest");
        return false;
    }
    if (!(format = get_clipboard_format(clipboard_request->type))) {
        vd_printf("Unsupported clipboard type %u", clipboard_request->type);
        return false;
    }
    // on encoding only, we use HBITMAP to keep the correct palette
    if (format == CF_DIB) {
        format = CF_BITMAP;
    }
    if (!IsClipboardFormatAvailable(format) || !OpenClipboard(_hwnd)) {
        return false;
    }
    if (!(clip_data = GetClipboardData(format))) {
        CloseClipboard();
        return false;
    }
    switch (clipboard_request->type) {
    case VD_AGENT_CLIPBOARD_UTF8_TEXT:
        if (!(new_data = (uint8_t*)GlobalLock(clip_data))) {
            break;
        }
        len = wcslen((LPCWSTR)new_data);
        new_size = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)new_data, (int)len, NULL, 0, NULL, NULL);
        break;
    case VD_AGENT_CLIPBOARD_IMAGE_PNG:
    case VD_AGENT_CLIPBOARD_IMAGE_BMP: {
        DWORD cximage_format = get_cximage_format(clipboard_request->type);
        HPALETTE pal = 0;

        ASSERT(cximage_format);
        if (IsClipboardFormatAvailable(CF_PALETTE)) {
            pal = (HPALETTE)GetClipboardData(CF_PALETTE);
        }
        if (!image.CreateFromHBITMAP((HBITMAP)clip_data, pal)) {
            vd_printf("Image create from handle failed");
            break;
        }
        if (!image.Encode(new_data, new_size, cximage_format)) {
            vd_printf("Image encode to type %u failed", clipboard_request->type);
            break;
        }
        vd_printf("Image encoded to %lu bytes", new_size);
        break;
    }
    }

    if (!new_size) {
        vd_printf("clipboard is empty");
        goto handle_clipboard_request_fail;
    }
    if ((_max_clipboard != -1) && (new_size > _max_clipboard)) {
        vd_printf("clipboard is too large (%ld > %d), discarding",
                  new_size, _max_clipboard);
        goto handle_clipboard_request_fail;
    }

    msg_size = sizeof(VDAgentMessage) + sizeof(VDAgentClipboard) + new_size;
    msg = (VDAgentMessage*)new uint8_t[msg_size];
    msg->protocol = VD_AGENT_PROTOCOL;
    msg->type = VD_AGENT_CLIPBOARD;
    msg->opaque = 0;
    msg->size = (uint32_t)(sizeof(VDAgentClipboard) + new_size);
    clipboard = (VDAgentClipboard*)msg->data;
    clipboard->type = clipboard_request->type;

    switch (clipboard_request->type) {
    case VD_AGENT_CLIPBOARD_UTF8_TEXT:
        WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)new_data, (int)len, (LPSTR)clipboard->data,
                            new_size, NULL, NULL);
        GlobalUnlock(clip_data);
        break;
    case VD_AGENT_CLIPBOARD_IMAGE_PNG:
    case VD_AGENT_CLIPBOARD_IMAGE_BMP:
        memcpy(clipboard->data, new_data, new_size);
        image.FreeMemory(new_data);
        break;
    }
    CloseClipboard();
    write_clipboard(msg, msg_size);
    delete[] (uint8_t *)msg;
    return true;

handle_clipboard_request_fail:
//.........这里部分代码省略.........
开发者ID:freedesktop-unofficial-mirror,项目名称:spice__win32__vd_agent,代码行数:101,代码来源:vdagent.cpp

示例3: WndProc

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static HWND hList;
	static HWND hButton;
	switch (msg)
	{
	case WM_CREATE:
		hButton = CreateWindow(TEXT("BUTTON"), TEXT("取得"), WS_VISIBLE | WS_CHILD | WS_DISABLED, 0, 0, 0, 0, hWnd, (HMENU)IDOK, ((LPCREATESTRUCT)lParam)->hInstance, 0);
		hList = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("LISTBOX"), 0, WS_VISIBLE | WS_CHILD | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | LBS_HASSTRINGS | LBS_NOTIFY, 0, 0, 0, 0, hWnd, 0, ((LPCREATESTRUCT)lParam)->hInstance, 0);
		PostMessage(hWnd, WM_COMMAND, IDOK, 0);
		break;
	case WM_SIZE:
		MoveWindow(hButton, 10, 10, 256, 32, TRUE);
		MoveWindow(hList, 10, 50, LOWORD(lParam) - 20, HIWORD(lParam) - 60, TRUE);
		break;
	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK)
		{
			EnableWindow(hButton, FALSE);
			SendMessage(hList, LB_RESETCONTENT, 0, 0);
			DWORD_PTR dwSize;
			LPBYTE lpByte = DownloadToMemory(TEXT("https://api.github.com/users/kenjinote/repos"), &dwSize);
			{
				picojson::value v;
				std::string err;
				picojson::parse(v, lpByte, lpByte + dwSize, &err);
				if (err.empty())
				{
					picojson::array arr = v.get<picojson::array>();
					for (auto v : arr)
					{
						picojson::object obj = v.get<picojson::object>();
						const INT_PTR nIndex = SendMessageA(hList, LB_ADDSTRING, 0, (LPARAM)(obj["name"].to_str().c_str()));
						std::string strCloneUrl = obj["clone_url"].to_str();
						LPSTR lpszCloneUrl = (LPSTR)GlobalAlloc(0, strCloneUrl.size() + 1);
						lstrcpyA(lpszCloneUrl, strCloneUrl.c_str());
						SendMessage(hList, LB_SETITEMDATA, nIndex, (LPARAM)lpszCloneUrl);
					}
				}
			}
			GlobalFree(lpByte);
			EnableWindow(hButton, TRUE);
		}
		else if ((HWND)lParam == hList && HIWORD(wParam) == LBN_SELCHANGE)
		{
			const INT_PTR nIndex = SendMessage(hList, LB_GETCURSEL, 0, 0);
			if (nIndex != LB_ERR)
			{
				LPSTR lpData = (LPSTR)SendMessage(hList, LB_GETITEMDATA, nIndex, 0);
				HGLOBAL hMem = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, lstrlenA(lpData) + 1);
				LPSTR lpszBuf = (LPSTR)GlobalLock(hMem);
				lstrcpyA(lpszBuf, lpData);
				GlobalUnlock(hMem);
				OpenClipboard(0);
				EmptyClipboard();
				SetClipboardData(CF_TEXT, hMem);
				CloseClipboard();
			}
		}
		break;
	case WM_DESTROY:
		{
			const INT_PTR nSize = SendMessage(hList, LB_GETCOUNT, 0, 0);
			for (int i = 0; i < nSize; ++i)
			{
				LPSTR lpData = (LPSTR)SendMessage(hList, LB_GETITEMDATA, i, 0);
				GlobalFree(lpData);
			}
		}
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, msg, wParam, lParam);
	}
	return 0;
}
开发者ID:kenjinote,项目名称:GetGitHubRepositoryList,代码行数:76,代码来源:Source.cpp

示例4: test_bom

static void test_bom(void)
{
    static const WCHAR versionW[] = {'v','e','r','s','i','o','n','=','"','1','.','0','"',0};
    static const WCHAR utf16W[] = {'u','t','f','-','1','6',0};
    static const WCHAR xmlW[] = {'x','m','l',0};
    static const WCHAR aW[] = {'a',0};
    IXmlWriterOutput *output;
    unsigned char *ptr;
    IXmlWriter *writer;
    IStream *stream;
    HGLOBAL hglobal;
    HRESULT hr;

    hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output);
    ok(hr == S_OK, "got %08x\n", hr);

    hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL);
    ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);

    hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = IXmlWriter_SetOutput(writer, output);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    /* BOM is on by default */
    hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = IXmlWriter_Flush(writer);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = GetHGlobalFromStream(stream, &hglobal);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    ptr = GlobalLock(hglobal);
    ok(ptr[0] == 0xff && ptr[1] == 0xfe, "got %x,%x\n", ptr[0], ptr[1]);
    GlobalUnlock(hglobal);

    IStream_Release(stream);
    IUnknown_Release(output);

    /* start with PI */
    hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output);
    ok(hr == S_OK, "got %08x\n", hr);

    hr = IXmlWriter_SetOutput(writer, output);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = IXmlWriter_WriteProcessingInstruction(writer, xmlW, versionW);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = IXmlWriter_Flush(writer);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = GetHGlobalFromStream(stream, &hglobal);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    ptr = GlobalLock(hglobal);
    ok(ptr[0] == 0xff && ptr[1] == 0xfe, "got %x,%x\n", ptr[0], ptr[1]);
    GlobalUnlock(hglobal);

    IUnknown_Release(output);
    IStream_Release(stream);

    /* start with element */
    hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = CreateXmlWriterOutputWithEncodingName((IUnknown*)stream, NULL, utf16W, &output);
    ok(hr == S_OK, "got %08x\n", hr);

    hr = IXmlWriter_SetOutput(writer, output);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = IXmlWriter_Flush(writer);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    hr = GetHGlobalFromStream(stream, &hglobal);
    ok(hr == S_OK, "got 0x%08x\n", hr);

    ptr = GlobalLock(hglobal);
    ok(ptr[0] == 0xff && ptr[1] == 0xfe, "got %x,%x\n", ptr[0], ptr[1]);
    GlobalUnlock(hglobal);

    IUnknown_Release(output);
    IStream_Release(stream);

    /* WriteElementString */
    hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
    ok(hr == S_OK, "got 0x%08x\n", hr);
//.........这里部分代码省略.........
开发者ID:GYGit,项目名称:reactos,代码行数:101,代码来源:writer.c

示例5: ImageToHBITMAP


//.........这里部分代码省略.........
%
%  The format of the ImageToHBITMAP method is:
%
%      HBITMAP ImageToHBITMAP(Image *image)
%
%  A description of each parameter follows:
%
%    o image: the image to convert.
%
*/
MagickExport void *ImageToHBITMAP(Image *image)
{
  BITMAP
    bitmap;

  ExceptionInfo
    *exception;

  HANDLE
    bitmap_bitsH;

  HBITMAP
    bitmapH;

  register ssize_t
    x;

  register const PixelPacket
    *p;

  register RGBQUAD
    *q;

  RGBQUAD
    *bitmap_bits;

  size_t
    length;

  ssize_t
    y;

  (void) ResetMagickMemory(&bitmap,0,sizeof(bitmap));
  bitmap.bmType=0;
  bitmap.bmWidth=(LONG) image->columns;
  bitmap.bmHeight=(LONG) image->rows;
  bitmap.bmWidthBytes=4*bitmap.bmWidth;
  bitmap.bmPlanes=1;
  bitmap.bmBitsPixel=32;
  bitmap.bmBits=NULL;
  length=bitmap.bmWidthBytes*bitmap.bmHeight;
  bitmap_bitsH=(HANDLE) GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,length);
  if (bitmap_bitsH == NULL)
    {
      char
        *message;

      message=GetExceptionMessage(errno);
      (void) ThrowMagickException(&image->exception,GetMagickModule(),
        ResourceLimitError,"MemoryAllocationFailed","`%s'",message);
      message=DestroyString(message);
      return(NULL);
    }
  bitmap_bits=(RGBQUAD *) GlobalLock((HGLOBAL) bitmap_bitsH);
  q=bitmap_bits;
  if (bitmap.bmBits == NULL)
    bitmap.bmBits=bitmap_bits;
  (void) TransformImageColorspace(image,RGBColorspace);
  exception=(&image->exception);
  for (y=0; y < (ssize_t) image->rows; y++)
  {
    p=GetVirtualPixels(image,0,y,image->columns,1,exception);
    if (p == (const PixelPacket *) NULL)
      break;
    for (x=0; x < (ssize_t) image->columns; x++)
    {
      q->rgbRed=ScaleQuantumToChar(GetRedPixelComponent(p));
      q->rgbGreen=ScaleQuantumToChar(GetGreenPixelComponent(p));
      q->rgbBlue=ScaleQuantumToChar(GetBluePixelComponent(p));
      q->rgbReserved=0;
      p++;
      q++;
    }
  }
  bitmap.bmBits=bitmap_bits;
  bitmapH=CreateBitmapIndirect(&bitmap);
  if (bitmapH == NULL)
    {
      char
        *message;

      message=GetExceptionMessage(errno);
      (void) ThrowMagickException(&image->exception,GetMagickModule(),
        ResourceLimitError,"MemoryAllocationFailed","`%s'",message);
      message=DestroyString(message);
    }
  GlobalUnlock((HGLOBAL) bitmap_bitsH);
  GlobalFree((HGLOBAL) bitmap_bitsH);
  return((void *) bitmapH);
}
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:101,代码来源:nt-feature.c

示例6: DragQueryFile

IFACEMETHODIMP LiferayNativityContextMenus::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT pDataObj, HKEY hKeyProgID)
{
	if (pDataObj)
	{
		FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };

		STGMEDIUM stm;

		if (FAILED(pDataObj->GetData(&fe, &stm)))
		{
			return E_INVALIDARG;
		}

		HDROP hDrop = static_cast<HDROP>(GlobalLock(stm.hGlobal));

		if (hDrop == NULL)
		{
			return E_INVALIDARG;
		}

		_nFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);

		if (_nFiles > 0)
		{
			_contextMenuUtil = new ContextMenuUtil();
			wchar_t szFileName[MAX_PATH];

			for (UINT i = 0; i < _nFiles; i++)
			{
				UINT success = DragQueryFile(hDrop, i, szFileName, ARRAYSIZE(szFileName));

				if (success != 0)
				{
					_contextMenuUtil->AddFile(szFileName);
				}
			}
		}

		GlobalUnlock(stm.hGlobal);

		ReleaseStgMedium(&stm);
	}
	else if (pidlFolder)
	{
		wstring folderPath;

		folderPath.resize(MAX_PATH);

		if (!SHGetPathFromIDList(pidlFolder, &folderPath[0]))
		{
			return E_INVALIDARG;
		}

		_nFiles = 1;

		_contextMenuUtil = new ContextMenuUtil();

		_contextMenuUtil->AddFile(folderPath);
	}

	return S_OK;
}
开发者ID:iterate-ch,项目名称:liferay-nativity,代码行数:62,代码来源:LiferayNativityContextMenus.cpp

示例7: MakeDib

static HANDLE  MakeDib( HBITMAP hbitmap, UINT bits )
{
	HANDLE              hdib ;
	HDC                 hdc ;
	BITMAP              bitmap ;
	UINT                wLineLen ;
	DWORD               dwSize ;
	DWORD               wColSize ;
	LPBITMAPINFOHEADER  lpbi ;
	LPBYTE              lpBits ;
	
	GetObject(hbitmap,sizeof(BITMAP),&bitmap) ;

	//
	// DWORD align the width of the DIB
	// Figure out the size of the colour table
	// Calculate the size of the DIB
	//
	wLineLen = (bitmap.bmWidth*bits+31)/32 * 4;
	wColSize = sizeof(RGBQUAD)*((bits <= 8) ? 1<<bits : 0);
	dwSize = sizeof(BITMAPINFOHEADER) + wColSize +
		(DWORD)(UINT)wLineLen*(DWORD)(UINT)bitmap.bmHeight;

	//
	// Allocate room for a DIB and set the LPBI fields
	//
	hdib = GlobalAlloc(GHND,dwSize);
	if (!hdib)
		return hdib ;

	lpbi = (LPBITMAPINFOHEADER)GlobalLock(hdib) ;

	lpbi->biSize = sizeof(BITMAPINFOHEADER) ;
	lpbi->biWidth = bitmap.bmWidth ;
	lpbi->biHeight = bitmap.bmHeight ;
	lpbi->biPlanes = 1 ;
	lpbi->biBitCount = (WORD) bits ;
	lpbi->biCompression = BI_RGB ;
	lpbi->biSizeImage = dwSize - sizeof(BITMAPINFOHEADER) - wColSize ;
	lpbi->biXPelsPerMeter = 0 ;
	lpbi->biYPelsPerMeter = 0 ;
	lpbi->biClrUsed = (bits <= 8) ? 1<<bits : 0;
	lpbi->biClrImportant = 0 ;

	//
	// Get the bits from the bitmap and stuff them after the LPBI
	//
	lpBits = (LPBYTE)(lpbi+1)+wColSize ;

	hdc = CreateCompatibleDC(NULL) ;

	GetDIBits(hdc,hbitmap,0,bitmap.bmHeight,lpBits,(LPBITMAPINFO)lpbi, DIB_RGB_COLORS);

	// Fix this if GetDIBits messed it up....
	lpbi->biClrUsed = (bits <= 8) ? 1<<bits : 0;

	DeleteDC(hdc) ;
	GlobalUnlock(hdib);

	return hdib ;
}
开发者ID:xinyaojiejie,项目名称:Dale,代码行数:61,代码来源:moviemaker.cpp

示例8: LogTrace

//当用户点击我们添加的菜单项时该方法将被调用
HRESULT CCCopyPathEx::InvokeCommand ( LPCMINVOKECOMMANDINFO pCmdInfo )
{	
	HWND m_pWnd = NULL;
	LogTrace("菜单ID:%d", LOWORD(pCmdInfo->lpVerb));

	m_pWnd = FindWindow(NULL,_T("Spring                                {8192000D-A7B6-433a-8B40-53A3FC3EC52A}")); // 查找DataRecv进程.
	if(m_pWnd == NULL)
	{
		MessageBox(NULL, TEXT("Unable to find DataRecv."), NULL, MB_OK);
		//return;
	}
	COPYDATASTRUCT cpd = {0}; // 给COPYDATASTRUCT结构赋值.
	cpd.dwData = 0;

	try {
		// copy the string to the clipboard
		if (!::OpenClipboard(pCmdInfo->hwnd))
		{
			// Fail silently
			return S_OK;
		}

		int cTextBytes = 0;
		if ( 1 == m_cFiles ) 
		{
			cTextBytes = (_tcslen( m_szFile ) + 1) * sizeof(TCHAR);
		} 
		else 
		{
			for ( int iFile = 0; iFile < m_cFiles; iFile++ ) 
			{
				cTextBytes += ((m_lstFiles[ iFile ].length() + 2 /*\r\n*/) * sizeof(TCHAR));
			}
			cTextBytes += sizeof(TCHAR); // null terminator
		}

		HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cTextBytes );
		if (hGlobal != NULL)
		{
			LPVOID lpText = GlobalLock(hGlobal);
			memset( lpText, 0, cTextBytes );
			if ( 1 == m_cFiles ) 
			{
				memcpy(lpText, m_szFile, cTextBytes);
				LogTrace("选择一个文件,文件名:%s;", m_szFile);
				//MessageBox(NULL, m_szFile, "Tips", MB_OK);
				cpd.cbData = strlen(m_szFile);
				cpd.lpData = (void*)lpText;
				::SendMessage(m_pWnd, WM_COPYDATA, NULL, (LPARAM)&cpd);
				//m_pWnd->SendMessage(WM_COPYDATA,NULL,(LPARAM)&cpd);// 发送.
			} 
			else 
			{
				LPTSTR szText = (LPTSTR)lpText;
				for ( int iFile = 0; iFile < m_cFiles; iFile++ ) 
				{
					_tcscat( szText, m_lstFiles[ iFile ].c_str() );
					_tcscat( szText, _T("\r\n") );

				}
				LogTrace("选择%d个文件,文件名:\r\n%s;", iFile, szText);
				//MessageBox(NULL, szText, "Tips", MB_OK);
				cpd.cbData = strlen(szText);
				cpd.lpData = (void*)szText;
				//m_pWnd->SendMessage(WM_COPYDATA,NULL,(LPARAM)&cpd);// 发送.
				::SendMessage(m_pWnd, WM_COPYDATA, NULL, (LPARAM)&cpd);
			}

			EmptyClipboard();
			GlobalUnlock(hGlobal);

#ifdef _UNICODE
			SetClipboardData(CF_UNICODETEXT, hGlobal);
#else
			SetClipboardData(CF_TEXT, hGlobal);
#endif
		}

		CloseClipboard();

	} 
	catch ( ... ) 
	{
		return E_FAIL;
	}

	return S_OK;
	/////////////////////////////////////////////////////////////////////////
	//// 如果lpVerb 实际指向一个字符串, 忽略此次调用并退出.
	//if ( 0 != HIWORD( pCmdInfo->lpVerb ))
	//	return E_INVALIDARG;
	//// 点击的命令索引 – 在这里,唯一合法的索引为0.
	//switch ( LOWORD( pCmdInfo->lpVerb ))
	//{
	//case 0:
	//	{
	//		TCHAR szMsg [MAX_PATH + 32];
	//		wsprintf ( szMsg, _T("The selected file was:\n\n%s"), m_szFile );
	//		MessageBox ( pCmdInfo->hwnd, szMsg, _T("CCCopyPathEx"),
//.........这里部分代码省略.........
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:101,代码来源:CCopyPathEx.cpp

示例9: GetDC

BYTE *ServerVideoManager::getPartialScreenshot(RECT r)
{
	HDC hDC = GetDC(0);
	int w=(int)((r.right - r.left)/scale_fact);
	int h=(int)((r.bottom - r.top)/scale_fact);
	HDC tmp = CreateCompatibleDC(hDC);
	HBITMAP tmp_bmp = CreateCompatibleBitmap(hDC,w,h);

	SelectObject(tmp,tmp_bmp);

	if(!StretchBlt(	tmp,
					0,0,
					w,h,
					hDC,
					r.left,
					r.top,
					r.right-r.left,
					r.bottom-r.top,
					SRCCOPY
	))
		printError(L"StretchBlt");

	POINT curPos;
	GetCursorPos(&curPos);

	if(	curPos.x>=r.left	&&	curPos.x<r.right	&&
		curPos.y>=r.top		&&	curPos.y<r.bottom)
	{
		// The cursor is inside the area; display it
		ICONINFO iconInfo;

		GetIconInfo(GetCursor(), &iconInfo);
		curPos.x -= ((int) iconInfo.xHotspot) + r.left ;
		curPos.y -= ((int) iconInfo.yHotspot) + r.top;
		
		// Draw the cursor
		DrawIconEx(	tmp,
					(int)(curPos.x/scale_fact), (int)(curPos.y/scale_fact),
					hCursor,
					0,0,
					0,NULL, DI_NORMAL);
	}


	BITMAP bmp;
	if(!GetObject(tmp_bmp,sizeof(BITMAP),&bmp))
		printError(L"GetObject");

	bytes_per_pixel=bmp.bmBitsPixel/8;
	int size=bmp.bmWidthBytes*bmp.bmHeight;

	BITMAPINFOHEADER  bi;
	bi.biSize = sizeof(BITMAPINFOHEADER);    
	bi.biWidth = w;    
	bi.biHeight = h;  
	bi.biBitCount = bmp.bmBitsPixel;    
	bi.biCompression = BI_RGB;    
	bi.biSizeImage = size; 
	bi.biPlanes = 1; 
	bi.biXPelsPerMeter = 0;    
	bi.biYPelsPerMeter = 0;    
	bi.biClrUsed = 0;    
	bi.biClrImportant = 0;

	DWORD dwBmpSize = ((bmp.bmWidth * bi.biBitCount + 31) / 32) * 4 * bmp.bmHeight;


	HANDLE hDIB = GlobalAlloc(GHND,dwBmpSize); 
	BYTE *lpbitmap = (BYTE *)GlobalLock(hDIB); 

	
	// Gets the "bits" from the bitmap and copies them into a buffer 
	// which is pointed to by lpbitmap.
	if(!GetDIBits(	hDC, tmp_bmp, 0,
					(UINT)bmp.bmHeight,
					reinterpret_cast<LPVOID>(lpbitmap),
					(BITMAPINFO *)&bi, DIB_RGB_COLORS))
		printError(L"GetDIBits");
	
	BYTE *bmp_copy=new BYTE[size];
	memcpy(bmp_copy,lpbitmap,size);
	
	GlobalUnlock(hDIB);    
	GlobalFree(hDIB);
	

	DeleteDC(tmp);
	DeleteObject(tmp_bmp);

	ReleaseDC(0,hDC);

	return bmp_copy;
}
开发者ID:giovannipessiva,项目名称:shareemall,代码行数:93,代码来源:ServerVideoManager.cpp

示例10: OleDuplicateData

/******************************************************************************
 *              OleDuplicateData        [[email protected]]
 *
 * Duplicates clipboard data.
 *
 * PARAMS
 *  hSrc     [I] Handle of the source clipboard data.
 *  cfFormat [I] The clipboard format of hSrc.
 *  uiFlags  [I] Flags to pass to GlobalAlloc.
 *
 * RETURNS
 *  Success: handle to the duplicated data.
 *  Failure: NULL.
 */
HANDLE WINAPI OleDuplicateData(HANDLE hSrc, CLIPFORMAT cfFormat,
	                          UINT uiFlags)
{
    HANDLE hDst = NULL;

    TRACE("(%p,%x,%x)\n", hSrc, cfFormat, uiFlags);

    if (!uiFlags) uiFlags = GMEM_MOVEABLE;

    switch (cfFormat)
    {
    case CF_ENHMETAFILE:
        hDst = CopyEnhMetaFileW(hSrc, NULL);
        break;
    case CF_METAFILEPICT:
        hDst = CopyMetaFileW(hSrc, NULL);
        break;
    case CF_PALETTE:
        {
            LOGPALETTE * logpalette;
            UINT nEntries = GetPaletteEntries(hSrc, 0, 0, NULL);
            if (!nEntries) return NULL;
            logpalette = HeapAlloc(GetProcessHeap(), 0,
                FIELD_OFFSET(LOGPALETTE, palPalEntry[nEntries]));
            if (!logpalette) return NULL;
            if (!GetPaletteEntries(hSrc, 0, nEntries, logpalette->palPalEntry))
            {
                HeapFree(GetProcessHeap(), 0, logpalette);
                return NULL;
            }
            logpalette->palVersion = 0x300;
            logpalette->palNumEntries = (WORD)nEntries;

            hDst = CreatePalette(logpalette);

            HeapFree(GetProcessHeap(), 0, logpalette);
            break;
        }
    case CF_BITMAP:
        {
            LONG size;
            BITMAP bm;
            if (!GetObjectW(hSrc, sizeof(bm), &bm))
                return NULL;
            size = GetBitmapBits(hSrc, 0, NULL);
            if (!size) return NULL;
            bm.bmBits = HeapAlloc(GetProcessHeap(), 0, size);
            if (!bm.bmBits) return NULL;
            if (GetBitmapBits(hSrc, size, bm.bmBits))
                hDst = CreateBitmapIndirect(&bm);
            HeapFree(GetProcessHeap(), 0, bm.bmBits);
            break;
        }
    default:
        {
            SIZE_T size = GlobalSize(hSrc);
            LPVOID pvSrc = NULL;
            LPVOID pvDst = NULL;

            /* allocate space for object */
            if (!size) return NULL;
            hDst = GlobalAlloc(uiFlags, size);
            if (!hDst) return NULL;

            /* lock pointers */
            pvSrc = GlobalLock(hSrc);
            if (!pvSrc)
            {
                GlobalFree(hDst);
                return NULL;
            }
            pvDst = GlobalLock(hDst);
            if (!pvDst)
            {
                GlobalUnlock(hSrc);
                GlobalFree(hDst);
                return NULL;
            }
            /* copy data */
            memcpy(pvDst, pvSrc, size);

            /* cleanup */
            GlobalUnlock(hDst);
            GlobalUnlock(hSrc);
        }
    }
//.........这里部分代码省略.........
开发者ID:AmesianX,项目名称:RosWine,代码行数:101,代码来源:ole2impl.c

示例11: AssertPtrReturn


//.........这里部分代码省略.........
                                RTMemFree(pszFile);

                            if (RT_FAILURE(rc))
                                break;

                            /* Add separation between filenames.
                             * Note: Also do this for the last element of the list. */
                            rc = RTStrAAppendExN(&pszFiles, 1 /* cPairs */,
                                                 "\r\n", 2 /* Bytes */);
                            if (RT_SUCCESS(rc))
                                cchFiles += 2; /* Include \r\n */
                        }

                        if (RT_SUCCESS(rc))
                        {
                            cchFiles += 1; /* Add string termination. */
                            uint32_t cbFiles = cchFiles * sizeof(char);

                            LogFlowFunc(("cFiles=%u, cchFiles=%RU32, cbFiles=%RU32, pszFiles=0x%p\n",
                                         cFiles, cchFiles, cbFiles, pszFiles));

                            /* Translate the list into URI elements. */
                            DnDURIList lstURI;
                            rc = lstURI.AppendNativePathsFromList(pszFiles, cbFiles,
                                                                  DNDURILIST_FLAGS_ABSOLUTE_PATHS);
                            if (RT_SUCCESS(rc))
                            {
                                RTCString strRoot = lstURI.RootToString();
                                size_t cbRoot = strRoot.length() + 1; /* Include termination */

                                mpvData = RTMemAlloc(cbRoot);
                                if (mpvData)
                                {
                                    memcpy(mpvData, strRoot.c_str(), cbRoot);
                                    mcbData = cbRoot;
                                }
                                else
                                    rc = VERR_NO_MEMORY;
                            }
                        }

                        LogFlowFunc(("Building CF_HDROP list rc=%Rrc, pszFiles=0x%p, cFiles=%RU16, cchFiles=%RU32\n",
                                     rc, pszFiles, cFiles, cchFiles));

                        if (pszFiles)
                            RTStrFree(pszFiles);
                        break;
                    }

                    default:
                        /* Note: Should not happen due to the checks done in DragEnter(). */
                        AssertMsgFailed(("Format of type %RI16 (%s) not supported\n",
                                         mFormatEtc.cfFormat,
                                         VBoxDnDDataObject::ClipboardFormatToString(mFormatEtc.cfFormat)));
                        hr = DV_E_CLIPFORMAT; /* Set special hr for OLE. */
                        break;
                }

                /*
                 * Third stage: Unlock + release access to the storage medium again.
                 */
                switch (mFormatEtc.tymed)
                {
                    case TYMED_HGLOBAL:
                        GlobalUnlock(stgMed.hGlobal);
                        break;

                    default:
                        AssertMsgFailed(("Really should not happen -- see init stage!\n"));
                        break;
                }
            }

            /* Release storage medium again. */
            ReleaseStgMedium(&stgMed);

            /* Signal waiters. */
            mDroppedRc = rc;
            RTSemEventSignal(hEventDrop);
        }
    }

    if (RT_SUCCESS(rc))
    {
        /* Note: pt is not used since we don't need to differentiate within our
         *       proxy window. */
        *pdwEffect = VBoxDnDDropTarget::GetDropEffect(grfKeyState, *pdwEffect);
    }
    else
        *pdwEffect = DROPEFFECT_NONE;

    if (mpWndParent)
        mpWndParent->hide();

    LogFlowFunc(("Returning with hr=%Rhrc (%Rrc), mFormatEtc.cfFormat=%RI16 (%s), *pdwEffect=%RI32\n",
                 hr, rc, mFormatEtc.cfFormat, VBoxDnDDataObject::ClipboardFormatToString(mFormatEtc.cfFormat),
                 *pdwEffect));

    return hr;
}
开发者ID:egraba,项目名称:vbox_openbsd,代码行数:101,代码来源:VBoxDnDDropTarget.cpp

示例12: while


//.........这里部分代码省略.........
				  sizeof (BITMAPINFO)
				+ NB_COLOUR*sizeof(RGBQUAD)
				+ _txB*1*_nb_oct 
			);

	_bmi->bmiHeader.biSize = (DWORD) sizeof (BITMAPINFOHEADER) ;
	_bmi->bmiHeader.biWidth = (LONG) _txB ;
	_bmi->bmiHeader.biHeight = (LONG) 1 ; // -ny
	_bmi->bmiHeader.biPlanes = (WORD) 1 ;
	_bmi->bmiHeader.biBitCount = (WORD) (8 * _nb_oct);
	_bmi->bmiHeader.biCompression = (DWORD) BI_RGB ;
	_bmi->bmiHeader.biSizeImage = (DWORD) 0 ;
	_bmi->bmiHeader.biXPelsPerMeter = (LONG) 0 ;
	_bmi->bmiHeader.biYPelsPerMeter = (LONG) 0 ;
	_bmi->bmiHeader.biClrUsed = (LONG) NB_COLOUR ;
	_bmi->bmiHeader.biClrImportant = (LONG) NB_COLOUR ;
	
	// sans doute inutile avant de gerer les palettes, 
	// surement a modifier avec gestion des palettes,
	// surement inutile en mode 16 ou 24 bits
	/*
		{
			int x;
			for (x=0; x<128; ++x) 
			{
				_bmi->bmiColors[x] . rgbBlue = 2*x ;
				_bmi->bmiColors[x] . rgbGreen = 2*x ;
				_bmi->bmiColors[x] . rgbRed = 2*x ;
				_bmi->bmiColors[x] . rgbReserved = 0 ;
			}
		}
	*/

	int offset_im = _bmi->bmiHeader.biSize 
					+ NB_COLOUR*sizeof(RGBQUAD);

	_im =		(unsigned char*)_bmi + offset_im;
	_hbm = CreateDIBitmap
			(
				_hdc,
				(LPBITMAPINFOHEADER)_bmi,
				(DWORD)CBM_INIT,
				(LPSTR)_bmi + offset_im,
				(LPBITMAPINFO)_bmi,
				DIB_RGB_COLORS 
			);

	if (_hbm==0)
		e-xit(-1);


//================================================
//   CREATION DU DC/BITMAP          
// Copie betement dans le "Richard Simon"
// Absolument pas bite une seule ligne de ce
// charabia. Apparament ca marche.
//================================================

     _bi.biSize     = sizeof(BITMAPINFOHEADER);
     _bi.biWidth    = _txB;
     _bi.biHeight   = _tyB;
     _bi.biPlanes   = 1;
     _bi.biBitCount = 8*_nb_oct;
     _bi.biCompression   = BI_RGB;
     _bi.biSizeImage     = 0;
     _bi.biXPelsPerMeter = 0;
     _bi.biYPelsPerMeter = 0;
     _bi.biClrUsed       = 0;
     _bi.biClrImportant  = 0;

     // Create DIB.
     //............
     _hBitmap = CreateDIBitmap( _hdc, &_bi, 0L, NULL,NULL, 0 );

     // Allocate memory for BITMAPINFO structure.
     //..........................................
     _hDIB    = GlobalAlloc( GHND, 
                            sizeof( BITMAPINFOHEADER )+
                            NB_COLOUR * sizeof( RGBQUAD ) );

     _lpbi = (BITMAPINFOHEADER*)GlobalLock( _hDIB );

     // Copy bi to top of BITMAPINFO structure.
     //........................................
     *_lpbi = _bi;

     // Use GetDIBits() to init bi struct data.
     //........................................
     GetDIBits( _hdc, _hBitmap, 0, 50, NULL, 
                (LPBITMAPINFO)_lpbi, DIB_RGB_COLORS );
     GlobalUnlock( _hDIB );

     // Create a memory device context 
     // and select the DIB into it.
     //...............................
     _hMemDC = CreateCompatibleDC( _hdc );
     SelectObject( _hMemDC, _hBitmap );

	 SetProp(_hWnd,"EliseThis",this);
}
开发者ID:jakexie,项目名称:micmac-archeos,代码行数:101,代码来源:fen_windows.cpp

示例13: SHGetItemFromDataObject

HRESULT WINAPI SHGetItemFromDataObject(IDataObject *pdtobj,
    DATAOBJ_GET_ITEM_FLAGS dwFlags, REFIID riid, void **ppv)
{
    FORMATETC fmt;
    STGMEDIUM medium;
    HRESULT ret;

    TRACE("%p, %x, %s, %p\n", pdtobj, dwFlags, debugstr_guid(riid), ppv);

    if(!pdtobj)
        return E_INVALIDARG;

    fmt.cfFormat = RegisterClipboardFormatW(CFSTR_SHELLIDLISTW);
    fmt.ptd = NULL;
    fmt.dwAspect = DVASPECT_CONTENT;
    fmt.lindex = -1;
    fmt.tymed = TYMED_HGLOBAL;

    ret = IDataObject_GetData(pdtobj, &fmt, &medium);
    if(SUCCEEDED(ret))
    {
        LPIDA pida = GlobalLock(medium.u.hGlobal);

        if((pida->cidl > 1 && !(dwFlags & DOGIF_ONLY_IF_ONE)) ||
           pida->cidl == 1)
        {
            LPITEMIDLIST pidl;

            /* Get the first pidl (parent + child1) */
            pidl = ILCombine((LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]),
                             (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]));

            ret = SHCreateItemFromIDList(pidl, riid, ppv);
            ILFree(pidl);
        }
        else
        {
            ret = E_FAIL;
        }

        GlobalUnlock(medium.u.hGlobal);
        GlobalFree(medium.u.hGlobal);
    }

    if(FAILED(ret) && !(dwFlags & DOGIF_NO_HDROP))
    {
        TRACE("Attempting to fall back on CF_HDROP.\n");

        fmt.cfFormat = CF_HDROP;
        fmt.ptd = NULL;
        fmt.dwAspect = DVASPECT_CONTENT;
        fmt.lindex = -1;
        fmt.tymed = TYMED_HGLOBAL;

        ret = IDataObject_GetData(pdtobj, &fmt, &medium);
        if(SUCCEEDED(ret))
        {
            DROPFILES *df = GlobalLock(medium.u.hGlobal);
            LPBYTE files = (LPBYTE)df + df->pFiles;
            BOOL multiple_files = FALSE;

            ret = E_FAIL;
            if(!df->fWide)
            {
                WCHAR filename[MAX_PATH];
                PCSTR first_file = (PCSTR)files;
                if(*(files + lstrlenA(first_file) + 1) != 0)
                    multiple_files = TRUE;

                if( !(multiple_files && (dwFlags & DOGIF_ONLY_IF_ONE)) )
                {
                    MultiByteToWideChar(CP_ACP, 0, first_file, -1, filename, MAX_PATH);
                    ret = SHCreateItemFromParsingName(filename, NULL, riid, ppv);
                }
            }
            else
            {
                PCWSTR first_file = (PCWSTR)files;
                if(*((PCWSTR)files + lstrlenW(first_file) + 1) != 0)
                    multiple_files = TRUE;

                if( !(multiple_files && (dwFlags & DOGIF_ONLY_IF_ONE)) )
                    ret = SHCreateItemFromParsingName(first_file, NULL, riid, ppv);
            }

            GlobalUnlock(medium.u.hGlobal);
            GlobalFree(medium.u.hGlobal);
        }
    }

    if(FAILED(ret) && !(dwFlags & DOGIF_NO_URL))
    {
        FIXME("Failed to create item, should try CF_URL.\n");
    }

    return ret;
}
开发者ID:Dietr1ch,项目名称:wine,代码行数:97,代码来源:shellitem.c

示例14: DocClipboardDataGet

/*!
	クリップボードのデータをいただく
	@param[in]	pdStyle	矩形かどうかを確認
	@return		確保した文字列・mallocしてるので、函数呼んだ方でfree忘れないように
*/
LPTSTR DocClipboardDataGet( PUINT pdStyle )
{
	LPTSTR	ptString = NULL, ptClipTxt;
	LPSTR	pcStr, pcClipTp;	//	変換用臨時
	DWORD	cbSize;
	UINT	ixSqrFmt, dEnumFmt;
	INT		ixCount, iC;
	HANDLE	hClipData;

	ixSqrFmt = RegisterClipboardFormat( CLIP_SQUARE );

	//	クリップボードの中身をチェキ・どっちにしてもユニコードテキストフラグはある
	if( IsClipboardFormatAvailable( CF_UNICODETEXT ) )
	{
		if( pdStyle )	//	矩形であるか
		{
			if( IsClipboardFormatAvailable( ixSqrFmt ) ){	*pdStyle = D_SQUARE;	}
		}

		OpenClipboard( NULL );	//	クリップボードをオーポンする
		//	開けっ放しだと他のアプリに迷惑なのですぐ閉めるように

		dEnumFmt = 0;	//	初期値は0
		ixCount = CountClipboardFormats(  );
		for( iC = 0; ixCount > iC; iC++ )
		{	//	順番に列挙して、先にヒットしたフォーマットで扱う
			dEnumFmt = EnumClipboardFormats( dEnumFmt );
			if( CF_UNICODETEXT == dEnumFmt || CF_TEXT == dEnumFmt ){	break;	}
		}
		if( 0 == dEnumFmt ){	return NULL;	}
		//	それ以上列挙が無いか、函数失敗なら0になる

		//	クリップボードのデータをゲッツ!
		//	ハンドルのオーナーはクリップボードなので、こちらからは操作しないように
		//	中身の変更などもってのほかである
		hClipData = GetClipboardData( dEnumFmt );

		if( CF_UNICODETEXT == dEnumFmt )
		{
			//	取得データを処理。TEXTなら、ハンドルはグローバルメモリハンドル
			//	新たにコピーされたらハンドルは無効になるので、中身をコピーせよ
			ptClipTxt = (LPTSTR)GlobalLock( hClipData );
			cbSize    = GlobalSize( (HGLOBAL)hClipData );
			//	確保出来るのはバイトサイズ・テキストだと末尾のNULLターミネータ含む

			if( 0 < cbSize )
			{
				ptString = (LPTSTR)malloc( cbSize );
				StringCchCopy( ptString, (cbSize / 2), ptClipTxt );
			}
		}
		else	//	非ユニコードが優先されている場合
		{
			pcClipTp = (LPSTR)GlobalLock( hClipData );
			cbSize   = GlobalSize( (HGLOBAL)hClipData );

			if( 0 < cbSize )
			{
				pcStr = (LPSTR)malloc( cbSize );
				StringCchCopyA( pcStr, cbSize, pcClipTp );

				ptString = SjisDecodeAlloc( pcStr );	//	SJISの内容をユニコードにする
				free( pcStr );
			}
		}


		//	使い終わったら閉じておく
		GlobalUnlock( hClipData );
		CloseClipboard(  );
	}

	return ptString;
}
开发者ID:SikigamiHNQ,项目名称:OrinrinEditor,代码行数:79,代码来源:DocInsDelCtrl.cpp

示例15: GetDocument

void CEditModeSelectView::OnDraw(CDC* pDC)
{
	
	CNoteEditingToolDoc* pDoc = GetDocument();
	// TODO: 여기에 그리기 코드를 추가합니다.
	
	// 더블버퍼링을 위해
	
	CDC memCDC;
	CBitmap bForMemCDC;
	CRect rect;
	// 창 크기를 받아온다.
	GetClientRect(&rect);


	bForMemCDC.DeleteObject();
	bForMemCDC.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());

	memCDC.CreateCompatibleDC(pDC);
	memCDC.SelectObject(&bForMemCDC);

	


	//Graphics graphics(pDC->m_hDC);
	Graphics graphics(memCDC.m_hDC);
		
	char noteEditingMode = pDoc->getNoteEditingMode();
	char noteWriteType = pDoc->getNoteWriteType();


	// 각각의 아이콘들을 출력 할 좌표를 저장하는 함수.
	int positionX = 0;
	int positionY = 0;


	// 배경 그리기
	HRSRC hResource = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDB_PNG_BACK), _T("PNG"));
	if(!hResource) return;

	DWORD imageSize = SizeofResource(AfxGetApp()->m_hInstance, hResource);
	HGLOBAL hGlobal = LoadResource(AfxGetApp()->m_hInstance, hResource);
	LPVOID pData = LockResource(hGlobal);

	HGLOBAL hBuffer = GlobalAlloc(GMEM_MOVEABLE, imageSize);
	LPVOID pBuffer = GlobalLock(hBuffer);

	CopyMemory(pBuffer,pData,imageSize);
	GlobalUnlock(hBuffer);

	IStream *pStream;
	HRESULT hr = CreateStreamOnHGlobal(hBuffer, TRUE, &pStream);

	Image imagePNG(pStream);


	pStream->Release();
	if (imagePNG.GetLastStatus() != Ok) return;

	graphics.DrawImage(&imagePNG, 0, 0, imagePNG.GetWidth(), imagePNG.GetHeight());



	
	// 현재 선택중인 위치의 음영
	hResource = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDB_PNG_SEL_OK), _T("PNG"));
	if(!hResource) return;
	imageSize = SizeofResource(AfxGetApp()->m_hInstance, hResource);
	hGlobal = LoadResource(AfxGetApp()->m_hInstance, hResource);
	pData = LockResource(hGlobal);
	hBuffer = GlobalAlloc(GMEM_MOVEABLE, imageSize);
	pBuffer = GlobalLock(hBuffer);
	CopyMemory(pBuffer,pData,imageSize);
	GlobalUnlock(hBuffer);
	hr = CreateStreamOnHGlobal(hBuffer, TRUE, &pStream);
	
	Image imagePNGSelOk(pStream);
	pStream->Release();
	if (imagePNGSelOk.GetLastStatus() != Ok) return;
	
	// 음영 위치를 상태에 맞게 변화시킨다.
	if ( calSelectedMenuCursor(noteWriteType, positionX, positionY) < 0 )
	{
		AfxMessageBox(_T("에러!"));
	}
	else
	{
		graphics.DrawImage(&imagePNGSelOk, positionX, positionY, imagePNGSelOk.GetWidth(), imagePNGSelOk.GetHeight());
	}


	// 현재 선택중인 편집 모드의 음영
	hResource = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDB_PNG_MODE_SEL), _T("PNG"));
	if(!hResource) return;
	imageSize = SizeofResource(AfxGetApp()->m_hInstance, hResource);
	hGlobal = LoadResource(AfxGetApp()->m_hInstance, hResource);
	pData = LockResource(hGlobal);
	hBuffer = GlobalAlloc(GMEM_MOVEABLE, imageSize);
	pBuffer = GlobalLock(hBuffer);
	CopyMemory(pBuffer,pData,imageSize);
//.........这里部分代码省略.........
开发者ID:kimyoungsik,项目名称:beethoveneffect1,代码行数:101,代码来源:EditModeSelectView.cpp


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