static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND: if (HIWORD(wParam) == STN_CLICKED) { CallService(MS_MSG_SENDMESSAGET, (WPARAM)PUGetContact(hWnd), 0); PUDeletePopup(hWnd); return 1; } break; case WM_CONTEXTMENU: PUDeletePopup(hWnd); return 1; case UM_INITPOPUP: WindowList_Add(hPopupsList, hWnd, PUGetContact(hWnd)); return 1; case UM_FREEPLUGINDATA: WindowList_Remove(hPopupsList, hWnd); return 1; } return DefWindowProc(hWnd, message, wParam, lParam); }
INT_PTR OnRecvMessage(WPARAM wParam, LPARAM lParam) { CCSDATA *pccsd = (CCSDATA *)lParam; PROTORECVEVENT *ppre = ( PROTORECVEVENT * )pccsd->lParam; if(strncmp(ppre->szMessage, szServicePrefix, strlen(szServicePrefix))) return CallService(MS_PROTO_CHAINRECV, wParam, lParam); HWND hwnd = WindowList_Find(hFileList, (HANDLE)pccsd->hContact); if(!IsWindow(hwnd)) { if(hwnd != 0) WindowList_Remove(hFileList, hwnd); FILEECHO *fe = new FILEECHO((HANDLE)pccsd->hContact); fe->inSend = FALSE; hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, DialogProc, (LPARAM)fe); if(hwnd == NULL) { delete fe; return 0; } } char *msg = strdup(ppre->szMessage + strlen(szServicePrefix)); PostMessage(hwnd, WM_FE_MESSAGE, (WPARAM)pccsd->hContact, (LPARAM)msg); return 0; }
CCList::~CCList() { WindowList_Remove(hCLWindowList, hTreeView); _ASSERT(GetWindowLongPtr(GetParent(hTreeView), GWLP_WNDPROC) == (LONG_PTR)ParentSubclassProc); // we won't allow anyone to change our WNDPROC. otherwise we're not sure that we're setting the right WNDPROC back SetWindowLongPtr(hTreeView, GWLP_WNDPROC, (LONG_PTR)OrigTreeViewProc); SetWindowLongPtr(GetParent(hTreeView), GWLP_WNDPROC, (LONG_PTR)OrigParentProc); CWndUserData(GetParent(hTreeView)).SetCList(nullptr); }
CMsgTree::~CMsgTree() { _ASSERT(GetWindowLongPtr(GetParent(hTreeView), GWLP_WNDPROC) == (LONG_PTR)ParentSubclassProc); // we won't allow anyone to change our WNDPROC. otherwise we're not sure that we're setting the right WNDPROC back SetWindowLongPtr(hTreeView, GWLP_WNDPROC, (GetWindowLongPtr(GetParent(hTreeView), GWLP_WNDPROC) == (LONG_PTR)ParentSubclassProc) ? (LONG_PTR)OrigTreeViewProc : (LONG_PTR)DefDlgProc); // yeah, if that crazy Help plugin substituted MY WndProc again, he won't get his WndProc back.. he-he >:) SetWindowLongPtr(GetParent(hTreeView), GWLP_WNDPROC, (LONG_PTR)OrigParentProc); CWndUserData(GetParent(hTreeView)).SetMsgTree(NULL); WindowList_Remove(hMTWindowList, hTreeView); ImageList_Destroy(hImageList); }
void removeWindow(HANDLE hContact) { DWORD frameId = DBGetContactSettingDword(hContact, WEATHERPROTONAME, "mwin", 0); WindowList_Remove(hMwinWindowList, WindowList_Find(hMwinWindowList, hContact)); CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0); DBWriteContactSettingDword(hContact, WEATHERPROTONAME, "mwin", 0); DBDeleteContactSetting(hContact, "CList", "Hidden"); }
int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) { MessageWindowEventData *event = (MessageWindowEventData *)lParam; if (event->uType == MSG_WINDOW_EVT_OPEN) { if (!hDialogsList) hDialogsList = WindowList_Create(); WindowList_Add(hDialogsList, event->hwndWindow, event->hContact); ptrT jid(getTStringA(event->hContact, "jid")); if (jid != NULL) { JABBER_LIST_ITEM *pItem = ListGetItemPtr(LIST_ROSTER, jid); if (pItem && (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_ARCHIVE_AUTO) && m_options.EnableMsgArchive) RetrieveMessageArchive(event->hContact, pItem); } } else if (event->uType == MSG_WINDOW_EVT_CLOSING) { if (hDialogsList) WindowList_Remove(hDialogsList, event->hwndWindow); DBVARIANT dbv; BOOL bSupportTyping = FALSE; if (!db_get(event->hContact, "SRMsg", "SupportTyping", &dbv)) { bSupportTyping = dbv.bVal == 1; db_free(&dbv); } else if (!db_get(NULL, "SRMsg", "DefaultTyping", &dbv)) { bSupportTyping = dbv.bVal == 1; db_free(&dbv); } if (!bSupportTyping || !m_bJabberOnline) return 0; TCHAR jid[JABBER_MAX_JID_LEN]; if (GetClientJID(event->hContact, jid, _countof(jid))) { pResourceStatus r(ResourceInfoFromJID(jid)); if (r && r->m_bMessageSessionActive) { r->m_bMessageSessionActive = FALSE; if (GetResourceCapabilites(jid, TRUE) & JABBER_CAPS_CHATSTATES) m_ThreadInfo->send( XmlNode(_T("message")) << XATTR(_T("to"), jid) << XATTR(_T("type"), _T("chat")) << XATTRID(SerialNext()) << XCHILDNS(_T("gone"), JABBER_FEAT_CHATSTATES)); } } } return 0; }
static INT_PTR CALLBACK QuoteInfoDlgProc1(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) { MCONTACT hContact = NULL; MWindowList hWL; switch (msg) { case WM_INITDIALOG: hContact = MCONTACT(lParam); hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, false); assert(hWL); WindowList_Add(hWL, hdlg, hContact); ::SetWindowLongPtr(hdlg, GWLP_USERDATA, hContact); Utils_RestoreWindowPositionNoSize(hdlg, hContact, QUOTES_MODULE_NAME, WINDOW_PREFIX_INFO); ::ShowWindow(hdlg, SW_SHOW); break; case WM_CLOSE: DestroyWindow(hdlg); return FALSE; case WM_DESTROY: hContact = get_contact(hdlg); if (hContact) { SetWindowLongPtr(hdlg, GWLP_USERDATA, 0); hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, false); assert(hWL); WindowList_Remove(hWL, hdlg); Utils_SaveWindowPosition(hdlg, hContact, QUOTES_MODULE_NAME, WINDOW_PREFIX_INFO); } return FALSE; case WM_COMMAND: if (LOWORD(wParam) == IDOK) { ::DestroyWindow(hdlg); return FALSE; } default: hContact = get_contact(hdlg); break; } return QuoteInfoDlgProcImpl(hContact, hdlg, msg, wParam, lParam); }
static int SrmmMenu_ProcessEvent(WPARAM, LPARAM lParam) { MessageWindowEventData *mwevent = (MessageWindowEventData *)lParam; if (mwevent->uType == MSG_WINDOW_EVT_OPEN) { if (!hDialogsList) hDialogsList = WindowList_Create(); WindowList_Add(hDialogsList, mwevent->hwndWindow, mwevent->hContact); SrmmMenu_UpdateIcon(mwevent->hContact); } else if (mwevent->uType == MSG_WINDOW_EVT_CLOSING) { if (hDialogsList) WindowList_Remove(hDialogsList, mwevent->hwndWindow); } return 0; }
int JabberMenuProcessSrmmEvent( WPARAM wParam, LPARAM lParam ) { MessageWindowEventData *event = (MessageWindowEventData *)lParam; if (event->uType == MSG_WINDOW_EVT_OPEN) { if (!hDialogsList) hDialogsList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); WindowList_Add(hDialogsList, event->hwndWindow, event->hContact); } else if (event->uType == MSG_WINDOW_EVT_CLOSING) { if (hDialogsList) WindowList_Remove(hDialogsList, event->hwndWindow); } return 0; }
int MsgAck(WPARAM, LPARAM lParam) { ACKDATA *ack=(ACKDATA*)lParam; if (ack && ack->cbSize == sizeof(ACKDATA) && ack->type == ACKTYPE_MESSAGE) { if (ack->hProcess == (HANDLE)WindowList_Find(hWindowList,ack->hContact)) { if (db_get_b(NULL, modname, "ShowDeliveryMessages", 1)) CreateMessageAcknowlegedWindow(ack->hContact,ack->result == ACKRESULT_SUCCESS); if (ack->result == ACKRESULT_SUCCESS) { // wrtie it to the DB DBEVENTINFO dbei = { 0 }; DBVARIANT dbv; int reuse = db_get_b(ack->hContact,modname, "Reuse", 0); if (!db_get_ts(ack->hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0')) { T2Utf pszUtf(dbv.ptszVal); dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_UTF | DBEF_SENT; dbei.szModule = (char*)ack->szModule; dbei.timestamp = time(NULL); dbei.cbBlob = (int)mir_strlen(pszUtf) + 1; dbei.pBlob = (PBYTE)(char*)pszUtf; db_event_add(ack->hContact, &dbei); } // check to reuse if (reuse > 1) db_set_b(ack->hContact, modname, "Reuse", (BYTE)(reuse-1)); else { db_set_b(ack->hContact,modname, "Reuse", 0); db_set_ws(ack->hContact, modname, "PounceMsg", _T("")); } } WindowList_Remove(hWindowList,(HWND)ack->hProcess); } } return 0; }
INT_PTR OnSendFile(WPARAM wParam, LPARAM lParam) { HWND hwnd = WindowList_Find(hFileList,(HANDLE)wParam); if(IsWindow(hwnd)) { SetForegroundWindow(hwnd); SetFocus(hwnd); } else { if(hwnd != 0) WindowList_Remove(hFileList, hwnd); FILEECHO *fe = new FILEECHO((HANDLE)wParam); fe->inSend = TRUE; hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, DialogProc, (LPARAM)fe); if(hwnd == NULL) { delete fe; return 0; } //SendMessage(hwnd, WM_FE_SERVICE, 0, TRUE); ShowWindow(hwnd, SW_SHOWNORMAL); } return 1; }
static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch(msg) { case WM_INITDIALOG: { DWORD dwMask; struct ClcContact *contact = NULL; int pCaps; HWND hwndAdd; hContact = (HANDLE)lParam; SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)hContact); dwMask = cfg::getDword(hContact, "Ignore", "Mask1", 0); SendMessage(hWnd, WM_USER + 100, (WPARAM)hContact, dwMask); SendMessage(hWnd, WM_USER + 120, 0, 0); TranslateDialogDefault(hWnd); hwndAdd = GetDlgItem(hWnd, IDC_IGN_ADDPERMANENTLY); // CreateWindowEx(0, _T("CLCButtonClass"), _T("FOO"), WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_hInst, NULL); SendMessage(hwndAdd, BUTTONSETASFLATBTN, 0, 1); SendMessage(hwndAdd, BUTTONSETASFLATBTN + 10, 0, 1); SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(210), IMAGE_ICON, 16, 16, LR_SHARED)); SetWindowText(hwndAdd, TranslateT("Add permanently")); EnableWindow(hwndAdd, cfg::getByte(hContact, "CList", "NotOnList", 0)); hwndAdd = GetDlgItem(hWnd, IDC_DSP_LOADDEFAULT); // CreateWindowEx(0, _T("CLCButtonClass"), _T("FOO"), WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_hInst, NULL); SendMessage(hwndAdd, BUTTONSETASFLATBTN, 0, 1); SendMessage(hwndAdd, BUTTONSETASFLATBTN + 10, 0, 1); SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, 16, 16, LR_SHARED)); SetWindowText(hwndAdd, TranslateT("Revert to default")); EnableWindow(hwndAdd, TRUE); SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Default (global setting)")); SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Show always when available")); SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Hide always")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Default (global setting)")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Never")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Always")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When space is available")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When needed by status message")); if(cfg::clcdat) { FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL); if(contact && contact->type != CLCIT_CONTACT) { DestroyWindow(hWnd); return FALSE; } else { TCHAR szTitle[512]; DWORD dwFlags = cfg::getDword(hContact, "CList", "CLN_Flags", 0); BYTE bSecondLine = cfg::getByte(hContact, "CList", "CLN_2ndline", -1); DWORD dwXMask = cfg::getDword(hContact, "CList", "CLN_xmask", 0); int i = 0; mir_sntprintf(szTitle, 512, TranslateT("Contact list display and ignore options for %s"), contact ? contact->szText : (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)); SetWindowText(hWnd, szTitle); SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); pCaps = CallProtoService(contact ? contact->proto : (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0), PS_GETCAPS, PFLAGNUM_1, 0); Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSONLINE, pCaps & PF1_INVISLIST ? TRUE : FALSE); Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSOFFLINE, pCaps & PF1_VISLIST ? TRUE : FALSE); CheckDlgButton(hWnd, IDC_IGN_PRIORITY, cfg::getByte(hContact, "CList", "Priority", 0) ? 1 : 0); Utils::enableDlgControl(hWnd, IDC_IGN_PRIORITY, TRUE); Utils::enableDlgControl(hWnd, IDC_AVATARDISPMODE, TRUE); Utils::enableDlgControl(hWnd, IDC_SECONDLINEMODE, TRUE); if(dwFlags & ECF_FORCEAVATAR) SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 1, 0); else if(dwFlags & ECF_HIDEAVATAR) SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 2, 0); else SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 0, 0); if(dwFlags & ECF_FORCEOVERLAY) SendDlgItemMessage(hWnd, IDC_OVERLAYICON, BM_SETCHECK, BST_CHECKED, 0); else if(dwFlags & ECF_HIDEOVERLAY) SendDlgItemMessage(hWnd, IDC_OVERLAYICON, BM_SETCHECK, BST_UNCHECKED, 0); else SendDlgItemMessage(hWnd, IDC_OVERLAYICON, BM_SETCHECK, BST_INDETERMINATE, 0); if(dwFlags & ECF_FORCELOCALTIME) SendDlgItemMessage(hWnd, IDC_SHOWLOCALTIME1, BM_SETCHECK, BST_CHECKED, 0); else if(dwFlags & ECF_HIDELOCALTIME) SendDlgItemMessage(hWnd, IDC_SHOWLOCALTIME1, BM_SETCHECK, BST_UNCHECKED, 0); else SendDlgItemMessage(hWnd, IDC_SHOWLOCALTIME1, BM_SETCHECK, BST_INDETERMINATE, 0); if(dwFlags & ECF_FORCEVISIBILITY) SendDlgItemMessage(hWnd, IDC_SHOWVISIBILITY, BM_SETCHECK, BST_CHECKED, 0); else if(dwFlags & ECF_HIDEVISIBILITY) SendDlgItemMessage(hWnd, IDC_SHOWVISIBILITY, BM_SETCHECK, BST_UNCHECKED, 0); else SendDlgItemMessage(hWnd, IDC_SHOWVISIBILITY, BM_SETCHECK, BST_INDETERMINATE, 0); while(xImgCtrlIds[i] != 0) { if(dwXMask & (1 << (2 * xImgCtrlBits[i]))) SendDlgItemMessage(hWnd, xImgCtrlIds[i], BM_SETCHECK, BST_CHECKED, 0); else if(dwXMask & (1 << (2 * xImgCtrlBits[i] + 1))) SendDlgItemMessage(hWnd, xImgCtrlIds[i], BM_SETCHECK, BST_UNCHECKED, 0); else SendDlgItemMessage(hWnd, xImgCtrlIds[i], BM_SETCHECK, BST_INDETERMINATE, 0); i++; } if(bSecondLine == 0xff) SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, 0, 0); else SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, (WPARAM)(bSecondLine + 1), 0); } } WindowList_Add(hWindowListIGN, hWnd, hContact); ShowWindow(hWnd, SW_SHOWNORMAL); return TRUE; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_IGN_PRIORITY: SendMessage(pcli->hwndContactTree, CLM_TOGGLEPRIORITYCONTACT, (WPARAM)hContact, 0); return 0; case IDC_IGN_ALL: SendMessage(hWnd, WM_USER + 100, (WPARAM)hContact, (LPARAM)0xffffffff); return 0; case IDC_IGN_NONE: SendMessage(hWnd, WM_USER + 100, (WPARAM)hContact, (LPARAM)0); return 0; case IDC_IGN_ALWAYSONLINE: if(IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSONLINE)) CheckDlgButton(hWnd, IDC_IGN_ALWAYSOFFLINE, FALSE); break; case IDC_IGN_ALWAYSOFFLINE: if(IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSOFFLINE)) CheckDlgButton(hWnd, IDC_IGN_ALWAYSONLINE, FALSE); break; case IDC_HIDECONTACT: cfg::writeByte(hContact, "CList", "Hidden", (BYTE)(IsDlgButtonChecked(hWnd, IDC_HIDECONTACT) ? 1 : 0)); break; case IDC_IGN_ADDPERMANENTLY: { ADDCONTACTSTRUCT acs = {0}; acs.handle = hContact; acs.handleType = HANDLE_CONTACT; acs.szProto = 0; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hWnd, (LPARAM)&acs); Utils::enableDlgControl(hWnd, IDC_IGN_ADDPERMANENTLY, cfg::getByte(hContact, "CList", "NotOnList", 0)); break; } case IDC_DSP_LOADDEFAULT: { int i = 0; SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, 0, 0); while(xImgCtrlIds[i] != 0) SendDlgItemMessage(hWnd, xImgCtrlIds[i++], BM_SETCHECK, BST_INDETERMINATE, 0); SendDlgItemMessage(hWnd, IDC_OVERLAYICON, BM_SETCHECK, BST_INDETERMINATE, 0); SendDlgItemMessage(hWnd, IDC_LOCALTIME, BM_SETCHECK, BST_INDETERMINATE, 0); SendDlgItemMessage(hWnd, IDC_SHOWVISIBILITY, BM_SETCHECK, BST_INDETERMINATE, 0); break; } case IDOK: { DWORD newMask = 0; struct ClcContact *contact = NULL; SendMessage(hWnd, WM_USER + 110, 0, (LPARAM)&newMask); cfg::writeDword(hContact, "Ignore", "Mask1", newMask); SendMessage(hWnd, WM_USER + 130, 0, 0); if(cfg::clcdat) { LRESULT iSel = SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_GETCURSEL, 0, 0); DWORD dwFlags = cfg::getDword(hContact, "CList", "CLN_Flags", 0), dwXMask = 0; LRESULT checked = 0; int i = 0; FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL); if(iSel != CB_ERR) { dwFlags &= ~(ECF_FORCEAVATAR | ECF_HIDEAVATAR); if(iSel == 1) dwFlags |= ECF_FORCEAVATAR; else if(iSel == 2) dwFlags |= ECF_HIDEAVATAR; if(contact) LoadAvatarForContact(contact); } dwFlags &= ~(ECF_FORCEOVERLAY | ECF_HIDEOVERLAY | ECF_FORCELOCALTIME | ECF_HIDELOCALTIME | ECF_FORCEVISIBILITY | ECF_HIDEVISIBILITY); checked = SendDlgItemMessage(hWnd, IDC_OVERLAYICON, BM_GETCHECK, 0, 0); if(checked == BST_CHECKED) dwFlags |= ECF_FORCEOVERLAY; else if(checked == BST_UNCHECKED) dwFlags |= ECF_HIDEOVERLAY; checked = SendDlgItemMessage(hWnd, IDC_SHOWLOCALTIME1, BM_GETCHECK, 0, 0); if(checked == BST_CHECKED) dwFlags |= ECF_FORCELOCALTIME; else if(checked == BST_UNCHECKED) dwFlags |= ECF_HIDELOCALTIME; checked = SendDlgItemMessage(hWnd, IDC_SHOWVISIBILITY, BM_GETCHECK, 0, 0); if(checked == BST_CHECKED) dwFlags |= ECF_FORCEVISIBILITY; else if(checked == BST_UNCHECKED) dwFlags |= ECF_HIDEVISIBILITY; cfg::writeDword(hContact, "CList", "CLN_Flags", dwFlags); if((iSel = SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_GETCURSEL, 0, 0)) != CB_ERR) { if(iSel == 0) { DBDeleteContactSetting(hContact, "CList", "CLN_2ndline"); if(contact) contact->bSecondLine = cfg::dat.dualRowMode; } else { DBWriteContactSettingByte(hContact, "CList", "CLN_2ndline", (BYTE)(iSel - 1)); if(contact) contact->bSecondLine = (BYTE)(iSel - 1); } } while(xImgCtrlIds[i] != 0) { checked = SendDlgItemMessage(hWnd, xImgCtrlIds[i], BM_GETCHECK, 0, 0); if(checked == BST_CHECKED) dwXMask |= (1 << (2 * xImgCtrlBits[i])); else if(checked == BST_UNCHECKED) dwXMask |= (1 << (2 * xImgCtrlBits[i] + 1)); i++; } cfg::writeDword(hContact, "CList", "CLN_xmask", dwXMask); if(contact) { if(contact->extraCacheEntry >= 0 && contact->extraCacheEntry <= cfg::nextCacheEntry) { cfg::eCache[contact->extraCacheEntry].dwDFlags = dwFlags; cfg::eCache[contact->extraCacheEntry].dwXMask = CalcXMask(hContact); } } else { int iIndex = cfg::getCache(hContact, NULL); if(iIndex >= 0 && iIndex <= cfg::nextCacheEntry) { cfg::eCache[iIndex].dwDFlags = dwFlags; cfg::eCache[iIndex].dwXMask = CalcXMask(hContact); } } cfg::writeByte(hContact, "CList", "Priority", (BYTE)(IsDlgButtonChecked(hWnd, IDC_IGN_PRIORITY) ? 1 : 0)); pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0); } } case IDCANCEL: DestroyWindow(hWnd); break; } break; case WM_USER + 100: // fill dialog (wParam = hContact, lParam = mask) { CheckDlgButton(hWnd, IDC_IGN_MSGEVENTS, lParam & (1 << (IGNOREEVENT_MESSAGE - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_FILEEVENTS, lParam & (1 << (IGNOREEVENT_FILE - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_URLEVENTS, lParam & (1 << (IGNOREEVENT_URL - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_AUTH, lParam & (1 << (IGNOREEVENT_AUTHORIZATION - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_ADD, lParam & (1 << (IGNOREEVENT_YOUWEREADDED - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_ONLINE, lParam & (1 << (IGNOREEVENT_USERONLINE - 1)) ? BST_CHECKED : BST_UNCHECKED); return 0; } case WM_USER + 110: // retrieve value { DWORD *dwNewMask = (DWORD *)lParam, dwMask = 0; dwMask = (IsDlgButtonChecked(hWnd, IDC_IGN_MSGEVENTS) ? (1 << (IGNOREEVENT_MESSAGE - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_FILEEVENTS) ? (1 << (IGNOREEVENT_FILE - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_URLEVENTS) ? (1 << (IGNOREEVENT_URL - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_AUTH) ? (1 << (IGNOREEVENT_AUTHORIZATION - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_ADD) ? (1 << (IGNOREEVENT_YOUWEREADDED - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_ONLINE) ? (1 << (IGNOREEVENT_USERONLINE - 1)) : 0); if(dwNewMask) *dwNewMask = dwMask; return 0; } case WM_USER + 120: // set visibility status { struct ClcContact *contact = NULL; if(FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL)) { if(contact) { WORD wApparentMode = cfg::getWord(contact->hContact, contact->proto, "ApparentMode", 0); CheckDlgButton(hWnd, IDC_IGN_ALWAYSOFFLINE, wApparentMode == ID_STATUS_OFFLINE ? TRUE : FALSE); CheckDlgButton(hWnd, IDC_IGN_ALWAYSONLINE, wApparentMode == ID_STATUS_ONLINE ? TRUE : FALSE); } } return 0; } case WM_USER + 130: // update apparent mode { struct ClcContact *contact = NULL; if(FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, NULL, NULL)) { if(contact) { WORD wApparentMode = 0, oldApparentMode = cfg::getWord(hContact, contact->proto, "ApparentMode", 0); if(IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSONLINE)) wApparentMode = ID_STATUS_ONLINE; else if(IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSOFFLINE)) wApparentMode = ID_STATUS_OFFLINE; //DBWriteContactSettingWord(hContact, contact->proto, "ApparentMode", wApparentMode); //if(oldApparentMode != wApparentMode) CallContactService(hContact, PSS_SETAPPARENTMODE, (WPARAM)wApparentMode, 0); SendMessage(hWnd, WM_USER + 120, 0, 0); } } return 0; } case WM_DESTROY: SetWindowLongPtr(hWnd, GWLP_USERDATA, 0); WindowList_Remove(hWindowListIGN, hWnd); break; } return FALSE; }
static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { AwayMsgDlgData *dat = (AwayMsgDlgData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (message) { case WM_INITDIALOG: { TCHAR str[256], format[128]; TCHAR *contactName; TranslateDialogDefault(hwndDlg); dat = (AwayMsgDlgData *)mir_alloc(sizeof(AwayMsgDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = lParam; dat->hSeq = (HANDLE)CallContactService(dat->hContact, PSS_GETAWAYMSG, 0, 0); dat->hAwayMsgEvent = dat->hSeq ? HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_AWAYMSG) : NULL; WindowList_Add(hWindowList2, hwndDlg, dat->hContact); contactName = (TCHAR *)pcli->pfnGetContactDisplayName(dat->hContact, 0); GetWindowText(hwndDlg, format, _countof(format)); mir_sntprintf(str, _countof(str), format, contactName); SetWindowText(hwndDlg, str); if (!dat->hSeq) DestroyWindow(hwndDlg); return TRUE; } case HM_AWAYMSG: { ACKDATA *ack = (ACKDATA *)lParam; if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) { DestroyWindow(hwndDlg); break; } if (ack->result != ACKRESULT_SUCCESS) { DestroyWindow(hwndDlg); break; } if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; } if (!OpenClipboard(hwndDlg)) { DestroyWindow(hwndDlg); break; } if (EmptyClipboard()) { TCHAR msg[1024]; TCHAR *tszMsg = StrNormNewline((TCHAR *)ack->lParam); _tcsncpy_s(msg, tszMsg, _TRUNCATE); mir_free(tszMsg); size_t len = mir_tstrlen(msg); if (len) { LPTSTR lptstrCopy; HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(TCHAR)); if (hglbCopy == NULL) { CloseClipboard(); DestroyWindow(hwndDlg); break; } lptstrCopy = (LPTSTR)GlobalLock(hglbCopy); memcpy(lptstrCopy, msg, len * sizeof(TCHAR)); lptstrCopy[len] = (TCHAR)0; GlobalUnlock(hglbCopy); SetClipboardData(CF_UNICODETEXT, hglbCopy); } } CloseClipboard(); DestroyWindow(hwndDlg); break; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: case IDOK: DestroyWindow(hwndDlg); break; } break; case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: if (dat->hAwayMsgEvent) UnhookEvent(dat->hAwayMsgEvent); WindowList_Remove(hWindowList2, hwndDlg); mir_free(dat); break; } return FALSE; }
INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct UrlSendData* dat = (struct UrlSendData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_URL); Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View user's history")); Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User menu")); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_LIMITTEXT, 450, 0); dat = (struct UrlSendData*)mir_alloc(sizeof(struct UrlSendData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = lParam; dat->hAckEvent = NULL; dat->hSendId = NULL; dat->sendBuffer = NULL; WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact); { TCHAR *str = pcli->pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_NAME, str); } GetOpenBrowserUrls(hwndDlg, GetDlgItem(hwndDlg, IDC_URLS)); SendDlgItemMessage(hwndDlg, IDC_URLS, CB_SETCURSEL, 0, 0); if (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0))SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_URLS, CBN_SELCHANGE), 0); EnableWindow(GetDlgItem(hwndDlg, IDOK), (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0) == CB_ERR)?FALSE:TRUE); Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "send"); mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MESSAGE), SendEditSubclassProc); mir_subclassWindow( GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), SendEditSubclassProc); // From message dlg if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0); // From message dlg end return TRUE; case WM_DDE_DATA: case WM_DDE_ACK: return DdeMessage(hwndDlg, msg, wParam, lParam); case WM_TIMER: if (wParam == 0) { //ICQ sendurl timed out KillTimer(hwndDlg, 0); MessageBox(hwndDlg, TranslateT("Send timed out"), _T(""), MB_OK); EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), TRUE); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, FALSE, 0); } break; case WM_MEASUREITEM: return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam); case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto = GetContactProto(dat->hContact); if (szProto) { HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); if (hIcon) { DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); } } } } return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); case DM_UPDATETITLE: sttUpdateTitle(hwndDlg, dat->hContact); break; case WM_COMMAND: if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { case IDOK: { char *body, *url; int bodySize, urlSize; urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS))+1; url = (char*)mir_alloc(urlSize); GetDlgItemTextA(hwndDlg, IDC_URLS, url, urlSize); if (url[0] == 0) { mir_free(url); break; } bodySize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE))+1; body = (char*)mir_alloc(bodySize); GetDlgItemTextA(hwndDlg, IDC_MESSAGE, body, bodySize); dat->sendBuffer = (char*)mir_realloc(dat->sendBuffer, mir_strlen(url)+mir_strlen(body)+2); mir_strcpy(dat->sendBuffer, url); mir_strcpy(dat->sendBuffer+mir_strlen(url)+1, body); dat->hAckEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT); dat->hSendId = (HANDLE)CallContactService(dat->hContact, PSS_URL, 0, (LPARAM)dat->sendBuffer); mir_free(url); mir_free(body); //create a timeout timer SetTimer(hwndDlg, 0, TIMEOUT_URLSEND, NULL); EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), FALSE); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, TRUE, 0); return TRUE; } case IDCANCEL: DestroyWindow(hwndDlg); return TRUE; case IDC_URLS: if (HIWORD(wParam) == CBN_SELCHANGE) { int i, urlSize; char *title; i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0); title = (char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, (WPARAM)i, 0); SetDlgItemTextA(hwndDlg, IDC_MESSAGE, title); urlSize = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETLBTEXTLEN, (WPARAM)i, 0); EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0)); } else if (HIWORD(wParam) == CBN_EDITCHANGE) { int urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS)); EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0)); } break; case IDC_USERMENU: { RECT rc; HMENU hMenu = Menu_BuildContactMenu(dat->hContact); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_ADD: ADDCONTACTSTRUCT acs = {0}; acs.hContact = dat->hContact; acs.handleType = HANDLE_CONTACT; acs.szProto = 0; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); } break; case HM_EVENTSENT: { ACKDATA *ack = (ACKDATA*)lParam; if (ack->hProcess != dat->hSendId) break; if (ack->hContact != dat->hContact) break; if (ack->type != ACKTYPE_URL || ack->result != ACKRESULT_SUCCESS) break; DBEVENTINFO dbei = { 0 }; dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_URL; dbei.flags = DBEF_SENT; dbei.szModule = GetContactProto(dat->hContact); dbei.timestamp = time(NULL); dbei.cbBlob = (DWORD)(mir_strlen(dat->sendBuffer)+mir_strlen(dat->sendBuffer+mir_strlen(dat->sendBuffer)+1)+2); dbei.pBlob = (PBYTE)dat->sendBuffer; db_event_add(dat->hContact, &dbei); KillTimer(hwndDlg, 0); DestroyWindow(hwndDlg); } break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); WindowList_Remove(hUrlWindowList, hwndDlg); if (dat->hAckEvent) UnhookEvent(dat->hAckEvent); if (dat->sendBuffer != NULL) mir_free(dat->sendBuffer); mir_free(dat); Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "send"); for (int i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0)-1;i>=0;i--) mir_free((char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, i, 0)); break; } return FALSE; }
INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct UrlRcvData *dat = (struct UrlRcvData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_URL); Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View user's history")); Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User menu")); dat = (struct UrlRcvData*)mir_alloc(sizeof(struct UrlRcvData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = ((CLISTEVENT*)lParam)->hContact; dat->hDbEvent = ((CLISTEVENT*)lParam)->hDbEvent; WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact); { DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent); dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); db_event_get(dat->hDbEvent, &dbei); SetDlgItemTextA(hwndDlg, IDC_URL, (char*)dbei.pBlob); SetDlgItemTextA(hwndDlg, IDC_MSG, (char*)dbei.pBlob+mir_strlen((char*)dbei.pBlob)+1); mir_free(dbei.pBlob); db_event_markRead(dat->hContact, dat->hDbEvent); TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0), msg[128]; mir_sntprintf(msg, _countof(msg), TranslateT("URL from %s"), contactName); SetWindowText(hwndDlg, msg); SetDlgItemText(hwndDlg, IDC_FROM, contactName); SendDlgItemMessage(hwndDlg, IDOK, BUTTONSETARROW, 1, 0); TCHAR str[128]; TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), str, _countof(str), 0); SetDlgItemText(hwndDlg, IDC_DATE, str); } // From message dlg if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0); // From message dlg end Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "recv"); return TRUE; case WM_MEASUREITEM: return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam); case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto = GetContactProto(dat->hContact); if (szProto) { HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); if (hIcon) { DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); } } } } return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); case DM_UPDATETITLE: sttUpdateTitle(hwndDlg, dat->hContact); break; case WM_COMMAND: if (!dat) break; if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch(LOWORD(wParam)) { case IDOK: { RECT rc; char url[256]; HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); HMENU hSubMenu = GetSubMenu(hMenu, 6); TranslateMenu(hSubMenu); GetWindowRect((HWND)lParam, &rc); GetDlgItemTextA(hwndDlg, IDC_URL, url, _countof(url)); switch(TrackPopupMenu(hSubMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, hwndDlg, NULL)) { case IDM_OPENNEW: Utils_OpenUrl(url); break; case IDM_OPENEXISTING: Utils_OpenUrl(url); break; case IDM_COPYLINK: { if ( !OpenClipboard(hwndDlg)) break; EmptyClipboard(); HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, mir_strlen(url)+1); mir_strcpy((char*)GlobalLock(hData), url); GlobalUnlock(hData); SetClipboardData(CF_TEXT, hData); CloseClipboard(); break; } } DestroyMenu(hMenu); } return TRUE; case IDC_USERMENU: { RECT rc; HMENU hMenu = Menu_BuildContactMenu(dat->hContact); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_ADD: { ADDCONTACTSTRUCT acs = {0}; acs.hContact = dat->hContact; acs.handleType = HANDLE_CONTACT; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); } if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) { ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); } break; case IDC_REPLY: CallService(MS_MSG_SENDMESSAGE, (WPARAM)dat->hContact, 0); //fall through case IDCANCEL: DestroyWindow(hwndDlg); return TRUE; } break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); WindowList_Remove(hUrlWindowList, hwndDlg); mir_free(dat); Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "recv"); break; } return FALSE; }
INT_PTR CALLBACK SendDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { TSendContactsData* wndData = (TSendContactsData*)GetWindowLongPtr(hwndDlg, DWLP_USER); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_CONTACTS))); ResetListOptions(GetDlgItem(hwndDlg, IDC_LIST)); SetAllContactChecks(GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)lParam); WindowList_Add(ghSendWindowList, hwndDlg, (HANDLE)lParam); wndData = new TSendContactsData((HANDLE)lParam); SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG)wndData); // new dlg init wndData->hIcons[0] = InitMButton(hwndDlg, IDC_ADD, MAKEINTRESOURCEA(IDI_ADDCONTACT), LPGEN("Add Contact Permanently to List")); wndData->hIcons[1] = InitMButton(hwndDlg, IDC_DETAILS, MAKEINTRESOURCEA(IDI_USERDETAILS), LPGEN("View User's Details")); wndData->hIcons[2] = InitMButton(hwndDlg, IDC_HISTORY, MAKEINTRESOURCEA(IDI_HISTORY), LPGEN("View User's History")); wndData->hIcons[3] = InitMButton(hwndDlg, IDC_USERMENU, MAKEINTRESOURCEA(IDI_DOWNARROW), LPGEN("User Menu")); SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0); // new dialog init done return TRUE; case WM_SETFOCUS: SetFocus(GetDlgItem(hwndDlg, IDC_LIST)); break; case WM_NOTIFY: if (((LPNMHDR)lParam)->idFrom == IDC_LIST) { switch (((LPNMHDR)lParam)->code) { case CLN_NEWCONTACT: case CLN_LISTREBUILT: // rebuild list if (wndData) SetAllContactChecks(GetDlgItem(hwndDlg, IDC_LIST), wndData->hContact); case CLN_OPTIONSCHANGED: ResetListOptions(GetDlgItem(hwndDlg, IDC_LIST)); break; } } break; case WM_TIMER: if (wParam == TIMERID_MSGSEND) { KillTimer(hwndDlg, wParam); wndData->ShowErrorDlg(hwndDlg, "The contacts send timed out.", TRUE); } break; case DM_ERRORDECIDED: EnableWindow(hwndDlg, TRUE); wndData->hError = NULL; switch (wParam) { case MSGERROR_CANCEL: wndData->UnhookProtoAck(); if (wndData->uacklist.Count) { for (int i = 0; i < wndData->uacklist.Count; i++) delete gaAckData.Remove(wndData->uacklist.Items[i]); // remove our ackdata & release structure mir_free(wndData->uacklist.Items); wndData->uacklist.Items = NULL; wndData->uacklist.Count = 0; } EnableDlgItem(hwndDlg, IDOK, TRUE); EnableDlgItem(hwndDlg, IDC_LIST, TRUE); ShowWindow(hwndDlg, SW_SHOWNORMAL); SetFocus(GetDlgItem(hwndDlg, IDC_LIST)); break; case MSGERROR_DONE: // contacts were delivered succesfully after timeout SetFocus(GetDlgItem(hwndDlg, IDC_LIST)); wndData->UnhookProtoAck(); break; case MSGERROR_RETRY:// resend timeouted packets for (int i = 0; i < wndData->uacklist.Count; i++) { TAckData *lla = gaAckData.Remove(wndData->uacklist.Items[i]); HANDLE hProcc = (HANDLE)CallContactService(wndData->hContact, PSS_CONTACTS, MAKEWPARAM(0, lla->nContacts), (LPARAM)lla->aContacts); if (!hProcc) { // if fatal do not include wndData->uacklist.Remove(wndData->uacklist.Items[i]); delete lla; // release the structure continue; } else { // update process code wndData->uacklist.Items[i] = hProcc; gaAckData.Add(hProcc, lla); } }// collect TAckData for our window, resend break; } break; case WM_COMMAND: if (!lParam && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)wndData->hContact)) break; switch (LOWORD(wParam)) { case IDOK: if (IsWindowEnabled(GetDlgItem(hwndDlg, IDOK))) { HANDLE hContact, hItem; wndData->ClearContacts(); // do not include contacts twice HWND hList = GetDlgItem(hwndDlg, IDC_LIST); hContact = FindFirstClistContact(hList, &hItem); while (hContact) { // build list of contacts to send if (SendMessage(hList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) wndData->AddContact(hContact); hContact = FindNextClistContact(hList, hContact, &hItem); } /* send contacts */ if (!wndData->SendContacts(hwndDlg)) break; SetTimer(hwndDlg, TIMERID_MSGSEND, db_get_dw(NULL, "SRMsg", "MessageTimeout", TIMEOUT_MSGSEND), NULL); } break; case IDCANCEL: DestroyWindow(hwndDlg); break; case ID_SELECTALL: { // select all contacts HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST); HANDLE hItem, hContact = FindFirstClistContact(hwndList, &hItem); while (hContact) { SendMessage(hwndList, CLM_SETCHECKMARK, (WPARAM)hItem, 1); hContact = FindNextClistContact(hwndList, hContact, &hItem); } } break; case IDC_USERMENU: { RECT rc; HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)wndData->hContact, 0); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)wndData->hContact, 0); break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)wndData->hContact, 0); break; case IDC_ADD: DialogAddContactExecute(hwndDlg, wndData->hContact); break; } break; case HM_EVENTSENT: { ACKDATA *ack = (ACKDATA*)lParam; if (ack->type != ACKTYPE_CONTACTS) break; TAckData *ackData = gaAckData.Get(ack->hProcess); if (ackData == NULL) break; // on unknown hprocc go away if (ackData->hContact != ack->hContact) break; // this is not ours, strange if (ack->result == ACKRESULT_FAILED) { // some process failed, show error dialog KillTimer(hwndDlg, TIMERID_MSGSEND); wndData->ShowErrorDlg(hwndDlg, (char *)ack->lParam, TRUE); // ackData get used in error handling, released there break; } DBEVENTINFO dbei = { sizeof(dbei) }; dbei.szModule = GetContactProto(ackData->hContact); dbei.eventType = EVENTTYPE_CONTACTS; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.timestamp = time(NULL); //make blob TCTSend* maSend = (TCTSend*)_alloca(ackData->nContacts*sizeof(TCTSend)); ZeroMemory(maSend, ackData->nContacts*sizeof(TCTSend)); dbei.cbBlob = 0; char* pBlob; int i; for (i = 0; i < ackData->nContacts; i++) { // prepare data & count size maSend[i].mcaNick = mir_utf8encodeT(pcli->pfnGetContactDisplayName(ackData->aContacts[i], 0)); maSend[i].mcaUIN = mir_utf8encodeT(ptrT(GetContactUID(ackData->aContacts[i]))); dbei.cbBlob += (DWORD)strlennull(maSend[i].mcaUIN) + (DWORD)strlennull((char*)maSend[i].mcaNick) + 2; } dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob); for (i = 0, pBlob = (char*)dbei.pBlob; i < ackData->nContacts; i++) { strcpynull(pBlob, (char*)maSend[i].mcaNick); pBlob += strlennull(pBlob) + 1; strcpynull(pBlob, maSend[i].mcaUIN); pBlob += strlennull(pBlob) + 1; } db_event_add(ackData->hContact, &dbei); gaAckData.Remove(ack->hProcess); // do not release here, still needed wndData->uacklist.Remove(ack->hProcess); // packet confirmed for (i = 0; i < ackData->nContacts; i++) { mir_free(maSend[i].mcaUIN); mir_free(maSend[i].mcaNick); } delete ackData; // all done, release structure if (!wndData->uacklist.Count) { SkinPlaySound("SentContacts"); KillTimer(hwndDlg, TIMERID_MSGSEND); if (wndData->hError) SendMessage(wndData->hError, DM_ERRORDECIDED, MSGERROR_DONE, 0); SendMessage(hwndDlg, WM_CLOSE, 0, 0); // all packets confirmed, close the dialog } } break; case WM_MEASUREITEM: return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: DrawProtocolIcon(hwndDlg, lParam, wndData->hContact); return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case DM_UPDATETITLE: UpdateDialogTitle(hwndDlg, wndData ? wndData->hContact : NULL, TranslateT("Send Contacts to")); if (wndData) UpdateDialogAddButton(hwndDlg, wndData->hContact); break; case WM_CLOSE: wndData->UnhookProtoAck(); DestroyWindow(hwndDlg); break; case WM_DESTROY: for (int i = 0; i < SIZEOF(wndData->hIcons); i++) DestroyIcon(wndData->hIcons[i]); WindowList_Remove(ghSendWindowList, hwndDlg); delete wndData; break; } return FALSE; }
INT_PTR CMimAPI::RemoveWindow(HWND hWnd) { return WindowList_Remove(m_hMessageWindowList, hWnd); }
static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { AwayMsgDlgData *dat = (AwayMsgDlgData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (message) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); dat = (AwayMsgDlgData *)mir_alloc(sizeof(AwayMsgDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = lParam; dat->hSeq = (HANDLE)CallContactService(dat->hContact, PSS_GETAWAYMSG, 0, 0); dat->hAwayMsgEvent = dat->hSeq ? HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_AWAYMSG) : NULL; WindowList_Add(hWindowList, hwndDlg, dat->hContact); { TCHAR str[256], format[128]; TCHAR *contactName = (TCHAR *)pcli->pfnGetContactDisplayName(dat->hContact, 0); char *szProto = GetContactProto(dat->hContact); WORD dwStatus = db_get_w(dat->hContact, szProto, "Status", ID_STATUS_OFFLINE); TCHAR *status = pcli->pfnGetStatusModeDescription(dwStatus, 0); GetWindowText(hwndDlg, format, _countof(format)); mir_sntprintf(str, _countof(str), format, status, contactName); SetWindowText(hwndDlg, str); if (dat->hSeq) { GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, _countof(format)); mir_sntprintf(str, _countof(str), format, status); } else { mir_sntprintf(str, _countof(str), TranslateT("Failed to retrieve %s message."), status); SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close")); } SetDlgItemText(hwndDlg, IDC_RETRIEVING, str); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_LoadProtoIcon(szProto, dwStatus)); SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_LoadProtoIcon(szProto, dwStatus)); EnableWindow(GetDlgItem(hwndDlg, IDC_COPY), FALSE); } Utils_RestoreWindowPosition(hwndDlg, lParam, "SRAway", "AwayMsgDlg"); return TRUE; case HM_AWAYMSG: { ACKDATA *ack = (ACKDATA *)lParam; if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) break; if (ack->result != ACKRESULT_SUCCESS) break; if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; } TCHAR *tszMsg = StrNormNewline((TCHAR *)ack->lParam); SetDlgItemText(hwndDlg, IDC_MSG, tszMsg); mir_free(tszMsg); if (ack->lParam && *((char *)ack->lParam) != '\0') EnableWindow(GetDlgItem(hwndDlg, IDC_COPY), TRUE); ShowWindow(GetDlgItem(hwndDlg, IDC_RETRIEVING), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_MSG), SW_SHOW); SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close")); break; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: case IDOK: DestroyWindow(hwndDlg); break; case IDC_COPY: if (!OpenClipboard(hwndDlg)) break; if (EmptyClipboard()) { TCHAR msg[1024]; int len = GetDlgItemText(hwndDlg, IDC_MSG, msg, _countof(msg)); if (len) { LPTSTR lptstrCopy; HGLOBAL hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(TCHAR)); if (hglbCopy == NULL) { CloseClipboard(); break; } lptstrCopy = (LPTSTR)GlobalLock(hglbCopy); memcpy(lptstrCopy, msg, len * sizeof(TCHAR)); lptstrCopy[len] = (TCHAR)0; GlobalUnlock(hglbCopy); SetClipboardData(CF_UNICODETEXT, hglbCopy); } } CloseClipboard(); break; } break; case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: if (dat->hAwayMsgEvent) UnhookEvent(dat->hAwayMsgEvent); Utils_SaveWindowPosition(hwndDlg, dat->hContact, "SRAway", "AwayMsgDlg"); WindowList_Remove(hWindowList, hwndDlg); IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, NULL)); IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, NULL)); mir_free(dat); break; } return FALSE; }
INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; RECT rc; TCHAR url[300]; MCONTACT hContact; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { MCONTACT hContact2 = lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) hContact2); WindowList_Add(hWindowList, hwndDlg, hContact2); url[0] = '\0'; if (!db_get_ts(hContact2, MODULENAME, URL_KEY, &dbv)) { _tcsncpy_s(url, dbv.ptszVal, _TRUNCATE); db_free(&dbv); } SetDlgItemText(hwndDlg, IDC_OPEN_URL, FixButtonText(url, _countof(url))); char preservename[100]; if (!db_get_s(hContact2, MODULENAME, PRESERVE_NAME_KEY, &dbv)) { strncpy_s(preservename, _countof(preservename), dbv.pszVal, _TRUNCATE); db_free(&dbv); } else preservename[0] = 0; SetWindowTextA(hwndDlg, preservename); SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE))); // ////// COLORREF colour = BackgoundClr; COLORREF txtcolor; SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETBKGNDCOLOR, 0, colour); SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_UPDATE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)); SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Update data"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_FIND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)); SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Find"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_OPTIONS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)); SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Contact options"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_ALERT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)); SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Alert options"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_STOP, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)); SendDlgItemMessage(hwndDlg, IDC_STOP, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Stop processing"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_OPEN_URL, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Click here to open this URL in a browser window."), BATF_TCHAR); if (!db_get_b(hContact2, MODULENAME, ON_TOP_KEY, 0)) { SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)); SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Stick to the front"), BATF_TCHAR); } else { SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)); SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Disable stick to the front"), BATF_TCHAR); } SendDlgItemMessage(hwndDlg, IDC_DATA, WM_SETFONT, (WPARAM) h_font, 1); txtcolor = TextClr; SetDlgItemText(hwndDlg, IDC_DATA, _T("")); InvalidateRect(hwndDlg, NULL, 1); SendDlgItemMessage(hwndDlg, IDC_DATA, EM_AUTOURLDETECT, 1, 0); int mask = (int)SendDlgItemMessage(hwndDlg, IDC_DATA, EM_GETEVENTMASK, 0, 0); SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETEVENTMASK, 0, mask | ENM_LINK | ENM_MOUSEEVENTS); SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONSETASFLATBTN, 0, 0); SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BUTTONSETASFLATBTN, 0, 0); SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BUTTONSETASFLATBTN, 0, 0); SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BUTTONSETASFLATBTN, 0, 0); SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BUTTONSETASFLATBTN, 0, 0); SendDlgItemMessage(hwndDlg, IDC_STOP, BUTTONSETASFLATBTN, 0, 0); SendDlgItemMessage(hwndDlg, IDC_OPEN_URL, BUTTONSETASFLATBTN, 0, 0); HDC hdc = GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR)); SelectObject(hdc, (HFONT) SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_GETFONT, 0, 0)); SIZE textSize; GetTextExtentPoint32(hdc, tszSizeString, _countof(tszSizeString), &textSize); int partWidth[2] = { textSize.cx, -1 }; ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc); SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, _countof(partWidth), (LPARAM)partWidth); SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_OWNERDRAW, 0); if ( db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0)) Utils_RestoreWindowPosition(hwndDlg, hContact2, MODULENAME, "WV"); } break; case WM_NOTIFY: switch (((NMHDR *) lParam)->code) { case EN_MSGFILTER: switch (((MSGFILTER *) lParam)->msg) { case WM_RBUTTONUP: { POINT pt; CHARRANGE sel, all = {0, -1}; HMENU hSubMenu = GetSubMenu(hMenu, 0); TranslateMenu(hSubMenu); SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM) & sel); EnableMenuItem(hSubMenu, IDM_COPY, MF_ENABLED); EnableMenuItem(hSubMenu, IDM_CUT, MF_ENABLED); EnableMenuItem(hSubMenu, IDM_DELETE, MF_ENABLED); if (sel.cpMin == sel.cpMax) { EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(hSubMenu, IDM_CUT, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(hSubMenu, IDM_DELETE, MF_BYCOMMAND | MF_GRAYED); } pt.x = (short) LOWORD(((ENLINK *) lParam)->lParam); pt.y = (short) HIWORD(((ENLINK *) lParam)->lParam); ClientToScreen(((NMHDR *) lParam)->hwndFrom, &pt); switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) { case IDM_COPY: SendMessage(((NMHDR *) lParam)->hwndFrom, WM_COPY, 0, 0); break; case IDM_COPYALL: SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & all); SendMessage(((NMHDR *) lParam)->hwndFrom, WM_COPY, 0, 0); SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & sel); break; case IDM_SELECTALL: SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & all); break; case IDM_CUT: SendMessage(((NMHDR *) lParam)->hwndFrom, WM_CUT, 0, 0); break; case IDM_PASTE: SendMessage(((NMHDR *) lParam)->hwndFrom, WM_PASTE, 0, 0); break; case IDM_DELETE: SendMessage(((NMHDR *) lParam)->hwndFrom, WM_CLEAR, 0, 0); break; case IDM_CLEAR_ALL: SetDlgItemTextA(hwndDlg, IDC_DATA, ""); SetFocus(GetDlgItem(hwndDlg, IDC_DATA)); break; } } } break; case EN_LINK: switch (((ENLINK *) lParam)->msg) { case WM_RBUTTONDOWN: case WM_LBUTTONUP: CHARRANGE sel; SendDlgItemMessage(hwndDlg, IDC_DATA, EM_EXGETSEL, 0, (LPARAM) & sel); if (sel.cpMin != sel.cpMax) break; TEXTRANGEA tr; tr.chrg = ((ENLINK *) lParam)->chrg; tr.lpstrText = (char*)malloc(tr.chrg.cpMax - tr.chrg.cpMin + 8); SendDlgItemMessage(hwndDlg, IDC_DATA, EM_GETTEXTRANGE, 0, (LPARAM) & tr); if (strchr(tr.lpstrText, '@') != NULL && strchr(tr.lpstrText, ':') == NULL && strchr(tr.lpstrText, '/') == NULL) { memmove(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1); memcpy(tr.lpstrText, "mailto:", 7); } Utils_OpenUrl(tr.lpstrText); SetFocus(GetDlgItem(hwndDlg, IDC_DATA)); free(tr.lpstrText); break; } } break; // notify case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_OPEN_URL: GetDlgItemText(hwndDlg, IDC_OPEN_URL, url, _countof(url)); Utils_OpenUrlT(url); db_set_w(wParam, MODULENAME, "Status", ID_STATUS_ONLINE); break; case IDC_UPDATE_BUTTON: if (hContact = FindContactByUrl(hwndDlg)) { EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 0); UpdateMenuCommand(wParam, lParam, hContact); } break; case IDC_STOP: if (hContact = FindContactByUrl(hwndDlg)) db_set_b(hContact, MODULENAME, STOP_KEY, 1); break; case IDC_STICK_BUTTON: if (hContact = FindContactByUrl(hwndDlg)) OnTopMenuCommand(wParam, lParam, hContact); { TCHAR *ptszToolTip; HWND hTopmost; if (!db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0)) { hTopmost = HWND_NOTOPMOST; ptszToolTip = TranslateT("Stick to the front"); } else { hTopmost = HWND_TOPMOST; ptszToolTip = TranslateT("Disable stick to the front"); } SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)); SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM)ptszToolTip, BATF_TCHAR); SetWindowPos(hwndDlg, hTopmost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); } break; case IDC_FIND_BUTTON: { HWND hwndFind = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FIND), hwndDlg, DlgProcFind, (LPARAM) wParam); ShowWindow(hwndFind, SW_SHOW); EnableWindow(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), 0); } break; case IDC_OPTIONS_BUTTON: if (hContact = FindContactByUrl(hwndDlg)) { ContactHwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT), hwndDlg, DlgProcContactOpt, (LPARAM) hContact); ShowWindow(ContactHwnd, SW_SHOW); SetActiveWindow(ContactHwnd); EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0); EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0); } break; case IDC_ALERT_BUTTON: if (hContact = FindContactByUrl(hwndDlg)) { HWND hwndAlertOpt = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), hwndDlg, DlgProcAlertOpt, (LPARAM) hContact); ShowWindow(hwndAlertOpt, SW_SHOW); SetActiveWindow(hwndAlertOpt); EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0); EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0); } break; case IDOK: case IDCANCEL: if (hwndDlg != NULL) DestroyWindow(hwndDlg); return TRUE; } break; case WM_CLOSE: if (Yposition == -32000) Yposition = 100; if (Xposition == -32000) Xposition = 100; SavewinSettings(); if (hContact = FindContactByUrl(hwndDlg)) Utils_SaveWindowPosition(hwndDlg, hContact, MODULENAME, "WV"); if (hwndDlg != NULL) DestroyWindow(hwndDlg); return 0; case WM_DESTROY: WindowList_Remove(hWindowList, hwndDlg); return 0; case WM_SIZE: Utils_ResizeDialog(hwndDlg, hInst, MAKEINTRESOURCEA(IDD_DISPLAY_DATA), DataDialogResize); InvalidateRect(hwndDlg, NULL, TRUE); // global GetWindowRect(hwndDlg, &rc); Xposition = rc.left; Yposition = rc.top; WindowHeight = rc.bottom - rc.top; WindowWidth = rc.right - rc.left; break; case WM_MOVE: if (!IsIconic(hwndDlg) && !IsZoomed(hwndDlg)) { GetWindowRect(hwndDlg, &rc); // global Xposition = rc.left; Yposition = rc.top; WindowHeight = rc.bottom - rc.top; WindowWidth = rc.right - rc.left; if ((GetAsyncKeyState(VK_CONTROL) & 0x8000)) break; ValidatePosition(hwndDlg); } } return FALSE; }
INT_PTR CALLBACK RecvDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { TRecvContactsData* wndData = (TRecvContactsData*)GetWindowLong(hwndDlg, DWLP_USER); switch (msg) { case WM_INITDIALOG: { CLISTEVENT* pcle = (CLISTEVENT*)lParam; /// got it TranslateDialogDefault(hwndDlg); WindowList_Add(ghRecvWindowList, hwndDlg, pcle->hContact); SendMessageT(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_CONTACTS))); EnableDlgItem(hwndDlg, IDOK, FALSE); EnableDlgItem(hwndDlg, IDDETAILS, FALSE); wndData = new TRecvContactsData(pcle->hContact); SetWindowLong(hwndDlg, DWLP_USER, (LONG)wndData); wndData->mhDbEvent = pcle->hDbEvent; /// initialized, pcle not needed anymore wndData->mhListIcon = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLORDDB|ILC_MASK, 0, 1); wndData->mhPopup = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTACTMENU)); CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM)wndData->mhPopup, 0); wndData->hHook = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT); char *szProto = GetContactProto(wndData->mhContact); HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS); ListView_SetExtendedListViewStyle(hLV, LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT); // add columns RecvListView_AddColumn(hLV, 120, (char*)SRCCallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0), FALSE, 0); RecvListView_AddColumn(hLV, 100, "Nick", TRUE, 1); RecvListView_AddColumn(hLV, 100, "First Name", TRUE, 2); RecvListView_AddColumn(hLV, 100, "Last Name", TRUE, 3); // fill in groups SendMessageT(GetDlgItem(hwndDlg, IDC_ENABLEGROUPS), BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); RebuildGroupCombo(hwndDlg); { // fill listview with received contacts DBEVENTINFO dbe = {0}; dbe.cbSize = sizeof(DBEVENTINFO); dbe.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)wndData->mhDbEvent, 0); if (dbe.cbBlob != -1) // this marks an invalid hDbEvent - all smashed anyway... dbe.pBlob = (PBYTE)_malloca(dbe.cbBlob); CallService(MS_DB_EVENT_GET, (WPARAM)wndData->mhDbEvent, (LPARAM)&dbe); char* pcBlob = (char*)dbe.pBlob; char* pcEnd = (char*)dbe.pBlob + dbe.cbBlob; HICON hiProto = LoadContactProtoIcon(wndData->mhContact); ImageList_AddIcon(wndData->mhListIcon, hiProto); DestroyIcon(hiProto); // imagelist copied the resource ListView_SetImageList(hLV, wndData->mhListIcon, LVSIL_SMALL); LVITEM lvi = {0}; lvi.iImage = 0; lvi.mask = LVIF_TEXT | LVIF_IMAGE; for (int nItem = 0; ; nItem++) { // Nick int strsize = (int)strlennull(pcBlob); TReceivedItem* pItem = wndData->AddReceivedItem(); if (dbe.flags & DBEF_UTF) pItem->mcaNick = utf8_to_tchar((unsigned char*)pcBlob); else pItem->mcaNick = ansi_to_tchar(pcBlob); pcBlob += strsize + 1; // UIN strsize = (int)strlennull(pcBlob); pItem->mcaUIN = null_strdup(pcBlob); pcBlob += strsize + 1; // add to listview lvi.iItem = nItem; lvi.pszText = pItem->mcaUIN; ListView_InsertItem(hLV, &lvi); // with image ListView_SetItemTextT(hLV, nItem, 1, pItem->mcaNick); // check for end of contacts if (pcBlob >= pcEnd) break; } } // new dlg init wndData->hIcons[0] = InitMButton(hwndDlg, IDC_ADD, MAKEINTRESOURCEA(IDI_ADDCONTACT), "Add Contact Permanently to List"); wndData->hIcons[1] = InitMButton(hwndDlg, IDC_DETAILS, MAKEINTRESOURCEA(IDI_USERDETAILS), "View User's Details"); wndData->hIcons[2] = InitMButton(hwndDlg, IDC_HISTORY, MAKEINTRESOURCEA(IDI_HISTORY), "View User's History"); wndData->hIcons[3] = InitMButton(hwndDlg, IDC_USERMENU, MAKEINTRESOURCEA(IDI_DOWNARROW), "User Menu"); SendMessageT(hwndDlg,DM_UPDATETITLE,0,0); // new dialog init done Utils_RestoreWindowPosition(hwndDlg, NULL, MODULENAME, ""); return TRUE; } case WM_NOTIFY: if (((LPNMHDR)lParam)->idFrom == IDC_CONTACTS) { switch (((LPNMHDR)lParam)->code) { case NM_DBLCLK: { HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS); if (ListView_GetSelectedCount(hLV) != 1) break; // if not clicking on item, bye wndData->iPopupItem = ListView_GetNextItem(hLV, -1, LVNI_ALL|LVNI_SELECTED); if (wndData->iPopupItem == -1) break; // if no item selected no user details available return SendMessageT(hwndDlg, WM_COMMAND, ID_POPUP_USERDETAILS, 0); // show user details } case LVN_ITEMCHANGED: { LPNMLISTVIEW pNMLV = (LPNMLISTVIEW)lParam; HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS); // optimisation, for FOR-Cycle bool bExistsCheckedItem = false; // there must be no checked items to disable "Add" button if (ListView_GetCheckState(hLV, pNMLV->iItem)) { // the user has checked this item bExistsCheckedItem = true; // enable "Add" button } else { // loop thru items and check if at least one is checked for (int i = 0; i < ListView_GetItemCount(hLV); i++) if (ListView_GetCheckState(hLV, i)) { // we found checked item, enable add, exit loop bExistsCheckedItem = true; break; } } EnableDlgItem(hwndDlg, IDOK, bExistsCheckedItem); EnableDlgItem(hwndDlg, IDDETAILS, ListView_GetSelectedCount(hLV) > 0); break; } } } break; case WM_COMMAND: { if (!lParam && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)wndData->mhContact)) break; switch(LOWORD(wParam)) { case IDOK: // "Add Selected" button click { // for each selected item, find its index in the hDbEvent // and after that add this item to the DB permanently char* caUIN; HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS); HWND hGroupsCombo = GetDlgItem(hwndDlg, IDC_GROUPS); HWND hGroupsCheck = GetDlgItem(hwndDlg, IDC_ENABLEGROUPS); int curs = SendMessageT(hGroupsCombo, CB_GETCURSEL, 0, 0); TCHAR* caGroup = NULL; int nGroupId = -1; if (curs != CB_ERR && IsWindowEnabled(hGroupsCheck) && SendMessageT(hGroupsCheck, BM_GETCHECK, 0, 0)) { //got groups, get the one selected in combo TCHAR* caGroup = (TCHAR*)_malloca((SendMessageT(hGroupsCombo, CB_GETLBTEXTLEN, curs, 0) + 1) * sizeof(WCHAR)); SendMessageT(hGroupsCombo, CB_GETLBTEXT, curs, (LPARAM)caGroup); nGroupId = SendMessageT(hGroupsCombo, CB_GETITEMDATA, curs, 0); } for (int i = 0; i < ListView_GetItemCount(hLV); i++) if (ListView_GetCheckState(hLV, i)) { // found checked contact item, add it caUIN = ListView_GetItemTextEx(hLV, i, 0); for (int j = 0; j < wndData->cbReceived; j++) // determine item index in packet if (!strcmpnull(wndData->maReceived[j]->mcaUIN, caUIN)) { char* szProto = GetContactProto(wndData->mhContact); HANDLE hContact = (HANDLE)SRCCallProtoService(szProto, PS_ADDTOLISTBYEVENT, MAKEWPARAM(0, j), (LPARAM)wndData->mhDbEvent); if (hContact && caGroup) { // use newest group API if available if (ServiceExists(MS_CLIST_CONTACTCHANGEGROUP)) CallService(MS_CLIST_CONTACTCHANGEGROUP, (WPARAM)hContact, (LPARAM)nGroupId); else DBWriteContactSettingStringT(hContact, "CList", "Group", caGroup); } break; } SAFE_FREE((void**)&caUIN); } // move to next item break; } case IDDETAILS: { // for each selected item, find its index in the hDbEvent // and after that add this item to the DB // finally, request Details window for this hContact HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS); for (int i = 0; i < ListView_GetItemCount(hLV); i++) if (ListView_GetItemState(hLV, i, LVIS_SELECTED)) { HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, i); if (hContact) CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0); } break; } case IDCANCEL: { SendMessageT(hwndDlg, WM_CLOSE, 0, 0); break; } case IDC_ENABLEGROUPS: { EnableGroupCombo(hwndDlg); break; } case IDC_GROUPS: { // rebuild group list on popup if (HIWORD(wParam) == CBN_DROPDOWN) RebuildGroupCombo(hwndDlg); break; } case ID_POPUP_ADDUSER: { HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, wndData->iPopupItem); if (hContact) DialogAddContactExecute(hwndDlg, hContact); break; } case ID_POPUP_USERDETAILS: { HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, wndData->iPopupItem); if (hContact) CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0 ); break; } case ID_POPUP_SENDMESSAGE: { HANDLE hContact = CreateTemporaryContactForItem(hwndDlg, wndData, wndData->iPopupItem); if (hContact) CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0); break; } case IDC_USERMENU: { RECT rc; HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)wndData->mhContact, 0); GetWindowRect(GetDlgItem(hwndDlg,IDC_USERMENU), &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); break; } case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY,(WPARAM)wndData->mhContact,0); break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)wndData->mhContact,0); break; case IDC_ADD: DialogAddContactExecute(hwndDlg, wndData->mhContact); break; } break; } case WM_CONTEXTMENU: { HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS); LVHITTESTINFO lvh; RECT rt; wndData->iPopupItem = -1; if ((HWND)wParam != hLV) break; // if not our ListView go away lvh.pt.x = LOWORD(lParam); lvh.pt.y = HIWORD(lParam); if (GetWindowRect(hLV, &rt)==0) return FALSE; // ?? why this, some check ?? ScreenToClient(hLV, &lvh.pt); // convert to ListView local coordinates int ci = ListView_HitTest(hLV, &lvh); if (ci==-1) break; // mouse is not over any item wndData->iPopupItem = ci; TrackPopupMenu(GetSubMenu(wndData->mhPopup, 0), TPM_LEFTALIGN|TPM_TOPALIGN, LOWORD(lParam), HIWORD(lParam), 0, hwndDlg, NULL); break; } case HM_EVENTSENT: { ACKDATA *ack=(ACKDATA*)lParam; if (ack->type!=ACKTYPE_SEARCH) break; // not search ack, go away if (ack->hProcess!=wndData->rhSearch) break; //not our search, go away if (ack->result==ACKRESULT_DATA) { HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS); PROTOSEARCHRESULT* psr = (PROTOSEARCHRESULT*)ack->lParam; LVFINDINFO fi; fi.flags = LVFI_STRING; fi.psz = wndData->haUin; int iLPos = ListView_FindItem(hLV, -1, &fi); if (iLPos==-1) iLPos=0; // ListView_SetItemText(hLV, iLPos, 0, psr->email); // not sent by ICQ, and currently unsupported either if (strcmpnull(psr->nick, "") && psr->nick) ListView_SetItemText(hLV, iLPos, 1, psr->nick); ListView_SetItemText(hLV, iLPos, 2, psr->firstName); ListView_SetItemText(hLV, iLPos, 3, psr->lastName); break; } SAFE_FREE((void**)&wndData->haUin); break; } case WM_CLOSE: // user closed window, so destroy it { WindowList_Remove(ghRecvWindowList, hwndDlg); DestroyWindow(hwndDlg); break; } case WM_DESTROY: // last message received by this dialog, cleanup { CallService(MS_DB_EVENT_MARKREAD, (WPARAM)wndData->mhContact, (LPARAM)wndData->mhDbEvent); Utils_SaveWindowPosition(hwndDlg, NULL, MODULENAME, ""); ImageList_Destroy(wndData->mhListIcon); UnhookEvent(wndData->hHook); DestroyMenu(wndData->mhPopup); for (int i=0; i < SIZEOF(wndData->hIcons); i++) DestroyIcon(wndData->hIcons[i]); delete wndData; // automatically calls destructor break; } case WM_MEASUREITEM: return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: { DrawProtocolIcon(hwndDlg, lParam, wndData->mhContact); return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); } case WM_SIZE: { // make the dlg resizeable UTILRESIZEDIALOG urd = {0}; if (IsIconic(hwndDlg)) break; urd.cbSize = sizeof(urd); urd.hInstance = hInst; urd.hwndDlg = hwndDlg; urd.lParam = 0; // user-defined urd.lpTemplate = MAKEINTRESOURCEA(IDD_RECEIVE); urd.pfnResizer = RecvDlg_Resize; CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM) & urd); break; } case WM_GETMINMAXINFO: { MINMAXINFO* mmi=(MINMAXINFO*)lParam; mmi->ptMinTrackSize.x = 480+2*GetSystemMetrics(SM_CXSIZEFRAME); mmi->ptMinTrackSize.y = 130+2*GetSystemMetrics(SM_CYSIZEFRAME); break; } case DM_UPDATETITLE: { UpdateDialogTitle(hwndDlg, wndData?wndData->mhContact:NULL, "Contacts from"); if (wndData) UpdateDialogAddButton(hwndDlg, wndData->mhContact); break; } } return FALSE; }
/* MainDlgProc handles messages to the main dialog box */ INT_PTR CALLBACK MainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DIALOGPARAM *DlgParam = (DIALOGPARAM*)GetWindowLongPtr(hDlg, GWLP_USERDATA); HMENU listMenu; switch (msg) { case WM_INITDIALOG: { MCONTACT hContact; TCHAR title[256]; TCHAR filter[FILTERTEXT]; RECT rc; POINT pt; SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam); DlgParam = (DIALOGPARAM*)lParam; listMenu = GetMenu(hDlg); TranslateDialogDefault(hDlg); TranslateMenu(listMenu); hContact = ((db_get_b(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0) == 0) ? NULL: DlgParam->hContact); if (db_get_b(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 0) == 0) { // First use of this plugin! Set default size! db_set_dw(hContact, LINKLIST_MODULE, "LinklistWidth", 400); db_set_dw(hContact, LINKLIST_MODULE, "LinklistHeight", 450); db_set_dw(hContact, LINKLIST_MODULE, "LinklistX", 0); db_set_dw(hContact, LINKLIST_MODULE, "LinklistY", 0); db_set_b(hContact, LINKLIST_MODULE, LINKLIST_FIRST, 1); } DlgParam->splitterPosNew = (int)db_get_dw(hContact, LINKLIST_MODULE, LINKLIST_SPLITPOS, -1); GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rc); DlgParam->minSize.cx = rc.right - rc.left; DlgParam->minSize.cy = rc.bottom - rc.top; GetWindowRect(GetDlgItem(hDlg, IDC_SPLITTER), &rc); pt.y = (rc.top + rc.bottom) / 2; pt.x = 0; ScreenToClient(hDlg, &pt); DlgParam->splitterPosOld = rc.bottom - 20 - pt.y; if(DlgParam->splitterPosNew == -1) DlgParam->splitterPosNew = DlgParam->splitterPosOld; Utils_RestoreWindowPosition(hDlg, hContact, LINKLIST_MODULE, "Linklist"); SetClassLongPtr(hDlg, GCLP_HICON, (LONG_PTR)LoadIcon(hInst, MAKEINTRESOURCE(IDI_LINKLISTICON))); WindowList_Add(hWindowList, hDlg, DlgParam->hContact); mir_sntprintf(title, _T("%s [%s]"), TranslateT("Linklist plugin"), pcli->pfnGetContactDisplayName(DlgParam->hContact, 0)); SetWindowText(hDlg, title); GetFilterText(listMenu, filter, _countof(filter)); SetDlgItemText(hDlg, IDC_STATUS, filter); mir_subclassWindow(GetDlgItem(hDlg, IDC_SPLITTER), SplitterProc); SendDlgItemMessage( hDlg, IDC_MAIN, EM_SETEVENTMASK, 0, (LPARAM)ENM_LINK); SendDlgItemMessage( hDlg, IDC_MAIN, EM_AUTOURLDETECT, TRUE, 0 ); // This is used in srmm... and I think he knew what he did... :) SendDlgItemMessage(hDlg, IDC_MAIN, EM_LIMITTEXT, (WPARAM)-1, 0); WriteLinkList(hDlg, WLL_ALL, (LISTELEMENT*)DlgParam->listStart, NULL, 0); return TRUE; } break; // open browser an load url if link is pressed // found at // http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.ui/2004-03/0133.html // // Popup menu on right mouse button is mainly taken from the miranda // send/receive messaging plugin. case WM_NOTIFY: { if (lParam == NULL) break; if (((LPNMHDR)lParam)->code != EN_LINK) break; LPTSTR link; BYTE mouseEvent; ENLINK *pENLink = (ENLINK*)lParam; mouseEvent = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF); switch (pENLink->msg) { case WM_MOUSEMOVE: if (mouseEvent != 0x01) break; memcpy(&DlgParam->chrg, &pENLink->chrg, sizeof(CHARRANGE)); SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)&pENLink->chrg); WriteMessage(hDlg, DlgParam->listStart, SendDlgItemMessage(hDlg, IDC_MAIN, EM_LINEFROMCHAR, -1, 0)); break; case WM_LBUTTONUP: link = (LPTSTR)mir_alloc((pENLink->chrg.cpMax - pENLink->chrg.cpMin + 2) * sizeof(TCHAR)); if (link == NULL) break; SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)&pENLink->chrg); SendDlgItemMessage(hDlg, IDC_MAIN, EM_GETSELTEXT, 0, (LPARAM)link); if (_tcsstr(link, _T("mailto:")) != NULL) ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL); else { bool openNewWindow = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_OPEN_WINDOW, 0xFF) != 0xFF; Utils_OpenUrlT(link,openNewWindow); } mir_free(link); break; case WM_RBUTTONDOWN: { HMENU hPopup, hSubMenu; POINT pt; hPopup = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU2)); hSubMenu = GetSubMenu(hPopup, 0); // Disable Menuoption if "mouse over" events are active mouseEvent = db_get_b(NULL, LINKLIST_MODULE, LINKLIST_MOUSE_EVENT, 0xFF); if (mouseEvent == 0x01) EnableMenuItem(hSubMenu, IDM_SHOWMESSAGE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); TranslateMenu(hSubMenu); link = (LPTSTR)mir_alloc((pENLink->chrg.cpMax - pENLink->chrg.cpMin + 4) * sizeof(TCHAR)); if (link == NULL) break; SendDlgItemMessage(hDlg, IDC_MAIN, EM_EXSETSEL, 0, (LPARAM)&pENLink->chrg); SendDlgItemMessage(hDlg, IDC_MAIN, EM_GETSELTEXT, 0, (LPARAM)link); pt.x = (short)LOWORD(pENLink->lParam); pt.y = (short)HIWORD(pENLink->lParam); ClientToScreen(((NMHDR*)lParam)->hwndFrom, &pt); switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL)) { case IDM_LINK_OPEN: if (_tcsstr(link, _T("mailto:")) != NULL) ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL); else Utils_OpenUrlT(link,false); break; case IDM_LINK_OPENNEW: if (_tcsstr(link, _T("mailto:")) != NULL) ShellExecute(HWND_TOP, NULL, link, NULL, NULL, SW_SHOWNORMAL); else Utils_OpenUrlT(link); break; case IDM_LINK_COPY: { if (!OpenClipboard(hDlg)) break; EmptyClipboard(); size_t dataLen = ((mir_tstrlen(link) + 1) * sizeof(TCHAR)); HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, dataLen); memcpy((LPTSTR)GlobalLock(hData), link, dataLen); GlobalUnlock(hData); SetClipboardData(CF_UNICODETEXT, hData); CloseClipboard(); } break; case IDM_SHOWMESSAGE: WriteMessage(hDlg, DlgParam->listStart, SendDlgItemMessage(hDlg, IDC_MAIN, EM_LINEFROMCHAR, -1, 0)); break; } mir_free(link); DestroyMenu(hPopup); } break; } } break; case WM_COMMAND: { TCHAR filter[40]; listMenu = GetMenu(hDlg); switch (wParam) { case IDM_SEARCH: // open Search Box if (DlgParam != 0) { HWND hWndSearchDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCH_DLG), hDlg, SearchDlgProc, (LPARAM)DlgParam); EnableMenuItem(listMenu, IDM_SEARCH, (MF_BYCOMMAND | MF_DISABLED | MF_GRAYED)); ShowWindow(hWndSearchDlg, SW_SHOW); SetFocus(GetDlgItem(hWndSearchDlg, IDC_SEARCHSTRING)); } break; case IDM_CLEARSEARCH: // clear search results GetFilterText(listMenu, filter, _countof(filter)); SetDlgItemText(hDlg, IDC_STATUS, filter); SetDlgItemText(hDlg, IDC_MAIN, _T("")); WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0); break; case IDM_SAVE: // save button SaveEditAsStream(hDlg); SetFocus(GetDlgItem(hDlg, IDC_MAIN)); break; case IDCANCEL: // Esc or Close pressed case IDM_CLOSE: SendMessage(hDlg, WM_CLOSE, 0, 0); break; case IDM_DIR_IN: // view only incoming messages GetFilterText(listMenu, filter, _countof(filter)); SetDlgItemText(hDlg, IDC_STATUS, filter); if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED)) break; // not possible if search dialog is open SetDlgItemText(hDlg, IDC_MAIN, _T("")); if (GetMenuState(listMenu, IDM_DIR_IN, MF_BYCOMMAND) == MF_CHECKED) { CheckMenuItem(listMenu, IDM_DIR_IN, MF_UNCHECKED); WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0); } else { CheckMenuItem(listMenu, IDM_DIR_IN, MF_CHECKED); CheckMenuItem(listMenu, IDM_DIR_OUT, MF_UNCHECKED); WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0); } GetFilterText(GetMenu(hDlg), filter, _countof(filter)); SetDlgItemText(hDlg, IDC_STATUS, filter); break; case IDM_DIR_OUT: // view only outgoing messages GetFilterText(listMenu, filter, _countof(filter)); SetDlgItemText(hDlg, IDC_STATUS, filter); if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED)) break; // not possible if search dialog is open SetDlgItemText(hDlg, IDC_MAIN, _T("")); if (GetMenuState(listMenu, IDM_DIR_OUT, MF_BYCOMMAND) == MF_CHECKED) { CheckMenuItem(listMenu, IDM_DIR_OUT, MF_UNCHECKED); WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0); } else { CheckMenuItem(listMenu, IDM_DIR_OUT, MF_CHECKED); CheckMenuItem(listMenu, IDM_DIR_IN, MF_UNCHECKED); WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0); } GetFilterText(listMenu, filter, _countof(filter)); SetDlgItemText(hDlg, IDC_STATUS, filter); break; case IDM_TYPE_WEB: // view only e-mail addresses GetFilterText(listMenu, filter, _countof(filter)); SetDlgItemText(hDlg, IDC_STATUS, filter); // not possible if search dialog is open if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED)) break; SetDlgItemText(hDlg, IDC_MAIN, _T("")); if (GetMenuState(listMenu, IDM_TYPE_WEB, MF_BYCOMMAND) == MF_CHECKED) { CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_UNCHECKED); WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0); } else { CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_CHECKED); CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_UNCHECKED); WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0); } GetFilterText(listMenu, filter, _countof(filter)); SetDlgItemText(hDlg, IDC_STATUS, filter); break; case IDM_TYPE_MAIL: // view only URLs if ((GetMenuState(listMenu, IDM_SEARCH, MF_BYCOMMAND) & MF_DISABLED)) break; // not possible if search dialog is open SetDlgItemText(hDlg, IDC_MAIN, _T("")); if (GetMenuState(listMenu, IDM_TYPE_MAIL, MF_BYCOMMAND) == MF_CHECKED) { CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_UNCHECKED); WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0); } else { CheckMenuItem(listMenu, IDM_TYPE_MAIL, MF_CHECKED); CheckMenuItem(listMenu, IDM_TYPE_WEB, MF_UNCHECKED); WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, NULL, 0); } GetFilterText(listMenu, filter, _countof(filter)); SetDlgItemText(hDlg, IDC_STATUS, filter); break; } } break; // Taken from srmm. // Btw: The longer I searched the source of this plugin // to learn how things work, the more I became a fan of // the programmer! case WM_GETMINMAXINFO: { MINMAXINFO *mmi = (MINMAXINFO *)lParam; RECT rcWindow, rcMain; GetWindowRect(hDlg, &rcWindow); GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rcMain); mmi->ptMinTrackSize.x = rcWindow.right - rcWindow.left - ((rcMain.right - rcMain.left) - DlgParam->minSize.cx); mmi->ptMinTrackSize.y = rcWindow.bottom - rcWindow.top - ((rcMain.bottom - rcMain.top) - DlgParam->minSize.cy); } break; case WM_SIZE: Utils_ResizeDialog(hDlg, hInst, MAKEINTRESOURCEA(IDD_MAIN_DLG), LinklistResizer, (LPARAM)DlgParam); // To get some scrollbars if needed... RedrawWindow(GetDlgItem(hDlg, IDC_MAIN), NULL, NULL, RDW_INVALIDATE); RedrawWindow(GetDlgItem(hDlg, IDC_MESSAGE), NULL, NULL, RDW_INVALIDATE); break; case DM_LINKSPLITTER: { POINT pt; RECT rc; int splitPosOld; GetClientRect(hDlg, &rc); pt.x = 0; pt.y = wParam; ScreenToClient(hDlg, &pt); splitPosOld = DlgParam->splitterPosNew; DlgParam->splitterPosNew = rc.bottom - pt.y; GetWindowRect(GetDlgItem(hDlg, IDC_MESSAGE), &rc); if (rc.bottom - rc.top + (DlgParam->splitterPosNew - splitPosOld) < 0) DlgParam->splitterPosNew = splitPosOld + 0 - (rc.bottom - rc.top); GetWindowRect(GetDlgItem(hDlg, IDC_MAIN), &rc); if (rc.bottom - rc.top - (DlgParam->splitterPosNew - splitPosOld) < DlgParam->minSize.cy) DlgParam->splitterPosNew = splitPosOld - DlgParam->minSize.cy + (rc.bottom - rc.top); SendMessage(hDlg, WM_SIZE, 0, 0); } break; case WM_CLOSE: DestroyWindow(hDlg); break; case WM_DESTROY: if (DlgParam != NULL) { MCONTACT hContact = ((db_get_b(NULL, LINKLIST_MODULE, LINKLIST_SAVESPECIAL, 0) == 0) ? NULL: DlgParam->hContact); Utils_SaveWindowPosition(hDlg, hContact, LINKLIST_MODULE, "Linklist"); db_set_dw(NULL, LINKLIST_MODULE, LINKLIST_SPLITPOS, DlgParam->splitterPosNew); RemoveList(DlgParam->listStart); mir_free(DlgParam); } // Remove entry from Window list WindowList_Remove(hWindowList, hDlg); break; } return FALSE; }
INT_PTR CALLBACK HistoryDlgProc(HWND hwndDlg, UINT Message, WPARAM wparam, LPARAM lparam) { MCONTACT hContact; TCHAR sztemp[1024]; switch (Message) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); hContact = (MCONTACT)lparam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lparam); mir_sntprintf(sztemp, _T("%s: %s"), pcli->pfnGetContactDisplayName(hContact, 0), TranslateT("last seen history")); SetWindowText(hwndDlg, sztemp); Window_SetSkinIcon_IcoLib(hwndDlg, SKINICON_OTHER_MIRANDA); if (db_get_b(hContact, S_MOD, "OnlineAlert", 0)) CheckDlgButton(hwndDlg, IDC_STATUSCHANGE, BST_CHECKED); SendDlgItemMessage(hwndDlg, IDC_DETAILS, BM_SETIMAGE, IMAGE_ICON, (WPARAM)Skin_LoadIcon(SKINICON_OTHER_USERDETAILS)); SendDlgItemMessage(hwndDlg, IDC_USERMENU, BM_SETIMAGE, IMAGE_ICON, (WPARAM)Skin_LoadIcon(SKINICON_OTHER_DOWNARROW)); SendDlgItemMessage(hwndDlg, IDC_SENDMSG, BM_SETIMAGE, IMAGE_ICON, (WPARAM)Skin_LoadIcon(SKINICON_EVENT_MESSAGE)); //set-up tooltips SendDlgItemMessage(hwndDlg, IDC_DETAILS, BUTTONADDTOOLTIP, (WPARAM)TranslateT("View User's Details"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_USERMENU, BUTTONADDTOOLTIP, (WPARAM)TranslateT("User Menu"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_SENDMSG, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Send Instant Message"), BATF_TCHAR); Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, S_MOD, "History_"); ShowWindow(hwndDlg, SW_SHOW); return TRUE; case WM_MEASUREITEM: return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lparam); case WM_DRAWITEM: return Menu_DrawItem((LPDRAWITEMSTRUCT)lparam); case WM_COMMAND: hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wparam), MPCF_CONTACTMENU), hContact)) break; switch (LOWORD(wparam)) { case IDCANCEL: SendMessage(hwndDlg, WM_CLOSE, 0, 0); break; case IDOK: if (IsDlgButtonChecked(hwndDlg, IDC_STATUSCHANGE) == BST_CHECKED) db_set_b(hContact, S_MOD, "OnlineAlert", 1); else db_set_b(hContact, S_MOD, "OnlineAlert", 0); SendMessage(hwndDlg, WM_CLOSE, 0, 0); break; case IDC_USERMENU: { RECT rc; GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); HMENU hMenu = Menu_BuildContactMenu(hContact); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, hContact, 0); break; case IDC_SENDMSG: CallService(MS_MSG_SENDMESSAGE, hContact, 0); break; case IDC_TEST: debug(ParseString(LPGENT("Date: %d.%m.%y(%Y) \n Date desc: %W - %w - %E - %e \n Time: %H:%M:%S (%h-%p) \n user: %n - %u \n Status: %s \n IP: %i - %r"), hContact)); break; } break; case WM_SIZE: int dx, dy; { HDWP hDwp = BeginDeferWindowPos(6); MyResizeGetOffset(GetDlgItem(hwndDlg, IDC_HISTORYLIST), LOWORD(lparam) - 15, HIWORD(lparam) - 99, &dx, &dy); hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_USERMENU), dx, 0, 0, 0); hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_DETAILS), dx, 0, 0, 0); hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_SENDMSG), dx, 0, 0, 0); hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_HISTORYLIST), 0, 0, dx, dy); hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_STATUSCHANGE), 0, dy, dx, 0); hDwp = MyHorizCenterWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDOK), LOWORD(lparam), dy, 0); EndDeferWindowPos(hDwp); } break; case WM_GETMINMAXINFO: MINMAXINFO mmi; { memcpy(&mmi, (LPMINMAXINFO)lparam, sizeof(MINMAXINFO)); /* The minimum width in points*/ mmi.ptMinTrackSize.x = 200; /* The minimum height in points*/ mmi.ptMinTrackSize.y = 190; memcpy((LPMINMAXINFO)lparam, &mmi, sizeof(MINMAXINFO)); } break; case WM_CLOSE: DestroyWindow(hwndDlg); WindowList_Remove(hWindowList, hwndDlg); break; case WM_DESTROY: Utils_SaveWindowPosition(hwndDlg, NULL, S_MOD, "History_"); DestroyIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0)); DestroyIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0)); break; } return FALSE; }
static BOOL CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg,UINT message,WPARAM wParam,LPARAM lParam) { struct AwayMsgDlgData *dat; dat=(struct AwayMsgDlgData*)GetWindowLong(hwndDlg,GWL_USERDATA); switch(message) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); dat=(struct AwayMsgDlgData*)mir_alloc(sizeof(struct AwayMsgDlgData)); SetWindowLong(hwndDlg,GWL_USERDATA,(LONG)dat); dat->hContact=(HANDLE)lParam; dat->hAwayMsgEvent=HookEventMessage(ME_PROTO_ACK,hwndDlg,HM_AWAYMSG); dat->hSeq=(HANDLE)CallContactService(dat->hContact,PSS_GETAWAYMSG,0,0); WindowList_Add(hWindowList,hwndDlg,dat->hContact); { char str[256],format[128]; char *status,*contactName; char *szProto; WORD dwStatus; contactName=(char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)dat->hContact,0); szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); dwStatus = DBGetContactSettingWord(dat->hContact,szProto,"Status",ID_STATUS_OFFLINE); status=(char*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,dwStatus,0); GetWindowText(hwndDlg,format,sizeof(format)); _snprintf(str,sizeof(str),format,status,contactName); SetWindowText(hwndDlg,str); GetDlgItemText(hwndDlg,IDC_RETRIEVING,format,sizeof(format)); _snprintf(str,sizeof(str),format,status); SetDlgItemText(hwndDlg,IDC_RETRIEVING,str); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedProtoIcon(szProto, dwStatus)); EnableWindow(GetDlgItem(hwndDlg, IDC_COPY), FALSE); } return TRUE; case HM_AWAYMSG: { ACKDATA *ack=(ACKDATA*)lParam; if(ack->hContact!=dat->hContact) break; if(ack->type!=ACKTYPE_AWAYMSG) break; if(ack->hProcess!=dat->hSeq) break; if(ack->result!=ACKRESULT_SUCCESS) break; if(dat->hAwayMsgEvent!=NULL) {UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent=NULL;} SetDlgItemText(hwndDlg,IDC_MSG,(const char*)ack->lParam); if (ack->lParam) { if (strlen((char*)ack->lParam)) EnableWindow(GetDlgItem(hwndDlg, IDC_COPY), TRUE); } ShowWindow(GetDlgItem(hwndDlg,IDC_RETRIEVING),SW_HIDE); ShowWindow(GetDlgItem(hwndDlg,IDC_MSG),SW_SHOW); SetDlgItemText(hwndDlg,IDOK,Translate("&Close")); break; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: case IDOK: DestroyWindow(hwndDlg); break; case IDC_COPY: { if (OpenClipboard(hwndDlg)) { if (EmptyClipboard()) { HGLOBAL hglbCopy; LPTSTR lptstrCopy; int len; char msg[1024]; len = GetDlgItemText(hwndDlg, IDC_MSG, msg, sizeof(msg)); if (len) { hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(TCHAR)); if (hglbCopy == NULL) { CloseClipboard(); break; } lptstrCopy = GlobalLock(hglbCopy); memcpy(lptstrCopy, msg, len*sizeof(TCHAR)); lptstrCopy[len] = (TCHAR)0; // null character GlobalUnlock(hglbCopy); SetClipboardData(CF_TEXT, hglbCopy); } } CloseClipboard(); } } break; } break; case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: if(dat->hAwayMsgEvent!=NULL) UnhookEvent(dat->hAwayMsgEvent); WindowList_Remove(hWindowList,hwndDlg); mir_free(dat); break; } return FALSE; }
static BOOL CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { struct AwayMsgDlgData *dat; dat=(struct AwayMsgDlgData*)GetWindowLong(hwndDlg, GWL_USERDATA); switch(message) { case WM_INITDIALOG: { char str[256],format[128]; char *contactName; TranslateDialogDefault(hwndDlg); dat = (struct AwayMsgDlgData*)mir_alloc(sizeof(struct AwayMsgDlgData)); SetWindowLong(hwndDlg, GWL_USERDATA, (LONG)dat); dat->hContact = (HANDLE)lParam; dat->hAwayMsgEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_AWAYMSG); dat->hSeq = (HANDLE)CallContactService(dat->hContact, PSS_GETAWAYMSG, 0, 0); WindowList_Add(hWindowList2, hwndDlg, dat->hContact); contactName = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)dat->hContact, 0); GetWindowText(hwndDlg, format, sizeof(format)); _snprintf(str, sizeof(str), format, contactName); SetWindowText(hwndDlg, str); return TRUE; } case HM_AWAYMSG: { ACKDATA *ack=(ACKDATA*)lParam; if(ack->hContact!=dat->hContact) break; if(ack->type!=ACKTYPE_AWAYMSG) break; if(ack->hProcess!=dat->hSeq) break; if(ack->result!=ACKRESULT_SUCCESS) break; if(dat->hAwayMsgEvent != NULL) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; } if (ack->lParam) { if (lstrlen((char*)ack->lParam)) { if (OpenClipboard(hwndDlg)) { if (EmptyClipboard()) { HGLOBAL hglbCopy; LPTSTR lptstrCopy; int len = lstrlen((char*)ack->lParam); hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(TCHAR)); if (hglbCopy == NULL) { CloseClipboard(); DestroyWindow(hwndDlg); break; } lptstrCopy = GlobalLock(hglbCopy); memcpy(lptstrCopy, (char*)ack->lParam, len*sizeof(TCHAR)); lptstrCopy[len] = (TCHAR)0; // null character GlobalUnlock(hglbCopy); SetClipboardData(CF_TEXT, hglbCopy); } CloseClipboard(); } } } DestroyWindow(hwndDlg); break; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: case IDOK: DestroyWindow(hwndDlg); break; } break; case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: if(dat->hAwayMsgEvent!=NULL) UnhookEvent(dat->hAwayMsgEvent); WindowList_Remove(hWindowList2,hwndDlg); mir_free(dat); break; } return FALSE; }
static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); hContact = lParam; WindowList_Add(hWindowList, hwndDlg, hContact); Utils_RestoreWindowPosition(hwndDlg, hContact, "History", ""); { TCHAR* contactName, str[200]; contactName = pcli->pfnGetContactDisplayName(hContact, 0); mir_sntprintf(str, TranslateT("History for %s"), contactName); SetWindowText(hwndDlg, str); } Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_HISTORY); SendMessage(hwndDlg, DM_HREBUILD, 0, 0); return TRUE; case DM_HREBUILD: { THistoryThread* hInfo = (THistoryThread*)mir_alloc(sizeof(THistoryThread)); EnableWindow(GetDlgItem(hwndDlg, IDC_LIST), FALSE); hInfo->hContact = hContact; hInfo->hwnd = hwndDlg; mir_forkthread(FillHistoryThread, hInfo); } return TRUE; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); Utils_SaveWindowPosition(hwndDlg, hContact, "History", ""); WindowList_Remove(hWindowList, hwndDlg); return TRUE; case WM_GETMINMAXINFO: ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 300; ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 230; break; case WM_SIZE: Utils_ResizeDialog(hwndDlg, hInst, MAKEINTRESOURCEA(IDD_HISTORY), HistoryDlgResizer); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: DestroyWindow(hwndDlg); return TRUE; case IDC_FIND: ShowWindow(CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_HISTORY_FIND), hwndDlg, DlgProcHistoryFind, (LPARAM)hwndDlg), SW_SHOW); return TRUE; case IDC_DELETEHISTORY: MEVENT hDbevent; { int index = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); if (index == LB_ERR) break; if (MessageBox(hwndDlg, TranslateT("Are you sure you want to delete this history item?"), TranslateT("Delete history"), MB_YESNO | MB_ICONQUESTION) == IDYES) { hDbevent = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0); db_event_delete(hContact, hDbevent); SendMessage(hwndDlg, DM_HREBUILD, 0, 0); } } return TRUE; case IDC_LIST: if (HIWORD(wParam) == LBN_SELCHANGE) { int sel = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); if (sel == LB_ERR) { EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), FALSE); break; } EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), TRUE); MEVENT hDbEvent = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, sel, 0); DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(hDbEvent); if ((int)dbei.cbBlob != -1) { dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); if (db_event_get(hDbEvent, &dbei) == 0) { TCHAR str[8192]; GetObjectDescription(&dbei, str, _countof(str)); if (str[0]) SetDlgItemText(hwndDlg, IDC_EDIT, str); } mir_free(dbei.pBlob); } } return TRUE; } break; case DM_FINDNEXT: int index = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); if (index == LB_ERR) break; DBEVENTINFO dbei = { sizeof(dbei) }; int oldBlobSize = 0; MEVENT hDbEventStart = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0); for (;;) { MEVENT hDbEvent = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, ++index, 0); if (hDbEvent == LB_ERR) { index = -1; continue; } if (hDbEvent == hDbEventStart) break; int newBlobSize = db_event_getBlobSize(hDbEvent); if (newBlobSize > oldBlobSize) { dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize); oldBlobSize = newBlobSize; } dbei.cbBlob = oldBlobSize; db_event_get(hDbEvent, &dbei); TCHAR str[1024]; GetObjectDescription(&dbei, str, _countof(str)); if (str[0]) { CharUpperBuff(str, (int)mir_tstrlen(str)); if (_tcsstr(str, (const TCHAR*)lParam) != NULL) { SendDlgItemMessage(hwndDlg, IDC_LIST, LB_SETCURSEL, index, 0); SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_LIST, LBN_SELCHANGE), 0); break; } } } mir_free(dbei.pBlob); break; } return FALSE; }
static LRESULT CALLBACK ToolBar_WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { static BOOL supressRepos=FALSE; MTBINFO * pMTBInfo=(MTBINFO *)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (msg) { case WM_CREATE: { HANDLE hFrame=NULL; CLISTFrame Frame={0}; CREATESTRUCT * lpcs = (CREATESTRUCT *) lParam; //create internal info MTBINFO * pMTBInfo = (MTBINFO *) mir_calloc( sizeof(MTBINFO) ); pMTBInfo->cbSize = sizeof(MTBINFO); SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG_PTR) pMTBInfo ); pMTBInfo->nButtonWidth = ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_BtnWidth", SETTINGS_BARBTNWIDTH_DEFAULT); pMTBInfo->nButtonHeight= ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_BtnHeight", SETTINGS_BARBTNHEIGHT_DEFAULT); pMTBInfo->nButtonSpace = ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_BtnSpace", SETTINGS_BARBTNSPACE_DEFAULT); pMTBInfo->fAutoSize = ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_Autosize", SETTINGS_BARAUTOSIZE_DEFAULT); pMTBInfo->fSingleLine = ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_Multiline", SETTINGS_BARMULTILINE_DEFAULT)==0; //register self frame Frame.cbSize=sizeof(CLISTFrame); Frame.hWnd=hwnd; Frame.align=alTop; Frame.hIcon=LoadSkinnedIcon (SKINICON_OTHER_MIRANDA); Frame.Flags=(ModernGetSettingByte(NULL,"CLUI","ShowButtonBar",SETTINGS_SHOWBUTTONBAR_DEFAULT)?F_VISIBLE:0)|F_LOCKED|F_NOBORDER|F_NO_SUBCONTAINER; Frame.height=ModernGetSettingDword(NULL, "ModernToolBar", "option_Bar0_OldHeight", pMTBInfo->nButtonHeight); pMTBInfo->wLastHeight=Frame.height; pMTBInfo->nLineCount = 1; pMTBInfo->pButtonList=li.List_Create(0,1); Frame.name=(char*) lpcs->lpCreateParams; hFrame=(HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,(LPARAM)0); CallService(MS_SKINENG_REGISTERPAINTSUB,(WPARAM)Frame.hWnd,(LPARAM)ToolBar_LayeredPaintProc); //$$$$$ register sub for frame pMTBInfo->hFrame = hFrame; pMTBInfo->hWnd = hwnd; //add self to window list WindowList_Add(tbdat.hToolBarWindowList, hwnd, NULL); pMTBInfo->mtbXPTheme=xpt_AddThemeHandle(hwnd,L"TOOLBAR"); ToolBar_DefaultButtonRegistration(); //SetTimer(hwnd,123,1000,NULL); return 0; } case WM_TIMER: { //KillTimer(hwnd,123); //ToolBar_DefaultButtonRegistration(); return 0; } case WM_SHOWWINDOW: { { int res; int ID; ID= Sync( FindFrameID, hwnd ); if (ID) { res=CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS,ID),0); if (res>=0) ModernWriteSettingByte(0,"CLUI","ShowButtonBar",(BYTE)(wParam/*(res&F_VISIBLE)*/?1:0)); if (wParam) SendMessage(hwnd, MTBM_REPOSBUTTONS, 0, 0); } } break; } case MTBM_UPDATEFRAMEVISIBILITY: { BOOL vis=(BOOL)wParam; INT_PTR frameopt; BOOL curvis=IsWindowVisible(hwnd); BOOL bResize=FALSE; int frameID=Sync( FindFrameID, hwnd ); int Height; pMTBInfo->nButtonWidth = ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_BtnWidth", SETTINGS_BARBTNWIDTH_DEFAULT); pMTBInfo->nButtonHeight= ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_BtnHeight", SETTINGS_BARBTNHEIGHT_DEFAULT); pMTBInfo->nButtonSpace = ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_BtnSpace", SETTINGS_BARBTNSPACE_DEFAULT); pMTBInfo->fAutoSize = ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_Autosize", SETTINGS_BARAUTOSIZE_DEFAULT); pMTBInfo->fSingleLine = ModernGetSettingByte(NULL, "ModernToolBar", "option_Bar0_Multiline", SETTINGS_BARMULTILINE_DEFAULT)==0; Height=sttReposButtons( pMTBInfo ); if (pMTBInfo->fAutoSize) { frameopt=CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT,frameID),0); if (Height!=frameopt) { frameopt=Height; CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_HEIGHT,frameID),frameopt); bResize=TRUE; } } if ((curvis!=vis || bResize) && vis !=-1) { frameopt=CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS,frameID),0); frameopt&=~F_VISIBLE; frameopt|=vis ? F_VISIBLE : 0; CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,frameID),frameopt); } break; } case WM_DESTROY: { xpt_FreeThemeForWindow(hwnd); WindowList_Remove( tbdat.hToolBarWindowList, hwnd ); SendMessage(hwnd, MTBM_REMOVE_ALL_BUTTONS, 0, 0 ); li.List_Destroy( pMTBInfo->pButtonList ); mir_free( pMTBInfo->pButtonList ); SetWindowLongPtr( hwnd, GWLP_USERDATA, 0 ); mir_free( pMTBInfo ); return 0; } case WM_COMMAND: { if (HIWORD(wParam)==BN_CLICKED && lParam!=0 ) sttButtonPressed(pMTBInfo, (HWND) lParam ); return TRUE; } case MTBM_ADDBUTTON: { //Adding button MTB_BUTTONINFO * mtbi=(MTB_BUTTONINFO * )wParam; HWND hwndButton = NULL; if (!(mtbi->bSeparator)) hwndButton= CreateWindow(SKINBUTTONCLASS /*MIRANDABUTTONCLASS*/, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP , 0, 0, pMTBInfo->nButtonWidth, pMTBInfo->nButtonHeight, hwnd, (HMENU) NULL, g_hInst, NULL); mtbi->hWindow=hwndButton; mtbi->hwndToolBar=hwnd; li.List_Insert(pMTBInfo->pButtonList, mtbi, pMTBInfo->pButtonList->realCount); //just insert pointer. such object are managed in global tbbutton list if (hwndButton) { char * buttonId=(char *)_malloca(sizeof("ToolBar.")+strlen(mtbi->szButtonID)+2); strcpy(buttonId,"ToolBar."); strcat(buttonId,mtbi->szButtonID); SendMessage(hwndButton, BUTTONSETID, 0 ,(LPARAM) buttonId ); if (pMTBInfo->bFlatButtons) SendMessage(hwndButton, BUTTONSETASFLATBTN, 0, 1 ); SetWindowLongPtr(hwndButton,GWLP_USERDATA,(LONG_PTR)mtbi); SendMessage(hwndButton, MBM_UPDATETRANSPARENTFLAG, 0, 2); } return (LRESULT)hwndButton; } case MTBM_REMOVE_ALL_BUTTONS: { int i; for (i=0; i<pMTBInfo->pButtonList->realCount; i++ ) { MTB_BUTTONINFO * mtbi=(MTB_BUTTONINFO *)pMTBInfo->pButtonList->items[i]; if (mtbi->hWindow && mtbi->hwndToolBar==hwnd) { DestroyWindow(mtbi->hWindow); mtbi->hWindow = NULL; mtbi->hwndToolBar = NULL; } } li.List_Destroy( pMTBInfo->pButtonList ); mir_free( pMTBInfo->pButtonList ); pMTBInfo->pButtonList=li.List_Create(0,1); break; } case WM_SIZE: if (pMTBInfo->wLastHeight!=HIWORD(lParam)) { ModernWriteSettingDword(NULL, "ModernToolBar", "option_Bar0_OldHeight", HIWORD(lParam)); pMTBInfo->wLastHeight=HIWORD(lParam); } if (supressRepos) { supressRepos=FALSE; break; } //fall through case MTBM_REPOSBUTTONS: { if (pMTBInfo && pMTBInfo->hWnd == hwnd) { int Height=sttReposButtons(pMTBInfo); if ( pMTBInfo->fAutoSize) { RECT rcClient; GetClientRect(pMTBInfo->hWnd, &rcClient); if (rcClient.bottom-rcClient.top != Height && Height) { supressRepos=TRUE; PostMessage(pMTBInfo->hWnd,MTBM_UPDATEFRAMEVISIBILITY, -1, 0); } } return 0; } break; } case WM_ERASEBKGND: if (g_CluiData.fDisableSkinEngine) return sttDrawToolBarBackground(hwnd, (HDC)wParam, NULL, pMTBInfo); else return 0; case WM_NCPAINT: case WM_PAINT: { BOOL ret=FALSE; PAINTSTRUCT ps; BOOL bFloat = (GetParent(hwnd)!=pcli->hwndContactList); if (g_CluiData.fDisableSkinEngine|| !g_CluiData.fLayered || bFloat ) { BeginPaint(hwnd,&ps); if ((!g_CluiData.fLayered || bFloat) && !g_CluiData.fDisableSkinEngine) { sttDrawNonLayeredSkinedBar(hwnd, ps.hdc); } else ret=sttDrawToolBarBackground(hwnd, ps.hdc, &ps.rcPaint, pMTBInfo); EndPaint(hwnd,&ps); } return DefWindowProc(hwnd, msg, wParam, lParam); } case WM_NOTIFY: { if (((LPNMHDR) lParam)->code==BUTTONNEEDREDRAW) pcli->pfnInvalidateRect(hwnd, NULL, FALSE); return 0; } case MTBM_LAYEREDPAINT: { int i; RECT MyRect={0}; HDC hDC=(HDC)wParam; GetWindowRect(hwnd,&MyRect); { RECT rcClient; GetClientRect(hwnd, &rcClient); SkinDrawGlyph(hDC,&rcClient,&rcClient,"Bar,ID=ToolBar,Part=Background"); } for (i=0; i<pMTBInfo->pButtonList->realCount; i++) { RECT childRect; POINT Offset; MTB_BUTTONINFO * mtbi=(MTB_BUTTONINFO *)pMTBInfo->pButtonList->items[i]; GetWindowRect(mtbi->hWindow,&childRect); Offset.x=childRect.left-MyRect.left;; Offset.y=childRect.top-MyRect.top; SendMessage(mtbi->hWindow, BUTTONDRAWINPARENT, (WPARAM)hDC,(LPARAM)&Offset); } return 0; } case MTBM_SETBUTTONSTATEBYID: case MTBM_SETBUTTONSTATE: { char * hButtonId=(msg==MTBM_SETBUTTONSTATEBYID) ? (char *) wParam : NULL; void * hButton=(msg==MTBM_SETBUTTONSTATE) ? (void *)wParam : NULL; MTB_BUTTONINFO *mtbi=NULL; int i; for (i=0; i<pMTBInfo->pButtonList->realCount; i++) { mtbi=(MTB_BUTTONINFO*)pMTBInfo->pButtonList->items[i]; if ((hButtonId && !strcmp(mtbi->szButtonID, hButtonId)) || (hButton == mtbi)) { mtbi->bPushButton=(BOOL)lParam; sttUpdateButtonState(mtbi); pcli->pfnInvalidateRect(hwnd, NULL, FALSE); break; } } break; } case MTBM_GETBUTTONSTATEBYID: case MTBM_GETBUTTONSTATE: { int * res= (int*)lParam; if (res==NULL) break; char * hButtonId=(msg==MTBM_GETBUTTONSTATEBYID) ? (char *) wParam : NULL; void * hButton=(msg==MTBM_GETBUTTONSTATE) ? (void *)wParam : NULL; MTB_BUTTONINFO *mtbi=NULL; int i; for (i=0; i<pMTBInfo->pButtonList->realCount; i++) { mtbi=(MTB_BUTTONINFO*)pMTBInfo->pButtonList->items[i]; if ((hButtonId && !strcmp(mtbi->szButtonID, hButtonId)) || (hButton == mtbi)) { *res=0; *res |= mtbi->bPushButton ? TBST_PUSHED : TBST_RELEASED; break; } } break; } case MTBM_REMOVEBUTTON: { MTB_BUTTONINFO *mtbi=NULL; for (int i=0; i<pMTBInfo->pButtonList->realCount; i++) { mtbi=(MTB_BUTTONINFO*)pMTBInfo->pButtonList->items[i]; if (mtbi==(MTB_BUTTONINFO*)wParam) { li.List_Remove(pMTBInfo->pButtonList,i); for (int j=0; j<tbdat.listOfButtons->realCount; j++) if (mtbi==(MTB_BUTTONINFO*)tbdat.listOfButtons->items[j]) { li.List_Remove(tbdat.listOfButtons,j); break; } li.List_RemovePtr(tbdat.listOfButtons,mtbi); delete_MTB_BUTTONINFO((void*)mtbi); mtbi=NULL; pcli->pfnInvalidateRect(hwnd, NULL, FALSE); break; } } break; } default : return DefWindowProc(hwnd, msg, wParam, lParam); } return TRUE; }
// dialog procedure for handling the contact ignore dialog (available from the contact menu static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { DWORD dwMask; ClcContact *contact = nullptr; int pCaps; HWND hwndAdd; hContact = lParam; SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)hContact); dwMask = db_get_dw(hContact, "Ignore", "Mask1", 0); SendMessage(hWnd, WM_USER + 100, hContact, dwMask); SendMessage(hWnd, WM_USER + 120, 0, 0); TranslateDialogDefault(hWnd); hwndAdd = GetDlgItem(hWnd, IDC_IGN_ADDPERMANENTLY); // CreateWindowEx(0, L"CLCButtonClass", L"FOO", WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_plugin.getInst(), NULL); CustomizeButton(hwndAdd, false, true, false); SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_ADDCONTACT)); SetWindowText(hwndAdd, TranslateT("Add permanently")); EnableWindow(hwndAdd, db_get_b(hContact, "CList", "NotOnList", 0)); hwndAdd = GetDlgItem(hWnd, IDC_DSP_LOADDEFAULT); // CreateWindowEx(0, L"CLCButtonClass", L"FOO", WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_plugin.getInst(), NULL); CustomizeButton(hwndAdd, false, true, false); SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_DELETE)); SetWindowText(hwndAdd, TranslateT("Revert to default")); EnableWindow(hwndAdd, TRUE); SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Default (global setting)")); SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Show always when available")); SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Hide always")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Default (global setting)")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Never")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Always")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When space is available")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When needed by status message")); if (cfg::clcdat) { Clist_FindItem(g_clistApi.hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr); if (contact && contact->type != CLCIT_CONTACT) { DestroyWindow(hWnd); return FALSE; } else { wchar_t szTitle[512]; DWORD dwFlags = db_get_dw(hContact, "CList", "CLN_Flags", 0); BYTE bSecondLine = db_get_b(hContact, "CList", "CLN_2ndline", -1); mir_snwprintf(szTitle, TranslateT("Contact list display and ignore options for %s"), contact ? contact->szText : Clist_GetContactDisplayName(hContact)); SetWindowText(hWnd, szTitle); Window_SetSkinIcon_IcoLib(hWnd, SKINICON_OTHER_MIRANDA); pCaps = CallProtoService(contact ? contact->proto : GetContactProto(hContact), PS_GETCAPS, PFLAGNUM_1, 0); Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSONLINE, pCaps & PF1_INVISLIST ? TRUE : FALSE); Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSOFFLINE, pCaps & PF1_VISLIST ? TRUE : FALSE); CheckDlgButton(hWnd, IDC_IGN_PRIORITY, db_get_b(hContact, "CList", "Priority", 0) ? BST_CHECKED : BST_UNCHECKED); Utils::enableDlgControl(hWnd, IDC_IGN_PRIORITY, TRUE); Utils::enableDlgControl(hWnd, IDC_AVATARDISPMODE, TRUE); Utils::enableDlgControl(hWnd, IDC_SECONDLINEMODE, TRUE); if (dwFlags & ECF_FORCEAVATAR) SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 1, 0); else if (dwFlags & ECF_HIDEAVATAR) SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 2, 0); else SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 0, 0); if (dwFlags & ECF_FORCEOVERLAY) CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_CHECKED); else if (dwFlags & ECF_HIDEOVERLAY) CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_UNCHECKED); else CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_INDETERMINATE); if (dwFlags & ECF_FORCELOCALTIME) CheckDlgButton(hWnd, IDC_SHOWLOCALTIME1, BST_CHECKED); else if (dwFlags & ECF_HIDELOCALTIME) CheckDlgButton(hWnd, IDC_SHOWLOCALTIME1, BST_UNCHECKED); else CheckDlgButton(hWnd, IDC_SHOWLOCALTIME1, BST_INDETERMINATE); if (bSecondLine == 0xff) SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, 0, 0); else SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, (WPARAM)(bSecondLine + 1), 0); } } WindowList_Add(hWindowListIGN, hWnd, hContact); ShowWindow(hWnd, SW_SHOWNORMAL); } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_IGN_PRIORITY: SendMessage(g_clistApi.hwndContactTree, CLM_TOGGLEPRIORITYCONTACT, hContact, 0); return 0; case IDC_IGN_ALL: SendMessage(hWnd, WM_USER + 100, hContact, (LPARAM)0xffffffff); return 0; case IDC_IGN_NONE: SendMessage(hWnd, WM_USER + 100, hContact, 0); return 0; case IDC_IGN_ALWAYSONLINE: if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSONLINE)) CheckDlgButton(hWnd, IDC_IGN_ALWAYSOFFLINE, BST_UNCHECKED); break; case IDC_IGN_ALWAYSOFFLINE: if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSOFFLINE)) CheckDlgButton(hWnd, IDC_IGN_ALWAYSONLINE, BST_UNCHECKED); break; case IDC_HIDECONTACT: db_set_b(hContact, "CList", "Hidden", (BYTE)(IsDlgButtonChecked(hWnd, IDC_HIDECONTACT) ? 1 : 0)); break; case IDC_IGN_ADDPERMANENTLY: Contact_Add(hContact, hWnd); Utils::enableDlgControl(hWnd, IDC_IGN_ADDPERMANENTLY, db_get_b(hContact, "CList", "NotOnList", 0)); break; case IDC_DSP_LOADDEFAULT: SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, 0, 0); CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_INDETERMINATE); CheckDlgButton(hWnd, IDC_LOCALTIME, BST_INDETERMINATE); break; case IDOK: { DWORD newMask = 0; ClcContact *contact = nullptr; SendMessage(hWnd, WM_USER + 110, 0, (LPARAM)&newMask); db_set_dw(hContact, "Ignore", "Mask1", newMask); SendMessage(hWnd, WM_USER + 130, 0, 0); if (cfg::clcdat) { LRESULT iSel = SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_GETCURSEL, 0, 0); DWORD dwFlags = db_get_dw(hContact, "CList", "CLN_Flags", 0), dwXMask = 0; LRESULT checked = 0; Clist_FindItem(g_clistApi.hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr); if (iSel != CB_ERR) { dwFlags &= ~(ECF_FORCEAVATAR | ECF_HIDEAVATAR); if (iSel == 1) dwFlags |= ECF_FORCEAVATAR; else if (iSel == 2) dwFlags |= ECF_HIDEAVATAR; if (contact) LoadAvatarForContact(contact); } dwFlags &= ~(ECF_FORCEOVERLAY | ECF_HIDEOVERLAY | ECF_FORCELOCALTIME | ECF_HIDELOCALTIME); checked = IsDlgButtonChecked(hWnd, IDC_OVERLAYICON); if (checked == BST_CHECKED) dwFlags |= ECF_FORCEOVERLAY; else if (checked == BST_UNCHECKED) dwFlags |= ECF_HIDEOVERLAY; checked = IsDlgButtonChecked(hWnd, IDC_SHOWLOCALTIME1); if (checked == BST_CHECKED) dwFlags |= ECF_FORCELOCALTIME; else if (checked == BST_UNCHECKED) dwFlags |= ECF_HIDELOCALTIME; db_set_dw(hContact, "CList", "CLN_Flags", dwFlags); if ((iSel = SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_GETCURSEL, 0, 0)) != CB_ERR) { if (iSel == 0) { db_unset(hContact, "CList", "CLN_2ndline"); if (contact) contact->bSecondLine = cfg::dat.dualRowMode; } else { db_set_b(hContact, "CList", "CLN_2ndline", (BYTE)(iSel - 1)); if (contact) contact->bSecondLine = (BYTE)(iSel - 1); } } db_set_dw(hContact, "CList", "CLN_xmask", dwXMask); if (contact) { if (contact->pExtra) contact->pExtra->dwDFlags = dwFlags; } else { TExtraCache *p = cfg::getCache(hContact, nullptr); if (p) p->dwDFlags = dwFlags; } db_set_b(hContact, "CList", "Priority", (BYTE)(IsDlgButtonChecked(hWnd, IDC_IGN_PRIORITY) ? 1 : 0)); Clist_Broadcast(CLM_AUTOREBUILD, 0, 0); } } case IDCANCEL: DestroyWindow(hWnd); break; } break; case WM_USER + 100: // fill dialog (wParam = hContact, lParam = mask) CheckDlgButton(hWnd, IDC_IGN_MSGEVENTS, lParam & (1 << (IGNOREEVENT_MESSAGE - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_FILEEVENTS, lParam & (1 << (IGNOREEVENT_FILE - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_URLEVENTS, lParam & (1 << (IGNOREEVENT_URL - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_AUTH, lParam & (1 << (IGNOREEVENT_AUTHORIZATION - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_ADD, lParam & (1 << (IGNOREEVENT_YOUWEREADDED - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_ONLINE, lParam & (1 << (IGNOREEVENT_USERONLINE - 1)) ? BST_CHECKED : BST_UNCHECKED); return 0; case WM_USER + 110: // retrieve value { DWORD *dwNewMask = (DWORD *)lParam, dwMask = 0; dwMask = (IsDlgButtonChecked(hWnd, IDC_IGN_MSGEVENTS) ? (1 << (IGNOREEVENT_MESSAGE - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_FILEEVENTS) ? (1 << (IGNOREEVENT_FILE - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_URLEVENTS) ? (1 << (IGNOREEVENT_URL - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_AUTH) ? (1 << (IGNOREEVENT_AUTHORIZATION - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_ADD) ? (1 << (IGNOREEVENT_YOUWEREADDED - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_ONLINE) ? (1 << (IGNOREEVENT_USERONLINE - 1)) : 0); if (dwNewMask) *dwNewMask = dwMask; } return 0; case WM_USER + 120: // set visibility status { ClcContact *contact = nullptr; if (Clist_FindItem(g_clistApi.hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr)) { if (contact) { WORD wApparentMode = db_get_w(contact->hContact, contact->proto, "ApparentMode", 0); CheckDlgButton(hWnd, IDC_IGN_ALWAYSOFFLINE, wApparentMode == ID_STATUS_OFFLINE ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_ALWAYSONLINE, wApparentMode == ID_STATUS_ONLINE ? BST_CHECKED : BST_UNCHECKED); } } } return 0; case WM_USER + 130: // update apparent mode { ClcContact *contact = nullptr; if (Clist_FindItem(g_clistApi.hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr)) { if (contact) { WORD wApparentMode = 0; if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSONLINE)) wApparentMode = ID_STATUS_ONLINE; else if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSOFFLINE)) wApparentMode = ID_STATUS_OFFLINE; ProtoChainSend(hContact, PSS_SETAPPARENTMODE, (WPARAM)wApparentMode, 0); SendMessage(hWnd, WM_USER + 120, 0, 0); } } } return 0; case WM_DESTROY: SetWindowLongPtr(hWnd, GWLP_USERDATA, 0); WindowList_Remove(hWindowListIGN, hWnd); break; } return FALSE; }
static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HANDLE hContact; hContact=(HANDLE)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)lParam); hContact = (HANDLE)lParam; WindowList_Add(hWindowList,hwndDlg,hContact); Utils_RestoreWindowPosition(hwndDlg,hContact,"History",""); { TCHAR* contactName, str[200]; contactName = cli.pfnGetContactDisplayName( hContact, 0 ); mir_sntprintf(str,SIZEOF(str),TranslateT("History for %s"),contactName); SetWindowText(hwndDlg,str); } Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_HISTORY); SendMessage(hwndDlg,DM_HREBUILD,0,0); return TRUE; case DM_HREBUILD: { THistoryThread* hInfo = (THistoryThread*)mir_alloc(sizeof(THistoryThread)); EnableWindow(GetDlgItem(hwndDlg, IDC_LIST), FALSE); hInfo->hContact = hContact; hInfo->hwnd = hwndDlg; forkthread(FillHistoryThread, 0, hInfo); } return TRUE; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); Utils_SaveWindowPosition(hwndDlg,hContact,"History",""); WindowList_Remove(hWindowList,hwndDlg); return TRUE; case WM_GETMINMAXINFO: ((MINMAXINFO*)lParam)->ptMinTrackSize.x=300; ((MINMAXINFO*)lParam)->ptMinTrackSize.y=230; case WM_SIZE: { UTILRESIZEDIALOG urd={0}; urd.cbSize=sizeof(urd); urd.hwndDlg=hwndDlg; urd.hInstance=hMirandaInst; urd.lpTemplate=MAKEINTRESOURCEA(IDD_HISTORY); urd.lParam=(LPARAM)NULL; urd.pfnResizer=HistoryDlgResizer; CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); return TRUE; } case WM_COMMAND: switch ( LOWORD( wParam )) { case IDOK: case IDCANCEL: DestroyWindow(hwndDlg); return TRUE; case IDC_FIND: ShowWindow(CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_HISTORY_FIND), hwndDlg, DlgProcHistoryFind, (LPARAM)hwndDlg), SW_SHOW); return TRUE; case IDC_DELETEHISTORY: { HANDLE hDbevent; int index = SendDlgItemMessage(hwndDlg,IDC_LIST,LB_GETCURSEL,0,0); if ( index == LB_ERR ) break; if ( MessageBox(hwndDlg,TranslateT("Are you sure you want to delete this history item?"),TranslateT("Delete History"),MB_YESNO|MB_ICONQUESTION)==IDYES) { hDbevent = (HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,LB_GETITEMDATA,index,0); CallService(MS_DB_EVENT_DELETE,(WPARAM)hContact,(LPARAM)hDbevent); SendMessage(hwndDlg,DM_HREBUILD,0,0); } return TRUE; } case IDC_LIST: if ( HIWORD(wParam) == LBN_SELCHANGE ) { TCHAR str[8192],*contactName; HANDLE hDbEvent; DBEVENTINFO dbei; int sel; sel=SendDlgItemMessage(hwndDlg,IDC_LIST,LB_GETCURSEL,0,0); if(sel==LB_ERR) { EnableWindow(GetDlgItem(hwndDlg,IDC_DELETEHISTORY),FALSE); break; } EnableWindow(GetDlgItem(hwndDlg,IDC_DELETEHISTORY),TRUE); contactName = cli.pfnGetContactDisplayName( hContact, 0 ); hDbEvent=(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,LB_GETITEMDATA,sel,0); ZeroMemory(&dbei,sizeof(dbei)); dbei.cbSize=sizeof(dbei); dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)hDbEvent,0); if ((int)dbei.cbBlob != -1) { dbei.pBlob=(PBYTE)mir_alloc(dbei.cbBlob); if (CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei) == 0) { GetObjectDescription(&dbei,str,SIZEOF(str)); if ( str[0] ) SetDlgItemText(hwndDlg, IDC_EDIT, str); } mir_free(dbei.pBlob); } } return TRUE; } break; case DM_FINDNEXT: { TCHAR str[1024]; HANDLE hDbEvent,hDbEventStart; DBEVENTINFO dbei; int newBlobSize,oldBlobSize; int index = SendDlgItemMessage(hwndDlg,IDC_LIST,LB_GETCURSEL,0,0); if ( index == LB_ERR ) break; hDbEventStart=(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,LB_GETITEMDATA,index,0); ZeroMemory(&dbei,sizeof(dbei)); dbei.cbSize=sizeof(dbei); dbei.pBlob=NULL; oldBlobSize=0; for(;;) { hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,LB_GETITEMDATA,++index,0); if(hDbEvent == ( HANDLE )LB_ERR) { index = -1; continue; } if(hDbEvent==hDbEventStart) break; newBlobSize=CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)hDbEvent,0); if(newBlobSize>oldBlobSize) { dbei.pBlob=(PBYTE)mir_realloc(dbei.pBlob,newBlobSize); oldBlobSize=newBlobSize; } dbei.cbBlob=oldBlobSize; CallService(MS_DB_EVENT_GET,(WPARAM)hDbEvent,(LPARAM)&dbei); GetObjectDescription(&dbei,str,SIZEOF(str)); if(str[0]) { CharUpperBuff(str,lstrlen(str)); if( _tcsstr(str,(const TCHAR*)lParam)!=NULL) { SendDlgItemMessage(hwndDlg,IDC_LIST,LB_SETCURSEL,index,0); SendMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_LIST,LBN_SELCHANGE),0); break; } } } mir_free(dbei.pBlob); break; } } return FALSE; }
/** * dialog procedure for the user preferences dialog. Handles the top * level window (a tab control with 2 subpages) * * @params: like any Win32 window procedure * * @return LRESULT (ignored for dialog procs, use * DWLP_MSGRESULT) */ INT_PTR CALLBACK DlgProcUserPrefsFrame(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch(msg) { case WM_INITDIALOG: { TCITEM tci = {0}; RECT rcClient; TCHAR szBuffer[180]; hContact = (HANDLE)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hContact); WindowList_Add(PluginConfig.hUserPrefsWindowList, hwndDlg, hContact); TranslateDialogDefault(hwndDlg); GetClientRect(hwndDlg, &rcClient); mir_sntprintf(szBuffer, safe_sizeof(szBuffer), CTranslator::getOpt(CTranslator::OPT_UPREFS_TITLE), (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)); SetWindowText(hwndDlg, szBuffer); tci.cchTextMax = 100; tci.mask = TCIF_PARAM | TCIF_TEXT; tci.lParam = (LPARAM)CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_USERPREFS), hwndDlg, DlgProcUserPrefs, (LPARAM)hContact); tci.pszText = const_cast<TCHAR *>(CTranslator::getOpt(CTranslator::OPT_UPREFS_GENERIC)); TabCtrl_InsertItem(GetDlgItem(hwndDlg, IDC_OPTIONSTAB), 0, &tci); MoveWindow((HWND)tci.lParam, 6, DPISCALEY_S(32), rcClient.right - 12, rcClient.bottom - DPISCALEY_S(80), 1); ShowWindow((HWND)tci.lParam, SW_SHOW); if (CMimAPI::m_pfnEnableThemeDialogTexture) CMimAPI::m_pfnEnableThemeDialogTexture((HWND)tci.lParam, ETDT_ENABLETAB); tci.lParam = (LPARAM)CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_USERPREFS1), hwndDlg, DlgProcUserPrefsLogOptions, (LPARAM)hContact); tci.pszText = const_cast<TCHAR *>(CTranslator::getOpt(CTranslator::OPT_UPREFS_MSGLOG)); TabCtrl_InsertItem(GetDlgItem(hwndDlg, IDC_OPTIONSTAB), 1, &tci); MoveWindow((HWND)tci.lParam, 6, DPISCALEY_S(32), rcClient.right - 12, rcClient.bottom - DPISCALEY_S(80), 1); ShowWindow((HWND)tci.lParam, SW_HIDE); if (CMimAPI::m_pfnEnableThemeDialogTexture) CMimAPI::m_pfnEnableThemeDialogTexture((HWND)tci.lParam, ETDT_ENABLETAB); TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_OPTIONSTAB), 0); ShowWindow(hwndDlg, SW_SHOW); return TRUE; } case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case IDC_OPTIONSTAB: switch (((LPNMHDR)lParam)->code) { case TCN_SELCHANGING: { TCITEM tci; tci.mask = TCIF_PARAM; TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_OPTIONSTAB), TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_OPTIONSTAB)), &tci); ShowWindow((HWND)tci.lParam, SW_HIDE); } break; case TCN_SELCHANGE: { TCITEM tci; tci.mask = TCIF_PARAM; TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_OPTIONSTAB), TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_OPTIONSTAB)), &tci); ShowWindow((HWND)tci.lParam, SW_SHOW); } break; } break; } break; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDOK: { TCITEM tci; int i, count; DWORD dwActionToTake = 0; // child pages request which action to take HWND hwnd = M->FindWindow(hContact); tci.mask = TCIF_PARAM; count = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_OPTIONSTAB)); for (i = 0;i < count;i++) { TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_OPTIONSTAB), i, &tci); SendMessage((HWND)tci.lParam, WM_COMMAND, WM_USER + 100, (LPARAM)&dwActionToTake); } if(hwnd) { struct TWindowData *dat = (struct TWindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); if(dat) { DWORD dwOldFlags = (dat->dwFlags & MWF_LOG_ALL); SetDialogToType(hwnd); #if defined(__FEAT_DEPRECATED_DYNAMICSWITCHLOGVIEWER) if(dwActionToTake & UPREF_ACTION_SWITCHLOGVIEWER) { unsigned int mode = GetIEViewMode(hwndDlg, dat->hContact); SwitchMessageLog(dat, mode); } #endif LoadLocalFlags(hwnd, dat); if((dat->dwFlags & MWF_LOG_ALL) != dwOldFlags) { BOOL fShouldHide = TRUE; if(IsIconic(dat->pContainer->hwnd)) fShouldHide = FALSE; else ShowWindow(dat->pContainer->hwnd, SW_HIDE); SendMessage(hwnd, DM_OPTIONSAPPLIED, 0, 0); SendMessage(hwnd, DM_DEFERREDREMAKELOG, (WPARAM)hwnd, 0); if(fShouldHide) ShowWindow(dat->pContainer->hwnd, SW_SHOWNORMAL); } } } DestroyWindow(hwndDlg); break; } case IDCANCEL: DestroyWindow(hwndDlg); break; } break; } case WM_DESTROY: WindowList_Remove(PluginConfig.hUserPrefsWindowList, hwndDlg); 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; }