本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}