00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "vmsDialogHelper.h"
00009
00010 #ifdef _DEBUG
00011 #undef THIS_FILE
00012 static char THIS_FILE[]=__FILE__;
00013 #define new DEBUG_NEW
00014 #endif
00015
00016 vmsDialogHelper::vmsDialogHelper()
00017 {
00018
00019 }
00020
00021 vmsDialogHelper::~vmsDialogHelper()
00022 {
00023
00024 }
00025
00026 BOOL vmsDialogHelper::GetDlgBytesGroup(CDialog *pDlg, UINT nIDVal, UINT nIDDim, UINT64 *pVal)
00027 {
00028 CString str;
00029 pDlg->GetDlgItemText (nIDVal, str);
00030
00031 if (str.GetLength () == 0)
00032 {
00033 SetLastError (NOERROR);
00034 return FALSE;
00035 }
00036
00037 int iDim = ((CComboBox*) pDlg->GetDlgItem (nIDDim))->GetCurSel ();
00038
00039 if (iDim == CB_ERR)
00040 {
00041 pDlg->MessageBox (LS (L_ENTERDIM), LS (L_INPERR), MB_ICONEXCLAMATION);
00042 pDlg->GetDlgItem (nIDDim)->SetFocus ();
00043 SetLastError (ERROR_INVALID_DATA);
00044 return FALSE;
00045 }
00046
00047 double d = atof (str);
00048
00049 while (iDim--)
00050 d *= 1024;
00051
00052 *pVal = (UINT64) d;
00053
00054 return TRUE;
00055 }
00056
00057 void vmsDialogHelper::SetDlgBytesGroup(CDialog *pDlg, UINT64 uVal, UINT nIDVal, UINT nIDDim)
00058 {
00059 double d = (double)(INT64)uVal;
00060 int i = 0;
00061
00062 while (d > 9999)
00063 {
00064 d /= 1024;
00065 i++;
00066 }
00067
00068 CString str;
00069 str.Format ("%.*g", d > 999 ? 4 : 3, d);
00070
00071 pDlg->SetDlgItemText (nIDVal, str);
00072 ((CComboBox*) pDlg->GetDlgItem (nIDDim))->SetCurSel (i);
00073 }