📄 chabout.cpp
字号:
BEGIN_MESSAGE_MAP( ChAbout, CPropertySheet )
//{{AFX_MSG_MAP(ChAbout)
ON_COMMAND(ID_HELP, OnHelp)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
int ChAbout::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
// Remove the Apply button fro the sheet
GetDlgItem( ID_APPLY_NOW )->ShowWindow( SW_HIDE );
GetDlgItem( IDCANCEL )->ShowWindow( SW_HIDE );
GetDlgItem( ID_HELP )->ShowWindow( SW_HIDE );
// Reposition the OK, Cancel and Help buttons
CRect rtFrame, rtBtn;
GetWindowRect( &rtFrame );
GetDlgItem( IDOK )->GetWindowRect( &rtBtn );
int xPos = (rtFrame.Width() - (rtBtn.Width() ))/2;
CPoint ptPos( xPos, rtBtn.top );
ScreenToClient( &ptPos );
ptPos.x = xPos;
GetDlgItem( IDOK )->SetWindowPos( 0, ptPos.x, ptPos.y, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE );
return 0;
}
/*----------------------------------------------------------------------------
ChAbout property sheet methods
----------------------------------------------------------------------------*/
void ChAbout::Construct()
{
AddPage( &puebloPage );
AddPage( &teamPage );
}
/*----------------------------------------------------------------------------
ChAbout message maps
----------------------------------------------------------------------------*/
void ChAbout::OnHelp()
{ /* This method gets the help
button press and passes it on
to the currently active
page to process */
WinHelp( 0x20000 + IDD_ABOUT_BOX );
}
/*----------------------------------------------------------------------------
ChPuebloAbout property page class
----------------------------------------------------------------------------*/
IMPLEMENT_DYNCREATE( ChPuebloAbout, CPropertyPage )
ChPuebloAbout::ChPuebloAbout() :
CPropertyPage( ChPuebloAbout::IDD )
{
//{{AFX_DATA_INIT(ChPuebloAbout)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
ChPuebloAbout::~ChPuebloAbout()
{
}
void ChPuebloAbout::DoDataExchange( CDataExchange* pDX )
{
CPropertyPage::DoDataExchange( pDX );
//{{AFX_DATA_MAP(ChPuebloAbout)
DDX_Control(pDX, IDC_STATIC_VERSION, m_staticVersion);
DDX_Control(pDX, IDC_PROD_NAME, m_staticProductName);
DDX_Control(pDX, IDC_LEGEND, m_staticLegend);
DDX_Control(pDX, IDC_COPYRIGHT, m_staticCopyright);
DDX_Control(pDX, IDC_CLAUSE, m_staticClause);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP( ChPuebloAbout, CPropertyPage )
//{{AFX_MSG_MAP(ChPuebloAbout)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*----------------------------------------------------------------------------
ChPuebloAbout message handlers
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
ChPuebloAbout message handlers
----------------------------------------------------------------------------*/
bool ChPuebloAbout::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// initialize the Chaco logo
m_logoBmp.SubclassDlgItem( IDC_CHACO_LOGO, this );
m_logoBmp.SizeToContent( ChLogoBitmap::left | ChLogoBitmap::vcenter );
{ /* Set fonts for static fields in
the page to make it more
attractive */
HDC hDC = ::GetDC( m_hWnd );
LOGFONT lf;
int iPixelSize = ::GetDeviceCaps( hDC, LOGPIXELSY );
CFont font;
::ReleaseDC( m_hWnd, hDC );
// Clear the font structure
ChMemClearStruct( &lf );
lf.lfHeight = -1 * (iPixelSize * 14 / 72);
lf.lfWeight = FW_BOLD;
lf.lfCharSet = ANSI_CHARSET;
lf.lfOutPrecision = OUT_STROKE_PRECIS;
lf.lfClipPrecision = CLIP_STROKE_PRECIS;
lf.lfQuality = DEFAULT_QUALITY;
lf.lfPitchAndFamily = FF_DONTCARE;
lstrcpy( lf.lfFaceName, "Arial" );
font.CreateFontIndirect( &lf );
m_staticProductName.SendMessage( WM_SETFONT,
(WPARAM)font.GetSafeHandle() );
font.Detach();
lf.lfHeight = -1 * (iPixelSize * 8 / 72);
lf.lfWeight = FW_NORMAL;
font.CreateFontIndirect( &lf );
m_staticVersion.SendMessage( WM_SETFONT,
(WPARAM)font.GetSafeHandle() );
font.Detach();
lf.lfHeight = -1 * (iPixelSize * 9 / 72);
lf.lfWeight = FW_BOLD;
font.CreateFontIndirect( &lf );
m_staticCopyright.SendMessage( WM_SETFONT,
(WPARAM)font.GetSafeHandle() );
font.Detach();
lf.lfHeight = -1 * (iPixelSize * 8 / 72);
lf.lfWeight = FW_BOLD;
font.CreateFontIndirect( &lf );
m_staticLegend.SendMessage( WM_SETFONT,
(WPARAM)font.GetSafeHandle() );
m_staticClause.SendMessage( WM_SETFONT,
(WPARAM)font.GetSafeHandle() );
font.Detach();
lf.lfHeight = -1 * (iPixelSize * 6 / 72);
lf.lfWeight = FW_MEDIUM;
font.CreateFontIndirect( &lf );
m_staticClause.SendMessage( WM_SETFONT,
(WPARAM)font.GetSafeHandle() );
font.Detach();
}
//m_staticVersion.SetWindowText( strVerNum );
return true; // return true unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
bool ChPuebloAbout::OnSetActive()
{
bool boolSuccess;
boolSuccess = CPropertyPage::OnSetActive();
return boolSuccess;
}
/*----------------------------------------------------------------------------
ChTeamAbout property sheet class
----------------------------------------------------------------------------*/
int ChTeamAbout::iTeamNames[namesCount] = { IDS_TEAM_GLENN,
IDS_TEAM_PRITHAM,
IDS_TEAM_RON,
IDS_TEAM_JIM,
IDS_TEAM_DAN };
IMPLEMENT_DYNCREATE( ChTeamAbout, CPropertyPage )
ChTeamAbout::ChTeamAbout() : CPropertyPage( ChTeamAbout::IDD )
{
//{{AFX_DATA_INIT(ChTeamAbout)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
ChTeamAbout::~ChTeamAbout()
{
}
void ChTeamAbout::DoDataExchange( CDataExchange* pDX )
{
CPropertyPage::DoDataExchange( pDX );
//{{AFX_DATA_MAP(ChTeamAbout)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP( ChTeamAbout, CPropertyPage )
//{{AFX_MSG_MAP(ChTeamAbout)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*----------------------------------------------------------------------------
ChTeamAbout protected methods
----------------------------------------------------------------------------*/
void ChTeamAbout::RandomizeNames()
{
int iLoop;
/* Initialize the random number
generator with the current
time */
srand( (unsigned int)time( 0 ) );
for (iLoop = 0; iLoop < 30; iLoop++)
{
int iFirst = GetRandomInt( namesCount - 1 );
int iSecond = GetRandomInt( namesCount - 1 );
if (iFirst != iSecond)
{
int iTemp;
// Swap the two
iTemp = iTeamNames[iFirst];
iTeamNames[iFirst] = iTeamNames[iSecond];
iTeamNames[iSecond] = iTemp;
}
}
}
int ChTeamAbout::GetRandomInt( int iMax )
{ /* Generates a random int between
zero and iMax, inclusive */
int iResult;
double dRan = (double)rand();
double fVal = dRan / (double)RAND_MAX;
iResult = (int)((fVal * (double)iMax) + 0.5);
ASSERT( iResult >= 0 && iResult <= iMax );
return iResult;
}
void ChTeamAbout::SetNames()
{
static int iFields[namesCount] = { IDC_NAME_1, IDC_NAME_2, IDC_NAME_3,
IDC_NAME_4, IDC_NAME_5 };
int iLoop;
for (iLoop = 0; iLoop < namesCount; iLoop++)
{
CStatic* pStatic;
if (pStatic = (CStatic*)GetDlgItem( iFields[iLoop] ))
{
string strName;
ChWebTrackerManager::WTrackerLoadString( iTeamNames[iLoop], strName );
pStatic->SetWindowText( strName );
}
}
}
/*----------------------------------------------------------------------------
ChTeamAbout message handlers
----------------------------------------------------------------------------*/
BOOL ChTeamAbout::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// initialize the Chaco logo
m_logoBmp.SubclassDlgItem( IDC_CHACO_LOGO, this );
m_logoBmp.SizeToContent( ChLogoBitmap::left | ChLogoBitmap::vcenter );
RandomizeNames();
SetNames();
return true; /* Return TRUE unless you set the
focus to a control */
}
bool ChTeamAbout::OnSetActive()
{
bool boolSuccess;
boolSuccess = CPropertyPage::OnSetActive();
return boolSuccess;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -