mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
display free and total disk space
svn path=/trunk/; revision=15265
This commit is contained in:
parent
3feb9db02b
commit
6f61a478e8
4 changed files with 45 additions and 4 deletions
|
@ -207,4 +207,6 @@ STRINGTABLE
|
|||
IDS_COL_LINKS "Links"
|
||||
IDS_COL_ATTR "Attribute"
|
||||
IDS_COL_SEC "Sicherheit"
|
||||
|
||||
IDS_FREE_SPACE_FMT "%s von %s frei"
|
||||
}
|
||||
|
|
|
@ -210,4 +210,6 @@ STRINGTABLE
|
|||
IDS_COL_LINKS "Links"
|
||||
IDS_COL_ATTR "Attributes"
|
||||
IDS_COL_SEC "Security"
|
||||
|
||||
IDS_FREE_SPACE_FMT "%s of %s free"
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@
|
|||
#define IDS_COL_LINKS 1216
|
||||
#define IDS_COL_ATTR 1217
|
||||
#define IDS_COL_SEC 1218
|
||||
#define IDS_FREE_SPACE_FMT 1219
|
||||
|
||||
|
||||
/* range for drive bar command ids: 0x9000..0x90FF */
|
||||
|
|
|
@ -2446,6 +2446,40 @@ static int insert_entries(Pane* pane, Entry* dir, int idx)
|
|||
}
|
||||
|
||||
|
||||
static void format_bytes(LPTSTR buffer, LONGLONG bytes)
|
||||
{
|
||||
const static TCHAR sFmtGB[] = {'%', '.', '1', 'f', ' ', 'G', 'B', '\0'};
|
||||
const static TCHAR sFmtMB[] = {'%', '.', '1', 'f', ' ', 'M', 'B', '\0'};
|
||||
const static TCHAR sFmtkB[] = {'%', '.', '1', 'f', ' ', 'k', 'B', '\0'};
|
||||
|
||||
float fBytes = (float)bytes;
|
||||
|
||||
if (bytes >= 1073741824) // 1 GB
|
||||
_stprintf(buffer, sFmtGB, fBytes/1073741824.f+.5f);
|
||||
else if (bytes >= 1048576) // 1 MB
|
||||
_stprintf(buffer, sFmtMB, fBytes/1048576.f+.5f);
|
||||
else if (bytes >= 1024) // 1 kB
|
||||
_stprintf(buffer, sFmtMB, fBytes/1024.f+.5f);
|
||||
else
|
||||
_stprintf(buffer, sLongNumFmt, bytes);
|
||||
}
|
||||
|
||||
static void set_space_status()
|
||||
{
|
||||
ULARGE_INTEGER ulFreeBytesToCaller, ulTotalBytes, ulFreeBytes;
|
||||
TCHAR fmt[64], b1[64], b2[64], buffer[BUFFER_LEN];
|
||||
|
||||
if (GetDiskFreeSpaceEx(NULL, &ulFreeBytesToCaller, &ulTotalBytes, &ulFreeBytes)) {
|
||||
format_bytes(b1, ulFreeBytesToCaller.QuadPart);
|
||||
format_bytes(b2, ulTotalBytes.QuadPart);
|
||||
_stprintf(buffer, RS(fmt,IDS_FREE_SPACE_FMT), b1, b2);
|
||||
} else
|
||||
_tcscpy(buffer, sQMarks);
|
||||
|
||||
SendMessage(Globals.hstatusbar, SB_SETTEXT, 0, (LPARAM)buffer);
|
||||
}
|
||||
|
||||
|
||||
static WNDPROC g_orgTreeWndProc;
|
||||
|
||||
static void create_tree_window(HWND parent, Pane* pane, int id, int id_header)
|
||||
|
@ -2755,13 +2789,13 @@ static void draw_item(Pane* pane, LPDRAWITEMSTRUCT dis, Entry* entry, int calcWi
|
|||
#endif
|
||||
)
|
||||
LineTo(dis->hDC, x, dis->rcItem.bottom);
|
||||
|
||||
/*@@
|
||||
if (entry->down && entry->expanded) {
|
||||
x += IMAGE_WIDTH+TREE_LINE_DX;
|
||||
MoveToEx(dis->hDC, x, dis->rcItem.top+IMAGE_HEIGHT, 0);
|
||||
LineTo(dis->hDC, x, dis->rcItem.bottom);
|
||||
}
|
||||
|
||||
*/
|
||||
SelectClipRgn(dis->hDC, hrgn_org);
|
||||
if (hrgn_org) DeleteObject(hrgn_org);
|
||||
/* SelectObject(dis->hDC, holdPen); */
|
||||
|
@ -3299,7 +3333,8 @@ static void set_curdir(ChildWnd* child, Entry* entry, HWND hwnd)
|
|||
SetWindowText(child->hwnd, path);
|
||||
|
||||
if (path[0])
|
||||
SetCurrentDirectory(path);
|
||||
if (SetCurrentDirectory(path))
|
||||
set_space_status();
|
||||
}
|
||||
|
||||
|
||||
|
@ -3728,7 +3763,8 @@ LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam
|
|||
#endif /* _NO_EXTENSIONS */
|
||||
|
||||
case WM_SETFOCUS:
|
||||
SetCurrentDirectory(child->path);
|
||||
if (SetCurrentDirectory(child->path))
|
||||
set_space_status();
|
||||
SetFocus(child->focus_pane? child->right.hwnd: child->left.hwnd);
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue