9d7d3199670e9c4329491fdaf922161e542c1616
[openafs.git] / src / WINNT / client_exp / partition_info_dlg.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include "stdafx.h"
11 #include <winsock2.h>
12 #include <ws2tcpip.h>
13
14 extern "C" {
15 #include <afs/param.h>
16 #include <afs/stds.h>
17 }
18
19 #include "afs_shl_ext.h"
20 #include "partition_info_dlg.h"
21
22 #ifdef _DEBUG
23 #define new DEBUG_NEW
24 #undef THIS_FILE
25 static char THIS_FILE[] = __FILE__;
26 #endif
27
28 /////////////////////////////////////////////////////////////////////////////
29 // CPartitionInfoDlg dialog
30
31
32 CPartitionInfoDlg::CPartitionInfoDlg(CWnd* pParent /*=NULL*/)
33         : CDialog()
34 {
35         InitModalIndirect (TaLocale_GetDialogResource (CPartitionInfoDlg::IDD), pParent);
36
37         //{{AFX_DATA_INIT(CPartitionInfoDlg)
38                 // NOTE: the ClassWizard will add member initialization here
39         //}}AFX_DATA_INIT
40         m_nSize = 0;
41         m_nFree = 0;
42 }
43
44 void CPartitionInfoDlg::DoDataExchange(CDataExchange* pDX)
45 {
46         CDialog::DoDataExchange(pDX);
47         //{{AFX_DATA_MAP(CPartitionInfoDlg)
48         DDX_Control(pDX, IDC_TOTAL_SIZE, m_Size);
49         DDX_Control(pDX, IDC_PERCENT_USED, m_PercentUsed);
50         DDX_Control(pDX, IDC_BLOCKS_FREE, m_Free);
51         //}}AFX_DATA_MAP
52 }
53
54 BEGIN_MESSAGE_MAP(CPartitionInfoDlg, CDialog)
55         //{{AFX_MSG_MAP(CPartitionInfoDlg)
56         ON_BN_CLICKED(IDHELP, OnHelp)
57         //}}AFX_MSG_MAP
58 END_MESSAGE_MAP()
59
60 /////////////////////////////////////////////////////////////////////////////
61 // CPartitionInfoDlg message handlers
62
63 BOOL CPartitionInfoDlg::OnInitDialog() 
64 {
65     double percentUsed;     // because partition sizes are big
66
67         CDialog::OnInitDialog();
68         
69         ASSERT(m_nSize != 0);
70
71         CString strSize;
72         strSize.Format(_T("%ld"), m_nSize);
73         
74         CString strFree;
75         strFree.Format(_T("%ld"), m_nFree);
76         
77         CString strPerUsed;
78         strPerUsed.Format(_T("%d"), ((m_nSize - m_nFree) * 100) / m_nSize);
79
80         m_Size.SetWindowText(strSize);
81         m_Free.SetWindowText(strFree);
82     percentUsed = ( double(m_nSize - m_nFree) * 100.0l ) / double(m_nSize);
83     strPerUsed.Format(_T("%2.2lf"), percentUsed );
84
85         return TRUE;  // return TRUE unless you set the focus to a control
86                       // EXCEPTION: OCX Property Pages should return FALSE
87 }
88
89 void CPartitionInfoDlg::OnHelp() 
90 {
91         ShowHelp(m_hWnd, PARTITION_INFO_HELP_ID);
92 }
93