示例#1
0
int CListIconsChanged(WPARAM wParam,LPARAM lParam)
{
	int i,j;

	for(i=0;i<sizeof(statusModeList)/sizeof(statusModeList[0]);i++)
		ImageList_ReplaceIcon(hCListImages,i+1,LoadSkinnedIcon(skinIconStatusList[i]));
	ImageList_ReplaceIcon(hCListImages,IMAGE_GROUPOPEN, LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN));
	ImageList_ReplaceIcon(hCListImages,IMAGE_GROUPSHUT, LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT));
	for(i=0;i<protoIconIndexCount;i++)
		for(j=0;j<sizeof(statusModeList)/sizeof(statusModeList[0]);j++)
			ImageList_ReplaceIcon(hCListImages,protoIconIndex[i].iIconBase+j,LoadSkinnedProtoIcon(protoIconIndex[i].szProto,statusModeList[j]));
	TrayIconIconsChanged();
	InvalidateRectZ((HWND)CallService(MS_CLUI_GETHWND,0,0),NULL,TRUE);
	return 0;
}
int CJabberProto::LoadAdvancedIcons(int iID)
{
	char *proto = TransportProtoTable[iID].proto;
	char defFile[MAX_PATH] = {0};
	TCHAR Group[255];
	char Uname[255];
	int first=-1;
	HICON empty=LoadSmallIcon(NULL,MAKEINTRESOURCE(102));

	mir_sntprintf(Group, SIZEOF(Group), _T("Status Icons/%s/%S %s"), m_tszUserName, proto, TranslateT("transport"));
	mir_snprintf(defFile, SIZEOF(defFile), "proto_%s.dll",proto);
	if (!hAdvancedStatusIcon)
		hAdvancedStatusIcon=(HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST,0,0);

	mir_cslock lck(m_csModeMsgMutex);
	for (int i=0; i < ID_STATUS_ONTHEPHONE-ID_STATUS_OFFLINE; i++) {
		BOOL needFree;
		int n = skinStatusToJabberStatus[i];
		TCHAR *descr = pcli->pfnGetStatusModeDescription(n+ID_STATUS_OFFLINE, 0);
		mir_snprintf(Uname, SIZEOF(Uname), "%s_Transport_%s_%d", m_szModuleName, proto, n);
		HICON hicon = LoadTransportIcon(defFile,-skinIconStatusToResourceId[i],Uname,Group,descr,-(n+ID_STATUS_OFFLINE),&needFree);
		int index = (m_transportProtoTableStartIndex[iID] == -1)?-1:m_transportProtoTableStartIndex[iID]+n;
		int added = ImageList_ReplaceIcon(hAdvancedStatusIcon,index,hicon?hicon:empty);
		if (first == -1)
			first = added;
		if (hicon && needFree)
			DestroyIcon(hicon);
	}

	if (m_transportProtoTableStartIndex[iID] == -1)
		m_transportProtoTableStartIndex[iID] = first;
	return 0;
}
示例#3
0
void LoadClientIcons()
{

	int i;
	HICON hicon;
	char name[256];
	for (i=0;i<ClientNumber;i++)
	{
		mir_snprintf(name,sizeof(name),"ClientIcons_%s",ClientNames[i]);
		
		if (ClientImageListIdx[i]==0)
		{
		hicon=LoadIconFromExternalFile("clisticons.dll",i+100,TRUE,TRUE,name,Translate("Contact List/Client Icons"),ClientNamesDesc[i],-ClientICOIDX[i]);
        if (!hicon) hicon=LoadIcon(g_hInst, MAKEINTRESOURCE(ClientICOIDX[i]));
		if (hicon) ClientImageListIdx[i]=ImageList_AddIcon(hExtraImageList,hicon );		
		}else
		{
		hicon=LoadIconFromExternalFile("clisticons.dll",i+100,TRUE,FALSE,name, Translate("Contact List/Client Icons"),ClientNamesDesc[i],-ClientICOIDX[i]);			
        if (!hicon) hicon=LoadIcon(g_hInst, MAKEINTRESOURCE(ClientICOIDX[ClientNumber]));
		if (hicon) ClientImageListIdx[i]=ImageList_ReplaceIcon(hExtraImageList,ClientImageListIdx[i],hicon );		
};

	}


}
int OnIconLibIconChanged(WPARAM wParam,LPARAM lParam)
{
	HICON hicon;
	hicon=LoadIconFromExternalFile("clisticons.dll",0,TRUE,FALSE,"Email","Contact List","Email Icon",-IDI_EMAIL);
	ExtraImageIconsIndex[0]=ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[0],hicon );		

	hicon=LoadIconFromExternalFile("clisticons.dll",1,TRUE,FALSE,"Sms","Contact List","Sms Icon",-IDI_SMS);
	ExtraImageIconsIndex[1]=ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[1],hicon );		

	hicon=LoadIconFromExternalFile("clisticons.dll",4,TRUE,FALSE,"Web","Contact List","Web Icon",-IDI_GLOBUS);
	ExtraImageIconsIndex[2]=ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[2],hicon );		

	NotifyEventHooks(ME_SKIN_ICONSCHANGED,0,0);
	pcli->pfnClcBroadcast( INTM_INVALIDATE,0,0);
	return 0;
}
示例#5
0
VOID setFileIcon (HWND hDlg, TCHAR* fileDir, WIN32_FIND_DATA* findData, LVITEM* lvI, HIMAGELIST hIL)
{
	SHFILEINFO shfi;
	if (lstrcmp (findData->cFileName, L"..") == 0)
	{
		HINSTANCE hInst = (HINSTANCE) GetWindowLong (hDlg, GWL_HINSTANCE);
		shfi.hIcon = LoadIcon (hInst, MAKEINTRESOURCE (IDI_ICON1));
		lvI->iImage = ImageList_AddIcon (hIL, shfi.hIcon);
	}
	else
	{
		TCHAR fullPath [FM_MAX_PATH];
		lstrcpy (fullPath, fileDir);
		lstrcat (fullPath, findData->cFileName);
		SHGetFileInfo (fullPath, findData->dwFileAttributes, &shfi, sizeof(SHFILEINFO),
			SHGFI_ICON | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS);
		if (shfi.hIcon == NULL)
		{
			wprintfd (L"Не найдена иконка для файла %s", fullPath);
			return;
		}
		lvI->iImage = ImageList_ReplaceIcon (hIL, -1, shfi.hIcon);
		if (lvI->iImage == -1)
		{
			lvI->iImage = 0;
		}
	}
	DestroyIcon (shfi.hIcon);
	return;
}
static int LoadAdvancedIcons(int iID)
{
	int i;
	char * proto=TransportProtoTable[iID].proto;    
	char * defFile[MAX_PATH]={0};
	char * Group[255];
	char * Uname[255];
	int first=-1;
	HICON empty=LoadSmallIcon(NULL,MAKEINTRESOURCE(102));

	_snprintf((char *)Group, sizeof(Group),"%s/%s/%s %s",Translate("Status Icons"), jabberModuleName, proto, Translate("transport"));
	_snprintf((char *)defFile, sizeof(defFile),"proto_%s.dll",proto);
	if (!hAdvancedStatusIcon)
		hAdvancedStatusIcon=(HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST,0,0);
	
	EnterCriticalSection( &modeMsgMutex );
	for (i=0; i<ID_STATUS_ONTHEPHONE-ID_STATUS_OFFLINE; i++) {
		HICON hicon;        
		BOOL needFree;
		int n=skinStatusToJabberStatus[i];
		char * descr=(char*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,n+ID_STATUS_OFFLINE,0);
		_snprintf((char *)Uname, sizeof(Uname),"%s_Transport_%s_%d",jabberProtoName,proto,n);
		hicon=(HICON)LoadTransportIcon((char*)defFile,-skinIconStatusToResourceId[i],(char*)Uname,(char*)Group,(char*)descr,-(n+ID_STATUS_OFFLINE),&needFree);
		int index=(TransportProtoTable[iID].startIndex==-1)?-1:TransportProtoTable[iID].startIndex+n;
		int added=ImageList_ReplaceIcon(hAdvancedStatusIcon,index,hicon?hicon:empty);          
		if (first==-1) first=added;
		if (hicon && needFree) DestroyIcon(hicon);
	}

	if (TransportProtoTable[iID].startIndex == -1)
		TransportProtoTable[iID].startIndex = first;
	LeaveCriticalSection( &modeMsgMutex );
	return 0;
}
示例#7
0
void LoadProtocolIcons() {
	PROTOCOLDESCRIPTOR **pProtos;
	int i, j, allProtoNum, k;

	CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM) &allProtoNum, (LPARAM) &pProtos);
	g_dat->protoNum  = 0;
	for(i = 0; i < allProtoNum; i++) {
        if (pProtos[i]->type == PROTOTYPE_PROTOCOL) g_dat->protoNum++;
	}

	if (g_dat->protoNames != NULL) {
		for(i = 0; i < g_dat->protoNum; i++) {
			if (g_dat->protoNames[i] != NULL) {
				mir_free(g_dat->protoNames[i]);
			}
		}
		mir_free(g_dat->protoNames);
	}
	g_dat->protoNames = (char **) mir_alloc(sizeof(char*) * g_dat->protoNum);
	if (g_dat->hTabIconList == NULL) {
		g_dat->hTabIconList = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, (g_dat->protoNum + 1) * 12 + 8, 0);
		ImageList_AddIcon_Ex(g_dat->hTabIconList, SKINICON_EVENT_MESSAGE);
		ImageList_AddIcon(g_dat->hTabIconList, g_dat->hIcons[SMF_ICON_TYPING]);
		for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
			ImageList_AddIcon_ProtoEx(g_dat->hTabIconList, NULL, i);
		}

		for(i = j = 0; i < allProtoNum; i++) {
			if (pProtos[i]->type != PROTOTYPE_PROTOCOL) continue;
			g_dat->protoNames[j] = mir_strdup(pProtos[i]->szName);
			for (k = ID_STATUS_OFFLINE; k <= ID_STATUS_OUTTOLUNCH; k++) {
				int id = ImageList_AddIcon_ProtoEx(g_dat->hTabIconList, pProtos[i]->szName, k);
				if (id == -1 ) {
					ImageList_AddIcon_ProtoEx(g_dat->hTabIconList, NULL, ID_STATUS_OFFLINE);
				}
			}
			j++;
		}
	} else {
		int index = 0;
		ImageList_ReplaceIcon_Ex(g_dat->hTabIconList, index++, SKINICON_EVENT_MESSAGE);
		ImageList_ReplaceIcon(g_dat->hTabIconList, index++, g_dat->hIcons[SMF_ICON_TYPING]);
		for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
			ImageList_ReplaceIcon_ProtoEx(g_dat->hTabIconList, index++, NULL, i);
		}

		for(i = j = 0; i < allProtoNum; i++) {
			if (pProtos[i]->type != PROTOTYPE_PROTOCOL) continue;
			g_dat->protoNames[j] = mir_strdup(pProtos[i]->szName);
			for (k = ID_STATUS_OFFLINE; k <= ID_STATUS_OUTTOLUNCH; k++) {
				int id = ImageList_ReplaceIcon_ProtoEx(g_dat->hTabIconList, index++, pProtos[i]->szName, k);
				if (id == -1) {
					ImageList_ReplaceIcon_ProtoEx(g_dat->hTabIconList, index++, NULL, ID_STATUS_OFFLINE);
 				}
			}
			j++;
		}
	}

}
示例#8
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;
}
示例#9
0
MIR_APP_DLL(int) Menu_ModifyItem(HGENMENU hMenuItem, const TCHAR *ptszName, HANDLE hIcolib, int iFlags)
{
	if (!bIsGenMenuInited)
		return -1;

	mir_cslock lck(csMenuHook);

	TMO_IntMenuItem *pimi = MO_GetIntMenuItem(hMenuItem);
	if (pimi == NULL)
		return -1;

	if (ptszName != NULL)
		replaceStrT(pimi->mi.name.t, ptszName);

	if (iFlags != -1) {
		// we allow to set only first 3 bits
		int oldflags = (pimi->mi.flags & 0xFFFFFFF8);
		pimi->mi.flags = (iFlags & 0x07) | oldflags;
	}

	if (hIcolib != INVALID_HANDLE_VALUE && !bIconsDisabled) {
		HANDLE hIcolibItem = IcoLib_IsManaged((HICON)hIcolib);
		if (hIcolibItem) {
			HICON hIcon = IcoLib_GetIconByHandle(hIcolibItem, false);
			if (hIcon != NULL) {
				pimi->hIcolibItem = hIcolibItem;
				pimi->iconId = ImageList_ReplaceIcon(pimi->parent->m_hMenuIcons, pimi->iconId, hIcon);
				IcoLib_ReleaseIcon(hIcon);
			}
			else pimi->iconId = -1, pimi->hIcolibItem = NULL;
		}
		else {
			pimi->mi.hIcon = (HICON)hIcolib;
			if (hIcolib != NULL)
				pimi->iconId = ImageList_ReplaceIcon(pimi->parent->m_hMenuIcons, pimi->iconId, (HICON)hIcolib);
			else
				pimi->iconId = -1;	  //fixme, should remove old icon & shuffle all iconIds
		}
		if (pimi->hBmp) {
			DeleteObject(pimi->hBmp);
			pimi->hBmp = NULL;
		}
	}

	return 0;
}
示例#10
0
 void ImageList::replace ( const Icon& image, int index )
 {
     const ::BOOL result = ImageList_ReplaceIcon(
         handle(), index, image.handle()
         );
     if ( result == FALSE ) {
         UNCHECKED_WIN32C_ERROR(ImageList_ReplaceIcon,0);
     }
 }
示例#11
0
bool IconList::changeIcon(int index, const TCHAR *iconLocation) const
{
	HBITMAP hBmp = (HBITMAP)::LoadImage(_hInst, iconLocation, IMAGE_ICON, _iconSize, _iconSize, LR_LOADFROMFILE | LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
	if (!hBmp)
		return false;
	int i = ImageList_ReplaceIcon(_hImglst, index, (HICON)hBmp);
	ImageList_AddMasked(_hImglst, (HBITMAP)hBmp, RGB(255,0,255));
	::DeleteObject(hBmp);
	return (i == index);
}
示例#12
0
// Replaces a bitmap and mask from an icon.
bool wxImageList::Replace(int i, const wxIcon& icon)
{
    bool ok = ImageList_ReplaceIcon(GetHImageList(), i, GetHiconOf(icon)) != -1;
    if ( !ok )
    {
        wxLogLastError(wxT("ImageList_ReplaceIcon()"));
    }

    return ok;
}
示例#13
0
int HIDPI_ImageList_ReplaceIcon(HIMAGELIST himl, int i, HICON hicon)
{
    int iRet;
    int cxIcon, cyIcon;
    HICON hiconStretched;

    ImageList_GetIconSize(himl, &cxIcon, &cyIcon);
    HIDPI_StretchIcon_Internal(hicon, &hiconStretched, cxIcon, cyIcon);
    if (hiconStretched != NULL)
    {
        iRet = ImageList_ReplaceIcon(himl, i, hiconStretched);
        DestroyIcon(hiconStretched);
    }
    else
    {
        iRet = ImageList_ReplaceIcon(himl, i, hicon);
    }

    return iRet;
}
示例#14
0
int OnIconLibIconChanged(WPARAM wParam,LPARAM lParam)
{
	HICON hicon;
				hicon=LoadIconFromExternalFile("clisticons.dll",0,TRUE,FALSE,"Email","Contact List",Translate("Email Icon"),-IDI_EMAIL);
				ExtraImageIconsIndex[0]=ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[0],hicon );		

				hicon=LoadIconFromExternalFile("clisticons.dll",1,TRUE,FALSE,"Sms","Contact List",Translate("Sms Icon"),-IDI_SMS);
				ExtraImageIconsIndex[1]=ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[1],hicon );		

				hicon=LoadIconFromExternalFile("clisticons.dll",4,TRUE,FALSE,"Web","Contact List",Translate("Web Icon"),-IDI_GLOBUS);
				ExtraImageIconsIndex[2]=ImageList_ReplaceIcon(hExtraImageList,ExtraImageIconsIndex[2],hicon );		
				
				LoadClientIcons();
				
				CListIconsChanged(wParam,lParam);
				CluiIconsChanged(wParam,lParam);
				ClcIconsChanged(wParam,lParam);
				NotifyEventHooks(ME_SKIN_ICONSCHANGED,0,0);
				return 0;
};
示例#15
0
int static OnIconLibIconChanged(WPARAM wParam, LPARAM lParam)
{
	HICON hicon = LoadIconFromExternalFile("clisticons.dll",2,TRUE,FALSE,"NewGroup","Contact list","New Group",-IDI_NEWGROUP,0);
	NewGroupIconidx = ImageList_ReplaceIcon(hCListImages,NewGroupIconidx,hicon);

	CLISTMENUITEM mi = { sizeof(mi) };
	mi.flags = CMIM_ICON;
	mi.hIcon = ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
	Menu_ModifyItem(hNewSubGroupMenuItem, &mi);
	Menu_ModifyItem(hNewGroupMenuItem, &mi);
	return 0;
}
示例#16
0
static int MO_ReloadIcon(TMO_IntMenuItem *pmi, void*)
{
	if (pmi->hIcolibItem) {
		HICON newIcon = IcoLib_GetIconByHandle(pmi->hIcolibItem, false);
		if (newIcon)
			ImageList_ReplaceIcon(pmi->parent->m_hMenuIcons, pmi->iconId, newIcon);

		IcoLib_ReleaseIcon(newIcon);
	}

	return FALSE;
}
void MM_IconsChanged(void)
{
	MODULEINFO *pTemp = m_ModList, *pLast = NULL;
	ImageList_ReplaceIcon(hIconsList, 0, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE));
	ImageList_ReplaceIcon(hIconsList, 1, LoadIconEx( "overlay", FALSE ));
	while (pTemp != NULL)
	{
		pTemp->OnlineIconIndex = ImageList_ReplaceIcon(hIconsList, pTemp->OnlineIconIndex, LoadSkinnedProtoIcon(pTemp->pszModule, ID_STATUS_ONLINE));
		pTemp->OfflineIconIndex = ImageList_ReplaceIcon(hIconsList, pTemp->OfflineIconIndex, LoadSkinnedProtoIcon(pTemp->pszModule, ID_STATUS_OFFLINE));

		if (pTemp->hOfflineIcon)
			DestroyIcon(pTemp->hOfflineIcon);
		if (pTemp->hOnlineIcon)
			DestroyIcon(pTemp->hOnlineIcon);
		if (pTemp->hOnlineTalkIcon)
			DestroyIcon(pTemp->hOnlineTalkIcon);
		if (pTemp->hOfflineTalkIcon)
			DestroyIcon(pTemp->hOfflineTalkIcon);
		pTemp->hOfflineIcon = ImageList_GetIcon(hIconsList, pTemp->OfflineIconIndex, ILD_TRANSPARENT);
		pTemp->hOnlineIcon = ImageList_GetIcon(hIconsList, pTemp->OnlineIconIndex, ILD_TRANSPARENT);

		pTemp->hOnlineTalkIcon = ImageList_GetIcon(hIconsList, pTemp->OnlineIconIndex, ILD_TRANSPARENT|INDEXTOOVERLAYMASK(1));
		ImageList_ReplaceIcon(hIconsList, pTemp->OnlineIconIndex+1, pTemp->hOnlineTalkIcon);

		pTemp->hOfflineTalkIcon = ImageList_GetIcon(hIconsList, pTemp->OfflineIconIndex, ILD_TRANSPARENT|INDEXTOOVERLAYMASK(1));
		ImageList_ReplaceIcon(hIconsList, pTemp->OfflineIconIndex+1, pTemp->hOfflineTalkIcon);

		pLast = pTemp;
		pTemp = pTemp->next;
	}
	return;
}
示例#18
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;
}
示例#19
0
/**
 * name:	OnIconsChanged
 * class:	CPsTreeItem
 * desc:	Handles reloading icons if changed by icolib
 * params:	none
 * return:	nothing
 **/
void CPsTreeItem::OnIconsChanged(CPsTree *pTree)
{
	HICON hIcon;
	RECT rc;

	// update tree item icons
	if (pTree->ImageList() && (hIcon = IcoLib_GetIcon(IconKey())) != NULL) {
		_iImage = (_iImage > 0)
			? ImageList_ReplaceIcon(pTree->ImageList(), _iImage, hIcon)
			: ImageList_AddIcon(pTree->ImageList(), hIcon);
		
		if (_hItem && TreeView_GetItemRect(pTree->Window(), _hItem, &rc, 0))
			InvalidateRect(pTree->Window(), &rc, TRUE);
	}
	// update pages icons
	OnPageIconsChanged();
}
示例#20
0
int static OnIconLibIconChanged(WPARAM wParam,LPARAM lParam)
{
    HICON hicon;
    CLISTMENUITEM clmi= {0};

    //hicon=LoadIconFromExternalFile("clisticons.dll",2,TRUE,FALSE,"NewGroup","Contact List","New Group",-IDI_NEWGROUP);
    NewGroupIconidx=ImageList_ReplaceIcon(hCListImages,NewGroupIconidx,hicon);

    clmi.cbSize=sizeof(clmi);
    clmi.flags=CMIM_ICON;
    clmi.hIcon=ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
    CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hNewSubGroupMenuItem,(LPARAM)&clmi);
    CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hNewGroupMenuItem,(LPARAM)&clmi);
    //


    return 0;
};
示例#21
0
int static OnIconLibIconChanged(WPARAM wParam,LPARAM lParam)
{
	HICON hicon;
	CLISTMENUITEM clmi={0};
	BOOL needFree;
    if (MirandaExiting()) return 0;
	hicon=CLUI_LoadIconFromExternalFile("clisticons.dll",2,TRUE,FALSE,"NewGroup","Contact List","New Group",-IDI_NEWGROUP2,&needFree);
	NewGroupIconidx=ImageList_ReplaceIcon(hCListImages,NewGroupIconidx,hicon);	
	if (needFree) DestroyIcon_protect(hicon);
	clmi.cbSize=sizeof(clmi);
	clmi.flags=CMIM_ICON;
	clmi.hIcon=ske_ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
	CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hNewSubGroupMenuItem,(LPARAM)&clmi);
	CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hNewGroupMenuItem,(LPARAM)&clmi);
	//
	

	return 0;
};
示例#22
0
/*
* supLoadImageList
*
* Purpose:
*
* Create and load image list from icon resource type.
*
*/
HIMAGELIST supLoadImageList(
	HINSTANCE hInst,
	UINT FirstId,
	UINT LastId
	)
{
	UINT i;
	HIMAGELIST list;
	HICON hIcon;
	list = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 42, 8);
	if (list) {
		for (i = FirstId; i <= LastId; i++) {
			hIcon = LoadImage(hInst, MAKEINTRESOURCE(i), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
			if (hIcon) {
				ImageList_ReplaceIcon(list, -1, hIcon);
				DestroyIcon(hIcon);
			}
		}
	}
	return list;
}
示例#23
0
//-----------------------------------------------------------------------------
// Name: ReplaceIcon
// Object: change icon of a button
// Parameters :
//     in  : CToolbar::ImageListType ImgListType : image liste CToolbar::ImageListTypeXXX
//           int ButtonID : button id
//           int IdNewIcon : resource icon id
//     out :
//     return : TRUE on success, FALSE on error
//-----------------------------------------------------------------------------
BOOL CToolbar::ReplaceIcon(int ButtonID,CToolbar::ImageListType ImgListType,int IdNewIcon)
{
    HIMAGELIST hImgL;
    HICON hicon;

    // get image list
    if (ImgListType==CToolbar::ImageListTypeEnable)
        hImgL=this->hImgList;
    else if (ImgListType==CToolbar::ImageListTypeDisable)
        hImgL=this->hImgListDisabled;
    else if (ImgListType==CToolbar::ImageListTypeHot)
        hImgL=this->hImgListHot;
    else
        return FALSE;


    // retrieve image index
    TBBUTTONINFO  ButtonInfo={0};
    ButtonInfo.dwMask=TBIF_IMAGE;
    ButtonInfo.cbSize=sizeof(TBBUTTONINFO);
    if (SendMessage( this->hwndTB,(UINT) TB_GETBUTTONINFO,(WPARAM) ButtonID,(LPARAM) &ButtonInfo)==-1)
        return FALSE;


    // load icon
    hicon=(HICON)LoadImage(this->hInstance, MAKEINTRESOURCE(IdNewIcon),IMAGE_ICON,0,0,LR_SHARED);
    if (!hicon)
        return FALSE;

    // replace icon
    if(ImageList_ReplaceIcon(hImgL,ButtonInfo.iImage,hicon)==-1)
        return FALSE;


    // force item to be redrawn
    RedrawWindow( this->hwndTB,NULL,NULL,RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN);

    return TRUE;

}
示例#24
0
//wparam MenuItemHandle
//lparam PMO_MenuItem
int MO_ModifyMenuItem(WPARAM wParam,LPARAM lParam)
{
	PMO_MenuItem pmiparam=(PMO_MenuItem)lParam;
	PMO_IntMenuItem pimi;
	int oldflags;
	int objidx;

	if (!isGenMenuInited) return -1;
	if (pmiparam==NULL){return(-1);}
	lockmo();
	pimi=MO_GetIntMenuItem(wParam);
	if (pimi==NULL){unlockmo();return(-1);}
	if (pmiparam->cbSize!=sizeof(TMO_MenuItem)){unlockmo();return(-1);}
	objidx=GetObjIdxByItemId(pimi->id);
	if (objidx==-1){unlockmo();return(-1);}

	if (pmiparam->flags&CMIM_NAME) {
		FreeAndNil(&pimi->mi.pszName);
		pimi->mi.pszName = mir_tstrdup(pmiparam->pszName);
	}
	if (pmiparam->flags&CMIM_FLAGS) {
		oldflags=(pimi->mi.flags&CMIF_ROOTPOPUP)|(pimi->mi.flags&CMIF_CHILDPOPUP);
		pimi->mi.flags=pmiparam->flags&~CMIM_ALL;
		pimi->mi.flags|=oldflags;
	}
	if (pmiparam->flags&CMIM_ICON) {
		pimi->mi.hIcon=pmiparam->hIcon;
		if (pmiparam->hIcon!=NULL) pimi->iconId=ImageList_ReplaceIcon(MenuObjects[objidx].hMenuIcons,pimi->iconId,pmiparam->hIcon);
		else pimi->iconId=-1;	  //fixme, should remove old icon & shuffle all iconIds
	}
	if (pmiparam->flags&CMIM_HOTKEY) {
		pimi->mi.hotKey=pmiparam->hotKey;
	}
	if (pmiparam->flags&CMIM_HOTKEY) {
		pimi->mi.hotKey=pmiparam->hotKey;
	}
	unlockmo();
	return(0);
}
示例#25
0
// Replaces a bitmap and mask from an icon.
bool wxImageList::Replace(int i, const wxIcon& icon)
{
    // ComCtl32 prior 6.0 doesn't support images with alpha
    // channel so if we have 32-bit icon with transparency
    // we need to replace it as a wxBitmap via dedicated method
    // where alpha channel will be converted to the mask.
    if ( wxApp::GetComCtl32Version() < 600 )
    {
        wxBitmap bmp(icon);
        if ( bmp.HasAlpha() )
        {
            return Replace(i, bmp);
        }
    }

    bool ok = ImageList_ReplaceIcon(GetHImageList(), i, GetHiconOf(icon)) != -1;
    if ( !ok )
    {
        wxLogLastError(wxT("ImageList_ReplaceIcon()"));
    }

    return ok;
}
示例#26
0
文件: tabs.cpp 项目: pezcode/FireFly
bool SetTabIcon(HWND TabWindow, int Index, HICON Icon)
{
	assert(IsWindow(TabWindow));
	assert(Index >= 0);
	assert(Index < TabCtrl_GetItemCount(TabWindow));

	HIMAGELIST ImageList = TabCtrl_GetImageList(TabWindow);
	if(!ImageList) // Create a new image list
	{
		ImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 1);
		TabCtrl_SetImageList(TabWindow, ImageList);
	}

	TC_ITEM TabData;
	TabData.mask = TCIF_IMAGE;

	if(TabCtrl_GetItem(TabWindow, Index, &TabData))
	{
		if(Icon) // Add icon
		{
			if(TabData.iImage == -1) // There is no icon yet
				TabData.iImage = ImageList_AddIcon(ImageList, Icon);
			else
				TabData.iImage = ImageList_ReplaceIcon(ImageList, TabData.iImage, Icon);
		}
		else // Remove icon
		{
			if(TabData.iImage != -1) // Skip if there is no icon
			{
				TabCtrl_RemoveImage(TabWindow, TabData.iImage);
				TabData.iImage = -1;
			}
		}
		return TabCtrl_SetItem(TabWindow, Index, &TabData);
	}
	return false;
}
示例#27
0
INT_PTR CSteamProto::OnRequestAdvStatusIconIdx(WPARAM wParam, LPARAM)
{
	int status = GetContactXStatus(wParam);
	if (status)
	{
		if (std::find(xstatusIconsValid.begin(), xstatusIconsValid.end(), status) == xstatusIconsValid.end())
		{
			// adding/updating icon
			HIMAGELIST clistImageList = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0);
			if (clistImageList)
			{
				HICON hXStatusIcon = GetXStatusIcon(status, LR_SHARED);

				std::map<int, int>::iterator it = xstatusIcons.find(status);
				if (it != xstatusIcons.end() && it->second > 0)
					ImageList_ReplaceIcon(clistImageList, it->first, hXStatusIcon);
				else
					xstatusIcons.insert(std::make_pair(status, ImageList_AddIcon(clistImageList, hXStatusIcon)));

				// mark icon index in the array as valid
				xstatusIconsValid.push_back(status);

				IcoLib_ReleaseIcon(hXStatusIcon);
			}
		}

		if (std::find(xstatusIconsValid.begin(), xstatusIconsValid.end(), status) != xstatusIconsValid.end())
		{
			std::map<int, int>::iterator it = xstatusIcons.find(status);
			if (it != xstatusIcons.end())
				return ((INT_PTR) it->second & 0xFFFF) << 16;
		}
	}

	return -1;
}
示例#28
0
/*
* DesktopListCreate
*
* Purpose:
*
* Initialize listview for desktop list.
* Called once.
*
*/
VOID DesktopListCreate(
	_In_ HWND hwndDlg
	)
{
	LVCOLUMNW	col;
	HANDLE		tmpb;

	DesktopList = GetDlgItem(hwndDlg, ID_DESKTOPSLIST);
	if (DesktopList == NULL)
		return;

	DesktopImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 8, 8);
	if (DesktopImageList) {

		//desktop image
		tmpb = LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_DESKTOP), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
		if (tmpb) {
			ImageList_ReplaceIcon(DesktopImageList, -1, tmpb);
			DestroyIcon(tmpb);
		}

		//sort images
		tmpb = LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_SORTUP), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
		if (tmpb) {
			ImageList_ReplaceIcon(DesktopImageList, -1, tmpb);
			DestroyIcon(tmpb);
		}
		tmpb = LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_SORTDOWN), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
		if (tmpb) {
			ImageList_ReplaceIcon(DesktopImageList, -1, tmpb);
			DestroyIcon(tmpb);
		}

		ListView_SetImageList(DesktopList, DesktopImageList, LVSIL_SMALL);
	}

	ListView_SetExtendedListViewStyle(DesktopList, 
		LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_GRIDLINES | LVS_EX_LABELTIP);

	RtlSecureZeroMemory(&col, sizeof(col));
	col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT | LVCF_WIDTH | LVCF_ORDER | LVCF_IMAGE;
	col.iSubItem = 1;
	col.pszText = L"Name";
	col.fmt = LVCFMT_LEFT | LVCFMT_BITMAP_ON_RIGHT;
	col.iOrder = 0;
	col.iImage = 2;
	col.cx = 200;
	ListView_InsertColumn(DesktopList, 1, &col);

	col.iSubItem = 2;
	col.pszText = L"SID";
	col.iOrder = 1;
	col.iImage = -1;
	col.cx = 100;
	ListView_InsertColumn(DesktopList, 2, &col);

	col.iSubItem = 3;
	col.pszText = L"Heap Size";
	col.iOrder = 2;
	col.iImage = -1;
	col.cx = 100;
	ListView_InsertColumn(DesktopList, 3, &col);
}
示例#29
0
int CIconList::CreateTabIconInt(LPCWSTR asIconDescr, bool bAdmin, LPCWSTR asWorkDir)
{
	wchar_t* pszExpanded = ExpandEnvStr(asIconDescr);

	// Need to be created!
	int iIconIdx = -1;
	HICON hFileIcon = NULL;
	wchar_t szTemp[MAX_PATH];
	LPCWSTR pszLoadFile = pszExpanded ? pszExpanded : asIconDescr;
	LPCWSTR lpszExt = (wchar_t*)PointToExt(pszLoadFile);

	bool bDirChanged = false;
	if (asWorkDir && *asWorkDir)
	{
		// Executable (or icon) file may be not availbale by %PATH%, let "cd" to it...
		bDirChanged = gpConEmu->ChangeWorkDir(asWorkDir);
	}

	if (!lpszExt)
	{
		LPWSTR pszFile = NULL;
		if (SearchPath(NULL, pszLoadFile, L".exe", countof(szTemp), szTemp, &pszFile))
		{
			pszLoadFile = szTemp;
			lpszExt = (wchar_t*)PointToExt(pszLoadFile);
		}

		if (!lpszExt)
			goto wrap;
	}

	if (lstrcmpi(lpszExt, L".ico") == 0)
	{
		hFileIcon = (HICON)LoadImage(0, pszLoadFile, IMAGE_ICON, mn_CxIcon, mn_CyIcon, LR_DEFAULTCOLOR|LR_LOADFROMFILE);
	}
	else if ((lstrcmpi(lpszExt, L".exe") == 0) || (lstrcmpi(lpszExt, L".dll") == 0))
	{
		//TODO: May be specified index of an icon in the file
		HICON hIconLarge = NULL, hIconSmall = NULL;
		ExtractIconEx(pszLoadFile, 0, &hIconLarge, &hIconSmall, 1);
		bool bUseLargeIcon = ((mn_CxIcon > 16) && (hIconLarge != NULL)) || (hIconSmall == NULL);
		HICON hDestroyIcon = bUseLargeIcon ? hIconSmall : hIconLarge;
		if (hDestroyIcon) DestroyIcon(hDestroyIcon);
		hFileIcon = bUseLargeIcon ? hIconLarge : hIconSmall;
	}
	else
	{
		//TODO: Shell icons for registered files (cmd, bat, sh, pl, py, ...)
	}

	if (hFileIcon)
	{
		wchar_t szIconInfo[80] = L"", szMergedInfo[80] = L"";
		GetIconInfoStr(hFileIcon, szIconInfo);

		if (gpSetCls->isAdvLogging)
		{
			CEStr lsLog(lstrmerge(L"Icon `", asIconDescr, L"` was loaded: ", szIconInfo));
			gpConEmu->LogString(lsLog);
		}

		int iIconIdxAdm = -1;
		iIconIdx = ImageList_ReplaceIcon(mh_TabIcons, -1, hFileIcon);

		TabIconCache NewIcon = {lstrdup(asIconDescr), iIconIdx, false};
		m_Icons.push_back(NewIcon);

		if (mn_AdminIcon >= 0)
		{
			HIMAGELIST hAdmList = ImageList_Merge(mh_TabIcons, iIconIdx, mh_TabIcons, mn_AdminIcon+2, 0,0);
			if (hAdmList)
			{
				HICON hNewIcon = ImageList_GetIcon(hAdmList, 0, ILD_TRANSPARENT);
				if (hNewIcon)
				{
					CEStr lsLog(lstrmerge(L"Admin icon `", asIconDescr, L"` was created: ", GetIconInfoStr(hNewIcon, szMergedInfo)));
					gpConEmu->LogString(lsLog);

					iIconIdxAdm = ImageList_ReplaceIcon(mh_TabIcons, -1, hNewIcon);
					DestroyIcon(hNewIcon);

					TabIconCache AdmIcon = {lstrdup(asIconDescr), iIconIdxAdm, true};
					m_Icons.push_back(AdmIcon);

					if (bAdmin && (iIconIdxAdm > 0))
					{
						iIconIdx = iIconIdxAdm;
					}
				}
				else
				{
					gpConEmu->LogString(L"GetIcon for admin icon was failed");
				}
				ImageList_Destroy(hAdmList);
			}
			else
			{
				gpConEmu->LogString(L"Admin icon merging was failed");
			}
		}

		DestroyIcon(hFileIcon);
	}

wrap:
	if (bDirChanged)
	{
		gpConEmu->ChangeWorkDir(NULL);
	}
	SafeFree(pszExpanded);
	if (gpSetCls->isAdvLogging && (iIconIdx < 0))
	{
		CEStr lsLog(lstrmerge(L"Icon `", asIconDescr, L"` loading was failed"));
		gpConEmu->LogString(lsLog);
	}
	return iIconIdx;
}
示例#30
0
int ImageList_ReplaceIcon_ProtoEx(HIMAGELIST hIml, int nIndex, const char* szProto, int status) {
	HICON hIcon = LoadSkinnedProtoIcon(szProto, status);
	int res = ImageList_ReplaceIcon(hIml, nIndex, hIcon);
 	CallService(MS_SKIN2_RELEASEICON,(WPARAM)hIcon, 0);
 	return res;
}