?? accountauthority.cpp
字號:
// AccountAuthority.cpp : implementation file
//
#include "stdafx.h"
#include "rmtool.h"
#include "math.h"
#include "AccountAuthority.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAccountAuthority dialog
CAccountAuthority cAuthority;
CAccountAuthority::CAccountAuthority(CWnd* pParent /*=NULL*/)
: CDialog(CAccountAuthority::IDD, pParent)
{
m_dwAuthority=0;
//{{AFX_DATA_INIT(CAccountAuthority)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CAccountAuthority::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAccountAuthority)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
UINT uID=IDC_MASK1; //IDC_MASK1何磐 IDC_MASK_ADMIN鱉瘤 搗促.
for(int i=0; i<31 ; i++)
{
DDX_Control( pDX, uID, c_Mask[i] );
uID++;
//CString szTest;
//szTest.Format( "%d", uID);
//AfxMessageBox( szTest );
}
}
BEGIN_MESSAGE_MAP(CAccountAuthority, CDialog)
//{{AFX_MSG_MAP(CAccountAuthority)
ON_BN_CLICKED(IDOK, OnOk)
ON_BN_CLICKED(IDC_GET_AUTHORITY, OnGetAuthority)
ON_BN_CLICKED(IDC_MASK_ADMIN, OnMaskAdmin)
ON_BN_CLICKED(IDC_MASK_CLEAR, OnMaskClear)
ON_BN_CLICKED(IDC_CALCULALT, OnCalculalt)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAccountAuthority message handlers
void CAccountAuthority::AllAuthorityCheck(bool bAllCheck)
{
for( int i=0; i < NUM_MASK_TYPE; i++)
{
c_Mask[i].SetCheck( bAllCheck );
}
}
int CAccountAuthority::SetAuthorityValue()
{
UpdateData( FALSE );
int iAuthority = 0;
for( int i=0; i < NUM_MASK_TYPE-1; i++)
{
if( c_Mask[i].GetCheck() )
{
iAuthority += (int)pow( 2, i );
//CString szTest;
//szTest.Format( "%d", m_dwAuthority);
//szTest.Format( "%d", i);
//AfxMessageBox( szTest );
}
}
return iAuthority;
}
void CAccountAuthority::OnOk()
{
// TODO: Add your control notification handler code here
UpdateData(FALSE); //泅犁 靜咯柳 藹撈 拌瀝藹撈促.
m_dwAuthority = SetAuthorityValue();
//磊腳狼 鼻茄闌 瘤瀝秦林綽 傈開竊薦
#ifdef __KOYANGHI__
SetUserAuthority( m_dwAuthority );
#endif
//int zz = c_Mask[30].GetCheck();
//CString szTest;
//szTest.Format( "%d", m_dwAuthority);
//AfxMessageBox( szTest );
CDialog::OnOK();
}
void CAccountAuthority::OnGetAuthority()
{
// TODO: Add your control notification handler code here
int iAuthority = GetUserAuthority(1);
CString szAuthority;
szAuthority.Format( "%d", iAuthority);
AfxMessageBox( szAuthority);
}
BOOL CAccountAuthority::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//NUM_MASK_TYPE-1 籃 MASK_ADMINISTRATOR狼 鍋齲撈促.
//郴 鼻茄闌 箭磊肺 焊咯林絆
CString szAuthority;
int iCkMask = GetUserAuthority( 1 ); // 021016 check
szAuthority.Format( "%d", iCkMask );
GetDlgItem( IDC_AUTHORITY_VALUE )->SetWindowText( szAuthority );
//check滾瓢俊 犬牢矯難霖促.
for( int i = 0 ; i < NUM_MASK_TYPE-1 ; i++)
{
int iMask = (int)pow( 2, i);
if( (iCkMask & iMask) == iMask )
c_Mask[i].SetCheck( TRUE );
}
//MASK_ADMINISTRATOR check甫 困秦
for( i=0;i< NUM_MASK_TYPE-1; i++)
{
if( !c_Mask[i].GetCheck() )
return TRUE;
}
c_Mask[ NUM_MASK_TYPE-1 ].SetCheck(TRUE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAccountAuthority::OnMaskAdmin()
{
// TODO: Add your control notification handler code here
if( c_Mask[ NUM_MASK_TYPE-1 ].GetCheck() )
AllAuthorityCheck( TRUE );
else
AllAuthorityCheck( FALSE );
}
void CAccountAuthority::OnMaskClear()
{
// TODO: Add your control notification handler code here
AllAuthorityCheck( FALSE );
SetCalculate( 0 );
}
void CAccountAuthority::OnCalculalt()
{
// TODO: Add your control notification handler code here
SetCalculate( 0 );
SetCalculate( SetAuthorityValue() );
}
void CAccountAuthority::SetCalculate( const int iCalcul )
{ //甸絹柯 藹欄肺 IDC_AUTHORITY_VALUE甫 技潑茄促.
CString szTmp;
szTmp.Format( "%d", iCalcul );
GetDlgItem( IDC_AUTHORITY_VALUE )->SetWindowText( szTmp );
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -