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; }
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 sttEnterStringDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { EnterStringFormParam *params = (EnterStringFormParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_RENAME, true)); SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_RENAME, false)); params = (EnterStringFormParam *)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)params); SetWindowText(hwndDlg, params->caption); { RECT rc; GetWindowRect(hwndDlg, &rc); switch (params->type) { case ESF_PASSWORD: params->idcControl = IDC_TXT_PASSWORD; params->height = rc.bottom - rc.top; break; case ESF_MULTILINE: params->idcControl = IDC_TXT_MULTILINE; params->height = 0; rc.bottom += (rc.bottom - rc.top) * 2; SetWindowPos(hwndDlg, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOREPOSITION); break; case ESF_COMBO: params->idcControl = IDC_TXT_COMBO; params->height = rc.bottom - rc.top; if (params->szDataPrefix && params->recentCount) ComboLoadRecentStrings(hwndDlg, params); break; case ESF_RICHEDIT: params->idcControl = IDC_TXT_RICHEDIT; SendDlgItemMessage(hwndDlg, IDC_TXT_RICHEDIT, EM_AUTOURLDETECT, TRUE, 0); SendDlgItemMessage(hwndDlg, IDC_TXT_RICHEDIT, EM_SETEVENTMASK, 0, ENM_LINK); params->height = 0; rc.bottom += (rc.bottom - rc.top) * 2; SetWindowPos(hwndDlg, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOREPOSITION); break; } } ShowWindow(GetDlgItem(hwndDlg, params->idcControl), SW_SHOW); if (params->ptszInitVal) SetDlgItemText(hwndDlg, params->idcControl, params->ptszInitVal); if (params->szDataPrefix) Utils_RestoreWindowPosition(hwndDlg, NULL, params->szModuleName, params->szDataPrefix); SetTimer(hwndDlg, 1000, 50, NULL); if (params->timeout > 0) { SetTimer(hwndDlg, 1001, 1000, NULL); TCHAR buf[128]; mir_sntprintf(buf, TranslateT("OK (%d)"), params->timeout); SetDlgItemText(hwndDlg, IDOK, buf); } return TRUE; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); break; case WM_TIMER: switch (wParam) { case 1000: KillTimer(hwndDlg, 1000); EnableWindow(GetParent(hwndDlg), TRUE); break; case 1001: TCHAR buf[128]; mir_sntprintf(buf, TranslateT("OK (%d)"), --params->timeout); SetDlgItemText(hwndDlg, IDOK, buf); if (params->timeout < 0) { KillTimer(hwndDlg, 1001); UIEmulateBtnClick(hwndDlg, IDOK); } } return TRUE; case WM_SIZE: Utils_ResizeDialog(hwndDlg, g_hInst, MAKEINTRESOURCEA(IDD_ENTER_STRING), sttEnterStringResizer); break; case WM_GETMINMAXINFO: { LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; if (params && params->height) lpmmi->ptMaxSize.y = lpmmi->ptMaxTrackSize.y = params->height; } break; case WM_NOTIFY: { ENLINK *param = (ENLINK *)lParam; if (param->nmhdr.idFrom != IDC_TXT_RICHEDIT) break; if (param->nmhdr.code != EN_LINK) break; if (param->msg != WM_LBUTTONUP) break; CHARRANGE sel; SendMessage(param->nmhdr.hwndFrom, EM_EXGETSEL, 0, (LPARAM)& sel); if (sel.cpMin != sel.cpMax) break; // allow link selection TEXTRANGE tr; tr.chrg = param->chrg; tr.lpstrText = (TCHAR *)mir_alloc(sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 2)); SendMessage(param->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr); Utils_OpenUrlT(tr.lpstrText); mir_free(tr.lpstrText); } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_TXT_MULTILINE: case IDC_TXT_RICHEDIT: if ((HIWORD(wParam) != EN_SETFOCUS) && (HIWORD(wParam) != EN_KILLFOCUS)) { SetDlgItemText(hwndDlg, IDOK, TranslateT("OK")); KillTimer(hwndDlg, 1001); } break; case IDC_TXT_COMBO: if ((HIWORD(wParam) != CBN_SETFOCUS) && (HIWORD(wParam) != CBN_KILLFOCUS)) { SetDlgItemText(hwndDlg, IDOK, TranslateT("OK")); KillTimer(hwndDlg, 1001); } break; case IDCANCEL: if (params->szDataPrefix) Utils_SaveWindowPosition(hwndDlg, NULL, params->szModuleName, params->szDataPrefix); EndDialog(hwndDlg, 0); break; case IDOK: HWND hWnd = GetDlgItem(hwndDlg, params->idcControl); int len = GetWindowTextLength(hWnd)+1; params->ptszResult = (LPTSTR)mir_alloc(sizeof(TCHAR)*len); GetWindowText(hWnd, params->ptszResult, len); if ((params->type == ESF_COMBO) && params->szDataPrefix && params->recentCount) ComboAddRecentString(hwndDlg, params); if (params->szDataPrefix) Utils_SaveWindowPosition(hwndDlg, NULL, params->szModuleName, params->szDataPrefix); EndDialog(hwndDlg, 1); 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; }
void CVkWallPostForm::OnDestroy() { Window_FreeIcon_IcoLib(m_hwnd); }
void OnDestroy() { Window_FreeIcon_IcoLib(m_hwnd); }
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; }
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; }
//======================================================= //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 DlgProcSetStatusMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SendDlgItemMessage(hwndDlg, IDC_STATUSMESSAGE, EM_LIMITTEXT, MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE - 1, 0); mir_subclassWindow(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), StatusMsgEditSubclassProc); return TRUE; case WMU_SETDATA: { SetStatusMessageData *data = (SetStatusMessageData *)malloc(sizeof(SetStatusMessageData)); data->status = (int)wParam; data->proto_num = (int)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)data); if (data->proto_num >= 0) { Protocol *proto = protocols->Get(data->proto_num); HICON hIcon = (HICON)CallProtoService(proto->name, PS_LOADICON, PLI_PROTOCOL, 0); if (hIcon != NULL) { SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); DestroyIcon(hIcon); } TCHAR title[256]; mir_sntprintf(title, TranslateT("Set my status message for %s"), proto->description); SetWindowText(hwndDlg, title); SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, proto->GetStatusMsg()); } else if (data->status != 0) { Window_SetProtoIcon_IcoLib(hwndDlg, NULL, data->status); TCHAR title[256]; mir_sntprintf(title, TranslateT("Set my status message for %s"), pcli->pfnGetStatusModeDescription(data->status, 0)); SetWindowText(hwndDlg, title); SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, protocols->GetDefaultStatusMsg(data->status)); } else { Window_SetSkinIcon_IcoLib(hwndDlg, SKINICON_OTHER_MIRANDA); SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, protocols->GetDefaultStatusMsg()); } } return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: { TCHAR tmp[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE]; GetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, tmp, _countof(tmp)); SetStatusMessageData *data = (SetStatusMessageData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (data->proto_num >= 0) protocols->Get(data->proto_num)->SetStatusMsg(tmp); else if (data->status == 0) protocols->SetStatusMsgs(tmp); else protocols->SetStatusMsgs(data->status, tmp); DestroyWindow(hwndDlg); } break; case IDCANCEL: DestroyWindow(hwndDlg); break; } break; case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), GWLP_WNDPROC, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), GWLP_USERDATA)); free((SetStatusMessageData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); Window_FreeIcon_IcoLib(hwndDlg); InterlockedExchange(&status_msg_dialog_open, 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; }
INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { FileDlgData *dat = (FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { struct FileSendData *fsd = (struct FileSendData*)lParam; dat = (FileDlgData*)mir_calloc(sizeof(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(); EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0); mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MSG), SendEditSubclassProc); Window_SetSkinIcon_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); } TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_TO, contactName); ptrT id(Contact_GetInfo(CNF_UNIQUEID, dat->hContact)); SetDlgItemText(hwndDlg, IDC_NAME, (id) ? id : 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 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 M_FILECHOOSEDONE: if (lParam != 0) { FilenameToFileList(hwndDlg, dat, (TCHAR*)lParam); mir_free((TCHAR*)lParam); dat->closeIfFileChooseCancelled = 0; } else if (dat->closeIfFileChooseCancelled) PostMessage(hwndDlg, WM_COMMAND, IDCANCEL, 0); 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); mir_forkthread(ChooseFilesThread, hwndDlg); break; case IDOK: NotifyEventHooks(hDlgSucceeded, dat->hContact, (LPARAM)hwndDlg); EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSE), FALSE); GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, _countof(dat->szSavePath)); GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, _countof(dat->szFilenames)); GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, _countof(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); DestroyWindow(hwndDlg); return TRUE; case IDCANCEL: NotifyEventHooks(hDlgCanceled, dat->hContact, (LPARAM)hwndDlg); DestroyWindow(hwndDlg); return TRUE; case IDC_USERMENU: { RECT rc; GetWindowRect((HWND)lParam, &rc); HMENU hMenu = Menu_BuildContactMenu(dat->hContact); 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); FreeFileDlgData(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); return TRUE; } return FALSE; }
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; }
void CVkCaptchaForm::OnDestroy() { Window_FreeIcon_IcoLib(m_hwnd); }
static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { SetAwayMsgData* dat = (SetAwayMsgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (message) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { SetAwasMsgNewData *newdat = (SetAwasMsgNewData*)lParam; dat = (SetAwayMsgData*)mir_alloc(sizeof(SetAwayMsgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->statusMode = newdat->statusMode; dat->szProto = newdat->szProto; mir_free(newdat); SendDlgItemMessage(hwndDlg, IDC_MSG, EM_LIMITTEXT, 1024, 0); mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MSG), MessageEditSubclassProc); { TCHAR str[256], format[128]; GetWindowText(hwndDlg, format, SIZEOF(format)); mir_sntprintf(str, SIZEOF(str), format, pcli->pfnGetStatusModeDescription(dat->statusMode, 0)); SetWindowText(hwndDlg, str); } GetDlgItemText(hwndDlg, IDOK, dat->okButtonFormat, SIZEOF(dat->okButtonFormat)); { TCHAR *msg = GetAwayMessage(dat->statusMode, dat->szProto); SetDlgItemText(hwndDlg, IDC_MSG, msg); mir_free(msg); } dat->countdown = 6; SendMessage(hwndDlg, WM_TIMER, 0, 0); Window_SetProtoIcon_IcoLib(hwndDlg, dat->szProto, dat->statusMode); Utils_RestoreWindowPosition(hwndDlg, NULL, "SRAway", "AwayMsgDlg"); SetTimer(hwndDlg, 1, 1000, 0); dat->hPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, DM_SRAWAY_SHUTDOWN); } return TRUE; case WM_TIMER: if (--dat->countdown >= 0) { TCHAR str[64]; mir_sntprintf(str, SIZEOF(str), dat->okButtonFormat, dat->countdown); SetDlgItemText(hwndDlg, IDOK, str); } else { KillTimer(hwndDlg, 1); PostMessage(hwndDlg, WM_CLOSE, 0, 0); } break; case WM_CLOSE: { TCHAR *msg = GetAwayMessage(dat->statusMode, dat->szProto); ChangeAllProtoMessages(dat->szProto, dat->statusMode, msg); mir_free(msg); } DestroyWindow(hwndDlg); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: if (dat->countdown < 0) { TCHAR str[1024]; GetDlgItemText(hwndDlg, IDC_MSG, str, SIZEOF(str)); ChangeAllProtoMessages(dat->szProto, dat->statusMode, str); db_set_ts(NULL, "SRAway", StatusModeToDbSetting(dat->statusMode, "Msg"), str); DestroyWindow(hwndDlg); } else PostMessage(hwndDlg, WM_CLOSE, 0, 0); break; case IDC_MSG: if (dat->countdown >= 0) { KillTimer(hwndDlg, 1); SetDlgItemText(hwndDlg, IDOK, TranslateT("OK")); dat->countdown = -1; } break; } break; case DM_SRAWAY_SHUTDOWN: DestroyWindow(hwndDlg); break; case WM_DESTROY: Utils_SaveWindowPosition(hwndDlg, NULL, "SRAway", "AwayMsgDlg"); KillTimer(hwndDlg, 1); UnhookEvent(dat->hPreshutdown); Window_FreeIcon_IcoLib(hwndDlg); mir_free(dat); hwndStatusMsg = NULL; break; } return FALSE; }
static INT_PTR CALLBACK sttChangePassword(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { DlgChangePassParam *param = (DlgChangePassParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); TCHAR buf[100]; switch (uMsg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SendDlgItemMessage(hwndDlg, IDC_HEADERBAR, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(iconList[0].hIcolib, true)); param = (DlgChangePassParam*)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); oldLangID = 0; SetTimer(hwndDlg, 1, 200, NULL); LanguageChanged(hwndDlg); return TRUE; case WM_CTLCOLORSTATIC: if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_LANG)) { SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT)); SetBkMode((HDC)wParam, TRANSPARENT); return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT); } return FALSE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); break; case IDREMOVE: if (!CheckOldPassword(hwndDlg, param->db)) { LBL_Error: SendDlgItemMessage(hwndDlg, IDC_HEADERBAR, WM_NCPAINT, 0, 0); SetDlgItemTextA(hwndDlg, IDC_USERPASS1, ""); SetDlgItemTextA(hwndDlg, IDC_USERPASS2, ""); } else { param->db->WriteSignature(dbSignatureU); param->db->SetPassword(NULL); param->db->StoreKey(); EndDialog(hwndDlg, IDREMOVE); } break; case IDOK: TCHAR buf2[100]; GetDlgItemText(hwndDlg, IDC_USERPASS1, buf2, _countof(buf2)); if (mir_tstrlen(buf2) < 3) { SetDlgItemText(hwndDlg, IDC_HEADERBAR, TranslateT("Password is too short!")); goto LBL_Error; } GetDlgItemText(hwndDlg, IDC_USERPASS2, buf, _countof(buf)); if (mir_tstrcmp(buf2, buf)) { SetDlgItemText(hwndDlg, IDC_HEADERBAR, TranslateT("Passwords do not match!")); goto LBL_Error; } if (!CheckOldPassword(hwndDlg, param->db)) goto LBL_Error; param->db->WriteSignature(dbSignatureE); param->db->SetPassword(buf2); param->db->StoreKey(); SecureZeroMemory(buf2, sizeof(buf2)); EndDialog(hwndDlg, IDOK); } break; case WM_TIMER: LanguageChanged(hwndDlg); return FALSE; case WM_DESTROY: KillTimer(hwndDlg, 1); Window_FreeIcon_IcoLib(hwndDlg); } 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; }
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 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 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 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 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; }
static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { AwayMsgDlgData *dat = (AwayMsgDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch(message) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = (HANDLE)lParam; dat->hAwayMsgEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_AWAYMSG); dat->hSeq = (HANDLE)CallContactService(dat->hContact, PSS_GETAWAYMSG, 0, 0); WindowList_Add(hWindowList, hwndDlg, dat->hContact); { TCHAR str[256], format[128]; TCHAR* contactName = cli.pfnGetContactDisplayName(dat->hContact, 0); char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); WORD dwStatus = DBGetContactSettingWord(dat->hContact, szProto, "Status", ID_STATUS_OFFLINE); TCHAR* status = cli.pfnGetStatusModeDescription(dwStatus, 0); GetWindowText(hwndDlg, format, SIZEOF(format)); mir_sntprintf(str, SIZEOF(str), format, status, contactName); SetWindowText(hwndDlg, str); GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, SIZEOF(format)); mir_sntprintf(str, SIZEOF(str), format, status); SetDlgItemText(hwndDlg, IDC_RETRIEVING, str); Window_SetProtoIcon_IcoLib(hwndDlg, szProto, dwStatus); } if (dat->hSeq == NULL) { ACKDATA ack = {0}; ack.cbSize = sizeof(ack); ack.hContact = dat->hContact; ack.type = ACKTYPE_AWAYMSG; ack.result = ACKRESULT_SUCCESS; SendMessage(hwndDlg, HM_AWAYMSG, 0, (LPARAM)&ack); } Utils_RestoreWindowPosition(hwndDlg, (HANDLE)lParam, "SRAway", "AwayMsgDlg"); return TRUE; case HM_AWAYMSG: { ACKDATA *ack = (ACKDATA*)lParam; if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) break; if (ack->result != ACKRESULT_SUCCESS) break; if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; } #ifdef _UNICODE DBVARIANT dbv; bool unicode = !DBGetContactSetting(dat->hContact, "CList", "StatusMsg", &dbv) && (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR); DBFreeVariant(&dbv); if (unicode) { DBGetContactSettingWString(dat->hContact, "CList", "StatusMsg", &dbv); SetDlgItemText(hwndDlg, IDC_MSG, dbv.pwszVal); } else #endif SetDlgItemTextA(hwndDlg, IDC_MSG, (const char*)ack->lParam); ShowWindow(GetDlgItem(hwndDlg,IDC_RETRIEVING), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg,IDC_MSG), SW_SHOW); SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close")); break; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: case IDOK: DestroyWindow(hwndDlg); break; } break; case WM_CLOSE: DestroyWindow(hwndDlg); break; case WM_DESTROY: if (dat->hAwayMsgEvent) UnhookEvent(dat->hAwayMsgEvent); Utils_SaveWindowPosition(hwndDlg,dat->hContact,"SRAway","AwayMsgDlg"); WindowList_Remove(hWindowList,hwndDlg); Window_FreeIcon_IcoLib(hwndDlg); mir_free(dat); break; } return FALSE; }