BOOL TSaveCommonDlg::SetInfo(void) { char buf[MAX_BUF], sizestr[MAX_LISTBUF]; Wstr fname_w(shareInfo->fileInfo[offset]->Fname()); ::SetDlgItemTextW(::GetParent(hWnd), 0x480, fname_w.Buf()); if (GET_MODE(shareInfo->fileInfo[offset]->Attr()) == IPMSG_FILE_DIR) strcpy(sizestr, GetLoadStrU8(IDS_DIRSAVE)); else MakeSizeString(sizestr, shareInfo->fileInfo[offset]->Size()); wsprintf(buf, GetLoadStrU8(IDS_FILEINFO), offset + 1, shareInfo->fileCnt, shareInfo->fileInfo[offset]->Fname(), sizestr); SetDlgItemTextU8(RESULT_STATIC, buf); _int64 total_size = 0; for (int i=0; i < shareInfo->fileCnt; i++) total_size += shareInfo->fileInfo[i]->Size(); MakeSizeString(sizestr, total_size); wsprintf(buf, GetLoadStrU8(IDS_LUMPBUTTON), sizestr, shareInfo->fileCnt); SetDlgItemTextU8(LUMP_CHECK, buf); const char *ext = strrchr(shareInfo->fileInfo[offset]->Fname(), '.'); isLinkFile = (ext && stricmp(ext, ".lnk") == 0) ? TRUE : FALSE; return TRUE; }
BOOL RecvTransEndDlg::EvCreate(LPARAM lParam) { char buf[MAX_BUF]; DWORD difftick = fileObj->lastTick - fileObj->startTick; int len = 0; len += wsprintf(buf + len, "Total: "); len += MakeSizeString(buf + len, fileObj->totalTrans); len += wsprintf(buf + len, " ("); len += MakeSizeString(buf + len, fileObj->totalTrans * 1000 / (difftick ? difftick : 1)); len += wsprintf(buf + len, "/s)\r\n%d", difftick/1000); if (difftick/1000 < 20) len += wsprintf(buf + len, ".%02d", (difftick%1000) / 10); len += wsprintf(buf + len, " sec "); if (fileObj->totalFiles > 1 || fileObj->isDir) len += wsprintf(buf + len, "%d files", fileObj->totalFiles); else len += wsprintf(buf + len, "%s", fileObj->fileInfo->Fname()); if (fileObj->status == FS_COMPLETE) { if (fileObj->totalFiles > 1 || fileObj->isDir) ::EnableWindow(GetDlgItem(EXEC_BUTTON), FALSE); } SetDlgItemTextU8(FILE_STATIC, buf); GetWindowRect(&rect); MoveWindow(rect.left + 30, rect.top + 30, rect.right - rect.left, rect.bottom - rect.top, TRUE); return TRUE; }
int MakeDirTransRateStr(char *buf, DWORD ticks, _int64 cur_size, int files) { int len = 0; buf[len++] = ' '; len += wsprintf(buf + len, "Total "); len += MakeSizeString(buf + len, cur_size); len += wsprintf(buf + len, "/%dfiles (", files); len += MakeSizeString(buf + len, cur_size * 1000 / (ticks ? ticks : 1)); return len + wsprintf(buf + len, "/s)" ); }
int MakeTransRateStr(char *buf, DWORD ticks, _int64 cur_size, _int64 total_size) { int len = 0; buf[len++] = ' '; len += MakeSizeString(buf + len, cur_size) -2; // "MB"部分を抜く buf[len++] = '/'; len += MakeSizeString(buf + len, total_size); buf[len++] = ' '; len += MakeSizeString(buf + len, cur_size * 1000 / (ticks ? ticks : 10)); return len + wsprintf(buf + len, "/s (%d%%)", (int)(cur_size * 100 / (total_size ? total_size : 1))); }
BOOL TShareStatDlg::SetAllList(void) { shareListView.DeleteAllItems(); int i=0, j=0, len=0; char buf[MAX_BUF_EX]; for (ShareInfo *info=shareMng->Top(); info; info=shareMng->Next(info)) { if (info->hostCnt == 0) continue; sprintf(buf, "%d", i); shareListView.InsertItem(i, buf); len = 0; *buf = 0; for (j=0; j < info->fileCnt && len < sizeof(buf); j++) { ForcePathToFname(info->fileInfo[j]->Fname(), buf + len); strcat(buf + len, " "); len += strlen(buf + len); if (len + MAX_PATH_U8 >= sizeof(buf)) break; } shareListView.SetSubItem(i, 1, buf); ShareCntInfo cntInfo; shareMng->GetShareCntInfo(&cntInfo, info); MakeSizeString(buf, cntInfo.totalSize, MSS_SPACE); if (cntInfo.dirCnt) wsprintf(buf + strlen(buf), "/%dDIR", cntInfo.dirCnt); shareListView.SetSubItem(i, 2, buf); shareMng->GetShareCntInfo(&cntInfo, info); wsprintf(buf, "%d / %d/ %d", cntInfo.fileCnt, cntInfo.doneCnt, cntInfo.transferCnt); shareListView.SetSubItem(i, 3, buf); len = 0; *buf = 0; for (j=0; j < info->hostCnt && len + 30 < sizeof(buf); j++) { Host *host = info->host[j]; len += _snprintf(buf + len, sizeof(buf)-len-1, "%.14s(%.10s) ", *host->nickName ? host->nickName : host->hostSub.userName, host->hostSub.hostName); } shareListView.SetSubItem(i, 4, buf); i++; } return TRUE; }
BOOL TShareDlg::AddList(int idx) { char buf[MAX_BUF_EX]; ForcePathToFname(shareInfo->fileInfo[idx]->Fname(), buf); shareListView.InsertItem(idx, buf); if (GET_MODE(shareInfo->fileInfo[idx]->Attr()) == IPMSG_FILE_DIR) strcpy(buf, "(DIR)"); else MakeSizeString(buf, shareInfo->fileInfo[idx]->Size(), MSS_SPACE); shareListView.SetSubItem(idx, 1, buf); PathToDir(shareInfo->fileInfo[idx]->Fname(), buf); shareListView.SetSubItem(idx, 2, buf); return TRUE; }