www.pudn.com > NoteBookVC++.rar > AUTOSAVE.cpp
// AUTOSAVE.cpp : implementation file
//
#include "stdafx.h"
#include "记事本.h"
#include "AUTOSAVE.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// AUTOSAVE dialog
AUTOSAVE::AUTOSAVE(CWnd* pParent /*=NULL*/)
: CDialog(AUTOSAVE::IDD, pParent)
{
//{{AFX_DATA_INIT(AUTOSAVE)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
AutoSave=FALSE;
DelayMinute=0;
DelaySecond=0;
}
void AUTOSAVE::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(AUTOSAVE)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(AUTOSAVE, CDialog)
//{{AFX_MSG_MAP(AUTOSAVE)
ON_BN_CLICKED(IDC_CHECK, OnCheck)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER1, OnCustomdrawSlider1)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER2, OnCustomdrawSlider2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// AUTOSAVE message handlers
BOOL AUTOSAVE::OnInitDialog()
{
CDialog::OnInitDialog();
AUTOSAVE::MinuteEdit.SubclassDlgItem(IDC_EDIT1,this);
AUTOSAVE::SecondEdit.SubclassDlgItem(IDC_EDIT2,this);
char temp[5]="";
sprintf(temp,"%d",DelayMinute);
MinuteEdit.SetWindowText(temp);
strcpy(temp,"");
sprintf(temp,"%d",DelaySecond);
SecondEdit.SetWindowText(temp);
Slider1.SubclassDlgItem(IDC_SLIDER1,this);
Slider2.SubclassDlgItem(IDC_SLIDER2,this);
Slider1.SetRange(1,60);
Slider2.SetRange(0,59);
Slider1.SetPos(DelayMinute);
Slider2.SetPos(DelaySecond);
Slider1.SetLineSize(3);
Slider2.SetLineSize(3);
button1.SubclassDlgItem(IDOK,this);
button1.EnableWindow(AutoSave);
button2.SubclassDlgItem(IDCANCEL,this);
if (AutoSave==TRUE)
button2.SetWindowText("取消");
else
button2.SetWindowText("退出");
if (AutoSave==FALSE)
{
AUTOSAVE::CheckDlgButton(IDC_CHECK,MF_CHECKED);
}
else
{
AUTOSAVE::CheckDlgButton(IDC_CHECK,MF_UNCHECKED);
}
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void AUTOSAVE::OnCheck()
{
// TODO: Add your control notification handler code here
AutoSave=1-AutoSave;
button1.EnableWindow(AutoSave);
if (AutoSave==TRUE)
button2.SetWindowText("取消");
else
button2.SetWindowText("退出");
}
void AUTOSAVE::OnCustomdrawSlider1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
DelayMinute=Slider1.GetPos();
char temp[5]="";
sprintf(temp,"%d",DelayMinute);
MinuteEdit.SetWindowText(temp);
*pResult = 0;
}
void AUTOSAVE::OnCustomdrawSlider2(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
DelaySecond=Slider2.GetPos();
char temp[5]="";
sprintf(temp,"%d",DelaySecond);
SecondEdit.SetWindowText(temp);
*pResult = 0;
}