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


C++ CreateIconIndirect函数代码示例

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


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

示例1: windowsIcon

	bool IconImpl::Create(const Image& icon)
	{
		Image windowsIcon(icon); // Vive le COW
		if (!windowsIcon.Convert(PixelFormatType_BGRA8))
		{
			NazaraError("Failed to convert icon to BGRA8");
			return false;
		}

		HBITMAP bitmap = CreateBitmap(windowsIcon.GetWidth(), windowsIcon.GetHeight(), 1, 32, windowsIcon.GetConstPixels());
		HBITMAP monoBitmap = CreateBitmap(windowsIcon.GetWidth(), windowsIcon.GetHeight(), 1, 1, nullptr);

		// http://msdn.microsoft.com/en-us/library/windows/desktop/ms648052(v=vs.85).aspx
		ICONINFO iconInfo;
		iconInfo.fIcon = TRUE;
		iconInfo.hbmMask = monoBitmap;
		iconInfo.hbmColor = bitmap;

		m_icon = CreateIconIndirect(&iconInfo);

		DeleteObject(bitmap);
		DeleteObject(monoBitmap);

		if (!m_icon)
		{
			NazaraError("Failed to create icon: " + Error::GetLastSystemError());
			return false;
		}

		return true;
	}
开发者ID:GigAnon,项目名称:NazaraEngine,代码行数:31,代码来源:IconImpl.cpp

示例2: sys_cursor_create_common

static Status sys_cursor_create_common(int w, int h, void* bgra_img, void* mask_img, int hx, int hy, sys_cursor* cursor)
{
	*cursor = 0;

	// MSDN says selecting this HBITMAP into a DC is slower since we use
	// CreateBitmap; bpp/format must be checked against those of the DC.
	// this is the simplest way and we don't care about slight performance
	// differences because this is typically only called once.
	HBITMAP hbmColor = CreateBitmap(w, h, 1, 32, bgra_img);

	// CreateIconIndirect doesn't access this; we just need to pass
	// an empty bitmap.
	HBITMAP hbmMask = CreateBitmap(w, h, 1, 1, mask_img);

	// create the cursor (really an icon; they differ only in
	// fIcon and the hotspot definitions).
	ICONINFO ii;
	ii.fIcon = FALSE;  // cursor
	ii.xHotspot = (DWORD)hx;
	ii.yHotspot = (DWORD)hy;
	ii.hbmMask  = hbmMask;
	ii.hbmColor = hbmColor;
	HICON hIcon = CreateIconIndirect(&ii);

	// CreateIconIndirect makes copies, so we no longer need these.
	DeleteObject(hbmMask);
	DeleteObject(hbmColor);

	if(!wutil_IsValidHandle(hIcon))
		WARN_RETURN(ERR::FAIL);

	*cursor = cursor_from_HICON(hIcon);
	return INFO::OK;
}
开发者ID:righnatios,项目名称:0ad,代码行数:34,代码来源:wcursor.cpp

示例3: GetDC

*/	HCURSOR Image_To_Cursor(REBYTE* image, REBINT width, REBINT height)
/*
**      Converts REBOL image! to Windows CURSOR
**
***********************************************************************/
{
	int xHotspot = 0;
	int yHotspot = 0;

	HICON result = NULL;
	HBITMAP hSourceBitmap;
	BITMAPINFO  BitmapInfo;
	ICONINFO iconinfo;

    //Get the system display DC
    HDC hDC = GetDC(NULL);

	//Create DIB
	unsigned char* ppvBits;
	int bmlen = width * height * 4;
	int i;

	BitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	BitmapInfo.bmiHeader.biWidth = width;
	BitmapInfo.bmiHeader.biHeight = -(signed)height;
	BitmapInfo.bmiHeader.biPlanes = 1;
	BitmapInfo.bmiHeader.biBitCount = 32;
	BitmapInfo.bmiHeader.biCompression = BI_RGB;
	BitmapInfo.bmiHeader.biSizeImage = 0;
	BitmapInfo.bmiHeader.biXPelsPerMeter = 0;
	BitmapInfo.bmiHeader.biYPelsPerMeter = 0;
	BitmapInfo.bmiHeader.biClrUsed = 0;
	BitmapInfo.bmiHeader.biClrImportant = 0;

	hSourceBitmap = CreateDIBSection(hDC, &BitmapInfo, DIB_RGB_COLORS, (void**)&ppvBits, NULL, 0);

	//Release the system display DC
    ReleaseDC(NULL, hDC);

	//Copy the image content to DIB
	COPY_MEM(ppvBits, image, bmlen);

	//Invert alphachannel from the REBOL format
	for (i = 3;i < bmlen;i+=4){
		ppvBits[i] ^= 0xff;
	}

	//Create the cursor using the masks and the hotspot values provided
	iconinfo.fIcon		= FALSE;
	iconinfo.xHotspot	= xHotspot;
	iconinfo.yHotspot	= yHotspot;
	iconinfo.hbmMask	= hSourceBitmap;
	iconinfo.hbmColor	= hSourceBitmap;

	result = CreateIconIndirect(&iconinfo);

	DeleteObject(hSourceBitmap);

	return result;
}
开发者ID:alepharchives,项目名称:R3A110,代码行数:60,代码来源:host-graphics.c

示例4: l_ui_create_cursor

static RD_HCURSOR
l_ui_create_cursor(struct rdp_inst * inst, uint32 x, uint32 y,
	int width, int height, uint8 * andmask, uint8 * xormask, int bpp)
{
	wfInfo * wfi;
	HCURSOR cursor;
	ICONINFO iconinfo;
	uint8 * cdata;

	wfi = GET_WFI(inst);
	if (bpp == 1)
	{
		cursor = CreateCursor(g_hInstance, x, y, width, height, andmask, xormask);
	}
	else
	{
		iconinfo.fIcon = FALSE;
		iconinfo.xHotspot = x;
		iconinfo.yHotspot = y;
		cdata = wf_cursor_mask_convert(wfi, width, height, andmask);
		iconinfo.hbmMask = CreateBitmap(width, height, 1, 1, cdata);
		iconinfo.hbmColor = wf_create_dib(wfi, width, height, bpp, 0, xormask);
		cursor = CreateIconIndirect(&iconinfo);
		DeleteObject(iconinfo.hbmMask);
		DeleteObject(iconinfo.hbmColor);
		free(cdata);
	}
	return (RD_HCURSOR)cursor;
}
开发者ID:alama,项目名称:freerdp,代码行数:29,代码来源:wf_win.cpp

示例5: QBitmap

HCURSOR QWindowsCursor::createPixmapCursor(const QPixmap &pixmap, int hotX, int hotY)
{
    HCURSOR cur = 0;
    QBitmap mask = pixmap.mask();
    if (mask.isNull()) {
        mask = QBitmap(pixmap.size());
        mask.fill(Qt::color1);
    }

    HBITMAP ic = qt_pixmapToWinHBITMAP(pixmap, /* HBitmapAlpha */ 2);
    const HBITMAP im = qt_createIconMask(mask);

    ICONINFO ii;
    ii.fIcon     = 0;
    ii.xHotspot  = hotX;
    ii.yHotspot  = hotY;
    ii.hbmMask   = im;
    ii.hbmColor  = ic;

    cur = CreateIconIndirect(&ii);

    DeleteObject(ic);
    DeleteObject(im);
    return cur;
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:25,代码来源:qwindowscursor.cpp

示例6: ASSERT

HICON CTrayNotifyIcon::BitmapToIcon(CBitmap* pBitmap)
{
  //Validate our parameters
  ASSERT(pBitmap);

  //Get the width and height of a small icon
  int w = GetSystemMetrics(SM_CXSMICON);
  int h = GetSystemMetrics(SM_CYSMICON);

  //Create a 0 mask
  int nMaskSize = h*(w/8);
  unsigned char* pMask = new unsigned char[nMaskSize];
  ZeroMemory(pMask, nMaskSize);

  //Create a mask bitmap
  CBitmap maskBitmap;
  BOOL bSuccess = maskBitmap.CreateBitmap(w, h, 1, 1, pMask);

  //Free up the heap memory now that we have created the mask bitmap
  delete [] pMask;

  //Handle the error
  if (!bSuccess)
    return NULL;

  //Create an ICON base on the bitmap just created
  ICONINFO iconInfo;
  iconInfo.fIcon = TRUE;
  iconInfo.xHotspot = 0;
  iconInfo.yHotspot = 0;
  iconInfo.hbmMask = maskBitmap;
  iconInfo.hbmColor = *pBitmap; 
  return CreateIconIndirect(&iconInfo); 
}
开发者ID:flebel,项目名称:Dorgem,代码行数:34,代码来源:NTray.cpp

示例7: WARN

//
/// Creates an icon object with the given ICONINFO information.
//
TIcon::TIcon(const ICONINFO& iconInfo)
{
  WARN(!iconInfo.fIcon, "TIcon constructor called with ICONINFO::fIcon == false"); // Turn this into a precondition?
  ICONINFO i = iconInfo; // Make a clone, since CreateIconIndirect is not const-correct.
  Handle = CreateIconIndirect(&i);
  CheckValid();
}
开发者ID:Darkman-M59,项目名称:Meridian59_115,代码行数:10,代码来源:icon.cpp

示例8: PhpSearchBitmapToIcon

HICON PhpSearchBitmapToIcon(
    _In_ HBITMAP BitmapHandle,
    _In_ INT Width,
    _In_ INT Height
    )
{
    HICON icon;
    HDC screenDc;
    HBITMAP screenBitmap;
    ICONINFO iconInfo = { 0 };

    screenDc = GetDC(NULL);
    screenBitmap = CreateCompatibleBitmap(screenDc, Width, Height);

    iconInfo.fIcon = TRUE;
    iconInfo.hbmColor = BitmapHandle;
    iconInfo.hbmMask = screenBitmap;

    icon = CreateIconIndirect(&iconInfo);

    DeleteObject(screenBitmap);
    ReleaseDC(NULL, screenDc);

    return icon;
}
开发者ID:amitamitamitamit,项目名称:processhacker2,代码行数:25,代码来源:searchbox.c

示例9: setcursor

static void setcursor(uint8_t * rgba, int16_t hotx, int16_t hoty) {
        HDC dc;
        HBITMAP bm;
        ICONINFO ii;
        BITMAPV5HEADER bh;
        int i;
        uint8_t * bits;
        ZeroMemory(&bh, sizeof(bh));
        bh.bV5Size = sizeof(bh);
        bh.bV5Width = 32;
        bh.bV5Height = -32;
        bh.bV5Planes = 1;
        bh.bV5BitCount = 32;
        bh.bV5Compression = BI_RGB;
        dc = GetDC(g_win);
        bm = CreateDIBSection(dc, (BITMAPINFO*)&bh, DIB_RGB_COLORS, (void **)&bits, 0, 0);
        ReleaseDC(g_win, dc);
        for (i = 0; i < 32*32; i++) {
                bits[4*i+0] = rgba[4*i+2];
                bits[4*i+1] = rgba[4*i+1];
                bits[4*i+2] = rgba[4*i+0];
                bits[4*i+3] = rgba[4*i+3];
        }
        if (bits[3] == 0)
                bits[3] = 1; // workaround for vbox
        ii.fIcon = FALSE;
        ii.xHotspot = hotx;
        ii.yHotspot = hoty;
        ii.hbmColor = bm;
        ii.hbmMask = CreateBitmap(32, 32, 1, 1, 0); 
        g_cursor = CreateIconIndirect(&ii);
        SetCursor(g_cursor);
        DeleteObject(bm);
        DeleteObject(ii.hbmMask);
}
开发者ID:jacereda,项目名称:glcv,代码行数:35,代码来源:win.c

示例10: CreateCompatibleBitmap

Cursor::Cursor(fs::path imgPath, float hotSpotX, float hotSpotY) {
	sf::Image gif;
	if(!gif.loadFromFile(imgPath.string())) {
		std::string error = "Error loading cursor from " + imgPath.string();
		throw error;
	}
	// Calculate the AND and XOR masks
	HBITMAP cursorAnd = CreateCompatibleBitmap(GetDC(NULL), gif.getSize().x, gif.getSize().y);
	HBITMAP cursorXor = CreateCompatibleBitmap(GetDC(NULL), gif.getSize().x, gif.getSize().y);
	GetMaskBitmaps(gif, cursorAnd, cursorXor);

	ICONINFO iconinfo = {0};
	iconinfo.fIcon = FALSE;
	iconinfo.xHotspot = hotSpotX;
	iconinfo.yHotspot = hotSpotY;
	iconinfo.hbmMask = cursorAnd;
	iconinfo.hbmColor = cursorXor;

	HCURSOR hCursor = CreateIconIndirect(&iconinfo);
	if(hCursor == NULL) {
		std::string error = "Error creating cursor from " + imgPath.string();
		error += " (error code " + std::to_string(GetLastError()) + ")";
		throw error;
	}
	ptr = hCursor;
	DeleteObject(cursorAnd);
	DeleteObject(cursorXor);
}
开发者ID:calref,项目名称:cboe,代码行数:28,代码来源:cursors.win.cpp

示例11: CreateLayoutIcon

static HICON
CreateLayoutIcon(LPTSTR szInd)
{
    HDC hdc, hdcsrc;
    HBITMAP hBitmap, hBmpNew, hBmpOld;
    RECT rect;
    DWORD bkColor, bkText;
    HFONT hFont = NULL;
    ICONINFO IconInfo;
    HICON hIcon = NULL;

    hdcsrc = GetDC(NULL);
    hdc = CreateCompatibleDC(hdcsrc);
    hBitmap = CreateCompatibleBitmap(hdcsrc, 16, 16);
    ReleaseDC(NULL, hdcsrc);

    if (hdc && hBitmap)
    {
        hBmpNew = CreateBitmap(16, 16, 1, 1, NULL);
        if (hBmpNew)
        {
            hBmpOld = SelectObject(hdc, hBitmap);
            rect.right = 16;
            rect.left = 0;
            rect.bottom = 16;
            rect.top = 0;

            bkColor = SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
            bkText  = SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));

            ExtTextOut(hdc, rect.left, rect.top, ETO_OPAQUE, &rect, _T(""), 0, NULL);

            hFont = CreateFont(-11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
                               OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
                               DEFAULT_QUALITY, FF_DONTCARE, _T("Tahoma"));

            SelectObject(hdc, hFont);
            DrawText(hdc, _tcsupr(szInd), 2, &rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER);
            SelectObject(hdc, hBmpNew);
            PatBlt(hdc, 0, 0, 16, 16, BLACKNESS);
            SelectObject(hdc, hBmpOld);

            IconInfo.hbmColor = hBitmap;
            IconInfo.hbmMask = hBmpNew;
            IconInfo.fIcon = TRUE;

            hIcon = CreateIconIndirect(&IconInfo);

            DeleteObject(hBmpNew);
            DeleteObject(hBmpOld);
            DeleteObject(hFont);
        }
    }

    DeleteDC(hdc);
    DeleteObject(hBitmap);

    return hIcon;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:59,代码来源:settings.c

示例12: WARN

//
/// Creates a TCursor object from the specified ICONINFO structure information.
//
TCursor::TCursor(const ICONINFO& iconInfo)
{
  WARN(iconInfo.fIcon, "TCursor constructor called with ICONINFO::fIcon == true"); // Turn this into a precondition?
  ICONINFO i = iconInfo; // Make a clone, since CreateIconIndirect is not const-correct.
  Handle = CreateIconIndirect(&i);
  CheckValid();
  TRACEX(OwlGDI, OWL_CDLEVEL, "TCursor constructed indirectly @" << static_cast<void*>(this));
}
开发者ID:Meridian59,项目名称:Meridian59,代码行数:11,代码来源:cursor.cpp

示例13: image_make_icon_handle

HICON
image_make_icon_handle( Handle img, Point size, Point * hotSpot)
{
   PIcon i = ( PIcon) img;
   HICON    r;
   ICONINFO ii;
   int    bpp = i-> type & imBPP;
   Bool  noSZ   = i-> w != size. x || i-> h != size. y;
   Bool  noBPP  = bpp != 1 && bpp != 4 && bpp != 8 && bpp != 24;
   HDC dc;
   XBITMAPINFO bi;
   Bool notAnIcon = !kind_of( img, CIcon);

   ii. fIcon = hotSpot ? false : true;
   ii. xHotspot = hotSpot ? hotSpot-> x : 0;
   ii. yHotspot = hotSpot ? hotSpot-> y : 0;

   if ( noSZ || noBPP) {
      i = ( PIcon)( i-> self-> dup( img));

      if ( noSZ)
         i-> self-> set_size(( Handle) i, size);
      if ( noBPP)
         i-> self-> set_type(( Handle) i,
             ( bpp < 4) ? 1 :
             (( bpp < 8) ? 4 :
             (( bpp < 24) ? 8 : 24))
      );
   }

   if (!( dc = dc_alloc())) {
      if (( Handle) i != img) Object_destroy(( Handle) i);
      return NULL;
   }
   image_get_binfo(( Handle)i, &bi);
   if ( bi. bmiHeader. biClrUsed > 0)
      bi. bmiHeader. biClrUsed = bi. bmiHeader. biClrImportant = i-> palSize;

   if ( !( ii. hbmColor = CreateDIBitmap( dc, &bi. bmiHeader, CBM_INIT,
       i-> data, ( BITMAPINFO*) &bi, DIB_RGB_COLORS))) apiErr;
   bi. bmiHeader. biBitCount = bi. bmiHeader. biPlanes = 1;
   bi. bmiColors[ 0]. rgbRed = bi. bmiColors[ 0]. rgbGreen = bi. bmiColors[ 0]. rgbBlue = 0;
   bi. bmiColors[ 1]. rgbRed = bi. bmiColors[ 1]. rgbGreen = bi. bmiColors[ 1]. rgbBlue = 255;

   if ( !( ii. hbmMask  = CreateDIBitmap( dc, &bi. bmiHeader, CBM_INIT,
      notAnIcon ? NULL : i-> mask, ( BITMAPINFO*) &bi, DIB_RGB_COLORS))) apiErr;
   
   dc_free();

   if ( !( r = CreateIconIndirect( &ii))) apiErr;

   DeleteObject( ii. hbmColor);
   DeleteObject( ii. hbmMask);
   if (( Handle) i != img) Object_destroy(( Handle) i);
   return r;
}
开发者ID:Absolight,项目名称:Prima,代码行数:56,代码来源:dev.c

示例14: WIN_CreateCursor

static SDL_Cursor *
WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
{
    SDL_Cursor *cursor;
    HICON hicon;
    HDC hdc;
    BITMAPV4HEADER bmh;
    LPVOID pixels;
    ICONINFO ii;

    SDL_zero(bmh);
    bmh.bV4Size = sizeof(bmh);
    bmh.bV4Width = surface->w;
    bmh.bV4Height = -surface->h; /* Invert the image */
    bmh.bV4Planes = 1;
    bmh.bV4BitCount = 32;
    bmh.bV4V4Compression = BI_BITFIELDS;
    bmh.bV4AlphaMask = 0xFF000000;
    bmh.bV4RedMask   = 0x00FF0000;
    bmh.bV4GreenMask = 0x0000FF00;
    bmh.bV4BlueMask  = 0x000000FF;

    hdc = GetDC(NULL);
    SDL_zero(ii);
    ii.fIcon = FALSE;
    ii.xHotspot = (DWORD)hot_x;
    ii.yHotspot = (DWORD)hot_y;
    ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO*)&bmh, DIB_RGB_COLORS, &pixels, NULL, 0);
    ii.hbmMask = CreateBitmap(surface->w, surface->h, 1, 1, NULL);
    ReleaseDC(NULL, hdc);

    SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
    SDL_assert(surface->pitch == surface->w * 4);
    SDL_memcpy(pixels, surface->pixels, surface->h * surface->pitch);

    hicon = CreateIconIndirect(&ii);

    DeleteObject(ii.hbmColor);
    DeleteObject(ii.hbmMask);

    if (!hicon) {
        WIN_SetError("CreateIconIndirect()");
        return NULL;
    }

    cursor = SDL_calloc(1, sizeof(*cursor));
    if (cursor) {
        cursor->driverdata = hicon;
    } else {
        DestroyIcon(hicon);
        SDL_OutOfMemory();
    }

    return cursor;
}
开发者ID:ktj007,项目名称:mmo,代码行数:55,代码来源:SDL_windowsmouse.c

示例15: memset

void Icon::fromBitmap(Bitmap *bitmap, Bitmap *mask)
{
  ICONINFO ii;

  memset(&ii, 0, sizeof(ICONINFO));

  ii.hbmColor = (bitmap != 0) ? bitmap->m_bitmap : 0;
  ii.hbmMask = (mask != 0) ? mask->m_bitmap : 0;

  m_icon = CreateIconIndirect(&ii);
}
开发者ID:gwupe,项目名称:GwupeSupportScreen,代码行数:11,代码来源:Icon.cpp


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