INT_PTR CALLBACK ChatRequestDialog(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { InviteChatReqParam* param = (InviteChatReqParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); param = (InviteChatReqParam*)lParam; Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_YAHOO)); SetDlgItemTextA(hwndDlg, IDC_SCREENNAME, param->who); SetDlgItemText(hwndDlg, IDC_MSG, param->msg); SetDlgItemText(hwndDlg, IDC_MSG2, TranslateT("No, thank you...")); break; case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_NCDESTROY: Window_FreeIcon_IcoLib(hwndDlg); delete param; break; case WM_COMMAND: { CYahooProto::ChatRoom *cm = param->ppro->m_chatrooms.find((CYahooProto::ChatRoom*)¶m->room); switch (LOWORD(wParam)) { case IDOK: if (cm) { param->ppro->ChatStart(param->room); for (YList *l = cm->members; l; l = l->next) param->ppro->ChatEvent(param->room, (char*)l->data, GC_EVENT_JOIN); yahoo_conference_logon(param->ppro->m_id, NULL, cm->members, param->room); } DestroyWindow(hwndDlg); break; case IDCANCEL: if (cm) { TCHAR msg[1024]; GetDlgItemText(hwndDlg, IDC_MSG2, msg, _countof(msg)); yahoo_conference_decline(param->ppro->m_id, NULL, cm->members, param->room, T2Utf(msg)); param->ppro->m_chatrooms.remove((CYahooProto::ChatRoom*)¶m->room); } DestroyWindow(hwndDlg); break; } } break; } return FALSE; }
void CFacebookGuardDialog::OnInitDialog() { Window_SetIcon_IcoLib(m_hwnd, GetIconHandle("facebook")); SendMessage(m_text.GetHwnd(), EM_LIMITTEXT, 6, 0); Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "GuardWindow"); }
void CVkCaptchaForm::OnInitDialog() { Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_KEYS)); m_btnOk.Disable(); m_btnOpenInBrowser.Enable((m_param->bmp != NULL)); m_instruction.SetText(TranslateT("Enter the text you see")); }
void CVkWallPostForm::OnInitDialog() { Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_WALL)); CMString tszTitle(FORMAT, _T("%s %s"), TranslateT("Wall message for"), m_param->ptszNick); SetCaption(tszTitle); m_btnShare.Disable(); }
void CJabberDlgGcJoin::OnInitDialog() { CSuper::OnInitDialog(); Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_GROUP)); JabberGcRecentInfo *pInfo = NULL; if (m_jid) pInfo = new JabberGcRecentInfo(m_proto, m_jid); else if (OpenClipboard(m_hwnd)) { HANDLE hData = GetClipboardData(CF_UNICODETEXT); if (hData) { TCHAR *buf = (TCHAR *)GlobalLock(hData); if (buf && _tcschr(buf, _T('@')) && !_tcschr(buf, _T(' '))) pInfo = new JabberGcRecentInfo(m_proto, buf); GlobalUnlock(hData); } CloseClipboard(); } if (pInfo) { pInfo->fillForm(m_hwnd); delete pInfo; } ptrT tszNick(m_proto->getTStringA("Nick")); if (tszNick == NULL) tszNick = JabberNickFromJID(m_proto->m_szJabberJID); SetDlgItemText(m_hwnd, IDC_NICK, tszNick); TEXTMETRIC tm = { 0 }; HDC hdc = GetDC(m_hwnd); GetTextMetrics(hdc, &tm); ReleaseDC(m_hwnd, hdc); sttTextLineHeight = tm.tmHeight; SendDlgItemMessage(m_hwnd, IDC_ROOM, CB_SETITEMHEIGHT, -1, sttTextLineHeight - 1); LOGFONT lf = { 0 }; HFONT hfnt = (HFONT)SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_GETFONT, 0, 0); GetObject(hfnt, sizeof(lf), &lf); lf.lfWeight = FW_BOLD; SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE); SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx("bookmarks")); SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONADDTOOLTIP, (WPARAM)"Bookmarks", 0); SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASPUSHBTN, TRUE, 0); m_proto->ComboLoadRecentStrings(m_hwnd, IDC_SERVER, "joinWnd_rcSvr"); int i; for (i = 0; i < 5; i++) { TCHAR jid[JABBER_MAX_JID_LEN]; JabberGcRecentInfo info(m_proto); if (!info.loadRecent(i)) break; mir_sntprintf(jid, _T("%s@%s (%s)"), info.m_room, info.m_server, info.m_nick ? info.m_nick : TranslateT("<no nick>")); SetDlgItemText(m_hwnd, IDC_RECENT1 + i, jid); } sttJoinDlgShowRecentItems(m_hwnd, i); }
INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct FileDlgData *dat; dat = (struct FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { TCHAR szPath[450]; CLISTEVENT* cle = (CLISTEVENT*)lParam; dat = (struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = cle->hContact; dat->hDbEvent = cle->hDbEvent; dat->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN); dat->dwTicks = GetTickCount(); EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE); 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")); TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_FROM, contactName); GetContactReceivedFilesDir(dat->hContact, szPath, SIZEOF(szPath), TRUE); SetDlgItemText(hwndDlg, IDC_FILEDIR, szPath); SHAutoComplete(GetWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), GW_CHILD), 1); for (int i=0; i < MAX_MRU_DIRS; i++) { char idstr[32]; mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i); DBVARIANT dbv; if (db_get_ts(NULL, "SRFile", idstr, &dbv)) break; SendDlgItemMessage(hwndDlg, IDC_FILEDIR, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal); db_free(&dbv); } db_event_markRead(dat->hContact, dat->hDbEvent); DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent); if (dbei.cbBlob > 4 && dbei.cbBlob <= 8196) { dbei.pBlob = (PBYTE)alloca(dbei.cbBlob + 1); db_event_get(dat->hDbEvent, &dbei); dbei.pBlob[dbei.cbBlob] = 0; dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob; char *str = (char*)dbei.pBlob + 4; ptrT ptszFileName( DbGetEventStringT(&dbei, str)); SetDlgItemText(hwndDlg, IDC_FILENAMES, ptszFileName); unsigned len = (unsigned)strlen(str) + 1; if (len + 4 < dbei.cbBlob) { str += len; ptrT ptszDescription( DbGetEventStringT(&dbei, str)); SetDlgItemText(hwndDlg, IDC_MSG, ptszDescription); } } else DestroyWindow(hwndDlg); TCHAR datetimestr[64]; tmi.printTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, SIZEOF(datetimestr), 0); SetDlgItemText(hwndDlg, IDC_DATE, datetimestr); char* szProto = GetContactProto(dat->hContact); if (szProto) { int hasName = 0; char buf[128]; CONTACTINFO ci = { 0 }; ci.cbSize = sizeof(ci); ci.hContact = dat->hContact; ci.szProto = szProto; ci.dwFlag = CNF_UNIQUEID; if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { switch(ci.type) { case CNFT_ASCIIZ: hasName = 1; mir_snprintf(buf, SIZEOF(buf), "%s", ci.pszVal); mir_free(ci.pszVal); break; case CNFT_DWORD: hasName = 1; mir_snprintf(buf, SIZEOF(buf), "%u", ci.dVal); break; } } if (hasName) SetDlgItemTextA(hwndDlg, IDC_NAME, buf); else SetDlgItemText(hwndDlg, IDC_NAME, contactName); } if (db_get_b(dat->hContact, "CList", "NotOnList", 0)) { RECT rcBtn1, rcBtn2, rcDateCtrl; GetWindowRect(GetDlgItem(hwndDlg, IDC_ADD), &rcBtn1); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rcBtn2); GetWindowRect(GetDlgItem(hwndDlg, IDC_DATE), &rcDateCtrl); SetWindowPos(GetDlgItem(hwndDlg, IDC_DATE), 0, 0, 0, rcDateCtrl.right-rcDateCtrl.left-(rcBtn2.left-rcBtn1.left), rcDateCtrl.bottom-rcDateCtrl.top, SWP_NOZORDER|SWP_NOMOVE); } else if (db_get_b(NULL, "SRFile", "AutoAccept", 0)) { //don't check auto-min here to fix BUG#647620 PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK)); } if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } return TRUE; case WM_MEASUREITEM: return CallService(MS_CLIST_MENUMEASUREITEM, wParam, 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 CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case WM_COMMAND: if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { case IDC_FILEDIRBROWSE: { TCHAR szDirName[MAX_PATH], szExistingDirName[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, szDirName, SIZEOF(szDirName)); GetLowestExistingDirName(szDirName, szExistingDirName, SIZEOF(szExistingDirName)); if (BrowseForFolder(hwndDlg, szExistingDirName)) SetDlgItemText(hwndDlg, IDC_FILEDIR, szExistingDirName); } break; case IDOK: { //most recently used directories TCHAR szRecvDir[MAX_PATH], szDefaultRecvDir[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, szRecvDir, SIZEOF(szRecvDir)); RemoveInvalidPathChars(szRecvDir); GetContactReceivedFilesDir(NULL, szDefaultRecvDir, SIZEOF(szDefaultRecvDir), TRUE); if (_tcsnicmp(szRecvDir, szDefaultRecvDir, lstrlen(szDefaultRecvDir))) { char idstr[32]; int i; DBVARIANT dbv; for (i = MAX_MRU_DIRS-2; i>=0; i--) { mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i); if (db_get_ts(NULL, "SRFile", idstr, &dbv)) continue; mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i+1); db_set_ts(NULL, "SRFile", idstr, dbv.ptszVal); db_free(&dbv); } db_set_ts(NULL, "SRFile", idstr, szRecvDir); } } EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAMES), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIRBROWSE), FALSE); GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, SIZEOF(dat->szSavePath)); GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, SIZEOF(dat->szFilenames)); GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, SIZEOF(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); //check for auto-minimize here to fix BUG#647620 if (db_get_b(NULL, "SRFile", "AutoAccept", 0) && db_get_b(NULL, "SRFile", "AutoMin", 0)) { ShowWindow(hwndDlg, SW_HIDE); ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE); } DestroyWindow(hwndDlg); break; case IDCANCEL: if (dat->fs) CallContactService(dat->hContact, PSS_FILEDENYT, (WPARAM)dat->fs, (LPARAM)TranslateT("Canceled")); dat->fs = NULL; /* the protocol will free the handle */ DestroyWindow(hwndDlg); break; case IDC_ADD: { ADDCONTACTSTRUCT acs = {0}; acs.handle = dat->hContact; acs.handleType = HANDLE_CONTACT; acs.szProto = ""; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } break; case IDC_USERMENU: { RECT rc; HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect((HWND)lParam, &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); break; } 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); if (dat) FreeFileDlgData(dat); 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; }
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; }
INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hwndPage; switch (message) { case WM_INITDIALOG: TranslateDialogDefault(hdlg); hwndPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_WIZARDINTRO), hdlg, WizardIntroPageProc); SetWindowPos(hwndPage, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE); ShowWindow(hwndPage, SW_SHOW); ShowWindow(hdlg, SW_SHOW); Window_SetIcon_IcoLib(hdlg, GetIconHandle(IDI_IMPORT)); return TRUE; case WIZM_GOTOPAGE: DestroyWindow(hwndPage); EnableWindow(GetDlgItem(hdlg, IDC_BACK), TRUE); EnableWindow(GetDlgItem(hdlg, IDOK), TRUE); EnableWindow(GetDlgItem(hdlg, IDCANCEL), TRUE); SetDlgItemText(hdlg, IDCANCEL, TranslateT("Cancel")); hwndPage = CreateDialog(hInst, MAKEINTRESOURCE(wParam), hdlg, (DLGPROC)lParam); SetWindowPos(hwndPage, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE); ShowWindow(hwndPage, SW_SHOW); break; case WIZM_DISABLEBUTTON: switch (wParam) { case 0: EnableWindow(GetDlgItem(hdlg, IDC_BACK), FALSE); break; case 1: EnableWindow(GetDlgItem(hdlg, IDOK), FALSE); break; case 2: EnableWindow(GetDlgItem(hdlg, IDCANCEL), FALSE); break; } break; case WIZM_ENABLEBUTTON: switch (wParam) { case 0: EnableWindow(GetDlgItem(hdlg, IDC_BACK), TRUE); break; case 1: EnableWindow(GetDlgItem(hdlg, IDOK), TRUE); break; case 2: EnableWindow(GetDlgItem(hdlg, IDCANCEL), TRUE); break; } break; case WIZM_SETCANCELTEXT: SetDlgItemText(hdlg, IDCANCEL, (TCHAR*)lParam); break; case WM_COMMAND: SendMessage(hwndPage, WM_COMMAND, wParam, lParam); break; case WM_CLOSE: DestroyWindow(hwndPage); DestroyWindow(hdlg); break; case WM_DESTROY: if (g_bServiceMode) PostQuitMessage(0); } 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 InviteToChatDialog(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { InviteChatParam* param = (InviteChatParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); param = (InviteChatParam*)lParam; Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_YAHOO)); SetDlgItemTextA(hwndDlg, IDC_ROOMNAME, param->room); SetDlgItemText(hwndDlg, IDC_MSG, TranslateT("Join My Conference...")); break; case WM_CLOSE: EndDialog(hwndDlg, 0); break; case WM_NCDESTROY: Window_FreeIcon_IcoLib(hwndDlg); delete param; break; case WM_NOTIFY: { NMCLISTCONTROL* nmc = (NMCLISTCONTROL*)lParam; if (nmc->hdr.idFrom == IDC_CCLIST) { switch (nmc->hdr.code) { case CLN_NEWCONTACT: if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0) ClistValidateContact((MCONTACT)nmc->hItem, nmc->hdr.hwndFrom, param->ppro); break; case CLN_LISTREBUILT: if (param) ClistChatPrepare(NULL, nmc->hdr.hwndFrom, param->ppro); break; } } } break; case WM_COMMAND: { switch (LOWORD(wParam)) { case IDC_ADDSCR: if (param->ppro->m_bLoggedIn) { TCHAR sn[64]; GetDlgItemText(hwndDlg, IDC_EDITSCR, sn, _countof(sn)); CLCINFOITEM cii = { 0 }; cii.cbSize = sizeof(cii); cii.flags = CLCIIF_CHECKBOX | CLCIIF_BELOWCONTACTS; cii.pszText = sn; HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_SETCHECKMARK, (LPARAM)hItem, 1); } break; case IDOK: { TCHAR msg[1024]; GetDlgItemText(hwndDlg, IDC_MSG, msg, _countof(msg)); HWND hwndList = GetDlgItem(hwndDlg, IDC_CCLIST); YList *who = NULL; clist_chat_invite_send(NULL, hwndList, who, param->room, param->ppro, msg); EndDialog(hwndDlg, IDOK); PostMessage(hwndDlg, WM_DESTROY, 0, 0); } break; case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); PostMessage(hwndDlg, WM_DESTROY, 0, 0); break; } } break; } return FALSE; }
void OnInitDialog() { char szUin[10]; Window_SetIcon_IcoLib(m_hwnd, SKINICON_OTHER_ADDCONTACT); if (m_acs.handleType == HANDLE_EVENT) { DWORD dwUin; DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = sizeof(DWORD); dbei.pBlob = (PBYTE)&dwUin; db_event_get(m_acs.hDbEvent, &dbei); _ltoa(dwUin, szUin, 10); m_acs.szProto = dbei.szModule; } MCONTACT hContact; TCHAR *szName = NULL, *tmpStr = NULL; if (m_acs.handleType == HANDLE_CONTACT) szName = cli.pfnGetContactDisplayName(hContact = m_acs.hContact, 0); else { int isSet = 0; hContact = 0; if (m_acs.handleType == HANDLE_EVENT) { DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(m_acs.hDbEvent); dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); db_event_get(m_acs.hDbEvent, &dbei); hContact = *(MCONTACT*)(dbei.pBlob + sizeof(DWORD)); mir_free(dbei.pBlob); if (hContact != INVALID_CONTACT_ID) { szName = cli.pfnGetContactDisplayName(hContact, 0); isSet = 1; } } if (!isSet) { if (m_acs.handleType == HANDLE_EVENT) szName = mir_a2t(szUin); else { szName = sttDecodeString(m_acs.psr->flags, m_acs.psr->id); if (!szName) szName = sttDecodeString(m_acs.psr->flags, m_acs.psr->nick); } } } if (szName && szName[0]) SetCaption(CMString(FORMAT, TranslateT("Add %s"), szName)); else SetCaption(TranslateT("Add contact")); mir_free(tmpStr); if (m_acs.handleType == HANDLE_CONTACT && m_acs.hContact) if (m_acs.szProto == NULL || (m_acs.szProto != NULL && *m_acs.szProto == 0)) m_acs.szProto = GetContactProto(m_acs.hContact); int groupSel = 0; ptrT tszGroup(db_get_tsa(hContact, "CList", "Group")); TCHAR *grpName; for (int groupId = 1; (grpName = cli.pfnGetGroupName(groupId, NULL)) != NULL; groupId++) { int id = m_group.AddString(grpName, groupId); if (!mir_tstrcmpi(tszGroup, grpName)) groupSel = id; } m_group.InsertString(TranslateT("None"), 0); m_group.SetCurSel(groupSel); // By default check both checkboxes m_chkAdded.SetState(true); m_chkAuth.SetState(true); // Set last choice if (db_get_b(NULL, "Miranda", "AuthOpenWindow", 1)) m_chkOpen.SetState(true); DWORD flags = (m_acs.szProto) ? CallProtoServiceInt(NULL, m_acs.szProto, PS_GETCAPS, PFLAGNUM_4, 0) : 0; if (flags & PF4_FORCEADDED) // force you were added requests for this protocol m_chkAdded.Enable(false); if (flags & PF4_FORCEAUTH) // force auth requests for this protocol m_chkAuth.Enable(false); if (flags & PF4_NOCUSTOMAUTH) m_authReq.Enable(false); else { m_authReq.Enable(m_chkAuth.Enabled()); m_authReq.SetText(TranslateT("Please authorize my request and add me to your contact list.")); } }
INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static int iState = 0; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { TCHAR filename[MAX_PATH], *productCopyright; DWORD unused; DWORD verInfoSize; UINT blockSize; PVOID pVerInfo; GetModuleFileName(NULL,filename,SIZEOF(filename)); verInfoSize=GetFileVersionInfoSize(filename,&unused); pVerInfo=mir_alloc(verInfoSize); GetFileVersionInfo(filename,0,verInfoSize,pVerInfo); VerQueryValue(pVerInfo,_T("\\StringFileInfo\\000004b0\\LegalCopyright"),(LPVOID*)&productCopyright,&blockSize); SetDlgItemText(hwndDlg,IDC_DEVS,productCopyright); mir_free(pVerInfo); } { char productVersion[56], *p; int isAnsi = 0; TCHAR str[64]; CallService(MS_SYSTEM_GETVERSIONTEXT,SIZEOF(productVersion),(LPARAM)productVersion); // Hide Unicode from version text as it is assumed at this point p = strstr(productVersion, " Unicode"); if (p) *p = '\0'; else isAnsi = 1; mir_sntprintf(str,SIZEOF(str),_T(STR_VERSION_FORMAT), TranslateT("v"), productVersion, isAnsi?" ANSI":""); { TCHAR oldTitle[256], newTitle[256]; GetDlgItemText( hwndDlg, IDC_HEADERBAR, oldTitle, SIZEOF( oldTitle )); mir_sntprintf( newTitle, SIZEOF(newTitle), oldTitle, str ); SetDlgItemText( hwndDlg, IDC_HEADERBAR, newTitle ); } mir_sntprintf(str,SIZEOF(str),TranslateT("Built %s %s"),_T(__DATE__),_T(__TIME__)); SetDlgItemText(hwndDlg,IDC_BUILDTIME,str); } ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); { HRSRC hResInfo = FindResource(hMirandaInst,MAKEINTRESOURCE(IDR_CREDITS),_T("TEXT")); DWORD ResSize = SizeofResource(hMirandaInst,hResInfo); HGLOBAL hRes = LoadResource(hMirandaInst,hResInfo); char* pszMsg = (char*)LockResource(hRes); if (pszMsg) { char* pszMsgt = (char*)alloca(ResSize + 1); memcpy(pszMsgt, pszMsg, ResSize); pszMsgt[ResSize] = 0; TCHAR *ptszMsg; if (ResSize >=3 && pszMsgt[0] == '\xef' && pszMsgt[1] == '\xbb' && pszMsgt[2] == '\xbf') ptszMsg = Utf8DecodeT(pszMsgt + 3); else ptszMsg = mir_a2t_cp(pszMsgt, 1252); SetDlgItemText(hwndDlg, IDC_CREDITSFILE, ptszMsg); UnlockResource(pszMsg); mir_free(ptszMsg); } FreeResource(hRes); } Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_MIRANDA); return TRUE; case WM_COMMAND: switch( LOWORD( wParam )) { case IDOK: case IDCANCEL: DestroyWindow(hwndDlg); return TRUE; case IDC_CONTRIBLINK: if (iState) { iState = 0; SetDlgItemText(hwndDlg, IDC_CONTRIBLINK, TranslateT("Credits >")); ShowWindow(GetDlgItem(hwndDlg, IDC_DEVS), SW_SHOW); ShowWindow(GetDlgItem(hwndDlg, IDC_BUILDTIME), SW_SHOW); ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); } else { iState = 1; SetDlgItemText(hwndDlg, IDC_CONTRIBLINK, TranslateT("< Copyright")); ShowWindow(GetDlgItem(hwndDlg, IDC_DEVS), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_BUILDTIME), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_SHOW); } break; } break; case WM_CTLCOLOREDIT: case WM_CTLCOLORSTATIC: switch ( GetWindowLongPtr(( HWND )lParam, GWL_ID )) { case IDC_WHITERECT: case IDC_BUILDTIME: case IDC_CREDITSFILE: case IDC_DEVS: SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); break; default: return FALSE; } SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); case WM_DESTROY: Window_FreeIcon_IcoLib( hwndDlg ); { HFONT hFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_VERSION,WM_GETFONT,0,0); SendDlgItemMessage(hwndDlg,IDC_VERSION,WM_SETFONT,SendDlgItemMessage(hwndDlg,IDOK,WM_GETFONT,0,0),0); DeleteObject(hFont); } break; } return FALSE; }
INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg,UINT message, WPARAM wParam, LPARAM lParam) { struct TAccMgrData *dat = (struct TAccMgrData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch(message) { case WM_INITDIALOG: { TAccMgrData *dat = (TAccMgrData *)mir_alloc(sizeof(TAccMgrData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); TranslateDialogDefault(hwndDlg); Window_SetIcon_IcoLib( hwndDlg, SKINICON_OTHER_ACCMGR ); Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("New account")); Button_SetIcon_IcoLib(hwndDlg, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit")); Button_SetIcon_IcoLib(hwndDlg, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove account")); Button_SetIcon_IcoLib(hwndDlg, IDC_OPTIONS, SKINICON_OTHER_OPTIONS, LPGEN( "Configure...")); Button_SetIcon_IcoLib(hwndDlg, IDC_UPGRADE, SKINICON_OTHER_ACCMGR, LPGEN("Upgrade account")); EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_UPGRADE), FALSE); { LOGFONT lf; HDC hdc; HFONT hfnt; TEXTMETRIC tm; GetObject((HFONT)SendMessage(hwndDlg, WM_GETFONT, 0, 0), sizeof(lf), &lf); dat->hfntText = CreateFontIndirect(&lf); GetObject((HFONT)SendMessage(hwndDlg, WM_GETFONT, 0, 0), sizeof(lf), &lf); lf.lfWeight = FW_BOLD; dat->hfntTitle = CreateFontIndirect(&lf); hdc = GetDC(hwndDlg); hfnt = ( HFONT )SelectObject(hdc, dat->hfntTitle); GetTextMetrics(hdc, &tm); dat->titleHeight = tm.tmHeight; SelectObject(hdc, dat->hfntText); GetTextMetrics(hdc, &tm); dat->textHeight = tm.tmHeight; SelectObject(hdc, hfnt); ReleaseDC(hwndDlg, hdc); dat->normalHeight = 4 + max(dat->titleHeight, GetSystemMetrics(SM_CYSMICON)); dat->selectedHeight = dat->normalHeight + 4 + 2 * dat->textHeight; SendDlgItemMessage(hwndDlg, IDC_NAME, WM_SETFONT, (WPARAM)dat->hfntTitle, 0); SendDlgItemMessage(hwndDlg, IDC_TXT_ACCOUNT, WM_SETFONT, (WPARAM)dat->hfntTitle, 0); SendDlgItemMessage(hwndDlg, IDC_TXT_ADDITIONAL, WM_SETFONT, (WPARAM)dat->hfntTitle, 0); } dat->iSelected = -1; sttSubclassAccList(GetDlgItem(hwndDlg, IDC_ACCLIST), TRUE); SendMessage( hwndDlg, WM_MY_REFRESH, 0, 0 ); Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "AccMgr", ""); } return TRUE; case WM_CTLCOLORSTATIC: switch ( GetDlgCtrlID(( HWND )lParam )) { case IDC_WHITERECT: case IDC_NAME: SetBkColor(( HDC )wParam, GetSysColor( COLOR_WINDOW )); return ( INT_PTR )GetSysColorBrush( COLOR_WINDOW ); } break; case WM_MEASUREITEM: { LPMEASUREITEMSTRUCT lps = (LPMEASUREITEMSTRUCT)lParam; PROTOACCOUNT *acc = (PROTOACCOUNT *)lps->itemData; if ((lps->CtlID != IDC_ACCLIST) || !acc) break; lps->itemWidth = 10; lps->itemHeight = dat->normalHeight; } return TRUE; case WM_DRAWITEM: { int tmp, size, length; TCHAR *text; HICON hIcon; HBRUSH hbrBack; SIZE sz; int cxIcon = GetSystemMetrics(SM_CXSMICON); int cyIcon = GetSystemMetrics(SM_CYSMICON); LPDRAWITEMSTRUCT lps = (LPDRAWITEMSTRUCT)lParam; PROTOACCOUNT *acc = (PROTOACCOUNT *)lps->itemData; if ((lps->CtlID != IDC_ACCLIST) || (lps->itemID == -1) || !acc) break; SetBkMode(lps->hDC, TRANSPARENT); if (lps->itemState & ODS_SELECTED) { hbrBack = GetSysColorBrush(COLOR_HIGHLIGHT); SetTextColor(lps->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); } else { hbrBack = GetSysColorBrush(COLOR_WINDOW); SetTextColor(lps->hDC, GetSysColor(COLOR_WINDOWTEXT)); } FillRect(lps->hDC, &lps->rcItem, hbrBack); lps->rcItem.left += 2; lps->rcItem.top += 2; lps->rcItem.bottom -= 2; if ( acc->bOldProto ) tmp = SKINICON_OTHER_ON; else if ( acc->bDynDisabled ) tmp = SKINICON_OTHER_OFF; else tmp = acc->bIsEnabled ? SKINICON_OTHER_TICK : SKINICON_OTHER_NOTICK; hIcon = LoadSkinnedIcon(tmp); DrawIconEx(lps->hDC, lps->rcItem.left, lps->rcItem.top, hIcon, cxIcon, cyIcon, 0, hbrBack, DI_NORMAL); IconLib_ReleaseIcon(hIcon, 0); lps->rcItem.left += cxIcon + 2; if (acc->ppro) { hIcon = acc->ppro->GetIcon( PLI_PROTOCOL | PLIF_SMALL ); DrawIconEx(lps->hDC, lps->rcItem.left, lps->rcItem.top, hIcon, cxIcon, cyIcon, 0, hbrBack, DI_NORMAL); DestroyIcon(hIcon); } lps->rcItem.left += cxIcon + 2; length = SendDlgItemMessage(hwndDlg, IDC_ACCLIST, LB_GETTEXTLEN, lps->itemID, 0); size = max(length+1, 256); text = (TCHAR *)_alloca(sizeof(TCHAR) * size); SendDlgItemMessage(hwndDlg, IDC_ACCLIST, LB_GETTEXT, lps->itemID, (LPARAM)text); SelectObject(lps->hDC, dat->hfntTitle); tmp = lps->rcItem.bottom; lps->rcItem.bottom = lps->rcItem.top + max(cyIcon, dat->titleHeight); DrawText(lps->hDC, text, -1, &lps->rcItem, DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS|DT_VCENTER); lps->rcItem.bottom = tmp; GetTextExtentPoint32(lps->hDC, text, length, &sz); lps->rcItem.top += max(cxIcon, sz.cy) + 2; if (lps->itemID == (unsigned)dat->iSelected) { SelectObject(lps->hDC, dat->hfntText); mir_sntprintf(text, size, _T("%s: ") _T(TCHAR_STR_PARAM), TranslateT("Protocol"), acc->szProtoName); length = lstrlen(text); DrawText(lps->hDC, text, -1, &lps->rcItem, DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS); GetTextExtentPoint32(lps->hDC, text, length, &sz); lps->rcItem.top += sz.cy + 2; if (acc->ppro && Proto_IsProtocolLoaded(acc->szProtoName)) { char *szIdName; TCHAR *tszIdName; CONTACTINFO ci = { 0 }; szIdName = (char *)acc->ppro->GetCaps( PFLAG_UNIQUEIDTEXT, 0 ); tszIdName = szIdName ? mir_a2t(szIdName) : mir_tstrdup(TranslateT("Account ID")); ci.cbSize = sizeof(ci); ci.hContact = NULL; ci.szProto = acc->szModuleName; ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR; if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) { switch (ci.type) { case CNFT_ASCIIZ: mir_sntprintf( text, size, _T("%s: %s"), tszIdName, ci.pszVal ); mir_free(ci.pszVal); break; case CNFT_DWORD: mir_sntprintf( text, size, _T("%s: %d"), tszIdName, ci.dVal ); break; } } else mir_sntprintf(text, size, _T("%s: %s"), tszIdName, TranslateT("<unknown>")); mir_free(tszIdName); } else mir_sntprintf(text, size, TranslateT("Protocol is not loaded.")); length = lstrlen(text); DrawText(lps->hDC, text, -1, &lps->rcItem, DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS); GetTextExtentPoint32(lps->hDC, text, length, &sz); lps->rcItem.top += sz.cy + 2; } } return TRUE; case WM_MY_REFRESH: { HWND hList = GetDlgItem(hwndDlg, IDC_ACCLIST); int i = ListBox_GetCurSel(hList); PROTOACCOUNT *acc = (i == LB_ERR) ? NULL : (PROTOACCOUNT *)ListBox_GetItemData(hList, i); dat->iSelected = -1; SendMessage( hList, LB_RESETCONTENT, 0, 0 ); for (i = 0; i < accounts.getCount(); ++i) { int iItem = SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)accounts[i]->tszAccountName); SendMessage(hList, LB_SETITEMDATA, iItem, (LPARAM)accounts[i]); if (accounts[i] == acc) ListBox_SetCurSel(hList, iItem); } dat->iSelected = ListBox_GetCurSel(hList); // -1 if error => nothing selected in our case if (dat->iSelected >= 0) sttSelectItem(dat, hList, dat->iSelected); else if (acc && acc->hwndAccMgrUI) ShowWindow(acc->hwndAccMgrUI, SW_HIDE); sttUpdateAccountInfo(hwndDlg, dat); } break; case WM_CONTEXTMENU: if ( GetWindowLongPtr(( HWND )wParam, GWL_ID ) == IDC_ACCLIST ) { HWND hwndList = GetDlgItem( hwndDlg, IDC_ACCLIST ); POINT pt = { (signed short)LOWORD( lParam ), (signed short)HIWORD( lParam ) }; int iItem = ListBox_GetCurSel( hwndList ); if (( pt.x == -1 ) && ( pt.y == -1 )) { if (iItem != LB_ERR) { RECT rc; ListBox_GetItemRect( hwndList, iItem, &rc ); pt.x = rc.left + GetSystemMetrics(SM_CXSMICON) + 4; pt.y = rc.top + 4 + max(GetSystemMetrics(SM_CXSMICON), dat->titleHeight); ClientToScreen( hwndList, &pt ); } } else { // menu was activated with mouse => find item under cursor & set focus to our control. POINT ptItem = pt; ScreenToClient( hwndList, &ptItem ); iItem = (short)LOWORD(SendMessage(hwndList, LB_ITEMFROMPOINT, 0, MAKELPARAM(ptItem.x, ptItem.y))); if (iItem != LB_ERR) { ListBox_SetCurSel(hwndList, iItem); sttUpdateAccountInfo(hwndDlg, dat); sttSelectItem(dat, hwndList, iItem); SetFocus(hwndList); } } if ( iItem != LB_ERR ) { PROTOACCOUNT* pa = (PROTOACCOUNT*)ListBox_GetItemData(hwndList, iItem); HMENU hMenu = CreatePopupMenu(); if ( !pa->bOldProto && !pa->bDynDisabled ) AppendMenu(hMenu, MF_STRING, 1, TranslateT("Rename")); AppendMenu(hMenu, MF_STRING, 3, TranslateT("Delete")); if ( Proto_IsAccountEnabled( pa )) AppendMenu(hMenu, MF_STRING, 4, TranslateT("Configure")); if ( pa->bOldProto || pa->bDynDisabled ) AppendMenu(hMenu, MF_STRING, 5, TranslateT("Upgrade")); AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); AppendMenu(hMenu, MF_STRING, 0, TranslateT("Cancel")); switch (TrackPopupMenu( hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL )) { case 1: PostMessage(hwndList, WM_MY_RENAME, 0, 0); break; case 2: sttClickButton(hwndDlg, IDC_EDIT); break; case 3: sttClickButton(hwndDlg, IDC_REMOVE); break; case 4: sttClickButton(hwndDlg, IDC_OPTIONS); break; case 5: sttClickButton(hwndDlg, IDC_UPGRADE); break; } DestroyMenu( hMenu ); } } break; case WM_COMMAND: switch( LOWORD(wParam)) { case IDC_ACCLIST: { HWND hwndList = GetDlgItem(hwndDlg, IDC_ACCLIST); switch (HIWORD(wParam)) { case LBN_SELCHANGE: sttUpdateAccountInfo(hwndDlg, dat); sttSelectItem(dat, hwndList, ListBox_GetCurSel(hwndList)); SetFocus(hwndList); break; case LBN_DBLCLK: PostMessage(hwndList, WM_MY_RENAME, 0, 0); break; case LBN_MY_CHECK: { PROTOACCOUNT *pa = (PROTOACCOUNT *)ListBox_GetItemData(hwndList, lParam); if ( pa ) { if ( pa->bOldProto || pa->bDynDisabled) break; pa->bIsEnabled = !pa->bIsEnabled; if ( pa->bIsEnabled ) { if ( ActivateAccount( pa )) { pa->ppro->OnEvent( EV_PROTO_ONLOAD, 0, 0 ); if (!DBGetContactSettingByte(NULL, "CList", "MoveProtoMenus", FALSE)) pa->ppro->OnEvent( EV_PROTO_ONMENU, 0, 0 ); } else pa->type = PROTOTYPE_DISPROTO; } else { DWORD dwStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); if (dwStatus >= ID_STATUS_ONLINE) { if (IDCANCEL == ::MessageBox(hwndDlg, TranslateT("Account is online. Disable account?"), TranslateT("Accounts"), MB_OKCANCEL)) { pa->bIsEnabled = 1; //stay enabled } } if ( !pa->bIsEnabled ) DeactivateAccount( pa, true, false ); } WriteDbAccounts(); NotifyEventHooks( hAccListChanged, PRAC_CHECKED, ( LPARAM )pa ); sttUpdateAccountInfo(hwndDlg, dat); RedrawWindow(hwndList, NULL, NULL, RDW_INVALIDATE); } } break; case LBN_MY_RENAME: { int iItem = ListBox_GetCurSel(hwndList); PROTOACCOUNT *pa = (PROTOACCOUNT *)ListBox_GetItemData(hwndList, iItem); if ( pa ) { mir_free(pa->tszAccountName); pa->tszAccountName = (TCHAR*)lParam; WriteDbAccounts(); NotifyEventHooks(hAccListChanged, PRAC_CHANGED, (LPARAM)pa); ListBox_DeleteString(hwndList, iItem); iItem = ListBox_AddString(hwndList, pa->tszAccountName); ListBox_SetItemData(hwndList, iItem, (LPARAM)pa); ListBox_SetCurSel(hwndList, iItem); sttSelectItem(dat, hwndList, iItem); RedrawWindow(hwndList, NULL, NULL, RDW_INVALIDATE); } else mir_free((TCHAR*)lParam); } break; } } break; case IDC_ADD: { AccFormDlgParam param = { PRAC_ADDED, NULL }; if ( IDOK == DialogBoxParam( hMirandaInst, MAKEINTRESOURCE(IDD_ACCFORM), hwndDlg, AccFormDlgProc, (LPARAM)¶m )) SendMessage( hwndDlg, WM_MY_REFRESH, 0, 0 ); } break; case IDC_EDIT: { HWND hList = GetDlgItem( hwndDlg, IDC_ACCLIST ); int idx = ListBox_GetCurSel( hList ); if ( idx != -1 ) PostMessage(hList, WM_MY_RENAME, 0, 0); } break; case IDC_REMOVE: { HWND hList = GetDlgItem( hwndDlg, IDC_ACCLIST ); int idx = ListBox_GetCurSel( hList ); if ( idx != -1 ) { PROTOACCOUNT* pa = ( PROTOACCOUNT* )ListBox_GetItemData( hList, idx ); TCHAR buf[ 200 ]; mir_sntprintf( buf, SIZEOF(buf), TranslateT( "Account %s is being deleted" ), pa->tszAccountName ); if (pa->bOldProto) { MessageBox( NULL, TranslateT( "You need to disable plugin to delete this account" ), buf, MB_ICONERROR | MB_OK ); break; } if ( IDYES == MessageBox( NULL, TranslateT( errMsg ), buf, MB_ICONSTOP | MB_DEFBUTTON2 | MB_YESNO )) { // lock controls to avoid changes during remove process ListBox_SetCurSel( hList, -1 ); sttUpdateAccountInfo( hwndDlg, dat ); EnableWindow( hList, FALSE ); EnableWindow( GetDlgItem(hwndDlg, IDC_ADD), FALSE ); ListBox_SetItemData( hList, idx, 0 ); accounts.remove( pa ); CheckProtocolOrder(); WriteDbAccounts(); NotifyEventHooks( hAccListChanged, PRAC_REMOVED, ( LPARAM )pa ); UnloadAccount( pa, true, true ); SendMessage( hwndDlg, WM_MY_REFRESH, 0, 0 ); EnableWindow( hList, TRUE ); EnableWindow( GetDlgItem(hwndDlg, IDC_ADD), TRUE ); } } } break; case IDC_OPTIONS: { HWND hList = GetDlgItem( hwndDlg, IDC_ACCLIST ); int idx = ListBox_GetCurSel( hList ); if ( idx != -1 ) { PROTOACCOUNT* pa = ( PROTOACCOUNT* )ListBox_GetItemData( hList, idx ); if ( pa->bOldProto ) { OPENOPTIONSDIALOG ood; ood.cbSize = sizeof(ood); ood.pszGroup = "Network"; ood.pszPage = pa->szModuleName; ood.pszTab = NULL; CallService( MS_OPT_OPENOPTIONS, 0, (LPARAM)&ood ); } else OpenAccountOptions( pa ); } } break; case IDC_UPGRADE: { HWND hList = GetDlgItem( hwndDlg, IDC_ACCLIST ); int idx = ListBox_GetCurSel( hList ); if ( idx != -1 ) { AccFormDlgParam param = { PRAC_UPGRADED, ( PROTOACCOUNT* )ListBox_GetItemData( hList, idx ) }; DialogBoxParam( hMirandaInst, MAKEINTRESOURCE(IDD_ACCFORM), hwndDlg, AccFormDlgProc, (LPARAM)¶m ); } } break; case IDC_LNK_NETWORK: { PSHNOTIFY pshn = {0}; pshn.hdr.code = PSN_APPLY; pshn.hdr.hwndFrom = hwndDlg; SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&pshn); OPENOPTIONSDIALOG ood = {0}; ood.cbSize = sizeof(ood); ood.pszPage = "Network"; CallService( MS_OPT_OPENOPTIONS, 0, (LPARAM)&ood ); break; } case IDC_LNK_ADDONS: CallService(MS_UTILS_OPENURL, TRUE, (LPARAM)"http://addons.miranda-im.org/"); break; case IDOK: { PSHNOTIFY pshn = {0}; pshn.hdr.code = PSN_APPLY; pshn.hdr.hwndFrom = hwndDlg; SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&pshn); DestroyWindow(hwndDlg); break; } case IDCANCEL: { PSHNOTIFY pshn = {0}; pshn.hdr.code = PSN_RESET; pshn.hdr.hwndFrom = hwndDlg; SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&pshn); DestroyWindow(hwndDlg); break; } } case PSM_CHANGED: { HWND hList = GetDlgItem( hwndDlg, IDC_ACCLIST ); int idx = ListBox_GetCurSel( hList ); if ( idx != -1 ) { PROTOACCOUNT *acc = (PROTOACCOUNT *)ListBox_GetItemData(hList, idx); if (acc) { acc->bAccMgrUIChanged = TRUE; SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } break; } case WM_NOTIFY: switch(((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: { int i; PSHNOTIFY pshn = {0}; pshn.hdr.code = PSN_APPLY; for (i = 0; i < accounts.getCount(); ++i) { if ( accounts[i]->hwndAccMgrUI && accounts[i]->bAccMgrUIChanged ) { pshn.hdr.hwndFrom = accounts[i]->hwndAccMgrUI; SendMessage(accounts[i]->hwndAccMgrUI, WM_NOTIFY, 0, (LPARAM)&pshn); accounts[i]->bAccMgrUIChanged = FALSE; } } return TRUE; } case PSN_RESET: { int i; PSHNOTIFY pshn = {0}; pshn.hdr.code = PSN_RESET; for (i = 0; i < accounts.getCount(); ++i) { if ( accounts[i]->hwndAccMgrUI && accounts[i]->bAccMgrUIChanged ) { pshn.hdr.hwndFrom = accounts[i]->hwndAccMgrUI; SendMessage(accounts[i]->hwndAccMgrUI, WM_NOTIFY, 0, (LPARAM)&pshn); accounts[i]->bAccMgrUIChanged = FALSE; } } return TRUE; } } break; } break; case WM_DESTROY: { for (int i = 0; i < accounts.getCount(); ++i) { accounts[i]->bAccMgrUIChanged = FALSE; if (accounts[i]->hwndAccMgrUI) { DestroyWindow(accounts[i]->hwndAccMgrUI); accounts[i]->hwndAccMgrUI = NULL; } } } Window_FreeIcon_IcoLib( hwndDlg ); Button_FreeIcon_IcoLib( hwndDlg, IDC_ADD ); Button_FreeIcon_IcoLib( hwndDlg, IDC_EDIT ); Button_FreeIcon_IcoLib( hwndDlg, IDC_REMOVE ); Button_FreeIcon_IcoLib( hwndDlg, IDC_OPTIONS ); Button_FreeIcon_IcoLib( hwndDlg, IDC_UPGRADE ); Utils_SaveWindowPosition( hwndDlg, NULL, "AccMgr", ""); sttSubclassAccList(GetDlgItem(hwndDlg, IDC_ACCLIST), FALSE); DeleteObject(dat->hfntTitle); DeleteObject(dat->hfntText); mir_free(dat); hAccMgr = NULL; break; } return FALSE; }
//======================================================= //Custom status message windows handling //======================================================= static INT_PTR CALLBACK DlgProcSetCustStat(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { CYahooProto* ppro = (CYahooProto*)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_YAHOO)); if (!ppro->getString(YAHOO_CUSTSTATDB, &dbv)) { SetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, dbv.pszVal); EnableWindow(GetDlgItem(hwndDlg, IDOK), mir_strlen(dbv.pszVal) > 0); db_free(&dbv); } else { SetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, ""); EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); } CheckDlgButton(hwndDlg, IDC_CUSTSTATBUSY, ppro->getByte("BusyCustStat", 0) ? BST_CHECKED : BST_UNCHECKED); } return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: { char str[255 + 1]; CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); /* Get String from dialog */ GetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, str, _countof(str)); /* Save it for later use */ ppro->setString(YAHOO_CUSTSTATDB, str); ppro->setByte("BusyCustStat", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY)); /* set for Idle/AA */ if (ppro->m_startMsg) mir_free(ppro->m_startMsg); ppro->m_startMsg = mir_strdup(str); /* notify Server about status change */ ppro->set_status(YAHOO_CUSTOM_STATUS, str, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY)); /* change local/miranda status */ ppro->BroadcastStatus((BYTE)IsDlgButtonChecked(hwndDlg, IDC_CUSTSTATBUSY) ? ID_STATUS_AWAY : ID_STATUS_ONLINE); } case IDCANCEL: DestroyWindow(hwndDlg); break; } if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) { if (LOWORD(wParam) == IDC_CUSTSTAT) { char str[255 + 1]; BOOL toSet; toSet = GetDlgItemTextA(hwndDlg, IDC_CUSTSTAT, str, _countof(str)) != 0; EnableWindow(GetDlgItem(hwndDlg, IDOK), toSet); } } break; /* case WM_COMMAND */ case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); break; } return FALSE; }
static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { CLCINFOITEM cii = {0}; HANDLE hMetaContactsEvent; SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam); TranslateDialogDefault(hwndDlg); Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_CONFERENCE)); gg_gc_resetclistopts(GetDlgItem(hwndDlg, IDC_CLIST)); // Hook MetaContacts event (if available) hMetaContactsEvent = HookEventMessage(ME_MC_SUBCONTACTSCHANGED, hwndDlg, HM_SUBCONTACTSCHANGED); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hMetaContactsEvent); } return TRUE; case WM_COMMAND: { switch (LOWORD(wParam)) { case IDOK: { HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST); GGPROTO* gg = (GGPROTO*)GetWindowLongPtr(hwndDlg, DWLP_USER); int count = 0, i = 0; // Check if connected if (!gg->isonline()) { MessageBox(NULL, TranslateT("You have to be connected to open new conference."), gg->m_tszUserName, MB_OK | MB_ICONSTOP); } else if (hwndList && (count = gg_gc_countcheckmarks(hwndList)) >= 2) { // Create new participiants table TCHAR* chat; uin_t* participants = (uin_t*)calloc(count, sizeof(uin_t)); gg->debugLogA("gg_gc_openconfdlg(): WM_COMMAND IDOK Opening new conference for %d contacts.", count); for (MCONTACT hContact = db_find_first(); hContact && i < count; hContact = db_find_next(hContact)) { HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0); if (hItem && SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) { MCONTACT hMetaContact = gg_getsubcontact(gg, hContact); // MetaContacts support participants[i++] = db_get_dw(hMetaContact ? hMetaContact : hContact, gg->m_szModuleName, GG_KEY_UIN, 0); } } if (count > i) i = count; chat = gg->gc_getchat(0, participants, count); if (chat) { GCDEST gcd = { gg->m_szModuleName, chat, GC_EVENT_CONTROL }; GCEVENT gce = { sizeof(gce), &gcd }; CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce); } free(participants); } } // fall through case IDCANCEL: DestroyWindow(hwndDlg); break; } break; } case WM_NOTIFY: { switch(((NMHDR*)lParam)->idFrom) { case IDC_CLIST: { switch(((NMHDR*)lParam)->code) { case CLN_OPTIONSCHANGED: gg_gc_resetclistopts(GetDlgItem(hwndDlg, IDC_CLIST)); break; case CLN_NEWCONTACT: case CLN_CONTACTMOVED: case CLN_LISTREBUILT: { char* szProto; uin_t uin; GGPROTO* gg = (GGPROTO*)GetWindowLongPtr(hwndDlg, DWLP_USER); if (!gg) break; // Delete non-gg contacts for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { MCONTACT hItem = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, hContact, 0); if (hItem) { MCONTACT hMetaContact = gg_getsubcontact(gg, hContact); // MetaContacts support if (hMetaContact) { szProto = gg->m_szModuleName; uin = (uin_t)gg->getDword(hMetaContact, GG_KEY_UIN, 0); } else { szProto = GetContactProto(hContact); uin = (uin_t)gg->getDword(hContact, GG_KEY_UIN, 0); } if (szProto == NULL || mir_strcmp(szProto, gg->m_szModuleName) || !uin || uin == gg->getDword(GG_KEY_UIN, 0)) SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_DELETEITEM, (WPARAM)hItem, 0); } } } break; case CLN_CHECKCHANGED: EnableWindow(GetDlgItem(hwndDlg, IDOK), gg_gc_countcheckmarks(GetDlgItem(hwndDlg, IDC_CLIST)) >= 2); break; } break; } } break; } case HM_SUBCONTACTSCHANGED: { HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST); SendMessage(hwndList, CLM_AUTOREBUILD, 0, 0); EnableWindow(GetDlgItem(hwndDlg, IDOK), gg_gc_countcheckmarks(hwndList) >= 2); break; } case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: { HANDLE hMetaContactsEvent = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (hMetaContactsEvent) UnhookEvent(hMetaContactsEvent); Window_FreeIcon_IcoLib(hwndDlg); break; } } return FALSE; }
static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { struct TFtMgrData *dat = (struct TFtMgrData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { TCITEM tci = {0}; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); TranslateDialogDefault(hwnd); Window_SetIcon_IcoLib(hwnd, SKINICON_EVENT_FILE); dat = (struct TFtMgrData *)mir_calloc(sizeof(struct TFtMgrData)); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat); dat->hhkPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwnd, M_PRESHUTDOWN); dat->hwndIncoming = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc); dat->hwndOutgoing = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc); ShowWindow(dat->hwndIncoming, SW_SHOW); tci.mask = TCIF_PARAM|TCIF_TEXT; tci.pszText = TranslateT("Incoming"); tci.lParam = (LPARAM)dat->hwndIncoming; TabCtrl_InsertItem(hwndTab, 0, &tci); tci.pszText = TranslateT("Outgoing"); tci.lParam = (LPARAM)dat->hwndOutgoing; TabCtrl_InsertItem(hwndTab, 1, &tci); // Utils_RestoreWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_"); SAVEWINDOWPOS swp; swp.hwnd = hwnd; swp.hContact = NULL; swp.szModule = "SRFile"; swp.szNamePrefix = "FtMgrDlg_"; CallService(MS_UTILS_RESTOREWINDOWPOSITION, RWPF_NOACTIVATE, (LPARAM)&swp); // Fall through to setup initial placement } case WM_SIZE: { RECT rc, rcButton; HDWP hdwp; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rcButton); OffsetRect(&rcButton, -rcButton.left, -rcButton.top); GetClientRect(hwnd, &rc); InflateRect(&rc, -6, -6); hdwp = BeginDeferWindowPos(3); hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_CLEAR), NULL, rc.left, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE); hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDCANCEL), NULL, rc.right-rcButton.right, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE); rc.bottom -= rcButton.bottom + 5; hdwp = DeferWindowPos(hdwp, hwndTab, NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); EndDeferWindowPos(hdwp); GetWindowRect(hwndTab, &rc); MapWindowPoints(NULL, hwnd, (LPPOINT)&rc, 2); TabCtrl_AdjustRect(hwndTab, FALSE, &rc); InflateRect(&rc, -5, -5); hdwp = BeginDeferWindowPos(2); hdwp = DeferWindowPos(hdwp, dat->hwndIncoming, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0); hdwp = DeferWindowPos(hdwp, dat->hwndOutgoing, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0); EndDeferWindowPos(hdwp); break; } case WM_MOUSEWHEEL: if (IsWindowVisible(dat->hwndIncoming)) SendMessage(dat->hwndIncoming, msg, wParam, lParam); if (IsWindowVisible(dat->hwndOutgoing)) SendMessage(dat->hwndOutgoing, msg, wParam, lParam); break; case WM_FT_SELECTPAGE: { TCITEM tci = {0}; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); if (TabCtrl_GetCurSel(hwndTab) == (int)wParam) break; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_HIDE); TabCtrl_SetCurSel(hwndTab, wParam); TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_SHOW); } break; case WM_GETMINMAXINFO: { LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; lpmmi->ptMinTrackSize.x = 300; lpmmi->ptMinTrackSize.y = 400; return 0; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: PostMessage(hwnd, WM_CLOSE , 0, 0); break; case IDC_CLEAR: PostMessage(dat->hwndIncoming, WM_FT_CLEANUP, 0, 0); PostMessage(dat->hwndOutgoing, WM_FT_CLEANUP, 0, 0); break; } break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case IDC_TABS: { HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); switch (((LPNMHDR)lParam)->code) { case TCN_SELCHANGING: { TCITEM tci = {0}; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_HIDE); break; } case TCN_SELCHANGE: { TCITEM tci = {0}; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_SHOW); break; } } break; } } break; case M_PRESHUTDOWN: SendMessage(dat->hwndIncoming, M_PRESHUTDOWN, 0, 0); SendMessage(dat->hwndOutgoing, M_PRESHUTDOWN, 0, 0); DestroyWindow(hwnd); break; case WM_CLOSE: ShowWindow(hwnd, SW_HIDE); if (db_get_b(NULL, "SRFile", "AutoClear", 1)) { PostMessage(dat->hwndIncoming, WM_FT_CLEANUP, 0, 0); PostMessage(dat->hwndOutgoing, WM_FT_CLEANUP, 0, 0); } return TRUE; /* Disable default IDCANCEL notification */ case WM_DESTROY: UnhookEvent(dat->hhkPreshutdown); Window_FreeIcon_IcoLib(hwnd); DestroyWindow(dat->hwndIncoming); DestroyWindow(dat->hwndOutgoing); mir_free(dat); SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); Utils_SaveWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_"); break; case WM_ACTIVATE: dat->errorState = TBPF_NOPROGRESS; wParam = 1; break; case WM_SHOWWINDOW: if ( !wParam) { // hiding KillTimer(hwnd, 1); break; } lParam = 0; case WM_TIMER: if (pTaskbarInterface) { SetTimer(hwnd, 1, 400, NULL); if ((lParam == ACKRESULT_FAILED) || (lParam == ACKRESULT_DENIED)) dat->errorState = TBPF_ERROR; TFtProgressData prg = {0}; SendMessage(dat->hwndIncoming, M_CALCPROGRESS, (WPARAM)&prg, 0); SendMessage(dat->hwndOutgoing, M_CALCPROGRESS, (WPARAM)&prg, 0); if (dat->errorState) { pTaskbarInterface->SetProgressState(hwnd, dat->errorState); if ( !prg.run) pTaskbarInterface->SetProgressValue(hwnd, 1, 1); } else if (prg.run) pTaskbarInterface->SetProgressState(hwnd, TBPF_NORMAL); else if (prg.init || prg.scan) pTaskbarInterface->SetProgressState(hwnd, TBPF_INDETERMINATE); else { pTaskbarInterface->SetProgressState(hwnd, TBPF_NOPROGRESS); KillTimer(hwnd, 1); } if (prg.run) pTaskbarInterface->SetProgressValue(hwnd, prg.totalProgress, prg.totalBytes); } 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 AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) { ADDCONTACTSTRUCT *acs; switch(msg) { case WM_INITDIALOG: { char szUin[10]; acs = (ADDCONTACTSTRUCT *)lparam; SetWindowLongPtr(hdlg, GWLP_USERDATA, (LONG_PTR)acs); TranslateDialogDefault(hdlg); Window_SetIcon_IcoLib(hdlg, SKINICON_OTHER_ADDCONTACT); if (acs->handleType == HANDLE_EVENT) { DWORD dwUin; DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = sizeof(DWORD); dbei.pBlob = (PBYTE)&dwUin; db_event_get(acs->hDbEvent, &dbei); _ltoa(dwUin, szUin, 10); acs->szProto = dbei.szModule; } { TCHAR *szName = NULL, *tmpStr = NULL; if (acs->handleType == HANDLE_CONTACT) szName = cli.pfnGetContactDisplayName(acs->hContact, 0); else { int isSet = 0; if (acs->handleType == HANDLE_EVENT) { DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(acs->hDbEvent); dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); db_event_get(acs->hDbEvent, &dbei); MCONTACT hcontact = *(MCONTACT*)(dbei.pBlob + sizeof(DWORD)); mir_free(dbei.pBlob); if (hcontact != INVALID_CONTACT_ID) { szName = cli.pfnGetContactDisplayName(hcontact, 0); isSet = 1; } } if (!isSet) { szName = (acs->handleType == HANDLE_EVENT) ? (tmpStr = mir_a2t(szUin)) : (acs->psr->id ? acs->psr->id : acs->psr->nick); } } if (szName && szName[0]) { TCHAR szTitle[128]; mir_sntprintf(szTitle, SIZEOF(szTitle), TranslateT("Add %s"), szName); SetWindowText(hdlg, szTitle); } else SetWindowText(hdlg, TranslateT("Add contact")); mir_free(tmpStr); } } if (acs->handleType == HANDLE_CONTACT && acs->hContact) if (acs->szProto == NULL || (acs->szProto != NULL && *acs->szProto == 0)) acs->szProto = GetContactProto(acs->hContact); { TCHAR *grpName; for (int groupId = 1; (grpName = cli.pfnGetGroupName(groupId, NULL)) != NULL; groupId++) { int id = SendDlgItemMessage(hdlg, IDC_GROUP, CB_ADDSTRING, 0, (LPARAM)grpName); SendDlgItemMessage(hdlg, IDC_GROUP, CB_SETITEMDATA, id, groupId); } } SendDlgItemMessage(hdlg, IDC_GROUP, CB_INSERTSTRING, 0, (LPARAM)TranslateT("None")); SendDlgItemMessage(hdlg, IDC_GROUP, CB_SETCURSEL, 0, 0); /* acs->szProto may be NULL don't expect it */ { // By default check both checkboxes CheckDlgButton(hdlg, IDC_ADDED, BST_CHECKED); CheckDlgButton(hdlg, IDC_AUTH, BST_CHECKED); // Set last choice if (db_get_b(NULL, "Miranda", "AuthOpenWindow", 1)) CheckDlgButton(hdlg, IDC_OPEN_WINDOW, BST_CHECKED); DWORD flags = (acs->szProto) ? CallProtoServiceInt(NULL,acs->szProto, PS_GETCAPS, PFLAGNUM_4, 0) : 0; if (flags&PF4_FORCEADDED) { // force you were added requests for this protocol EnableWindow( GetDlgItem(hdlg, IDC_ADDED), FALSE); } if (flags&PF4_FORCEAUTH) { // force auth requests for this protocol EnableWindow( GetDlgItem(hdlg, IDC_AUTH), FALSE); } if (flags&PF4_NOCUSTOMAUTH) { EnableWindow( GetDlgItem(hdlg, IDC_AUTHREQ), FALSE); EnableWindow( GetDlgItem(hdlg, IDC_AUTHGB), FALSE); } else { EnableWindow( GetDlgItem(hdlg, IDC_AUTHREQ), IsDlgButtonChecked(hdlg, IDC_AUTH)); EnableWindow( GetDlgItem(hdlg, IDC_AUTHGB), IsDlgButtonChecked(hdlg, IDC_AUTH)); SetDlgItemText(hdlg, IDC_AUTHREQ, TranslateT("Please authorize my request and add me to your contact list.")); } } break; case WM_COMMAND: acs = (ADDCONTACTSTRUCT *)GetWindowLongPtr(hdlg, GWLP_USERDATA); switch (LOWORD(wparam)) { case IDC_AUTH: { DWORD flags = CallProtoServiceInt(NULL,acs->szProto, PS_GETCAPS, PFLAGNUM_4, 0); if (flags & PF4_NOCUSTOMAUTH) { EnableWindow( GetDlgItem(hdlg, IDC_AUTHREQ), FALSE); EnableWindow( GetDlgItem(hdlg, IDC_AUTHGB), FALSE); } else { EnableWindow( GetDlgItem(hdlg, IDC_AUTHREQ), IsDlgButtonChecked(hdlg, IDC_AUTH)); EnableWindow( GetDlgItem(hdlg, IDC_AUTHGB), IsDlgButtonChecked(hdlg, IDC_AUTH)); } } break; case IDC_OPEN_WINDOW: // Remember this choice db_set_b(NULL, "Miranda", "AuthOpenWindow", IsDlgButtonChecked(hdlg, IDC_OPEN_WINDOW)); break; case IDOK: { MCONTACT hContact = INVALID_CONTACT_ID; switch (acs->handleType) { case HANDLE_EVENT: { DBEVENTINFO dbei = { sizeof(dbei) }; db_event_get(acs->hDbEvent, &dbei); hContact = (MCONTACT)CallProtoServiceInt(NULL, dbei.szModule, PS_ADDTOLISTBYEVENT, 0, (LPARAM)acs->hDbEvent); } break; case HANDLE_SEARCHRESULT: hContact = (MCONTACT)CallProtoServiceInt(NULL, acs->szProto, PS_ADDTOLIST, 0, (LPARAM)acs->psr); break; case HANDLE_CONTACT: hContact = acs->hContact; break; } if (hContact == NULL) break; TCHAR szHandle[256]; if ( GetDlgItemText(hdlg, IDC_MYHANDLE, szHandle, SIZEOF(szHandle))) db_set_ts(hContact, "CList", "MyHandle", szHandle); int item = SendDlgItemMessage(hdlg, IDC_GROUP, CB_GETCURSEL, 0, 0); if (item > 0) { item = SendDlgItemMessage(hdlg, IDC_GROUP, CB_GETITEMDATA, item, 0); CallService(MS_CLIST_CONTACTCHANGEGROUP, hContact, item); } db_unset(hContact, "CList", "NotOnList"); if (IsDlgButtonChecked(hdlg, IDC_ADDED)) CallContactService(hContact, PSS_ADDED, 0, 0); if (IsDlgButtonChecked(hdlg, IDC_AUTH)) { DWORD flags = CallProtoServiceInt(NULL,acs->szProto, PS_GETCAPS, PFLAGNUM_4, 0); if (flags & PF4_NOCUSTOMAUTH) CallContactService(hContact, PSS_AUTHREQUESTT, 0, 0); else { TCHAR szReason[512]; GetDlgItemText(hdlg, IDC_AUTHREQ, szReason, SIZEOF(szReason)); CallContactService(hContact, PSS_AUTHREQUESTT, 0, (LPARAM)szReason); } } if (IsDlgButtonChecked(hdlg, IDC_OPEN_WINDOW)) CallService(MS_CLIST_CONTACTDOUBLECLICKED, hContact, 0); } // fall through case IDCANCEL: if (GetParent(hdlg) == NULL) DestroyWindow(hdlg); else EndDialog(hdlg, 0); break; } break; case WM_CLOSE: /* if there is no parent for the dialog, its a modeless dialog and can't be killed using EndDialog() */ if (GetParent(hdlg) == NULL) DestroyWindow(hdlg); else EndDialog(hdlg, 0); break; case WM_DESTROY: Window_FreeIcon_IcoLib(hdlg); acs = (ADDCONTACTSTRUCT*)GetWindowLongPtr(hdlg, GWLP_USERDATA); if (acs) { if (acs->psr) { mir_free(acs->psr->nick); mir_free(acs->psr->firstName); mir_free(acs->psr->lastName); mir_free(acs->psr->email); mir_free(acs->psr); } mir_free(acs); } break; } return FALSE; }
static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { OptionsPageData *opd; OptionsDlgData *dat = (OptionsDlgData*)GetWindowLongPtr(hdlg, GWLP_USERDATA); HWND hwndTree = GetDlgItem(hdlg, IDC_PAGETREE); switch (message) { case WM_CTLCOLORSTATIC: switch (GetDlgCtrlID((HWND)lParam)) { case IDC_WHITERECT: case IDC_KEYWORD_FILTER: SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); } break; case WM_INITDIALOG: TranslateDialogDefault(hdlg); if (!ServiceExists(MS_MODERNOPT_SHOW)) ShowWindow(GetDlgItem(hdlg, IDC_MODERN), FALSE); { PROPSHEETHEADER *psh = (PROPSHEETHEADER*)lParam; OPENOPTIONSDIALOG *ood = (OPENOPTIONSDIALOG*)psh->pStartPage; COMBOBOXINFO cbi; cbi.cbSize = sizeof(COMBOBOXINFO); GetComboBoxInfo(GetDlgItem(hdlg, IDC_KEYWORD_FILTER), &cbi); mir_subclassWindow(cbi.hwndItem, OptionsFilterSubclassProc); if (IsAeroMode()) { mir_subclassWindow(cbi.hwndCombo, AeroPaintSubclassProc); mir_subclassWindow(cbi.hwndItem, AeroPaintSubclassProc); } Utils_RestoreWindowPositionNoSize(hdlg, NULL, "Options", ""); Window_SetIcon_IcoLib(hdlg, SKINICON_OTHER_OPTIONS); EnableWindow(GetDlgItem(hdlg, IDC_APPLY), FALSE); dat = new OptionsDlgData; SetWindowLongPtr(hdlg, GWLP_USERDATA, (LONG_PTR)dat); SetWindowText(hdlg, psh->pszCaption); LOGFONT lf; dat->hBoldFont = (HFONT)SendDlgItemMessage(hdlg, IDC_APPLY, WM_GETFONT, 0, 0); GetObject(dat->hBoldFont, sizeof(lf), &lf); lf.lfWeight = FW_BOLD; dat->hBoldFont = CreateFontIndirect(&lf); dat->hPluginLoad = HookEventMessage(ME_SYSTEM_MODULELOAD, hdlg, HM_MODULELOAD); dat->hPluginUnload = HookEventMessage(ME_SYSTEM_MODULEUNLOAD, hdlg, HM_MODULEUNLOAD); dat->currentPage = -1; ptrT lastPage, lastGroup, lastTab; if (ood->pszPage == NULL) { lastPage = db_get_tsa(NULL, "Options", "LastPage"); if (ood->pszGroup == NULL) lastGroup = db_get_tsa(NULL, "Options", "LastGroup"); else lastGroup = mir_a2t(ood->pszGroup); } else { lastPage = mir_a2t(ood->pszPage); lastGroup = mir_a2t(ood->pszGroup); } if (ood->pszTab == NULL) lastTab = db_get_tsa(NULL, "Options", "LastTab"); else lastTab = mir_a2t(ood->pszTab); OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)psh->ppsp; for (UINT i = 0; i < psh->nPages; i++, odp++) { opd = (OptionsPageData*)mir_calloc(sizeof(OptionsPageData)); if (!LoadOptionsPage(odp, opd)) { mir_free(opd); continue; } dat->arOpd.insert(opd); if (!lstrcmp(lastPage, odp->ptszTitle) && !lstrcmpnull(lastGroup, odp->ptszGroup)) if ((ood->pszTab == NULL && dat->currentPage == -1) || !lstrcmpnull(lastTab, odp->ptszTab)) dat->currentPage = (int)i; } GetWindowRect(GetDlgItem(hdlg, IDC_STNOPAGE), &dat->rcDisplay); MapWindowPoints(NULL, hdlg, (LPPOINT)&dat->rcDisplay, 2); // Add an item to count in height TCITEM tie; tie.mask = TCIF_TEXT | TCIF_IMAGE; tie.iImage = -1; tie.pszText = _T("X"); TabCtrl_InsertItem(GetDlgItem(hdlg, IDC_TAB), 0, &tie); GetWindowRect(GetDlgItem(hdlg, IDC_TAB), &dat->rcTab); MapWindowPoints(NULL, hdlg, (LPPOINT)&dat->rcTab, 2); TabCtrl_AdjustRect(GetDlgItem(hdlg, IDC_TAB), FALSE, &dat->rcTab); FillFilterCombo(hdlg, dat); PostMessage(hdlg, DM_REBUILDPAGETREE, 0, 0); } return TRUE; case DM_REBUILDPAGETREE: RebuildPageTree(hdlg, dat); break; case HM_MODULELOAD: LoadOptionsModule(hdlg, dat, (HINSTANCE)lParam); break; case HM_MODULEUNLOAD: UnloadOptionsModule(hdlg, dat, (HINSTANCE)lParam); break; case PSM_CHANGED: EnableWindow(GetDlgItem(hdlg, IDC_APPLY), TRUE); opd = dat->getCurrent(); if (opd) opd->changed = 1; return TRUE; case PSM_GETBOLDFONT: SetWindowLongPtr(hdlg, DWLP_MSGRESULT, (LONG_PTR)dat->hBoldFont); return TRUE; case WM_NOTIFY: switch (wParam) { case IDC_TAB: case IDC_PAGETREE: switch (((LPNMHDR)lParam)->code) { case TVN_ITEMEXPANDING: SetWindowLongPtr(hdlg, DWLP_MSGRESULT, FALSE); return TRUE; case TCN_SELCHANGING: case TVN_SELCHANGING: opd = dat->getCurrent(); if (opd && opd->hwnd != NULL) { PSHNOTIFY pshn; pshn.hdr.code = PSN_KILLACTIVE; pshn.hdr.hwndFrom = dat->arOpd[dat->currentPage]->hwnd; pshn.hdr.idFrom = 0; pshn.lParam = 0; if (SendMessage(dat->arOpd[dat->currentPage]->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) { SetWindowLongPtr(hdlg, DWLP_MSGRESULT, TRUE); return TRUE; } } break; case TCN_SELCHANGE: case TVN_SELCHANGED: ShowWindow(GetDlgItem(hdlg, IDC_STNOPAGE), SW_HIDE); opd = dat->getCurrent(); if (opd && opd->hwnd != NULL) ShowWindow(opd->hwnd, SW_HIDE); if (wParam != IDC_TAB) { TVITEM tvi; tvi.hItem = dat->hCurrentPage = TreeView_GetSelection(hwndTree); if (tvi.hItem == NULL) { ShowWindow(GetDlgItem(hdlg, IDC_TAB), SW_HIDE); break; } tvi.mask = TVIF_HANDLE | TVIF_PARAM; TreeView_GetItem(hwndTree, &tvi); dat->currentPage = tvi.lParam; ShowWindow(GetDlgItem(hdlg, IDC_TAB), SW_HIDE); } else { TCITEM tie; tie.mask = TCIF_PARAM; TabCtrl_GetItem(GetDlgItem(hdlg, IDC_TAB), TabCtrl_GetCurSel(GetDlgItem(hdlg, IDC_TAB)), &tie); dat->currentPage = tie.lParam; TVITEM tvi; tvi.hItem = dat->hCurrentPage; tvi.mask = TVIF_PARAM; tvi.lParam = dat->currentPage; TreeView_SetItem(hwndTree, &tvi); } opd = dat->getCurrent(); if (opd == NULL) { ShowWindow(GetDlgItem(hdlg, IDC_STNOPAGE), SW_SHOW); break; } if (opd->hwnd == NULL) { opd->hwnd = CreateDialogIndirectParamA(opd->hInst, opd->pTemplate, hdlg, opd->dlgProc, opd->dwInitParam); if (opd->flags & ODPF_BOLDGROUPS) EnumChildWindows(opd->hwnd, BoldGroupTitlesEnumChildren, (LPARAM)dat->hBoldFont); RECT rcPage; GetClientRect(opd->hwnd, &rcPage); int w = opd->width = rcPage.right; int h = opd->height = rcPage.bottom; RECT rc; GetWindowRect(opd->hwnd, &rc); opd->offsetX = 0; opd->offsetY = 0; opd->insideTab = IsInsideTab(hdlg, dat, dat->currentPage); if (opd->insideTab) { SetWindowPos(opd->hwnd, HWND_TOP, (dat->rcTab.left + dat->rcTab.right - w) >> 1, dat->rcTab.top, w, h, 0); ThemeDialogBackground(opd->hwnd, TRUE); } else { SetWindowPos(opd->hwnd, HWND_TOP, (dat->rcDisplay.left + dat->rcDisplay.right - w) >> 1, (dat->rcDisplay.top + dat->rcDisplay.bottom - h) >> 1, w, h, 0); ThemeDialogBackground(opd->hwnd, FALSE); } } if (wParam != IDC_TAB) { opd->insideTab = IsInsideTab(hdlg, dat, dat->currentPage); if (opd->insideTab) { // Make tabbed pane int pages = 0, sel = 0; HWND hwndTab = GetDlgItem(hdlg, IDC_TAB); TabCtrl_DeleteAllItems(hwndTab); TCITEM tie; tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; tie.iImage = -1; for (int i = 0; i < dat->arOpd.getCount(); i++) { if (!CheckPageShow(hdlg, dat, i)) continue; OptionsPageData *p = dat->arOpd[i]; if (lstrcmp(opd->ptszTitle, p->ptszTitle) || lstrcmpnull(opd->ptszGroup, p->ptszGroup)) continue; tie.pszText = TranslateTH(p->hLangpack, p->ptszTab); tie.lParam = i; TabCtrl_InsertItem(hwndTab, pages, &tie); if (!lstrcmp(opd->ptszTab, p->ptszTab)) sel = pages; pages++; } TabCtrl_SetCurSel(hwndTab, sel); ShowWindow(hwndTab, opd->insideTab ? SW_SHOW : SW_HIDE); } if (opd->insideTab) ThemeDialogBackground(opd->hwnd, TRUE); else ThemeDialogBackground(opd->hwnd, FALSE); } ShowWindow(opd->hwnd, SW_SHOW); if (((LPNMTREEVIEW)lParam)->action == TVC_BYMOUSE) PostMessage(hdlg, DM_FOCUSPAGE, 0, 0); else SetFocus(hwndTree); }
INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct FileDlgData *dat; dat=(struct FileDlgData*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { struct FileSendData *fsd=(struct FileSendData*)lParam; dat=(struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData)); SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)dat); dat->hContact=fsd->hContact; dat->send=1; dat->hPreshutdownEvent=HookEventMessage(ME_SYSTEM_PRESHUTDOWN,hwndDlg,M_PRESHUTDOWN); dat->fs=NULL; dat->dwTicks=GetTickCount(); TranslateDialogDefault(hwndDlg); EnumChildWindows(hwndDlg,ClipSiblingsChildEnumProc,0); OldSendEditProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_MSG),GWLP_WNDPROC,(LONG_PTR)SendEditSubclassProc); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE); 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")); EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); if(fsd->ppFiles!=NULL && fsd->ppFiles[0]!=NULL) { int totalCount,i; for(totalCount=0;fsd->ppFiles[totalCount];totalCount++); dat->files = ( TCHAR** )mir_alloc( sizeof(TCHAR*)*(totalCount+1)); // Leaks for(i=0;i<totalCount;i++) dat->files[i] = mir_tstrdup( fsd->ppFiles[i] ); dat->files[totalCount]=NULL; SetFileListAndSizeControls(hwndDlg,dat); } { char *szProto; TCHAR* contactName = cli.pfnGetContactDisplayName( dat->hContact, 0 ); SetDlgItemText(hwndDlg,IDC_TO,contactName); szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); if (szProto) { CONTACTINFO ci; int hasName = 0; char buf[128]; ZeroMemory(&ci,sizeof(ci)); ci.cbSize = sizeof(ci); ci.hContact = dat->hContact; ci.szProto = szProto; ci.dwFlag = CNF_UNIQUEID; if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) { switch(ci.type) { case CNFT_ASCIIZ: hasName = 1; mir_snprintf(buf, SIZEOF(buf), "%s", ci.pszVal); mir_free(ci.pszVal); break; case CNFT_DWORD: hasName = 1; mir_snprintf(buf, SIZEOF(buf),"%u",ci.dVal); break; } } if ( hasName ) SetDlgItemTextA(hwndDlg,IDC_NAME,buf); else SetDlgItemText(hwndDlg,IDC_NAME,contactName); } } if ( fsd->ppFiles == NULL ) { EnableWindow(hwndDlg, FALSE); dat->closeIfFileChooseCancelled=1; PostMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_CHOOSE,BN_CLICKED),(LPARAM)GetDlgItem(hwndDlg,IDC_CHOOSE)); } return TRUE; } case WM_MEASUREITEM: return CallService(MS_CLIST_MENUMEASUREITEM,wParam,lParam); case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis=(LPDRAWITEMSTRUCT)lParam; if(dis->hwndItem==GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto; szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); 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 CallService(MS_CLIST_MENUDRAWITEM,wParam,lParam); case M_FILECHOOSEDONE: if( lParam != 0 ) { FilenameToFileList( hwndDlg, dat, ( TCHAR* )lParam ); mir_free(( TCHAR* )lParam ); dat->closeIfFileChooseCancelled = 0; } else if(dat->closeIfFileChooseCancelled) DestroyWindow(hwndDlg); EnableWindow(hwndDlg,TRUE); break; case WM_COMMAND: if(CallService(MS_CLIST_MENUPROCESSCOMMAND,MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU),(LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { case IDC_CHOOSE: EnableWindow(hwndDlg,FALSE); //GetOpenFileName() creates its own message queue which prevents any incoming events being processed forkthread(ChooseFilesThread,0,hwndDlg); break; case IDOK: EnableWindow(GetDlgItem(hwndDlg,IDC_FILENAME),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_MSG),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_CHOOSE),FALSE); GetDlgItemText(hwndDlg,IDC_FILEDIR,dat->szSavePath,SIZEOF(dat->szSavePath)); GetDlgItemText(hwndDlg,IDC_FILE,dat->szFilenames,SIZEOF(dat->szFilenames)); GetDlgItemText(hwndDlg,IDC_MSG,dat->szMsg,SIZEOF(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr( hwndDlg, GWLP_USERDATA, 0); DestroyWindow(hwndDlg); return TRUE; case IDCANCEL: DestroyWindow(hwndDlg); return TRUE; case IDC_USERMENU: { RECT rc; HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT,(WPARAM)dat->hContact,0); GetWindowRect((HWND)lParam,&rc); TrackPopupMenu(hMenu,0,rc.left,rc.bottom,0,hwndDlg,NULL); DestroyMenu(hMenu); break; } case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)dat->hContact,0); return TRUE; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY,(WPARAM)dat->hContact,0); return TRUE; } break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); Button_FreeIcon_IcoLib(hwndDlg,IDC_DETAILS); Button_FreeIcon_IcoLib(hwndDlg,IDC_HISTORY); Button_FreeIcon_IcoLib(hwndDlg,IDC_USERMENU); if ( dat ) FreeFileDlgData( dat ); SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_MSG),GWLP_WNDPROC,(LONG_PTR)OldSendEditProc); return TRUE; } return FALSE; }
//============ WEATHER INI SETUP DIALOG ============ // static INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); // make the buttons flat SendDlgItemMessage(hwndDlg, IDC_STEP1, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_STEP2, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_STEP3, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_STEP4, BUTTONSETASFLATBTN, TRUE, 0); // set icons Window_SetIcon_IcoLib(hwndDlg, GetIconHandle("main")); WindowList_Add(hWindowList, hwndDlg, NULL); ShowWindow(hwndDlg, SW_SHOW); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_STEP1: // update current data Utils_OpenUrl("http://miranda-ng.org/"); break; case IDC_STEP2: { TCHAR szPath[1024]; GetModuleFileName(GetModuleHandle(NULL), szPath, _countof(szPath)); TCHAR *chop = _tcsrchr(szPath, '\\'); if (chop) { *chop = '\0'; mir_tstrncat(szPath, _T("\\Plugins\\weather\\"), _countof(szPath) - mir_tstrlen(szPath)); if (_tmkdir(szPath) == 0) ShellExecute((HWND)lParam, _T("open"), szPath, _T(""), _T(""), SW_SHOW); } break; } case IDC_STEP3: if (LoadWIData(false)) MessageBox(NULL, TranslateT("All update data has been reloaded."), TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION); break; case IDC_STEP4: WeatherAdd(0, 0); // fall through case IDCANCEL: // close the info window DestroyWindow(hwndDlg); break; } break; case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); break; } return FALSE; }
INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { post_status_data *data; switch (message) { case WM_INITDIALOG: { TranslateDialogDefault(hwnd); Window_SetIcon_IcoLib(hwnd, GetIconHandle("mind")); data = reinterpret_cast<post_status_data*>(lparam); SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam); SendDlgItemMessage(hwnd, IDC_MINDMSG, EM_LIMITTEXT, FACEBOOK_MIND_LIMIT, 0); SendDlgItemMessage(hwnd, IDC_URL, EM_LIMITTEXT, 1024, 0); ptrT place(data->proto->getTStringA(FACEBOOK_KEY_PLACE)); SetDlgItemText(hwnd, IDC_PLACE, place != NULL ? place : _T("Miranda NG")); bShowContacts = data->proto->getByte("PostStatusExpand", 0) > 0; ResizeHorizontal(hwnd, bShowContacts); HWND hwndClist = GetDlgItem(hwnd, IDC_CCLIST); SetWindowLongPtr(hwndClist, GWL_STYLE, GetWindowLongPtr(hwndClist, GWL_STYLE) & ~CLS_HIDEOFFLINE); for (std::vector<wall_data*>::size_type i = 0; i < data->walls.size(); i++) SendDlgItemMessage(hwnd, IDC_WALL, CB_INSERTSTRING, i, reinterpret_cast<LPARAM>(data->walls[i]->title)); SendDlgItemMessage(hwnd, IDC_WALL, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hwnd, IDC_WALL, CB_SETCURSEL, data->proto->getByte(FACEBOOK_KEY_LAST_WALL, 0), 0); RefreshPrivacy(hwnd, data); ptrA firstname(data->proto->getStringA(FACEBOOK_KEY_FIRST_NAME)); if (firstname != NULL) { char title[100]; mir_snprintf(title, Translate("What's on your mind, %s?"), firstname); SetWindowTextA(hwnd, title); } } EnableWindow(GetDlgItem(hwnd, IDOK), FALSE); return TRUE; case WM_NOTIFY: { NMCLISTCONTROL *nmc = (NMCLISTCONTROL *)lparam; if (nmc->hdr.idFrom == IDC_CCLIST) { switch (nmc->hdr.code) { case CLN_LISTREBUILT: data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); ClistPrepare(data->proto, NULL, nmc->hdr.hwndFrom); break; } } } break; case WM_COMMAND: switch (LOWORD(wparam)) { case IDC_WALL: if (HIWORD(wparam) == CBN_SELCHANGE) { data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); RefreshPrivacy(hwnd, data); } break; case IDC_MINDMSG: case IDC_URL: if (HIWORD(wparam) == EN_CHANGE) { bool ok = SendDlgItemMessage(hwnd, IDC_MINDMSG, WM_GETTEXTLENGTH, 0, 0) > 0; if (!ok && SendDlgItemMessage(hwnd, IDC_URL, WM_GETTEXTLENGTH, 0, 0) > 0) ok = true; EnableWindow(GetDlgItem(hwnd, IDOK), ok); return TRUE; } break; case IDC_EXPAND: bShowContacts = !bShowContacts; ResizeHorizontal(hwnd, bShowContacts); break; case IDOK: { data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); TCHAR mindMessageT[FACEBOOK_MIND_LIMIT + 1]; TCHAR urlT[1024]; TCHAR placeT[100]; GetDlgItemText(hwnd, IDC_MINDMSG, mindMessageT, _countof(mindMessageT)); GetDlgItemText(hwnd, IDC_PLACE, placeT, _countof(placeT)); GetDlgItemText(hwnd, IDC_URL, urlT, _countof(urlT)); ShowWindow(hwnd, SW_HIDE); int wall_id = SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCURSEL, 0, 0); int privacy_id = SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCURSEL, 0, 0); data->proto->setTString(FACEBOOK_KEY_PLACE, placeT); data->proto->setByte("PostStatusExpand", bShowContacts); // remember last wall, only when there are more options if (SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCOUNT, 0, 0) > 1) data->proto->setByte(FACEBOOK_KEY_LAST_WALL, wall_id); // remember last privacy, only when there are more options if (SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCOUNT, 0, 0) > 1) data->proto->setByte(FACEBOOK_KEY_PRIVACY_TYPE, privacy_id); status_data *status = new status_data(); status->user_id = data->walls[wall_id]->user_id; status->isPage = data->walls[wall_id]->isPage; status->privacy = privacy_types[privacy_id].id; status->place = T2Utf(placeT); status->url = _T2A(urlT); HWND hwndList = GetDlgItem(hwnd, IDC_CCLIST); GetSelectedContacts(data->proto, NULL, hwndList, &status->users); T2Utf narrow(mindMessageT); status->text = narrow; if (status->user_id == data->proto->facy.self_.user_id && data->proto->last_status_msg_ != (char*)narrow) data->proto->last_status_msg_ = narrow; data->proto->ForkThread(&FacebookProto::SetAwayMsgWorker, status); EndDialog(hwnd, wparam); return TRUE; } case IDCANCEL: EndDialog(hwnd, wparam); return TRUE; } break; case WM_DESTROY: data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); for (std::vector<wall_data*>::size_type i = 0; i < data->walls.size(); i++) { mir_free(data->walls[i]->title); delete data->walls[i]; } delete data; } return FALSE; }