📄 tardefs.cpp
字号:
/*============================================================================
Copyright (c) 1996
Hewlett-Packard Company
ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
Permission to use, copy, modify, distribute and/or sell this software
and/or its documentation is hereby granted without fee. User agrees
to display the above copyright notice and this license notice in all
copies of the software and any documentation of the software. User
agrees to assume all liability for the use of the software; Hewlett-Packard
makes no representations about the suitability of this software for any
purpose. It is provided "AS-IS without warranty of any kind,either express
or implied. User hereby grants a royalty-free license to any and all
derivatives based upon this software code base.
=============================================================================*/
#include "stdafx.h"
#include "browser.h"
#include "Tardefs.h"
#include "tarinc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Tardefs property page
IMPLEMENT_DYNCREATE(Tardefs, CPropertyPage)
Tardefs::Tardefs() : CPropertyPage(Tardefs::IDD)
{
//{{AFX_DATA_INIT(Tardefs)
m_db_name = _T("");
m_read_community = _T("");
m_write_community = _T("");
m_retries = 0;
m_timeout = 0;
//}}AFX_DATA_INIT
}
Tardefs::~Tardefs()
{
}
void Tardefs::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Tardefs)
DDX_Text(pDX, IDC_TARGET_DB_NAME, m_db_name);
DDV_MaxChars(pDX, m_db_name, 40);
DDX_Text(pDX, IDC_READ_COMMUNITY, m_read_community);
DDV_MaxChars(pDX, m_read_community, 80);
DDX_Text(pDX, IDC_WRITE_COMMUNITY, m_write_community);
DDV_MaxChars(pDX, m_write_community, 80);
DDX_Text(pDX, IDC_RETRIES, m_retries);
DDX_Text(pDX, IDC_TIMEOUT, m_timeout);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Tardefs, CPropertyPage)
//{{AFX_MSG_MAP(Tardefs)
ON_BN_CLICKED(IDSAVE, OnSave)
ON_WM_HSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Tardefs message handlers
BOOL Tardefs::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
// look in registery for info
// if not found, assume defaults
CString temp;
// get the defaults
m_db_name = theApp.GetProfileString( BROWSER_VALUE,DB_NAME,DEF_DB_NAME);
m_read_community = theApp.GetProfileString( BROWSER_VALUE,READ_COMMUNITY,PUBLIC);
m_write_community = theApp.GetProfileString( BROWSER_VALUE,WRITE_COMMUNITY,PUBLIC);
m_timeout = theApp.GetProfileInt( BROWSER_VALUE,TIMEOUT,DEF_TIMEOUT);
m_retries = theApp.GetProfileInt( BROWSER_VALUE,RETRIES,DEF_RETRIES);
temp = theApp.GetProfileString( BROWSER_VALUE,PROTOCOL,IP);
if ( strcmp( temp,IP) == 0)
CheckRadioButton( IDC_RADIO_IP,IDC_RADIO_IPX,IDC_RADIO_IP);
else
CheckRadioButton( IDC_RADIO_IP,IDC_RADIO_IPX,IDC_RADIO_IPX);
temp = theApp.GetProfileString( BROWSER_VALUE,SNMPTYPE,V1);
if ( strcmp( temp,V1) == 0)
CheckRadioButton( IDC_RADIO_V1,IDC_RADIO_V2C,IDC_RADIO_V1);
else
CheckRadioButton( IDC_RADIO_V1,IDC_RADIO_V2C,IDC_RADIO_V2C);
// set up the slider controls
CSliderCtrl *slider;
slider = (CSliderCtrl *) GetDlgItem( IDC_SLIDER_TIMEOUT);
slider->SetRange(50,500);
slider->SetPos( m_timeout);
slider = (CSliderCtrl *) GetDlgItem( IDC_SLIDER_RETRIES);
slider->SetRange(0,5);
slider->SetPos( m_retries);
UpdateData( FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void Tardefs::OnSave()
{
// TODO: Add your control notification handler code here
// write the default settings out
UpdateData( TRUE);
// v2c not allowed in this version
if ( GetCheckedRadioButton( IDC_RADIO_V1, IDC_RADIO_V2C) == IDC_RADIO_V2C)
{
AfxMessageBox("V2c Not Supported in this version!");
return;
}
theApp.WriteProfileString( BROWSER_VALUE,DB_NAME,m_db_name);
theApp.WriteProfileString( BROWSER_VALUE,READ_COMMUNITY,m_read_community);
theApp.WriteProfileString( BROWSER_VALUE,WRITE_COMMUNITY,m_write_community);
theApp.WriteProfileInt( BROWSER_VALUE,TIMEOUT,m_timeout);
theApp.WriteProfileInt( BROWSER_VALUE,RETRIES,m_retries);
if ( GetCheckedRadioButton( IDC_RADIO_IP, IDC_RADIO_IPX) == IDC_RADIO_IP)
theApp.WriteProfileString( BROWSER_VALUE,PROTOCOL,IP);
else
theApp.WriteProfileString( BROWSER_VALUE,PROTOCOL,IPX);
if ( GetCheckedRadioButton( IDC_RADIO_V1, IDC_RADIO_V2C) == IDC_RADIO_V1)
theApp.WriteProfileString( BROWSER_VALUE,SNMPTYPE,V1);
else
theApp.WriteProfileString( BROWSER_VALUE,SNMPTYPE,V2C);
}
void Tardefs::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
// determine which slider bar it is
CSliderCtrl *slider_retries, *slider_timeouts;
slider_timeouts = (CSliderCtrl *) GetDlgItem( IDC_SLIDER_TIMEOUT);
slider_retries = (CSliderCtrl *) GetDlgItem( IDC_SLIDER_RETRIES);
if ( (CSliderCtrl *) pScrollBar == slider_timeouts)
{
m_timeout = slider_timeouts->GetPos();
UpdateData( FALSE);
}
if ( (CSliderCtrl *) pScrollBar == slider_retries)
{
m_retries = slider_retries->GetPos();
UpdateData( FALSE);
}
CPropertyPage::OnHScroll(nSBCode, nPos, pScrollBar);
}
void Tardefs::OnCancel()
{
// TODO: Add extra cleanup here
CWnd *parent;
parent = GetParent();
parent->DestroyWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -