/*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;
	}
Example #2
0
/*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;
}
Example #3
0
/*static*/
HICON UIWin::LoadImageAsIcon(std::string& path, int sizeX, int sizeY)
{
    UINT flags = LR_DEFAULTSIZE | LR_LOADFROMFILE |
        LR_LOADTRANSPARENT | LR_CREATEDIBSECTION;

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

    loadedICOs.push_back(h);
    return (HICON) h;
}
	/*static*/
	HICON Win32UIBinding::LoadImageAsIcon(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));
		HICON h = 0;
		if (_stricmp(ext.c_str(), ".ico") == 0)
		{
			h = (HICON) LoadImageW(NULL,
				widePath.c_str(), IMAGE_ICON, sizeX, sizeY, LR_LOADFROMFILE);
		}
		else if (_stricmp(ext.c_str(), ".bmp") == 0)
		{
			HBITMAP bitmap = (HBITMAP) LoadImageW(
				NULL, widePath.c_str(), IMAGE_BITMAP, sizeX, sizeY, flags);
			h = Win32UIBinding::BitmapToIcon(bitmap, sizeX, sizeY);
			DeleteObject(bitmap);
		}
		else if (_stricmp(ext.c_str(), ".png") == 0)
		{
			HBITMAP bitmap = LoadPNGAsBitmap(path, sizeX, sizeY);
			h = Win32UIBinding::BitmapToIcon(bitmap, sizeX, sizeY);
			DeleteObject(bitmap);
		}

		loadedICOs.push_back(h);
		return (HICON) h;
	}
Example #5
0
// 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;
}
Example #6
0
/*************************************************************************
 * 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);
}
Example #7
0
// 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;
}
Example #8
0
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);
}
Example #9
0
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;
}
Example #10
0
NTSTATUS
WINAPI
User32CallSetWndIconsFromKernel(PVOID Arguments, ULONG ArgumentLength)
{
  PSETWNDICONS_CALLBACK_ARGUMENTS Common = Arguments;

  if (!hIconSmWindows)
  {
      hIconSmWindows = LoadImageW(0, IDI_WINLOGO, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
      hIconWindows   = LoadImageW(0, IDI_WINLOGO, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
  }
  Common->hIconSmWindows = hIconSmWindows;
  Common->hIconWindows = hIconWindows;
  ERR("hIconSmWindows %p hIconWindows %p \n",hIconSmWindows,hIconWindows);
  return ZwCallbackReturn(Arguments, ArgumentLength, STATUS_SUCCESS);
}
Example #11
0
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);
}
Example #12
0
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;
}
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;
}
Example #14
0
// 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;
}
Example #15
0
/***********************************************************************
 *           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;
}
Example #16
0
		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;
		}
Example #17
0
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;
}
Example #18
0
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);
}
Example #19
0
LICE_IBitmap *LICE_LoadBMP(const char *filename, LICE_IBitmap *bmp) // returns a bitmap (bmp if nonzero) on success
{
  HBITMAP bm=NULL;
#ifdef _WIN32
#ifndef WDL_NO_SUPPORT_UTF8
  #ifdef WDL_SUPPORT_WIN9X
  if (GetVersion()<0x80000000)
  #endif
  {
    WCHAR wf[2048];
    if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wf,2048))
      bm = (HBITMAP) LoadImageW(NULL,wf,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
  }
#endif

  if (!bm) bm=(HBITMAP) LoadImage(NULL,filename,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
#else
  bm=(HBITMAP) LoadNamedImage(filename,false);
#endif
  if (!bm) return 0;

  LICE_IBitmap *ret=hbmToBit(bm,bmp);

  DeleteObject(bm);
  return ret;
}
Example #20
0
void MYMENU_HelpAbout()
{
    HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr( hwnd, GWLP_HINSTANCE );
    HICON icon = LoadImageW( hInstance, MAKEINTRESOURCEW(IDI_MYICON), IMAGE_ICON, 48, 48, LR_SHARED );
    static const WCHAR apptitle[] = {'O','x','y','g','e','n',' ','S','p','r','e','a','d','\0'};
    static const WCHAR extratext[] = L"(C) 2009 Ni Hui";
    ShellAboutW( hwnd, apptitle, extratext, icon );
}
Example #21
0
/* createicon
 *
 * Creates an icon resource from its filename
 *
 * usage: luasystray.createicon(<icon description table>)
 *
 * @param 	options 	Systray Icon Description Table:
 *
 * Systray Icon Description Table
 *   resourceid	: resource identifier to load icon from
 *   filename 	: icon filename to load icon from
 *   bitmap 	: true if icon file is a bitmap
 *	 width		: desired width for icon
 *	 height		: desired height for icon
 */
int createIcon(lua_State*L) {
	luaL_checkany(L, 1);
	int type = lua_type(L, 1);

	HMODULE hinstance = 0;
	int imgtype = IMAGE_ICON;

	const char*filename = NULL;
	const char*resourceid = NULL;

	int width = 0;
	int height = 0;
	int bitmap = 0;

	int loadtype = LR_LOADFROMFILE;

	if(type==LUA_TSTRING) {
		filename = lua_tostring(L, 1);
	}

	if(type==LUA_TTABLE) {
		getoption(1, resourceid);
		getoption(1, filename);
		getoption(1, bitmap);
		getoption(1, width);
		getoption(1, height);
	}

	if(bitmap) {
		imgtype = IMAGE_BITMAP;
		width = 0;
		height = 0;
	}

	if(resourceid) {
		loadtype = LR_DEFAULTCOLOR | LR_DEFAULTSIZE;
		hinstance = GetModuleHandleW(NULL);
		filename = resourceid;
	}

	HANDLE img = LoadImageW(
		hinstance,
		_T(filename),
		imgtype,
		width, height,
		loadtype
	);

	if(img) {
		luaL_error(L, "Error loading image");
	}

	lua_settop(L, 0);
	lua_pushlightuserdata(L, img);

	return 1;
}
Example #22
0
BOOL CIETabBar::AddTabItem(PVOID PageID,CString strPageUrl,CString strPageTitle)
{
	if ( PageID == NULL )
	{
		return false;
	}

	int nInsertIndex = GetCurSel()+1;
	LONG nNewIndex = InsertItem(nInsertIndex,strPageTitle.GetLength() == 0?strPageUrl:strPageTitle);
	
	bool bRes = false;
	if (nNewIndex != -1)
	{
		if(strPageUrl.GetLength() > 0)
		{
			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);
			}
		}

		ItemData *pData = new ItemData;
		pData->PageID = PageID;
		pData->hIcon = NULL;
		pData->strUrl = strPageUrl;

		if(SetItemData(nNewIndex,pData))
		{
			SetCurSel(nInsertIndex);
			bRes = true;
		}
		else
		{
			DeleteItem(nNewIndex);
			delete pData;

			bRes = false;;
		}
	}
	
	AdjustTabWidth();

	return bRes;

}	
Example #23
0
VOID DIALOG_HelpAboutNotepad(VOID)
{
    static const WCHAR notepadW[] = { 'W','i','n','e',' ','N','o','t','e','p','a','d',0 };
    WCHAR szNotepad[MAX_STRING_LEN];
    HICON icon = LoadImageW(Globals.hInstance, MAKEINTRESOURCEW(IDI_NOTEPAD),
                            IMAGE_ICON, 48, 48, LR_SHARED);

    LoadStringW(Globals.hInstance, STRING_NOTEPAD, szNotepad, ARRAY_SIZE(szNotepad));
    ShellAboutW(Globals.hMainWnd, szNotepad, notepadW, icon);
}
Example #24
0
void setIcon(const wchar_t* iconFile, int lenth) {
    HICON hIcon = (HICON) LoadImageW(NULL, iconFile, IMAGE_ICON, 64, 64, LR_LOADFROMFILE);
    if (hIcon == NULL) {
        reportWindowsError("load icon image");
    } else {
        nid.hIcon = hIcon;
        nid.uFlags = NIF_ICON;
        Shell_NotifyIcon(NIM_MODIFY, &nid);
    }
}
Example #25
0
static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
    WCHAR empty = 0;
    WNDCLASSEXW wndclass = {0};

    /* Frame class */
    wndclass.cbSize = sizeof(WNDCLASSEXW);
    wndclass.style = CS_HREDRAW | CS_VREDRAW;
    wndclass.lpfnWndProc = FrameWndProc;
    wndclass.hInstance = hInstance;
    wndclass.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT));
    wndclass.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW);
    wndclass.lpszClassName = szFrameClass;
    wndclass.hIconSm = LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT), IMAGE_ICON,
                                  GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
    RegisterClassExW(&wndclass);

    /* Child class */
    wndclass.lpfnWndProc = ChildWndProc;
    wndclass.cbWndExtra = sizeof(HANDLE);
    wndclass.lpszClassName = szChildClass;
    RegisterClassExW(&wndclass);

    hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU));
    hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS));

    /* Initialize the Windows Common Controls DLL */
    InitCommonControls();

    /* register our hex editor control */
    HexEdit_Register();

    nClipboardFormat = RegisterClipboardFormatW(strClipboardFormat);

    hFrameWnd = CreateWindowExW(0, szFrameClass, szTitle,
                                WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE,
                                CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                                NULL, hMenuFrame, hInstance, NULL/*lpParam*/);

    if (!hFrameWnd) {
        return FALSE;
    }

    /* Create the status bar */
    hStatusBar = CreateStatusWindowW(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
                                     &empty, hFrameWnd, STATUS_WINDOW);
    if (hStatusBar) {
        /* Create the status bar panes */
        SetupStatusBar(hFrameWnd, FALSE);
        CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
    }
    ShowWindow(hFrameWnd, nCmdShow);
    UpdateWindow(hFrameWnd);
    return TRUE;
}
HRESULT CLangBarItemButton::_GetIcon(HICON *phIcon, BOOL bNT62)
{
    size_t iconindex = 0;
    WORD iconid = 0;

    if(!_pTextService->_IsKeyboardDisabled() && _pTextService->_IsKeyboardOpen())
    {
        switch(_pTextService->inputmode)
        {
        case im_hiragana:
            iconindex = 1;
            break;
        case im_katakana:
            iconindex = 2;
            break;
        case im_katakana_ank:
            iconindex = 3;
            break;
        case im_jlatin:
            iconindex = 4;
            break;
        case im_ascii:
            iconindex = 5;
            break;
        default:
            break;
        }
    }

    if(bNT62)
    {
        if(iconindex < _countof(iconIDZ))
        {
            iconid = iconIDZ[iconindex];
        }
    }
    else
    {
        if(iconindex < _countof(iconIDX))
        {
            iconid = iconIDX[iconindex];
        }
    }

    //DPIを考慮
    HDC hdc = GetDC(nullptr);
    int dpi = GetDeviceCaps(hdc, LOGPIXELSY);
    ReleaseDC(nullptr, hdc);
    int size = MulDiv(16, dpi, 96);

    *phIcon = (HICON)LoadImageW(g_hInst, MAKEINTRESOURCEW(iconid), IMAGE_ICON, size, size, LR_SHARED);

    return (*phIcon != nullptr) ? S_OK : E_FAIL;
}
Example #27
0
INT_PTR CALLBACK
CreateHelpDialogProc(HWND hDlg,
                     UINT message,
                     WPARAM wParam,
                     LPARAM lParam)
{
    HWND hHelp;
    HICON hIcon = NULL;
    WCHAR Buf[1000];

    switch (message)
    {
        case WM_INITDIALOG:
        {
            hIcon = (HICON) LoadImageW(hInstance,
                                       MAKEINTRESOURCE(IDI_SM_ICON),
                                       IMAGE_ICON,
                                       16,
                                       16,
                                       0);

            SendMessageW(hDlg,
                         WM_SETICON,
                         ICON_SMALL,
                         (LPARAM)hIcon);

            hHelp = GetDlgItem(hDlg,
                               IDC_CREATE_HELP);

            LoadStringW(hInstance,
                        IDS_HELP_OPTIONS,
                        Buf,
                        sizeof(Buf) / sizeof(WCHAR));

            SetWindowTextW(hHelp, Buf);

            return TRUE;
        }

        case WM_COMMAND:
        {
            if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
            {
                bHelpOpen = FALSE;
                DestroyIcon(hIcon);
                DestroyWindow(hDlg);
                return TRUE;
            }
            break;
        }
    }

    return FALSE;
}
Example #28
0
HICON AP_Win32App::getSmallIcon(void)
{

	int sy = GetSystemMetrics(SM_CYICON);
	int sx = GetSystemMetrics(SM_CXICON);
	UT_DEBUGMSG(("GetIcon(): system metrics [%d %d]\n",sx,sy));

	if ((sx==16) && (sy==16))
		return LoadIconW(getInstance(), MAKEINTRESOURCEW(AP_RID_ICON_APPLICATION_16));
	else
		return (HICON) LoadImageW(getInstance(), MAKEINTRESOURCEW(AP_RID_ICON_APPLICATION_16), IMAGE_ICON, 0,0,0);
}
Example #29
0
LRESULT CIETabBar::OnIconChange(WPARAM wParam,LPARAM lParam)
{
	WCHAR *pszFilePath = (WCHAR *)lParam;
	PVOID PageID = (PVOID)wParam;

	UpdateTabItemIcon(
		PageID,
		(HICON)LoadImageW(AfxGetInstanceHandle(),pszFilePath,IMAGE_ICON,16,16,LR_LOADFROMFILE)
		);
	delete pszFilePath;

	return 0;
}
Example #30
0
csMenu::csMenu()
  : m_lRefCount()
  , _files()
  , _menuBitmap(NULL)
{
  InterlockedIncrement(&g_lDllRefCount);

  const int iconWidth  = GetSystemMetrics(SM_CXMENUCHECK);
  const int iconHeight = GetSystemMetrics(SM_CYMENUCHECK);
  HICON icon = (HICON)LoadImageW(g_hDllInst,
                                 MAKEINTRESOURCEW(IDI_csMenu), IMAGE_ICON,
                                 iconWidth, iconHeight, 0);
  if( icon != NULL ) {
    _menuBitmap = createBitmapFromIcon(icon, iconWidth, iconHeight);
    DestroyIcon(icon);
  }
}