home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.funduc.com
/
2014.08.ftp.funduc.com.tar
/
ftp.funduc.com
/
fshedcode-072212.zip
/
ManipulateBitsDlg.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2010-09-13
|
4KB
|
132 lines
/////////////////////////////////////////////////////////////////////////////
// License (GPLv2+):
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "fshed.h"
#include "ManipulateBitsDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CManipulateBitsDlg dialog
CManipulateBitsDlg::CManipulateBitsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CManipulateBitsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CManipulateBitsDlg)
m_bChk1 = FALSE;
m_bChk2 = FALSE;
m_bChk3 = FALSE;
m_bChk4 = FALSE;
m_bChk5 = FALSE;
m_bChk6 = FALSE;
m_bChk7 = FALSE;
m_bChk8 = FALSE;
m_strLabel1 = _T("");
m_strLabel2 = _T("");
//}}AFX_DATA_INIT
m_nBitPos = 0;
m_chValue = 0;
}
void CManipulateBitsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CManipulateBitsDlg)
DDX_Check(pDX, IDC_CHECK1, m_bChk1);
DDX_Check(pDX, IDC_CHECK2, m_bChk2);
DDX_Check(pDX, IDC_CHECK3, m_bChk3);
DDX_Check(pDX, IDC_CHECK4, m_bChk4);
DDX_Check(pDX, IDC_CHECK5, m_bChk5);
DDX_Check(pDX, IDC_CHECK6, m_bChk6);
DDX_Check(pDX, IDC_CHECK7, m_bChk7);
DDX_Check(pDX, IDC_CHECK8, m_bChk8);
//}}AFX_DATA_MAP
if (pDX->m_bSaveAndValidate)
{
m_chValue = 0;
if (m_bChk8) m_chValue += 128;
if (m_bChk7) m_chValue += 64;
if (m_bChk6) m_chValue += 32;
if (m_bChk5) m_chValue += 16;
if (m_bChk4) m_chValue += 8;
if (m_bChk3) m_chValue += 4;
if (m_bChk2) m_chValue += 2;
if (m_bChk1) m_chValue += 1;
}
else
{
m_strLabel1.Format(IDS_LAB_MANIP_OFFSET, m_nBitPos, m_nBitPos );
m_strLabel2.Format(IDS_LAB_MANIP_SIGNED, (unsigned char) m_chValue, (signed char) m_chValue, (unsigned char) m_chValue);
}
DDX_Text(pDX, IDC_STATIC1, m_strLabel1);
DDX_Text(pDX, IDC_STATIC2, m_strLabel2);
}
BEGIN_MESSAGE_MAP(CManipulateBitsDlg, CDialog)
//{{AFX_MSG_MAP(CManipulateBitsDlg)
ON_BN_CLICKED(IDC_CHECK1, OnCheck)
ON_BN_CLICKED(IDC_CHECK2, OnCheck)
ON_BN_CLICKED(IDC_CHECK3, OnCheck)
ON_BN_CLICKED(IDC_CHECK4, OnCheck)
ON_BN_CLICKED(IDC_CHECK5, OnCheck)
ON_BN_CLICKED(IDC_CHECK6, OnCheck)
ON_BN_CLICKED(IDC_CHECK7, OnCheck)
ON_BN_CLICKED(IDC_CHECK8, OnCheck)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CManipulateBitsDlg message handlers
#define bitval(base,pos) ((base)[(pos)/8]&(1<<((pos)%8)))
BOOL CManipulateBitsDlg::OnInitDialog()
{
m_bChk1 = (bitval(&m_chValue,0) ? TRUE : FALSE);
m_bChk2 = (bitval(&m_chValue,1) ? TRUE : FALSE);
m_bChk3 = (bitval(&m_chValue,2) ? TRUE : FALSE);
m_bChk4 = (bitval(&m_chValue,3) ? TRUE : FALSE);
m_bChk5 = (bitval(&m_chValue,4) ? TRUE : FALSE);
m_bChk6 = (bitval(&m_chValue,5) ? TRUE : FALSE);
m_bChk7 = (bitval(&m_chValue,6) ? TRUE : FALSE);
m_bChk8 = (bitval(&m_chValue,7) ? TRUE : FALSE);
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CManipulateBitsDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void CManipulateBitsDlg::OnCheck()
{
UpdateData();
UpdateData(FALSE);
}