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


C++ LoadImageW函数代码示例

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


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

示例1: widePath

	/*static*/
	HBITMAP Win32UIBinding::LoadImageAsBitmap(std::string& path, int sizeX, int sizeY)
	{
		std::string ext = path.substr(path.size() - 4, 4);
		UINT flags = LR_DEFAULTSIZE | LR_LOADFROMFILE |
			LR_LOADTRANSPARENT | LR_CREATEDIBSECTION;

		std::wstring widePath(::UTF8ToWide(path));
		HBITMAP h = 0;
		if (_stricmp(ext.c_str(), ".ico") == 0)
		{
			HICON hicon = (HICON) LoadImageW(NULL, widePath.c_str(), IMAGE_ICON,
				sizeX, sizeY, LR_LOADFROMFILE);
			h = Win32UIBinding::IconToBitmap(hicon, sizeX, sizeY);
			DestroyIcon(hicon);
		}
		else if (_stricmp(ext.c_str(), ".bmp") == 0)
		{
			h = (HBITMAP) LoadImageW(
				NULL, widePath.c_str(), IMAGE_BITMAP, sizeX, sizeY, flags);
		}
		else if (_stricmp(ext.c_str(), ".png") == 0)
		{
			h = LoadPNGAsBitmap(path, sizeX, sizeY);
		}

		loadedBMPs.push_back(h);
		return h;
	}
开发者ID:JamesHayton,项目名称:titanium_desktop,代码行数:29,代码来源:win32_ui_binding.cpp

示例2: widePath

/*static*/
HBITMAP UIWin::LoadImageAsBitmap(std::string& path, int sizeX, int sizeY)
{
    UINT flags = LR_DEFAULTSIZE | LR_LOADFROMFILE |
        LR_LOADTRANSPARENT | LR_CREATEDIBSECTION;

    std::wstring widePath(::UTF8ToWide(path));
    const char* ext = path.c_str() + path.size() - 4;
    HBITMAP h = 0;
    if (_stricmp(ext, ".ico") == 0)
    {
        HICON hicon = (HICON) LoadImageW(NULL, widePath.c_str(), IMAGE_ICON,
            sizeX, sizeY, LR_LOADFROMFILE);
        h = UIWin::IconToBitmap(hicon, sizeX, sizeY);
        DestroyIcon(hicon);
    }
    else if (_stricmp(ext, ".bmp") == 0)
    {
        h = (HBITMAP) LoadImageW(
            NULL, widePath.c_str(), IMAGE_BITMAP, sizeX, sizeY, flags);
    }
    else if (_stricmp(ext, ".png") == 0)
    {
        h = LoadPNGAsBitmap(path, sizeX, sizeY);
    }
    else
    {
        throw ValueException::FromFormat("Unsupported image file: %s", path);
    }

    loadedBMPs.push_back(h);
    return h;
}
开发者ID:OnlyChristopher,项目名称:TideSDK,代码行数:33,代码来源:UIWin.cpp

示例3: _glfwRegisterWindowClass

// Registers the GLFW window class
//
GLFWbool _glfwRegisterWindowClass(void)
{
    WNDCLASSW wc;

    wc.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
    wc.lpfnWndProc   = (WNDPROC) windowProc;
    wc.cbClsExtra    = 0;                           // No extra class data
    wc.cbWndExtra    = sizeof(void*) + sizeof(int); // Make room for one pointer
    wc.hInstance     = GetModuleHandleW(NULL);
    wc.hCursor       = LoadCursorW(NULL, IDC_ARROW);
    wc.hbrBackground = NULL;                        // No background
    wc.lpszMenuName  = NULL;                        // No menu
    wc.lpszClassName = _GLFW_WNDCLASSNAME;

    // Load user-provided icon if available
    wc.hIcon = LoadImageW(GetModuleHandleW(NULL),
                          L"GLFW_ICON", IMAGE_ICON,
                          0, 0, LR_DEFAULTSIZE | LR_SHARED);
    if (!wc.hIcon)
    {
        // No user-provided icon found, load default icon
        wc.hIcon = LoadImageW(NULL,
                              IDI_APPLICATION, IMAGE_ICON,
                              0, 0, LR_DEFAULTSIZE | LR_SHARED);
    }

    if (!RegisterClassW(&wc))
    {
        _glfwInputError(GLFW_PLATFORM_ERROR,
                        "Win32: Failed to register window class");
        return GLFW_FALSE;
    }

    return GLFW_TRUE;
}
开发者ID:notetau,项目名称:glfw,代码行数:37,代码来源:win32_window.c

示例4: Printer_LoadIconsW

/*************************************************************************
 * Printer_LoadIconsW        [SHELL32.205]
 */
VOID WINAPI Printer_LoadIconsW(LPCWSTR wsPrinterName, HICON * pLargeIcon, HICON * pSmallIcon)
{
    INT iconindex=IDI_SHELL_PRINTER;

    TRACE("(%s, %p, %p)\n", debugstr_w(wsPrinterName), pLargeIcon, pSmallIcon);

    /* We should check if wsPrinterName is
       1. the Default Printer or not
       2. connected or not
       3. a Local Printer or a Network-Printer
       and use different Icons
    */
    if((wsPrinterName != NULL) && (wsPrinterName[0] != 0))
    {
        FIXME("(select Icon by PrinterName %s not implemented)\n", debugstr_w(wsPrinterName));
    }

    if(pLargeIcon != NULL)
        *pLargeIcon = LoadImageW(shell32_hInstance,
                                 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
                                 0, 0, LR_DEFAULTCOLOR|LR_DEFAULTSIZE);

    if(pSmallIcon != NULL)
        *pSmallIcon = LoadImageW(shell32_hInstance,
                                 (LPCWSTR) MAKEINTRESOURCE(iconindex), IMAGE_ICON,
                                 16, 16, LR_DEFAULTCOLOR);
}
开发者ID:bdidemus,项目名称:wine,代码行数:30,代码来源:shell32_main.c

示例5: _glfwRegisterWindowClassWin32

// Registers the GLFW window class
//
GLFWbool _glfwRegisterWindowClassWin32(void)
{
    WNDCLASSEXW wc;

    ZeroMemory(&wc, sizeof(wc));
    wc.cbSize        = sizeof(wc);
    wc.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
    wc.lpfnWndProc   = (WNDPROC) windowProc;
    wc.hInstance     = GetModuleHandleW(NULL);
    wc.hCursor       = LoadCursorW(NULL, IDC_ARROW);
    wc.lpszClassName = _GLFW_WNDCLASSNAME;

    // Load user-provided icon if available
    wc.hIcon = LoadImageW(GetModuleHandleW(NULL),
                          L"GLFW_ICON", IMAGE_ICON,
                          0, 0, LR_DEFAULTSIZE | LR_SHARED);
    if (!wc.hIcon)
    {
        // No user-provided icon found, load default icon
        wc.hIcon = LoadImageW(NULL,
                              IDI_APPLICATION, IMAGE_ICON,
                              0, 0, LR_DEFAULTSIZE | LR_SHARED);
    }

    if (!RegisterClassExW(&wc))
    {
        _glfwInputError(GLFW_PLATFORM_ERROR,
                        "Win32: Failed to register window class");
        return GLFW_FALSE;
    }

    return GLFW_TRUE;
}
开发者ID:kypp,项目名称:glfw,代码行数:35,代码来源:win32_window.c

示例6: GeneralOnInit

static VOID
GeneralOnInit(HWND hwnd,
              PINFO pInfo)
{
    SetWindowLongPtrW(hwnd,
                      GWLP_USERDATA,
                      (LONG_PTR)pInfo);

    pInfo->hGeneralPage = hwnd;

    SetWindowPos(pInfo->hGeneralPage,
                 NULL,
                 2,
                 22,
                 0,
                 0,
                 SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);

    pInfo->hLogon = LoadImageW(hInst,
                               MAKEINTRESOURCEW(IDI_LOGON),
                               IMAGE_ICON,
                               32,
                               32,
                               LR_DEFAULTCOLOR);
    if (pInfo->hLogon)
    {
        SendDlgItemMessageW(pInfo->hGeneralPage,
                            IDC_LOGONICON,
                            STM_SETICON,
                            (WPARAM)pInfo->hLogon,
                            0);
    }

    pInfo->hConn = LoadImageW(hInst,
                              MAKEINTRESOURCEW(IDI_CONN),
                              IMAGE_ICON,
                              32,
                              32,
                              LR_DEFAULTCOLOR);
    if (pInfo->hConn)
    {
        SendDlgItemMessageW(pInfo->hGeneralPage,
                            IDC_CONNICON,
                            STM_SETICON,
                            (WPARAM)pInfo->hConn,
                            0);
    }

    FillServerAddressCombo(pInfo);
    ReLoadGeneralPage(pInfo);
}
开发者ID:sunnyden,项目名称:reactos,代码行数:51,代码来源:connectdialog.c

示例7: LoadImageUW

static WINUSERAPI HANDLE WINAPI LoadImageUW(HINSTANCE hInst, LPCSTR lpszName, UINT uType,
        int cxDesired, int cyDesired, UINT fuLoad)
{
    if ((DWORD_PTR)lpszName < 0x10000)
    {
        // lpszName is a resource ID.
        return LoadImageW(hInst, (LPCWSTR)lpszName, uType, cxDesired, cyDesired, fuLoad);
    }

    // lpszName is a string. Convert it from UTF-8 to UTF-16.
    wchar_t *lpszwName = w32u_UTF8toUTF16(lpszName);
    HANDLE hRet = LoadImageW(hInst, lpszwName, uType, cxDesired, cyDesired, fuLoad);
    free(lpszwName);
    return hRet;
}
开发者ID:PhilrocWP,项目名称:gens,代码行数:15,代码来源:w32u_windowsW.c

示例8: InitializeDxDiagDialog

VOID
InitializeDxDiagDialog(HWND hwndDlg)
{
    PDXDIAG_CONTEXT pContext;
    HICON hIcon;

    pContext = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DXDIAG_CONTEXT));
    if (!pContext)
        return;

    /* store window handle */
    pContext->hMainDialog = hwndDlg;

    /* store the context */
    SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);

    /* initialize the tab ctrl */
    InitializeTabCtrl(hwndDlg, pContext);

    /* load application icon */
    hIcon = LoadImageW(hInst, MAKEINTRESOURCEW(IDI_APPICON), IMAGE_ICON, 16, 16, 0);
    if (!hIcon)
        return;
    /* display icon */
    SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
}
开发者ID:RareHare,项目名称:reactos,代码行数:26,代码来源:dxdiag.c

示例9: PageIDToIndex

BOOL CIETabBar::UpdateTabItemUrl(PVOID PageID,CString strPageUrl)
{
	int nIndex = PageIDToIndex(PageID);
	if ( nIndex != -1 && strPageUrl.GetLength() > 0 )
	{
		ItemData *pData = (ItemData *)GetItemData(nIndex);
		if (pData)
		{
			if (pData->strUrl != strPageUrl)
			{
				pData->strUrl = strPageUrl;

				CString strIconFileName;
				strIconFileName = strTempPath+UrlToFaviconFileName(UrlToFaviconUrl(strPageUrl));
				if (::PathFileExistsW(strIconFileName))
				{
					UpdateTabItemIcon(
						PageID,
						(HICON)LoadImageW(AfxGetInstanceHandle(),strIconFileName,IMAGE_ICON,16,16,LR_LOADFROMFILE)
						);
				}
				else
				{
					WCHAR  *pszFilePath = new WCHAR[strIconFileName.GetLength()+1];
					wcscpy_s(pszFilePath,strIconFileName.GetLength()+1,strIconFileName.GetBuffer());
					m_IconLoader.StartDownload(m_hWnd,WM_TAB_NOTIFY_ICON_CHANGE,(WPARAM)PageID,(LPARAM)pszFilePath,UrlToFaviconUrl(strPageUrl),strIconFileName);
				}
			}
			return true;
		}
	}
	return false;
}
开发者ID:gaozan198912,项目名称:myproject,代码行数:33,代码来源:IE8TabBar.cpp

示例10: if

CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args)
{
    CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
    if (pPlatform->m_GdiplusExt.IsAvailable()) {
        return pPlatform->m_GdiplusExt.LoadDIBitmap(args);
    } else if (args.flags == WINDIB_OPEN_MEMORY) {
        return NULL;
    }
    HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    if (hBitmap == NULL) {
        return NULL;
    }
    HDC hDC = CreateCompatibleDC(NULL);
    int width, height;
    GetBitmapSize(hBitmap, width, height);
    CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap;
    if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) {
        delete pDIBitmap;
        DeleteDC(hDC);
        return NULL;
    }
    CFX_ByteString info = GetBitmapInfo(pDIBitmap);
    int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS);
    if (!ret) {
        delete pDIBitmap;
        pDIBitmap = NULL;
    }
    DeleteDC(hDC);
    return pDIBitmap;
}
开发者ID:mariospr,项目名称:chromium-browser,代码行数:30,代码来源:fx_win32_dib.cpp

示例11: WndProc

// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HINSTANCE hInstance = GetModuleHandle(NULL);
    switch(msg)
    {
		case WM_CREATE:
    
			hBitmap = (HBITMAP) LoadImageW(NULL, L"sticker.bmp", 
                IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

			if (hBitmap == NULL) {
				MessageBoxW(hwnd, L"Failed to load image", L"Error", MB_OK); 
			}

        break;      
		case WM_PAINT:
			DrawPixels(hwnd);
		break;
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
        break;
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}
开发者ID:Diamorph,项目名称:CoursesRepo-1,代码行数:30,代码来源:main.c

示例12: DESKTOP_LoadBitmap

/***********************************************************************
 *           DESKTOP_LoadBitmap
 */
static HBITMAP DESKTOP_LoadBitmap( const WCHAR *filename )
{
    HBITMAP hbitmap;

    if (!filename[0]) return 0;
    hbitmap = LoadImageW( 0, filename, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );
    if (!hbitmap)
    {
        WCHAR buffer[MAX_PATH];
        UINT len = GetWindowsDirectoryW( buffer, MAX_PATH - 2 );
        if (buffer[len - 1] != '\\') buffer[len++] = '\\';
        lstrcpynW( buffer + len, filename, MAX_PATH - len );
        hbitmap = LoadImageW( 0, buffer, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );
    }
    return hbitmap;
}
开发者ID:Kelimion,项目名称:wine,代码行数:19,代码来源:desktop.c

示例13: LoadBitmap

		IFACEMETHODIMP Credential::GetBitmapValue(__in DWORD dwFieldID, __out HBITMAP* phbmp)
		{
			if(!m_fields || dwFieldID >= m_fields->fieldCount || !phbmp)
				return E_INVALIDARG;

			if(m_fields->fields[dwFieldID].fieldDescriptor.cpft != CPFT_TILE_IMAGE)
				return E_INVALIDARG;

			HBITMAP bitmap = NULL;
			std::wstring tileImage = pGina::Registry::GetString(L"TileImage", L"");
			if(tileImage.empty() || tileImage.length() == 1)
			{
				// Use builtin
				bitmap = LoadBitmap(GetMyInstance(), MAKEINTRESOURCE(IDB_LOGO_MONOCHROME_200));
			}
			else
			{
				pDEBUG(L"Credential::GetBitmapValue: Loading image from: %s", tileImage.c_str());
				bitmap = (HBITMAP) LoadImageW((HINSTANCE) NULL, tileImage.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);			
			}
			
			if(!bitmap)
				return HRESULT_FROM_WIN32(GetLastError());
			
			*phbmp = bitmap;
			return S_OK;
		}
开发者ID:leoayt,项目名称:pgina,代码行数:27,代码来源:Credential.cpp

示例14: SetCertDlgItem

BOOL SetCertDlgItem(HWND hDlg,
                    DWORD dwIconCtl,
                    DWORD dwTextCtl,
                    DWORD dwString,
                    BOOL  fError)
{
    ASSERT(hDlg);

    // Load small icon and set it
    HICON hicon = (HICON)LoadImageW(HINST_RESDLL,
                        MAKEINTRESOURCEW(fError ? IDI_WARN : IDI_SUCCESS),
                        IMAGE_ICON, AM_SM_CXSMICON, AM_SM_CYSMICON, 0);

    if(hicon)
    {
        HICON hiconOld = (HICON)SendDlgItemMessageW(hDlg,dwIconCtl,
                                STM_SETIMAGE,(WPARAM)IMAGE_ICON,
                                (LPARAM)hicon);

        if(hiconOld)
            DestroyIcon(hiconOld);
    }

    // The dialog displays the error string by default.  Replace this with the
    // success string if an error didn't occur.
    if(!fError)
    {
        WCHAR sz[512];
        if(LoadStringW(HINST_RESDLL,dwString,sz,ARRAYSIZE(sz)))
            SetDlgItemTextW(hDlg,dwTextCtl,sz);
    }
    return TRUE;
}
开发者ID:NemProjects,项目名称:WLAN,代码行数:33,代码来源:wininetui_i.cpp

示例15: ShowAboutBox

void ShowAboutBox(HWND hWnd)
{
    WCHAR title[64];
    HICON icon = LoadImageW( hInst, MAKEINTRESOURCEW(IDI_REGEDIT), IMAGE_ICON, 48, 48, LR_SHARED );
    LoadStringW(hInst, IDS_APP_TITLE, title, ARRAY_SIZE(title));
    ShellAboutW(hWnd, title, NULL, icon);
}
开发者ID:ccpgames,项目名称:wine,代码行数:7,代码来源:about.c


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