void __stdcall ShowPopup( const char* line1, const char* line2, int flags ) { if(CallService(MS_SYSTEM_TERMINATED, 0, 0)) return; if ( !ServiceExists( MS_POPUP_ADDPOPUP )) { MessageBox( NULL, line2, PROTO " Message", MB_OK | MB_ICONINFORMATION ); return; } POPUPDATAEX* ppd = ( POPUPDATAEX* )calloc( sizeof( POPUPDATAEX ), 1 ); ppd->lchContact = NULL; ppd->lchIcon = (flags ? LoadSkinnedProtoIcon(PROTO, options.rstatus) : LoadSkinnedProtoIcon(PROTO, options.nrstatus)); strcpy( ppd->lpzContactName, line1 ); strcpy( ppd->lpzText, line2 ); ppd->colorBack = GetSysColor( COLOR_BTNFACE ); ppd->colorText = GetSysColor( COLOR_WINDOWTEXT ); ppd->iSeconds = 10; ppd->PluginWindowProc = ( WNDPROC )NullWindowProc; ppd->PluginData = NULL; QueueUserAPC( sttMainThreadCallback , mainThread, ( ULONG )ppd ); }
void LoadModuleIcons(MODULEINFO * mi) { mi->OnlineIconIndex = ImageList_AddIcon(g_dat->hTabIconList, LoadSkinnedProtoIcon(mi->pszModule, ID_STATUS_ONLINE)); mi->hOnlineIcon = ImageList_GetIcon(g_dat->hTabIconList, mi->OnlineIconIndex, ILD_TRANSPARENT); mi->hOnlineTalkIcon = ImageList_GetIcon(g_dat->hTabIconList, mi->OnlineIconIndex, ILD_TRANSPARENT|INDEXTOOVERLAYMASK(1)); ImageList_AddIcon(g_dat->hTabIconList, mi->hOnlineTalkIcon); mi->OfflineIconIndex = ImageList_AddIcon(g_dat->hTabIconList, LoadSkinnedProtoIcon(mi->pszModule, ID_STATUS_OFFLINE)); mi->hOfflineIcon = ImageList_GetIcon(g_dat->hTabIconList, mi->OfflineIconIndex, ILD_TRANSPARENT); mi->hOfflineTalkIcon = ImageList_GetIcon(g_dat->hTabIconList, mi->OfflineIconIndex, ILD_TRANSPARENT|INDEXTOOVERLAYMASK(1)); ImageList_AddIcon(g_dat->hTabIconList, mi->hOfflineTalkIcon); }
void ShowPopup(SHOWPOPUP_DATA *sd) { TCString PopupText; if (sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_SHOWPREVCLIENT)) { mir_sntprintf(PopupText.GetBuffer(MAX_MSG_LEN), MAX_MSG_LEN, TranslateT("changed client to %s (was %s)"), (const TCHAR*)sd->MirVer, (const TCHAR*)sd->OldMirVer); PopupText.ReleaseBuffer(); } else { mir_sntprintf(PopupText.GetBuffer(MAX_MSG_LEN), MAX_MSG_LEN, TranslateT("changed client to %s"), (const TCHAR*)sd->MirVer); PopupText.ReleaseBuffer(); } PLUGIN_DATA *pdata = (PLUGIN_DATA*)calloc(1, sizeof(PLUGIN_DATA)); POPUPDATAT ppd = {0}; ppd.lchContact = sd->hContact; char *szProto = GetContactProto(sd->hContact); pdata->hIcon = ppd.lchIcon = Finger_GetClientIcon(sd->MirVer, false); _ASSERT(ppd.lchIcon); if (!ppd.lchIcon || (DWORD)ppd.lchIcon == CALLSERVICE_NOTFOUND) { // if we didn't succeed retrieving client icon, show the usual status icon instead ppd.lchIcon = LoadSkinnedProtoIcon(szProto, db_get_w(sd->hContact, szProto, "Status", ID_STATUS_OFFLINE)); pdata->hIcon = NULL; } _tcsncpy(ppd.lptzContactName, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)sd->hContact, GCDNF_TCHAR), lengthof(ppd.lptzContactName) - 1); _tcsncpy(ppd.lptzText, PopupText, lengthof(ppd.lptzText) - 1); ppd.colorBack = (sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_DEFBGCOLOUR) ? 0 : sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_BGCOLOUR)); ppd.colorText = (sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_DEFTEXTCOLOUR) ? 0 : sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_TEXTCOLOUR)); ppd.PluginWindowProc = PopupWndProc; pdata->PopupLClickAction = sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_LCLICK_ACTION); pdata->PopupRClickAction = sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_RCLICK_ACTION); ppd.iSeconds = sd->PopupOptPage->GetValue(IDC_POPUPOPTDLG_POPUPDELAY); ppd.PluginData = pdata; PUAddPopupT(&ppd); }
static HICON LoadTransportIcon(char *filename,int i,char *IconName,TCHAR *SectName,TCHAR *Description,int internalidx, BOOL * needFree) { char szPath[MAX_PATH],szMyPath[MAX_PATH], szFullPath[MAX_PATH],*str; BOOL has_proto_icon=FALSE; if (needFree) *needFree=FALSE; GetModuleFileNameA(NULL, szPath, MAX_PATH); str=strrchr(szPath,'\\'); if (str != NULL) *str=0; mir_snprintf(szMyPath, sizeof(szMyPath), "%s\\Icons\\%s", szPath, filename); mir_snprintf(szFullPath, sizeof(szFullPath), "%s\\Icons\\%s,%d", szPath, filename, i); BOOL nf; HICON hi=ExtractIconFromPath(szFullPath,&nf); if (hi) has_proto_icon=TRUE; if (hi && nf) DestroyIcon(hi); if (IconName != NULL && SectName != NULL) { SKINICONDESC sid = { sizeof(sid) }; sid.hDefaultIcon = (has_proto_icon) ? NULL : LoadSkinnedProtoIcon(0, -internalidx); sid.ptszSection = SectName; sid.pszName = IconName; sid.ptszDescription = Description; sid.pszDefaultFile = szMyPath; sid.iDefaultIndex = i; sid.flags = SIDF_TCHAR; Skin_AddIcon(&sid); } return Skin_GetIcon(IconName); }
int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) { HookEvent(ME_CLIST_PREBUILDCONTACTMENU, Meta_ModifyMenu); // hook srmm window close/open events HookEvent(ME_MSG_WINDOWEVENT, Meta_MessageWindowEvent); HookEvent(ME_MSG_ICONPRESSED, Meta_SrmmIconClicked); ////////////////////////////////////////////////////////////////////////////////////// InitMenus(); // create srmm icon StatusIconData sid = { sizeof(sid) }; sid.szModule = META_PROTO; sid.hIcon = LoadSkinnedProtoIcon(META_PROTO, ID_STATUS_ONLINE); Srmm_AddIcon(&sid); // hook protocol nudge events to forward to subcontacts int numberOfProtocols; PROTOACCOUNT ** ppProtocolDescriptors; ProtoEnumAccounts(&numberOfProtocols, &ppProtocolDescriptors); for (int i = 0; i < numberOfProtocols; i++) if (strcmp(ppProtocolDescriptors[i]->szModuleName, META_PROTO)) { char str[MAXMODULELABELLENGTH + 10]; mir_snprintf(str, SIZEOF(str), "%s/Nudge", ppProtocolDescriptors[i]->szModuleName); HookEvent(str, NudgeRecieved); } return 0; }
/** * retrieve the tab/title icon for the corresponding session. */ HICON CContactCache::getIcon(int& iSize) const { HICON hIcon; if(m_dat && m_hwnd) { if (m_dat->dwFlags & MWF_ERRORSTATE) hIcon = PluginConfig.g_iconErr; else if (m_dat->mayFlashTab) hIcon = m_dat->iFlashIcon; else { if (m_dat->si && m_dat->iFlashIcon) { int sizeX, sizeY; hIcon = m_dat->iFlashIcon; Utils::getIconSize(hIcon, sizeX, sizeY); iSize = sizeX; } else if (m_dat->hTabIcon == m_dat->hTabStatusIcon && m_dat->hXStatusIcon) hIcon = m_dat->hXStatusIcon; else hIcon = m_dat->hTabIcon; } } else hIcon = LoadSkinnedProtoIcon(m_szProto, m_wStatus); return(hIcon); }
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; }
int BuildContactMenu(WPARAM wparam,LPARAM) { int id = -1, isetting; MCONTACT hContact = (MCONTACT)wparam; char *szProto = GetContactProto(hContact); CLISTMENUITEM cmi = { sizeof(cmi) }; if (!IsWatchedProtocol(szProto) || !db_get_b(NULL,S_MOD,"MenuItem",1)) cmi.flags = CMIM_FLAGS | CMIF_HIDDEN | CMIF_TCHAR; else { cmi.flags = CMIM_NAME | CMIM_FLAGS | CMIM_ICON | CMIF_TCHAR; cmi.hIcon = NULL; DBVARIANT dbv; if ( !db_get_ts(NULL, S_MOD, "MenuStamp", &dbv)) { cmi.ptszName = ParseString(dbv.ptszVal, (MCONTACT)wparam, 0); db_free(&dbv); } else cmi.ptszName = ParseString(DEFAULT_MENUSTAMP, (MCONTACT)wparam, 0); if ( !_tcscmp(cmi.ptszName, TranslateT("<unknown>"))) { if ( IsWatchedProtocol(szProto)) cmi.flags |= CMIF_GRAYED; else cmi.flags |= CMIF_HIDDEN; } else if ( db_get_b(NULL, S_MOD, "ShowIcon",1)) { isetting = db_get_w(hContact, S_MOD, "StatusTriger", -1); cmi.hIcon = LoadSkinnedProtoIcon(szProto, isetting|0x8000); } } Menu_ModifyItem(hmenuitem, &cmi); return 0; }
void LoadModuleIcons(MODULEINFO * mi) { int index; HIMAGELIST hList = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 0, 0); int overlayIcon = ImageList_AddIcon(hList, GetCachedIcon("chat_overlay")); ImageList_SetOverlayImage(hList, overlayIcon, 1); mi->hOnlineIconBig = LoadSkinnedProtoIconBig(mi->pszModule, ID_STATUS_ONLINE); mi->hOnlineIcon = LoadSkinnedProtoIcon(mi->pszModule, ID_STATUS_ONLINE); index = ImageList_AddIcon(hList, mi->hOnlineIcon); mi->hOnlineTalkIcon = ImageList_GetIcon(hList, index, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1)); mi->hOfflineIconBig = LoadSkinnedProtoIconBig(mi->pszModule, ID_STATUS_OFFLINE); mi->hOfflineIcon = LoadSkinnedProtoIcon(mi->pszModule, ID_STATUS_OFFLINE); index = ImageList_AddIcon(hList, mi->hOfflineIcon); mi->hOfflineTalkIcon = ImageList_GetIcon(hList, index, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1)); ImageList_Destroy(hList); }
void LoadGlobalIcons() { int i; if (ServiceExists(MS_SKIN2_ADDICON)) { g_dat->hIcons[SMF_ICON_ADD] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_ADD"); g_dat->hIcons[SMF_ICON_USERDETAILS] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_USERDETAILS"); g_dat->hIcons[SMF_ICON_HISTORY] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_HISTORY"); g_dat->hIcons[SMF_ICON_TYPING] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_TYPING"); g_dat->hIcons[SMF_ICON_SEND] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_SEND"); g_dat->hIcons[SMF_ICON_CANCEL] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_CANCEL"); g_dat->hIcons[SMF_ICON_SMILEY] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_SMILEY"); g_dat->hIcons[SMF_ICON_UNICODEON] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_UNICODEON"); g_dat->hIcons[SMF_ICON_UNICODEOFF] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_UNICODEOFF"); g_dat->hIcons[SMF_ICON_DELIVERING] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_DELIVERING"); g_dat->hIcons[SMF_ICON_QUOTE] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_QUOTE"); g_dat->hIcons[SMF_ICON_INCOMING] = (HICON) LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_INCOMING)); g_dat->hIcons[SMF_ICON_OUTGOING] = (HICON) LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_OUTGOING)); g_dat->hIcons[SMF_ICON_NOTICE] = (HICON) LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_NOTICE)); g_dat->hIcons[SMF_ICON_CLOSEX] = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"scriver_CLOSEX"); } else { g_dat->hIcons[SMF_ICON_ADD] = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_ADDCONTACT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); g_dat->hIcons[SMF_ICON_USERDETAILS] = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_USERDETAILS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); g_dat->hIcons[SMF_ICON_HISTORY] = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_HISTORY), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); g_dat->hIcons[SMF_ICON_SEND] = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_SEND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); g_dat->hIcons[SMF_ICON_CANCEL] = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_CANCEL), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); g_dat->hIcons[SMF_ICON_SMILEY] = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_SMILEY), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); g_dat->hIcons[SMF_ICON_TYPING] = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_TYPING), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); g_dat->hIcons[SMF_ICON_UNICODEON] = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_UNICODEON), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); g_dat->hIcons[SMF_ICON_UNICODEOFF] = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_UNICODEOFF), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); g_dat->hIcons[SMF_ICON_DELIVERING] = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_TIMESTAMP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); g_dat->hIcons[SMF_ICON_QUOTE] = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_QUOTE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); g_dat->hIcons[SMF_ICON_INCOMING] = (HICON) LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_INCOMING)); g_dat->hIcons[SMF_ICON_OUTGOING] = (HICON) LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_OUTGOING)); g_dat->hIcons[SMF_ICON_NOTICE] = (HICON) LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_NOTICE)); g_dat->hIcons[SMF_ICON_CLOSEX] = (HICON) LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_CLOSEX)); } if (g_dat->hButtonIconList == NULL) { g_dat->hButtonIconList = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, (g_dat->protoNum + 1) * 12 + 8, 0); } else { ImageList_RemoveAll(g_dat->hButtonIconList); } for (i=0; i<sizeof(buttonIcons)/sizeof(int); i++) { if (buttonIcons[i] == -1) { ImageList_AddIcon(g_dat->hButtonIconList, LoadSkinnedProtoIcon(NULL, ID_STATUS_OFFLINE)); } else { ImageList_AddIcon(g_dat->hButtonIconList, g_dat->hIcons[buttonIcons[i]]); } } }
void LoadProtocolIcons() { PROTOCOLDESCRIPTOR **pProtos; int i, j, allProtoNum, k; HICON hIcon; int iCurIcon = 0; 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) { } g_dat->protoNames = (char **) malloc(sizeof(char **) * g_dat->protoNum); if (g_dat->hIconList == NULL) { g_dat->hIconList = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, (g_dat->protoNum + 1) * 12 + 8, 0); } else { ImageList_RemoveAll(g_dat->hIconList); } ImageList_AddIcon(g_dat->hIconList, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); ImageList_AddIcon(g_dat->hIconList, g_dat->hIcons[SMF_ICON_TYPING]); for (i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { ImageList_AddIcon(g_dat->hIconList, LoadSkinnedProtoIcon(NULL, i)); } for(i = j = 0; i < allProtoNum; i++) { if (pProtos[i]->type != PROTOTYPE_PROTOCOL) continue; g_dat->protoNames[j] = _strdup(pProtos[i]->szName); for (k = ID_STATUS_OFFLINE; k <= ID_STATUS_OUTTOLUNCH; k++) { hIcon = LoadSkinnedProtoIcon(pProtos[i]->szName, k); if (hIcon != NULL) { ImageList_AddIcon(g_dat->hIconList, hIcon); } else { ImageList_AddIcon(g_dat->hIconList, LoadSkinnedProtoIcon(NULL, ID_STATUS_OFFLINE)); } } j++; } }
HICON createProtoOverlayedIcon(MCONTACT hContact) { HICON icon1 = LoadIconEx(I_OVERLAY); char *szProto = GetContactProto(hContact); HICON icon0 = LoadSkinnedProtoIcon(szProto, ID_STATUS_ONLINE); HICON resIcon = getOverlayedIcon(icon0, icon1, FALSE); ReleaseIconEx(icon1); Skin_ReleaseIcon(icon0); return resIcon; }
HICON VoiceProvider::GetIcon() { if (!IsEmptyA(icon)) { return IcoLib_LoadIcon(icon); } else if (is_protocol) { return LoadSkinnedProtoIcon(name, ID_STATUS_ONLINE); } else { return NULL; } }
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; }
HIMAGELIST GetStatusIconsImgList(char *szProto) { HIMAGELIST hList = NULL; if (szProto) { hList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16 | ILC_MASK, STATUS_COUNT, 0); if (hList != NULL) { for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX; i++) ImageList_AddIcon(hList, LoadSkinnedProtoIcon(szProto, StatusList[Index(i)].ID)); ImageList_AddIcon(hList, LoadSkinnedIcon(SKINICON_OTHER_USERONLINE)); } } return hList; }
void ipcGetSkinIcons(THeaderIPC *ipch) { TSlotProtoIcons spi; char szTmp[64]; int protoCount; PROTOACCOUNT **pp; if ( CallService(MS_PROTO_ENUMACCOUNTS, WPARAM(&protoCount), LPARAM(&pp)) == 0 && protoCount != 0) { spi.pid = GetCurrentProcessId(); while (protoCount > 0) { PROTOACCOUNT *pa = *pp; lstrcpyA(szTmp, pa->szModuleName); lstrcatA(szTmp, PS_GETCAPS); DWORD dwCaps = CallService(szTmp, PFLAGNUM_1, 0); if (dwCaps & PF1_FILESEND) { TSlotIPC *pct = ipcAlloc(ipch, sizeof(TSlotProtoIcons)); if (pct != NULL) { // capture all the icons! spi.hProto = murmur_hash(pa->szModuleName); for (int j = 0; j <= 10; j++) spi.hIcons[j] = LoadSkinnedProtoIcon(pa->szModuleName, ID_STATUS_OFFLINE + j); pct->fType = REQUEST_NEWICONS; memcpy(LPSTR(pct) + sizeof(TSlotIPC), &spi, sizeof(TSlotProtoIcons)); if (ipch->NewIconsBegin == NULL) ipch->NewIconsBegin = pct; } } pp++; protoCount--; } } // add Miranda icon TSlotIPC *pct = ipcAlloc(ipch, sizeof(TSlotProtoIcons)); if (pct != NULL) { ZeroMemory(&spi.hIcons, sizeof(spi.hIcons)); spi.hProto = 0; // no protocol spi.hIcons[0] = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA); pct->fType = REQUEST_NEWICONS; memcpy(LPSTR(pct) + sizeof(TSlotIPC), &spi, sizeof(TSlotProtoIcons)); if (ipch->NewIconsBegin == NULL) ipch->NewIconsBegin = pct; } }
int BuildContactMenu(WPARAM wparam,LPARAM lparam) { CLISTMENUITEM cmi; DBVARIANT dbv; int id=-1,isetting; HANDLE hContact; char *szProto; hContact = (HANDLE)wparam; szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); ZeroMemory(&cmi,sizeof(cmi)); cmi.cbSize=sizeof(cmi); if(!IsWatchedProtocol(szProto) || !DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)) { cmi.flags=CMIM_FLAGS|CMIF_HIDDEN; } else { cmi.flags=CMIM_NAME|CMIM_FLAGS|CMIM_ICON; cmi.hIcon=NULL; cmi.pszName=ParseString(!DBGetContactSetting(NULL,S_MOD,"MenuStamp",&dbv)?dbv.pszVal:DEFAULT_MENUSTAMP,(HANDLE)wparam,0); if(!strcmp(cmi.pszName,Translate("<unknown>"))) { if (IsWatchedProtocol(szProto)) cmi.flags|=CMIF_GRAYED; else cmi.flags|=CMIF_HIDDEN; } else if(DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1)) { isetting=DBGetContactSettingWord((HANDLE)hContact,S_MOD,"StatusTriger",-1); cmi.hIcon=LoadSkinnedProtoIcon(szProto,isetting|0x8000); } } CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hmenuitem,(LPARAM)&cmi); DBFreeVariant(&dbv); return 0; }
static ProtoInfo* FindProto(const char *proto) { ProtoInfo *p = arProtos.find((ProtoInfo*)&proto); if (p) return p; HICON hIcon = LoadSkinnedProtoIcon(proto, ID_STATUS_ONLINE); if (hIcon == NULL) return NULL; HANDLE hImage = ExtraIcon_Add(hIcon); if (hImage == INVALID_HANDLE_VALUE) return NULL; p = new ProtoInfo(proto, hImage); arProtos.insert(p); return p; }
void ReloadExtraIcons() { { int count,i; PROTOCOLDESCRIPTOR **protos; HICON hicon; SendMessage(hwndContactTree,CLM_SETEXTRACOLUMNSSPACE,DBGetContactSettingByte(NULL,"CLUI","ExtraColumnSpace",18),0); SendMessage(hwndContactTree,CLM_SETEXTRAIMAGELIST,0,(LPARAM)NULL); if (hExtraImageList){ImageList_Destroy(hExtraImageList);}; hExtraImageList=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,1,256); memset(ClientImageListIdx,0,sizeof(ClientImageListIdx)); //adding protocol icons CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&count,(LPARAM)&protos); //loading icons hicon=LoadIconFromExternalFile("clisticons.dll",0,TRUE,TRUE,"Email","Contact List",Translate("Email Icon"),-IDI_EMAIL); if (!hicon) hicon=LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_EMAIL)); ExtraImageIconsIndex[0]=ImageList_AddIcon(hExtraImageList,hicon ); hicon=LoadIconFromExternalFile("clisticons.dll",1,TRUE,TRUE,"Sms","Contact List",Translate("Sms Icon"),-IDI_SMS); if (!hicon) hicon=LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_SMS)); ExtraImageIconsIndex[1]=ImageList_AddIcon(hExtraImageList,hicon ); hicon=LoadIconFromExternalFile("clisticons.dll",4,TRUE,TRUE,"Web","Contact List",Translate("Web Icon"),-IDI_GLOBUS); if (!hicon) hicon=LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_GLOBUS)); ExtraImageIconsIndex[2]=ImageList_AddIcon(hExtraImageList,hicon ); //calc only needed protocols for(i=0;i<count;i++) { if(protos[i]->type!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue; ImageList_AddIcon(hExtraImageList,LoadSkinnedProtoIcon(protos[i]->szName,ID_STATUS_ONLINE)); } LoadClientIcons(); SendMessage(hwndContactTree,CLM_SETEXTRAIMAGELIST,0,(LPARAM)hExtraImageList); //SetAllExtraIcons(hImgList); SetNewExtraColumnCount(); NotifyEventHooks(hExtraImageListRebuilding,0,0); ImageCreated=TRUE; TRACE("ReloadExtraIcons Done\r\n"); } };
void ReloadExtraIcons() { int count,i; PROTOACCOUNT **accs; HICON hicon; SendMessage(pcli->hwndContactTree,CLM_SETEXTRACOLUMNSSPACE,DBGetContactSettingByte(NULL,"CLUI","ExtraColumnSpace",18),0); SendMessage(pcli->hwndContactTree,CLM_SETEXTRAIMAGELIST,0,(LPARAM)NULL); if (hExtraImageList){ImageList_Destroy(hExtraImageList);}; hExtraImageList=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,1,256); if (!HasExtraIconsService()) { //loading icons hicon=LoadIconFromExternalFile("clisticons.dll",0,TRUE,TRUE,"Email","Contact List","Email Icon",-IDI_EMAIL); if (!hicon) hicon=LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_EMAIL)); ExtraImageIconsIndex[0]=ImageList_AddIcon(hExtraImageList,hicon ); hicon=LoadIconFromExternalFile("clisticons.dll",1,TRUE,TRUE,"Sms","Contact List","Sms Icon",-IDI_SMS); if (!hicon) hicon=LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_SMS)); ExtraImageIconsIndex[1]=ImageList_AddIcon(hExtraImageList,hicon ); hicon=LoadIconFromExternalFile("clisticons.dll",4,TRUE,TRUE,"Web","Contact List","Web Icon",-IDI_GLOBUS); if (!hicon) hicon=LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_GLOBUS)); ExtraImageIconsIndex[2]=ImageList_AddIcon(hExtraImageList,hicon ); //calc only needed protocols ProtoEnumAccounts( &count, &accs ); for ( i=0; i < count; i++ ) if ( IsAccountEnabled( accs[i] ) && CallProtoService( accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0 )) ImageList_AddIcon( hExtraImageList, LoadSkinnedProtoIcon( accs[i]->szModuleName, ID_STATUS_ONLINE )); } SendMessage(pcli->hwndContactTree,CLM_SETEXTRAIMAGELIST,0,(LPARAM)hExtraImageList); //SetAllExtraIcons(hImgList); SetNewExtraColumnCount(); NotifyEventHooks(hExtraImageListRebuilding,0,0); ImageCreated=TRUE; }
static int AwayMsgPreBuildMenu(WPARAM wParam,LPARAM lParam) { CLISTMENUITEM clmi; char str[128]; int status; char *szProto; szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); ZeroMemory(&clmi,sizeof(clmi)); clmi.cbSize=sizeof(clmi); clmi.flags=CMIM_FLAGS|CMIF_HIDDEN; if(szProto!=NULL) { status = DBGetContactSettingWord((HANDLE)wParam,szProto,"Status",ID_STATUS_OFFLINE); wsprintf(str,Translate("Re&ad %s Message"),(char*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,status,0)); clmi.pszName=str; if(CallProtoService(szProto,PS_GETCAPS,PFLAGNUM_1,0)&PF1_MODEMSGRECV) { if(CallProtoService(szProto,PS_GETCAPS,PFLAGNUM_3,0)&Proto_Status2Flag(status == ID_STATUS_OFFLINE ? ID_STATUS_INVISIBLE : status)) { clmi.flags=CMIM_FLAGS|CMIM_NAME|CMIM_ICON; clmi.hIcon = LoadSkinnedProtoIcon(szProto, status); } } } CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hAwayMsgMenuItem,(LPARAM)&clmi); if (!ShowCopy) clmi.flags |= CMIF_HIDDEN; wsprintf(str,Translate("Copy %s Message"),(char*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,status,0)); clmi.pszName = str; if (ServiceExists(MS_SKIN2_GETICON)) clmi.hIcon = (HICON)CallService(MS_SKIN2_GETICON, (WPARAM)0, (LPARAM)ICON_COPY); else clmi.hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_COPY), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hCopyMsgMenuItem,(LPARAM)&clmi); return 0; }
void CSrmmProxyWindow::UpdateIcon() { HICON hIcon; if (m_bTyping) { hIcon = LoadSkinnedIcon(SKINICON_OTHER_TYPING); } else if (m_bUnread) { hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE); } else { char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)m_hContact, 0); if (!szProto) return; int iStatus = DBGetContactSettingWord(m_hContact, szProto, "Status", ID_STATUS_OFFLINE); hIcon = (HICON)LoadSkinnedProtoIcon(szProto, iStatus); } SendMessage(hwnd(), WM_SETICON, ICON_BIG, (LPARAM)hIcon); SendMessage(hwnd(), WM_SETICON, ICON_SMALL, (LPARAM)hIcon); }
// display weather popups // wParam = the contact to display popup // lParam = whether the weather data is changed or not int WeatherPopup(WPARAM hContact, LPARAM lParam) { // determine if the popup should display or not if (opt.UsePopup && opt.UpdatePopup && (!opt.PopupOnChange || (BOOL)lParam) && !db_get_b(hContact, WEATHERPROTONAME, "DPopUp", 0)) { WEATHERINFO winfo = LoadWeatherInfo(hContact); // setup the popup POPUPDATAT ppd = { 0 }; ppd.lchContact = hContact; ppd.PluginData = ppd.lchIcon = LoadSkinnedProtoIcon(WEATHERPROTONAME, winfo.status); GetDisplay(&winfo, opt.pTitle, ppd.lptzContactName); GetDisplay(&winfo, opt.pText, ppd.lptzText); ppd.PluginWindowProc = PopupDlgProc; ppd.colorBack = (opt.UseWinColors)?GetSysColor(COLOR_BTNFACE):opt.BGColour; ppd.colorText = (opt.UseWinColors)?GetSysColor(COLOR_WINDOWTEXT):opt.TextColour; ppd.iSeconds = opt.pDelay; PUAddPopupT( &ppd ); } return 0; }
static int ContactListModulesLoaded(WPARAM wParam,LPARAM lParam) { int i,protoCount,j,iImg; PROTOCOLDESCRIPTOR **protoList; TRACE("ContactListModulesLoaded Start\r\n"); CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&protoCount,(LPARAM)&protoList); protoIconIndexCount=0; protoIconIndex=NULL; for(i=0;i<protoCount;i++) { if(protoList[i]->type!=PROTOTYPE_PROTOCOL) continue; protoIconIndex=(struct ProtoIconIndex*)mir_realloc(protoIconIndex,sizeof(struct ProtoIconIndex)*(protoIconIndexCount+1)); protoIconIndex[protoIconIndexCount].szProto=protoList[i]->szName; for(j=0;j<sizeof(statusModeList)/sizeof(statusModeList[0]);j++) { iImg=ImageList_AddIcon(hCListImages,LoadSkinnedProtoIcon(protoList[i]->szName,statusModeList[j])); if(j==0) protoIconIndex[protoIconIndexCount].iIconBase=iImg; } protoIconIndexCount++; } // LoadContactTree(); TRACE("ContactListModulesLoaded Done\r\n"); return 0; }
static ProtoInfo *FindProto(const char * proto) { for (unsigned int i = 0; i < protos.size(); ++i) { ProtoInfo *pi = &protos[i]; if (strcmp(pi->proto.c_str(), proto) == 0) return pi; } HICON hIcon = LoadSkinnedProtoIcon(proto, ID_STATUS_ONLINE); if (hIcon == NULL) return NULL; HANDLE hImage = (HANDLE) CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM) hIcon, 0); if (hImage == INVALID_HANDLE_VALUE) return NULL; ProtoInfo tmp; tmp.proto = proto; tmp.hImage = hImage; protos.push_back(tmp); return &protos[protos.size() - 1]; }
void TSAPI AddContactToFavorites(HANDLE hContact, const TCHAR *szNickname, const char *szProto, TCHAR *szStatus, WORD wStatus, HICON hIcon, BOOL mode, HMENU hMenu) { MENUITEMINFO mii = {0}; TCHAR szMenuEntry[80]; TCHAR szFinalNick[100]; if (szNickname == NULL) { mir_sntprintf(szFinalNick, safe_sizeof(szFinalNick), _T("%s"), (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)); } else { _tcsncpy(szFinalNick, szNickname, 100); szFinalNick[99] = 0; } if (szProto == NULL) szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); if (szProto) { if (wStatus == 0) wStatus = DBGetContactSettingWord((HANDLE)hContact, szProto, "Status", ID_STATUS_OFFLINE); if (szStatus == NULL) szStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, wStatus, GSMDF_TCHAR); } else return; if (hIcon == 0) hIcon = LoadSkinnedProtoIcon(szProto, wStatus); PROTOACCOUNT *acc = (PROTOACCOUNT *)CallService(MS_PROTO_GETACCOUNT, (WPARAM)0, (LPARAM)szProto); if(acc && acc->tszAccountName) { mii.cbSize = sizeof(mii); mir_sntprintf(szMenuEntry, safe_sizeof(szMenuEntry), _T("%s: %s (%s)"), acc->tszAccountName, szFinalNick, szStatus); if (mode) { if (hMenu == PluginConfig.g_hMenuRecent) { if (CheckMenuItem(hMenu, (UINT_PTR)hContact, MF_BYCOMMAND | MF_UNCHECKED) == 0) { DeleteMenu(hMenu, (UINT_PTR)hContact, MF_BYCOMMAND); goto addnew; // move to the end of the menu... } if (GetMenuItemCount(PluginConfig.g_hMenuRecent) > nen_options.wMaxRecent) { // throw out oldest entry in the recent menu... UINT uid = GetMenuItemID(hMenu, 0); if (uid) { DeleteMenu(hMenu, (UINT_PTR)0, MF_BYPOSITION); M->WriteDword((HANDLE)uid, SRMSGMOD_T, "isRecent", 0); } } addnew: M->WriteDword(hContact, SRMSGMOD_T, "isRecent", time(NULL)); AppendMenu(hMenu, MF_BYCOMMAND, (UINT_PTR)hContact, szMenuEntry); } else if (hMenu == PluginConfig.g_hMenuFavorites) { // insert the item sorted... MENUITEMINFO mii2 = {0}; TCHAR szBuffer[142]; int i, c = GetMenuItemCount(PluginConfig.g_hMenuFavorites); mii2.fMask = MIIM_STRING; mii2.cbSize = sizeof(mii2); if (c == 0) InsertMenu(PluginConfig.g_hMenuFavorites, 0, MF_BYPOSITION, (UINT_PTR)hContact, szMenuEntry); else { for (i = 0; i <= c; i++) { mii2.cch = 0; mii2.dwTypeData = NULL; GetMenuItemInfo(PluginConfig.g_hMenuFavorites, i, TRUE, &mii2); mii2.cch++; mii2.dwTypeData = szBuffer; GetMenuItemInfo(PluginConfig.g_hMenuFavorites, i, TRUE, &mii2); if (_tcsncmp((TCHAR *)mii2.dwTypeData, szMenuEntry, 140) > 0 || i == c) { InsertMenu(PluginConfig.g_hMenuFavorites, i, MF_BYPOSITION, (UINT_PTR)hContact, szMenuEntry); break; } } } } } mii.fMask = MIIM_BITMAP | MIIM_DATA; if (!mode) { mii.fMask |= MIIM_STRING; mii.dwTypeData = (LPTSTR)szMenuEntry; mii.cch = lstrlen(szMenuEntry) + 1; } mii.hbmpItem = HBMMENU_CALLBACK; mii.dwItemData = (ULONG_PTR)hIcon; SetMenuItemInfo(hMenu, (UINT)hContact, FALSE, &mii); } }
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; }
static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { MWinDataType *data = (MWinDataType*)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch(msg) { case WM_CREATE: data = (MWinDataType*)mir_calloc(sizeof(MWinDataType)); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data); data->hContact = (HANDLE)((LPCREATESTRUCT)lParam)->lpCreateParams; data->hAvt = CreateWindow(AVATAR_CONTROL_CLASS, TEXT(""), WS_CHILD, 0, 0, opt.AvatarSize, opt.AvatarSize, hwnd, NULL, hInst, 0); if (data->hAvt) SendMessage(data->hAvt, AVATAR_SETCONTACT, 0, (LPARAM)data->hContact); break; case WM_DESTROY: mir_free(data); break; case WM_CONTEXTMENU: { POINT pt; HMENU hMenu; hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)data->hContact, 0); GetCursorPos(&pt); TrackPopupMenu(hMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hwnd, NULL); DestroyMenu(hMenu); } break; case WM_MOUSEMOVE: if (f_TrackMouseEvent) { TRACKMOUSEEVENT tme = {0}; tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.hwndTrack = hwnd; tme.dwFlags = TME_QUERY; f_TrackMouseEvent(&tme); if (tme.dwFlags == 0) { tme.dwFlags = TME_HOVER | TME_LEAVE; tme.hwndTrack = hwnd; tme.dwHoverTime = CallService(MS_CLC_GETINFOTIPHOVERTIME, 0, 0); f_TrackMouseEvent(&tme); } } break; case WM_MOUSEHOVER: { POINT pt; CLCINFOTIP ti = {0}; GetCursorPos(&pt); GetWindowRect(hwnd, &ti.rcItem); ti.cbSize = sizeof(ti); ti.hItem = data->hContact; ti.ptCursor = pt; ti.isTreeFocused = 1; CallService(MS_TOOLTIP_SHOWTIP, 0, (LPARAM)&ti); } break; case WM_LBUTTONDBLCLK: BriefInfo((WPARAM)data->hContact, 0); break; case WM_COMMAND: //Needed by the contact's context menu if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU), (LPARAM)data->hContact)) break; return FALSE; case WM_MEASUREITEM: //Needed by the contact's context menu return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: //Needed by the contact's context menu return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case WM_NOTIFY: if (((LPNMHDR)lParam)->code == NM_AVATAR_CHANGED) { BOOL newava = CallService(MS_AV_GETAVATARBITMAP, (WPARAM)data->hContact, 0) != 0; if (newava != data->haveAvatar) { LONG_PTR style = GetWindowLongPtr(data->hAvt, GWL_STYLE); data->haveAvatar = newava; SetWindowLongPtr(data->hAvt, GWL_STYLE, newava ? (style | WS_VISIBLE) : (style & ~WS_VISIBLE)); RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE); } } break; case WM_REDRAWWIN: if (data->hAvt != NULL) MoveWindow(data->hAvt, 0, 0, opt.AvatarSize, opt.AvatarSize, TRUE); RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); break; case WM_PAINT: { RECT r, rc; if(GetUpdateRect(hwnd, &r, FALSE)) { DBVARIANT dbv = {0}; PAINTSTRUCT ps; HDC hdc; LOGFONT lfnt, lfnt1; COLORREF fntc, fntc1; COLORREF clr; int picSize = opt.AvatarSize; HICON hIcon = NULL; if (!data->haveAvatar) { int statusIcon = DBGetContactSettingWord(data->hContact, WEATHERPROTONAME, "Status", 0); picSize = GetSystemMetrics(SM_CXICON); hIcon = LoadSkinnedProtoIconBig(WEATHERPROTONAME, statusIcon); if ((INT_PTR)hIcon == CALLSERVICE_NOTFOUND) { picSize = GetSystemMetrics(SM_CXSMICON); hIcon = LoadSkinnedProtoIcon(WEATHERPROTONAME, statusIcon); } } clr = DBGetContactSettingDword(NULL, WEATHERPROTONAME, "ColorMwinFrame", GetSysColor(COLOR_3DFACE)); { FontID fntid = {0}; strcpy(fntid.group, WEATHERPROTONAME); strcpy(fntid.name, "Frame Font"); fntc = CallService(MS_FONT_GET, (WPARAM)&fntid, (LPARAM)&lfnt); strcpy(fntid.name, "Frame Title Font"); fntc1 = CallService(MS_FONT_GET, (WPARAM)&fntid, (LPARAM)&lfnt1); } DBGetContactSettingString(data->hContact, WEATHERCONDITION, "WeatherInfo", &dbv); GetClientRect(hwnd, &rc); hdc = BeginPaint(hwnd, &ps); if (ServiceExists(MS_SKIN_DRAWGLYPH)) { SKINDRAWREQUEST rq; memset(&rq, 0, sizeof(rq)); rq.hDC = hdc; rq.rcDestRect = rc; rq.rcClipRect = rc; strcpy(rq.szObjectID, "Main,ID=WeatherFrame"); CallService(MS_SKIN_DRAWGLYPH, (WPARAM)&rq, 0); } if (clr != 0xFFFFFFFF) { HBRUSH hBkgBrush = CreateSolidBrush(clr); FillRect(hdc, &rc, hBkgBrush); DeleteObject(hBkgBrush); } if (!data->haveAvatar) DrawIconEx(hdc, 1, 1, hIcon, 0, 0, 0, NULL, DI_NORMAL); SetBkMode(hdc, TRANSPARENT); { HFONT hfnt = CreateFontIndirect(&lfnt1); HFONT hfntold = SelectObject(hdc, hfnt); SIZE fontSize; char *nick = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)data->hContact, 0); GetTextExtentPoint32(hdc, _T("|"), 1, &fontSize); rc.top += 1; rc.left += picSize + fontSize.cx; SetTextColor(hdc, fntc1); DrawText(hdc, nick, -1, &rc, DT_LEFT | DT_EXPANDTABS); rc.top += fontSize.cy; SelectObject(hdc, hfntold); DeleteObject(hfnt); } if (dbv.pszVal) { HFONT hfnt = CreateFontIndirect(&lfnt); HFONT hfntold = SelectObject(hdc, hfnt); SetTextColor(hdc, fntc); DrawText(hdc, dbv.pszVal, -1, &rc, DT_LEFT | DT_EXPANDTABS); SelectObject(hdc, hfntold); DeleteObject(hfnt); } EndPaint(hwnd, &ps); CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); DBFreeVariant(&dbv); } break; } default: return DefWindowProc(hwnd, msg, wParam, lParam); } return(TRUE); }
static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { AwayMsgDlgData *dat = (AwayMsgDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); HWND hLst = GetDlgItem(hwndDlg, IDC_LST_STATUS); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->oldPage = -1; for (int i = 0; i < SIZEOF(statusModes); i++) { if (!(protoModeMsgFlags & Proto_Status2Flag(statusModes[i]))) continue; int j; if (hLst) { j = SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(statusModes[i], 0)); SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_SETITEMDATA, j, statusModes[i]); } else { j = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(statusModes[i], 0)); SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETITEMDATA, j, statusModes[i]); } dat->info[j].ignore = GetStatusModeByte(statusModes[i], "Ignore"); dat->info[j].noDialog = GetStatusModeByte(statusModes[i], "NoDlg", true); dat->info[j].usePrevious = GetStatusModeByte(statusModes[i], "UsePrev"); DBVARIANT dbv; if (db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusModes[i], "Default"), &dbv)) if (db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusModes[i], "Msg"), &dbv)) dbv.ptszVal = mir_tstrdup(GetDefaultMessage(statusModes[i])); lstrcpy(dat->info[j].msg, dbv.ptszVal); mir_free(dbv.ptszVal); } if (hLst) SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_SETCURSEL, 0, 0); else SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETCURSEL, 0, 0); SendMessage(hwndDlg, WM_COMMAND, hLst ? MAKEWPARAM(IDC_LST_STATUS, LBN_SELCHANGE) : MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0); } return TRUE; case WM_MEASUREITEM: { LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam; if (mis->CtlID == IDC_LST_STATUS) mis->itemHeight = 20; } break; case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->CtlID != IDC_LST_STATUS) break; if (dis->itemID < 0) break; TCHAR buf[128]; SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETTEXT, dis->itemID, (LPARAM)buf); if (dis->itemState & (ODS_SELECTED | ODS_FOCUS)) { FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT)); SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); } else { FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_WINDOW)); SetTextColor(dis->hDC, GetSysColor(COLOR_WINDOWTEXT)); } RECT rc = dis->rcItem; DrawIconEx(dis->hDC, 3, (rc.top + rc.bottom - 16) / 2, LoadSkinnedProtoIcon(NULL, dis->itemData), 16, 16, 0, NULL, DI_NORMAL); rc.left += 25; SetBkMode(dis->hDC, TRANSPARENT); DrawText(dis->hDC, buf, -1, &rc, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_LST_STATUS: case IDC_STATUS: if ((HIWORD(wParam) == CBN_SELCHANGE) || (HIWORD(wParam) == LBN_SELCHANGE)) { int i = hLst ? SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETCURSEL, 0, 0) : SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCURSEL, 0, 0); if (dat->oldPage != -1) { dat->info[dat->oldPage].ignore = IsDlgButtonChecked(hwndDlg, IDC_DONTREPLY); dat->info[dat->oldPage].noDialog = IsDlgButtonChecked(hwndDlg, IDC_NODIALOG); dat->info[dat->oldPage].usePrevious = IsDlgButtonChecked(hwndDlg, IDC_USEPREVIOUS); GetDlgItemText(hwndDlg, IDC_MSG, dat->info[dat->oldPage].msg, SIZEOF(dat->info[dat->oldPage].msg)); } CheckDlgButton(hwndDlg, IDC_DONTREPLY, i < 0 ? 0 : dat->info[i].ignore); CheckDlgButton(hwndDlg, IDC_NODIALOG, i < 0 ? 0 : dat->info[i].noDialog); CheckDlgButton(hwndDlg, IDC_USEPREVIOUS, i < 0 ? 0 : dat->info[i].usePrevious); CheckDlgButton(hwndDlg, IDC_USESPECIFIC, i < 0 ? 0 : !dat->info[i].usePrevious); SetDlgItemText(hwndDlg, IDC_MSG, i < 0 ? _T("") : dat->info[i].msg); EnableWindow(GetDlgItem(hwndDlg, IDC_NODIALOG), i < 0 ? 0 : !dat->info[i].ignore); EnableWindow(GetDlgItem(hwndDlg, IDC_USEPREVIOUS), i < 0 ? 0 : !dat->info[i].ignore); EnableWindow(GetDlgItem(hwndDlg, IDC_USESPECIFIC), i < 0 ? 0 : !dat->info[i].ignore); EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), i < 0 ? 0 : !(dat->info[i].ignore || dat->info[i].usePrevious)); dat->oldPage = i; } return 0; case IDC_DONTREPLY: case IDC_USEPREVIOUS: case IDC_USESPECIFIC: SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0); break; case IDC_MSG: if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0; break; } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0); { int i = hLst ? (SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETCOUNT, 0, 0) - 1) : (SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCOUNT, 0, 0) - 1); for (; i >= 0; i--) { int status = hLst ? SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETITEMDATA, i, 0) : SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETITEMDATA, i, 0); SetStatusModeByte(status, "Ignore", (BYTE)dat->info[i].ignore); SetStatusModeByte(status, "NoDlg", (BYTE)dat->info[i].noDialog); SetStatusModeByte(status, "UsePrev", (BYTE)dat->info[i].usePrevious); db_set_ts(NULL, "SRAway", StatusModeToDbSetting(status, "Default"), dat->info[i].msg); } return TRUE; } } break; } break; case WM_DESTROY: mir_free(dat); break; } return FALSE; }
BOOL CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DWORD ws; struct ParentWindowData *dat; dat = (struct ParentWindowData *) GetWindowLong(hwndDlg, GWL_USERDATA); if (!dat && msg!=WM_INITDIALOG) return FALSE; switch (msg) { case WM_INITDIALOG: { HMENU hMenu; HANDLE hSContact; int savePerContact = DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT); struct NewMessageWindowLParam *newData = (struct NewMessageWindowLParam *) lParam; dat = (struct ParentWindowData *) malloc(sizeof(struct ParentWindowData)); dat->foregroundWindow = GetForegroundWindow(); dat->hContact = newData->hContact; dat->nFlash = 0; dat->nFlashMax = DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_FLASHCOUNT, SRMSGDEFSET_FLASHCOUNT); dat->childrenCount = 0; dat->children = NULL; dat->hwnd = hwndDlg; dat->flags = g_dat->flags;// | SMF_SHOWTITLEBAR; dat->mouseLBDown = 0; dat->windowWasCascaded = 0; dat->bMinimized = 0; dat->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hwndDlg, NULL, g_hInst, NULL); { int statwidths[4]; RECT rc; SendMessage(dat->hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0); GetWindowRect(dat->hwndStatus, &rc); /* statwidths[0] = rc.right - rc.left - SB_CHAR_WIDTH - SB_TYPING_WIDTH - SB_SENDING_WIDTH; statwidths[1] = rc.right - rc.left - SB_TYPING_WIDTH - SB_SENDING_WIDTH; //rc.right - rc.left - SB_CHAR_WIDTH; statwidths[2] = rc.right - rc.left - SB_TYPING_WIDTH; //rc.right - rc.left - SB_CHAR_WIDTH; statwidths[3] = -1; SendMessage(dat->hwndStatus, SB_SETPARTS, 4, (LPARAM) statwidths); */ statwidths[0] = rc.right - rc.left - SB_CHAR_WIDTH - SB_TYPING_WIDTH; statwidths[1] = rc.right - rc.left - SB_TYPING_WIDTH; statwidths[2] = -1; SendMessage(dat->hwndStatus, SB_SETPARTS, 3, (LPARAM) statwidths); } dat->hwndTabs = GetDlgItem(hwndDlg, IDC_TABS); dat->hwndActive = NULL; SetWindowLong(hwndDlg, GWL_USERDATA, (LONG) dat); if (g_dat->hIconList != NULL) { TabCtrl_SetImageList(dat->hwndTabs, g_dat->hIconList); } WindowList_Add(g_dat->hParentWindowList, hwndDlg, 0); dat->tabCtrlDat = (struct TabCtrlData *) malloc(sizeof(struct TabCtrlData)); dat->tabCtrlDat->bDragging = FALSE; SetWindowLong(dat->hwndTabs, GWL_USERDATA, (LONG) dat->tabCtrlDat); OldTabCtrlProc = (WNDPROC) SetWindowLong(dat->hwndTabs, GWL_WNDPROC, (LONG) TabCtrlProc); ws = GetWindowLong(dat->hwndTabs, GWL_STYLE) & ~(TCS_BOTTOM); if (dat->flags & SMF_TABSATBOTTOM) { ws |= TCS_BOTTOM; } SetWindowLong(dat->hwndTabs, GWL_STYLE, ws); ws = GetWindowLong(hwndDlg, GWL_STYLE) & ~(WS_CAPTION); if (dat->flags & SMF_SHOWTITLEBAR) { ws |= WS_CAPTION; SetWindowLong(hwndDlg, GWL_STYLE, ws); } else { RECT rc; SetWindowLong(hwndDlg, GWL_STYLE, ws); GetWindowRect(hwndDlg, &rc); SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING); } ws = GetWindowLong(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED; ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0; SetWindowLong(hwndDlg , GWL_EXSTYLE , ws); if (dat->flags & SMF_USETRANSPARENCY) { pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->inactiveAlpha), LWA_ALPHA); // RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } if (!(dat->flags & SMF_SHOWSTATUSBAR)) { ShowWindow(dat->hwndStatus, SW_HIDE); } hSContact = !(dat->flags & SMF_USETABS) && savePerContact ? dat->hContact : NULL; dat->bTopmost = DBGetContactSettingByte(hSContact, SRMMMOD, SRMSGSET_TOPMOST, SRMSGDEFSET_TOPMOST); if (ScriverRestoreWindowPosition(hwndDlg, hSContact, SRMMMOD, "", 0, SW_HIDE)) { if (ScriverRestoreWindowPosition(hwndDlg, hSContact, SRMMMOD, "", RWPF_NOSIZE, SW_HIDE)) { SetWindowPos(GetParent(hwndDlg), 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_HIDEWINDOW); } else { SetWindowPos(hwndDlg, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_HIDEWINDOW); } } if (!(dat->flags & SMF_USETABS)) { if (!savePerContact && DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_CASCADE, SRMSGDEFSET_CASCADE)) WindowList_Broadcast(g_dat->hParentWindowList, DM_CASCADENEWWINDOW, (WPARAM) hwndDlg, (LPARAM) & dat->windowWasCascaded); } hMenu = GetSystemMenu( hwndDlg, FALSE ); AppendMenu( hMenu, MF_SEPARATOR, 0, NULL ); if (dat->bTopmost) { AppendMenu( hMenu, MF_ENABLED | MF_CHECKED | MF_STRING, IDM_TOPMOST, TranslateT("Always On Top")); SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); } else { AppendMenu( hMenu, MF_ENABLED | MF_UNCHECKED | MF_STRING, IDM_TOPMOST, TranslateT("Always On Top")); } } return TRUE; case WM_GETMINMAXINFO: { MINMAXINFO *mmi = (MINMAXINFO *) lParam; SIZE size; if (GetKeyState(VK_CONTROL) & 0x8000) { WINDOWPLACEMENT wp; RECT rcDesktop; wp.length = sizeof(wp); GetWindowPlacement(hwndDlg, &wp); SystemParametersInfo(SPI_GETWORKAREA, 0, &rcDesktop, 0); mmi->ptMaxSize.x = wp.rcNormalPosition.right - wp.rcNormalPosition.left; mmi->ptMaxSize.y = rcDesktop.bottom - rcDesktop.top; mmi->ptMaxPosition.x = wp.rcNormalPosition.left; if(IsIconic(hwndDlg)) { mmi->ptMaxPosition.y = rcDesktop.top; } else { mmi->ptMaxPosition.y = 0; } } GetMinimunWindowSize(dat, &size); mmi->ptMinTrackSize.x = size.cx; mmi->ptMinTrackSize.y = size.cy; return FALSE; } case WM_SIZE: if (wParam == SIZE_MINIMIZED) { dat->bMinimized = 1; } if (IsIconic(hwndDlg)) { MoveWindow(dat->hwndActive, dat->childRect.left, dat->childRect.top, dat->childRect.right-dat->childRect.left, dat->childRect.bottom - dat->childRect.top, TRUE); } else { // } // if (!IsIconic(hwndDlg)) { int i; RECT rc, rcStatus, rcChild, rcWindow; SIZE size; dat->bMinimized = 0; GetClientRect(hwndDlg, &rc); GetWindowRect(hwndDlg, &rcWindow); rcStatus.top = rcStatus.bottom = 0; if (dat->flags & SMF_SHOWSTATUSBAR) { int statwidths[4]; GetWindowRect(dat->hwndStatus, &rcStatus); statwidths[0] = rc.right - rc.left - SB_CHAR_WIDTH - SB_TYPING_WIDTH; statwidths[1] = rc.right - rc.left - SB_TYPING_WIDTH; statwidths[2] = -1; SendMessage(dat->hwndStatus, SB_SETPARTS, 3, (LPARAM) statwidths); SendMessage(dat->hwndStatus, WM_SIZE, 0, 0); } MoveWindow(dat->hwndTabs, 0, 2, (rc.right - rc.left), (rc.bottom - rc.top) - (rcStatus.bottom - rcStatus.top) - 2, FALSE); RedrawWindow(dat->hwndTabs, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE); GetMinimunWindowSize(dat, &size); if ((rcWindow.bottom-rcWindow.top) < size.cy || (rcWindow.right-rcWindow.left) < size.cx) { if ((rcWindow.bottom-rcWindow.top) < size.cy) { rcWindow.bottom = rcWindow.top + size.cy; } if ((rcWindow.right-rcWindow.left) < size.cx) { rcWindow.right = rcWindow.left + size.cx; } MoveWindow(hwndDlg, rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE); } GetChildWindowRect(dat, &rcChild); memcpy(&dat->childRect, &rcChild, sizeof(RECT)); for (i=0;i<dat->childrenCount;i++) { if (dat->children[i] == dat->hwndActive) { MoveWindow(dat->children[i], rcChild.left, rcChild.top, rcChild.right-rcChild.left, rcChild.bottom - rcChild.top, TRUE); RedrawWindow(GetDlgItem(dat->children[i], IDC_LOG), NULL, NULL, RDW_INVALIDATE); } } if (dat->flags & SMF_SHOWSTATUSBAR) { RedrawWindow(dat->hwndStatus, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); } } return FALSE; case WM_SETFOCUS: if (dat->hwndActive != NULL) { SetFocus(dat->hwndActive); } return TRUE; case WM_CLOSE: DestroyWindow(hwndDlg); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: //DestroyWindow(hwndDlg); return TRUE; } case WM_NOTIFY: { NMHDR* pNMHDR = (NMHDR*) lParam; if (pNMHDR->hwndFrom == dat->hwndTabs) { switch (pNMHDR->code) { case TCN_SELCHANGE: { TCITEM tci = {0}; int iSel = TabCtrl_GetCurSel(dat->hwndTabs); tci.mask = TCIF_PARAM; if (TabCtrl_GetItem(dat->hwndTabs, iSel, &tci)) { struct MessageWindowData * mdat = (struct MessageWindowData *) tci.lParam; ActivateChild(dat, mdat->hwnd); SetFocus(dat->hwndActive); } } break; case NM_RCLICK: { TCHITTESTINFO thinfo; int tabId, x, y; GetCursorPos(&thinfo.pt); x = thinfo.pt.x; y = thinfo.pt.y; ScreenToClient(dat->hwndTabs, &thinfo.pt); tabId = TabCtrl_HitTest(dat->hwndTabs, &thinfo); if (tabId != -1) { struct MessageWindowData * mwd = GetChildFromTab(dat->hwndTabs, tabId); //CallService(MS_USERINFO_SHOWDIALOG, (WPARAM) mwd->hContact, 0); HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) mwd->hContact, 0); TrackPopupMenu(hMenu, 0, x, y, 0, mwd->hwnd, NULL); DestroyMenu(hMenu); } } break; } } else if (pNMHDR->hwndFrom == dat->hwndStatus) { switch (pNMHDR->code) { case NM_CLICK: { NMMOUSE *nm=(NMMOUSE*)lParam; RECT rc; SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 1, (LPARAM)&rc); if (nm->pt.x >= rc.left) SendMessage(dat->hwndActive, DM_SWITCHUNICODE, 0, 0); } } break; } } break; case WM_DROPFILES: SendMessage(dat->hwndActive, WM_DROPFILES, wParam, lParam); break; case WM_TIMER: if (wParam == TIMERID_FLASHWND) { if ((dat->nFlash > dat->nFlashMax)) {// || ((GetActiveWindow() == hwndDlg) && (GetForegroundWindow() == hwndDlg))) { KillTimer(hwndDlg, TIMERID_FLASHWND); FlashWindow(hwndDlg, FALSE); } else if (dat->nFlash < dat->nFlashMax) { FlashWindow(hwndDlg, TRUE); dat->nFlash++; } } break; case WM_CONTEXTMENU: { if (dat->hwndStatus && dat->hwndStatus == (HWND) wParam) { RECT rc; POINT pt, pt2; GetCursorPos(&pt); pt2.x = pt.x; pt2.y = pt.y; ScreenToClient(dat->hwndStatus, &pt); SendMessage(dat->hwndStatus, SB_GETRECT, SendMessage(dat->hwndStatus, SB_GETPARTS, 0, 0) - 1, (LPARAM)&rc); if (pt.x >= rc.left && dat->hwndActive != NULL) { int codePage = (int) SendMessage(dat->hwndActive, DM_GETCODEPAGE, 0, 0); int i, iSel; for(i = 0; i < GetMenuItemCount(g_dat->hMenuANSIEncoding); i++) { CheckMenuItem (g_dat->hMenuANSIEncoding, i, MF_BYPOSITION | MF_UNCHECKED); } if(codePage == CP_ACP) { CheckMenuItem(g_dat->hMenuANSIEncoding, 0, MF_BYPOSITION | MF_CHECKED); } else { CheckMenuItem(g_dat->hMenuANSIEncoding, codePage, MF_BYCOMMAND | MF_CHECKED); } iSel = TrackPopupMenu(g_dat->hMenuANSIEncoding, TPM_RETURNCMD, pt2.x, pt2.y, 0, hwndDlg, NULL); if (iSel >= 500) { if (iSel == 500) iSel = CP_ACP; SendMessage(dat->hwndActive, DM_SETCODEPAGE, 0, iSel); } } else SendMessage(dat->hwndActive, WM_CONTEXTMENU, (WPARAM)hwndDlg, 0); } break; } case WM_ACTIVATE: if (LOWORD(wParam) == WA_INACTIVE) { ws = GetWindowLong(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED; ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0; SetWindowLong(hwndDlg , GWL_EXSTYLE , ws); if (dat->flags & SMF_USETRANSPARENCY) { pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->inactiveAlpha), LWA_ALPHA); // RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } } if (LOWORD(wParam) != WA_ACTIVE) break; if (dat->hwndActive == NULL) { // do not set foreground window at all (always stay in the background !) // SendMessage(hwndDlg, DM_DEACTIVATE, 0, 0); } else { PostMessage(hwndDlg, WM_SETFOCUS, 0, 0); } case WM_MOUSEACTIVATE: if (KillTimer(hwndDlg, TIMERID_FLASHWND)) { FlashWindow(hwndDlg, FALSE); dat->nFlash = 0; } ws = GetWindowLong(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED; ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0; SetWindowLong(hwndDlg , GWL_EXSTYLE , ws); if (dat->flags & SMF_USETRANSPARENCY) { pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->activeAlpha), LWA_ALPHA); // RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } break; case WM_LBUTTONDOWN: if (!IsZoomed(hwndDlg)) { POINT pt; GetCursorPos(&pt); // dat->mouseLBDown = 1; // GetCursorPos(&dat->mouseLBDownPos); return SendMessage(hwndDlg, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y)); // SetCapture(hwndDlg); } break; case WM_LBUTTONUP: //if (dat->mouseLBDown) { // dat->mouseLBDown = 0; // ReleaseCapture(); //} break; case WM_MOUSEMOVE:/* if (dat->mouseLBDown) { POINT pt; RECT rc; GetCursorPos(&pt); GetWindowRect(hwndDlg, &rc); SetWindowPos(hwndDlg, 0, rc.left - (dat->mouseLBDownPos.x - pt.x), rc.top - (dat->mouseLBDownPos.y - pt.y), 0, 0, SWP_NOZORDER | SWP_NOSIZE); dat->mouseLBDownPos = pt; }*/ break; case WM_MOVING: { int snapPixels = 10; RECT rcDesktop; RECT *pRect = (RECT *)lParam; POINT pt; SIZE szSize = {pRect->right-pRect->left,pRect->bottom-pRect->top}; GetCursorPos(&pt); SystemParametersInfo(SPI_GETWORKAREA, 0, &rcDesktop, 0); pRect->left = pt.x-dat->mouseLBDownPos.x; pRect->top = pt.y-dat->mouseLBDownPos.y; pRect->right = pRect->left+szSize.cx; pRect->bottom = pRect->top+szSize.cy; if (!(GetAsyncKeyState(VK_CONTROL) & 0x8000)) { if(pRect->top < snapPixels && pRect->top > -snapPixels) { pRect->top = 0; pRect->bottom = szSize.cy; } if(pRect->left < snapPixels && pRect->left > -snapPixels) { pRect->left = 0; pRect->right = szSize.cx; } if(pRect->right < rcDesktop.right+snapPixels && pRect->right > rcDesktop.right-snapPixels) { pRect->right = rcDesktop.right; pRect->left = rcDesktop.right-szSize.cx; } if(pRect->bottom < rcDesktop.bottom+snapPixels && pRect->bottom > rcDesktop.bottom-snapPixels) { pRect->bottom = rcDesktop.bottom; pRect->top = rcDesktop.bottom-szSize.cy; } } } break; case WM_SYSCOMMAND: if ((wParam & 0xFFF0) == SC_MOVE) { RECT rc; GetWindowRect(hwndDlg, &rc); dat->mouseLBDownPos.x = LOWORD(lParam) - rc.left; dat->mouseLBDownPos.y = HIWORD(lParam) - rc.top; } else if (wParam == IDM_TOPMOST) { HMENU hMenu = GetSystemMenu(hwndDlg, FALSE); if (dat->bTopmost) { CheckMenuItem(hMenu, IDM_TOPMOST, MF_BYCOMMAND | MF_UNCHECKED); SetWindowPos(hwndDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); dat->bTopmost = FALSE; } else { CheckMenuItem(hMenu, IDM_TOPMOST, MF_BYCOMMAND | MF_CHECKED); SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); dat->bTopmost = TRUE; } } break; case WM_DESTROY: { WINDOWPLACEMENT wp = { 0 }; HANDLE hContact; g_dat->hParent = NULL; SetWindowLong(hwndDlg, GWL_USERDATA, 0); WindowList_Remove(g_dat->hParentWindowList, hwndDlg); if (dat->children!=NULL) free (dat->children); free(dat->tabCtrlDat); free(dat); if (!(dat->flags & SMF_USETABS) && DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT)) hContact = dat->hContact; else hContact = NULL; wp.length = sizeof(wp); GetWindowPlacement(hwndDlg, &wp); if (!dat->windowWasCascaded) { DBWriteContactSettingDword(hContact, SRMMMOD, "x", wp.rcNormalPosition.left); DBWriteContactSettingDword(hContact, SRMMMOD, "y", wp.rcNormalPosition.top); } DBWriteContactSettingDword(hContact, SRMMMOD, "width", wp.rcNormalPosition.right - wp.rcNormalPosition.left); DBWriteContactSettingDword(hContact, SRMMMOD, "height", wp.rcNormalPosition.bottom - wp.rcNormalPosition.top); DBWriteContactSettingByte(hContact, SRMMMOD, SRMSGSET_TOPMOST, (BYTE)dat->bTopmost); } break; case DM_DEACTIVATE: SetForegroundWindow(dat->foregroundWindow); break; case DM_ERRORDECIDED: break; case DM_STARTFLASHING: if (GetActiveWindow() != hwndDlg || GetForegroundWindow() != hwndDlg) { dat->nFlash = 0; SetTimer(hwndDlg, TIMERID_FLASHWND, TIMEOUT_FLASHWND, NULL); } break; case DM_REMOVECHILD: { RemoveChild(dat, (HWND) lParam); if (dat->childrenCount != 0) { SetFocus(dat->hwndActive); } else { DestroyWindow(hwndDlg); } } return TRUE; case DM_ADDCHILD: { struct MessageWindowData * mdat = (struct MessageWindowData *) lParam; AddChild(dat, mdat); } return TRUE; case DM_ACTIVATECHILD: // if((HWND) lParam != dat->hwndActive) { ActivateChild(dat, (HWND) lParam); // } return TRUE; case DM_ACTIVATEPREV: ActivatePrevChild(dat, (HWND) lParam); SetFocus(dat->hwndActive); return TRUE; case DM_ACTIVATENEXT: ActivateNextChild(dat, (HWND) lParam); SetFocus(dat->hwndActive); return TRUE; case DM_SENDMESSAGE: { int i; for (i=0;i<dat->childrenCount;i++) { SendMessage(dat->children[i], DM_SENDMESSAGE, wParam, lParam); } } break; case DM_OPTIONSAPPLIED: { RECT rc; dat->flags = g_dat->flags; if (!(dat->flags & SMF_SHOWSTATUSBAR)) { ShowWindow(dat->hwndStatus, SW_HIDE); } else { ShowWindow(dat->hwndStatus, SW_SHOW); } ws = GetWindowLong(hwndDlg, GWL_STYLE) & ~(WS_CAPTION); if (dat->flags & SMF_SHOWTITLEBAR) { ws |= WS_CAPTION; } SetWindowLong(hwndDlg, GWL_STYLE, ws); ws = GetWindowLong(hwndDlg, GWL_EXSTYLE)& ~WS_EX_LAYERED; ws |= dat->flags & SMF_USETRANSPARENCY ? WS_EX_LAYERED : 0; SetWindowLong(hwndDlg , GWL_EXSTYLE , ws); if (dat->flags & SMF_USETRANSPARENCY) { pSetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat->inactiveAlpha), LWA_ALPHA); // RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } ws = GetWindowLong(dat->hwndTabs, GWL_STYLE) & ~(TCS_BOTTOM); if (dat->flags & SMF_TABSATBOTTOM) { ws |= TCS_BOTTOM; } SetWindowLong(dat->hwndTabs, GWL_STYLE, ws); RedrawWindow(dat->hwndTabs, NULL, NULL, RDW_INVALIDATE); GetWindowRect(hwndDlg, &rc); SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING); SendMessage(hwndDlg, WM_SIZE, 0, 0); //RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); break; } case DM_UPDATETITLE: { struct MessageWindowData * mdat = (struct MessageWindowData *) lParam; TCITEM tci; int tabId; TCHAR *tContactName; if (mdat && mdat->hwnd == dat->hwndActive) { TCHAR *newtitle, oldtitle[256]; #if defined ( _UNICODE ) newtitle = GetWindowTitle(mdat->hContact, mdat->szProto); #else newtitle = GetWindowTitle(mdat->hContact, mdat->szProto); #endif GetWindowText(hwndDlg, oldtitle, sizeof(oldtitle)); if (lstrcmp(newtitle, oldtitle)) { //swt() flickers even if the title hasn't actually changed SetWindowText(hwndDlg, newtitle); //SendMessage(hwndDlg, WM_SIZE, 0, 0); } free(newtitle); } tabId = GetTabFromHWND(dat, mdat->hwnd); tContactName = GetTabName(mdat->hContact); tci.mask = TCIF_TEXT; tci.pszText = tContactName; TabCtrl_SetItem(dat->hwndTabs, tabId, &tci); free(tContactName); break; } case DM_UPDATEWINICON: { struct MessageWindowData * mdat = (struct MessageWindowData *) lParam; if (mdat) { if (mdat->szProto) { int i, icoIdx = 0; WORD wStatus; char *szProto = mdat->szProto; HANDLE hContact = mdat->hContact; if (strcmp(mdat->szProto, "MetaContacts") == 0 && DBGetContactSettingByte(NULL,"CLC","Meta",0) == 0) { hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(UINT)mdat->hContact, 0); if (hContact != NULL) { szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(UINT)hContact,0); } else { hContact = mdat->hContact; } } wStatus = DBGetContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE); mdat->wStatus = wStatus; if (mdat->hwnd == dat->hwndActive) { if (DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_STATUSICON, SRMSGDEFSET_STATUSICON)) { if (mdat->showTyping && (g_dat->flags&SMF_SHOWTYPINGWIN)) { SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) g_dat->hIcons[SMF_ICON_TYPING]); } else if (mdat->showUnread && (GetActiveWindow() != hwndDlg || GetForegroundWindow() != hwndDlg)) { SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); } else { SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedProtoIcon(szProto, wStatus)); } } else { SendMessage(hwndDlg, WM_SETICON, (WPARAM) ICON_BIG, (LPARAM) LoadSkinnedIcon(SKINICON_EVENT_MESSAGE)); } } SendDlgItemMessage(mdat->hwnd, IDC_USERMENU, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadSkinnedProtoIcon(szProto, wStatus)); icoIdx = 0; for (i = 0; i < g_dat->protoNum; i++) { if (!strcmp(g_dat->protoNames[i], szProto)) { icoIdx = wStatus - ID_STATUS_OFFLINE + (ID_STATUS_OUTTOLUNCH - ID_STATUS_OFFLINE + 1) * (i +1) + 2; break; } } if (mdat->hwnd != dat->hwndActive) { if (mdat->showTyping) { icoIdx = 1; } else if (mdat->showUnread & 1) { icoIdx = 0; } } i = GetTabFromHWND(dat, mdat->hwnd); if (i>=0) { TCITEM tci; tci.mask = TCIF_IMAGE; tci.iImage = icoIdx; TabCtrl_SetItem(dat->hwndTabs, i, &tci); } } } break; } case DM_UPDATESTATUSBAR: break; case DM_SWITCHSTATUSBAR: dat->flags ^= SMF_SHOWSTATUSBAR; if (!(dat->flags & SMF_SHOWSTATUSBAR)) { ShowWindow(dat->hwndStatus, SW_HIDE); } else { ShowWindow(dat->hwndStatus, SW_SHOW); } SendMessage(hwndDlg, WM_SIZE, 0, 0); break; case DM_SWITCHTOOLBAR: { int i; dat->flags ^= SMF_SHOWBTNS; for (i=0;i<dat->childrenCount;i++) { SendMessage(dat->children[i], DM_SWITCHTOOLBAR, 0, 0); } SendMessage(hwndDlg, WM_SIZE, 0, 0); } break; case DM_SWITCHTITLEBAR: { RECT rc; dat->flags ^= SMF_SHOWTITLEBAR; ws = GetWindowLong(hwndDlg, GWL_STYLE) & ~(WS_CAPTION); if (dat->flags & SMF_SHOWTITLEBAR) { ws |= WS_CAPTION; } SetWindowLong(hwndDlg, GWL_STYLE, ws); GetWindowRect(hwndDlg, &rc); SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING); // SendMessage(hwndDlg, WM_SIZE, 0, 0); RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); } break; case DM_CASCADENEWWINDOW: if ((HWND) wParam == hwndDlg) break; { RECT rcThis, rcNew; GetWindowRect(hwndDlg, &rcThis); GetWindowRect((HWND) wParam, &rcNew); if (abs(rcThis.left - rcNew.left) < 3 && abs(rcThis.top - rcNew.top) < 3) { int offset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME); SetWindowPos((HWND) wParam, 0, rcNew.left + offset, rcNew.top + offset, 0, 0, SWP_NOZORDER | SWP_NOSIZE); *(int *) lParam = 1; } } break; //case DM_MESSAGESENDING: // dat->messagesInProgress += wParam ? -1 : 1; // if (dat->messagesInProgress < 0) dat->messagesInProgress = 0; // break; } return FALSE; }