示例#1
0
int ImageList_AddIcon_NotShared(HIMAGELIST hIml, LPCTSTR szResource)
{
	HICON hTempIcon=LoadIconEx( hMirandaInst, szResource, 0);
	int res = ImageList_AddIcon(hIml, hTempIcon);
	Safe_DestroyIcon(hTempIcon);
	return res;
}
示例#2
0
int ImageList_ReplaceIcon_NotShared(HIMAGELIST hIml, int iIndex, HINSTANCE hInstance, LPCTSTR szResource)
{
	HICON hTempIcon = LoadIconEx(hInstance, szResource, 0);
	int res = ImageList_ReplaceIcon(hIml, iIndex, hTempIcon);
	Safe_DestroyIcon(hTempIcon);
	return res;
}
示例#3
0
static int MO_RegisterIcon(TMO_IntMenuItem *pmi, void*)
{
	TCHAR *uname = (pmi->UniqName) ? mir_a2t(pmi->UniqName) : mir_tstrdup(pmi->CustomName),
		*descr = GetMenuItemText(pmi);

	if (!uname && !descr)
		return FALSE;

	if (!pmi->hIcolibItem) {
		HICON hIcon = ImageList_GetIcon(pmi->parent->m_hMenuIcons, pmi->iconId, 0);

		TCHAR sectionName[256];
		mir_sntprintf(sectionName, LPGENT("Menu icons") _T("/%s"), TranslateTS(pmi->parent->ptszDisplayName));

		char iconame[256];
		mir_snprintf(iconame, "genmenu_%s_%s", pmi->parent->pszName, uname && *uname ? uname : descr);

		// remove '&'
		if (descr) {
			descr = NEWTSTR_ALLOCA(descr);

			for (TCHAR *p = descr; *p; p++) {
				if ((p = _tcschr(p, '&')) == NULL)
					break;

				memmove(p, p + 1, sizeof(TCHAR)*(mir_tstrlen(p + 1) + 1));
				if (*p == '\0')
					p++;
			}
		}

		SKINICONDESC sid = { 0 };
		sid.flags = SIDF_TCHAR;
		sid.section.t = sectionName;
		sid.pszName = iconame;
		sid.description.t = descr;
		sid.hDefaultIcon = hIcon;
		pmi->hIcolibItem = IcoLib_AddIcon(&sid, 0);

		Safe_DestroyIcon(hIcon);
		if (hIcon = IcoLib_GetIcon(iconame)) {
			ImageList_ReplaceIcon(pmi->parent->m_hMenuIcons, pmi->iconId, hIcon);
			IcoLib_ReleaseIcon(hIcon);
		}
	}

	mir_free(uname);
	return FALSE;
}
示例#4
0
static int MO_RegisterIcon( PMO_IntMenuItem pmi, void* )
{
	char *uname, *descr;
	uname = pmi->UniqName;
	if ( uname == NULL )
		#ifdef UNICODE
			uname = mir_u2a(pmi->CustomName);
			descr = mir_u2a(pmi->mi.ptszName);
		#else
			uname = pmi->CustomName;
			descr = pmi->mi.pszName;
		#endif

	if ( !uname && !descr )
		return FALSE;

	if ( !pmi->hIcolibItem ) {
		HICON hIcon = ImageList_GetIcon( pmi->parent->m_hMenuIcons, pmi->iconId, 0 );
		char* buf = NEWSTR_ALLOCA( descr );

		char sectionName[256], iconame[256];
		mir_snprintf( sectionName, sizeof(sectionName), "Menu Icons/%s", pmi->parent->Name );

		// remove '&'
		char* start = buf;
		while ( start ) {
			if (( start = strchr( start, '&' )) == NULL )
				break;

			memmove(start,start+1,strlen(start+1)+1);
			if (*start!='\0') start++;
			else break;
		}

		mir_snprintf(iconame, sizeof(iconame), "genmenu_%s_%s", pmi->parent->Name, uname && *uname ? uname : descr);

		SKINICONDESC sid={0};
		sid.cbSize = sizeof(sid);
		sid.cx = 16;
		sid.cy = 16;
		sid.pszSection = sectionName;
		sid.pszName = iconame;
		sid.pszDefaultFile = NULL;
		sid.pszDescription = buf;
		sid.hDefaultIcon = hIcon;
		pmi->hIcolibItem = ( HANDLE )CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);

		Safe_DestroyIcon( hIcon );
		if ( hIcon = ( HICON )CallService( MS_SKIN2_GETICON, 0, (LPARAM)iconame )) {
			ImageList_ReplaceIcon( pmi->parent->m_hMenuIcons, pmi->iconId, hIcon );
			IconLib_ReleaseIcon( hIcon, 0 );
	}	}

	#ifdef UNICODE
		if ( !pmi->UniqName )
			mir_free( uname );
		mir_free( descr );
	#endif

	return FALSE;
}