📄 dlgother.cpp
字号:
// DlgOther.cpp : implementation file
//
#include "stdafx.h"
#include "ex5.h"
#include "DlgOther.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgOther dialog
CDlgOther::CDlgOther(CWnd* pParent /*=NULL*/)
: CDialog(CDlgOther::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgOther)
m_nRValue = 10;
m_nEdit1 = 10;
m_nGValue = 5;
m_nEdit2 = 5;
//}}AFX_DATA_INIT
}
void CDlgOther::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgOther)
DDX_Control(pDX, IDC_PROGRESS1, m_Prgs1);
DDX_Control(pDX, IDC_SLIDER1, m_Slider1);
DDX_Control(pDX, IDC_SCROLLBAR1, m_ScrlBar1);
DDX_Scroll(pDX, IDC_SCROLLBAR1, m_nRValue);
DDX_Text(pDX, IDC_EDIT1, m_nEdit1);
DDX_Slider(pDX, IDC_SLIDER1, m_nGValue);
DDX_Text(pDX, IDC_EDIT2, m_nEdit2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgOther, CDialog)
//{{AFX_MSG_MAP(CDlgOther)
ON_WM_HSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgOther message handlers
void CDlgOther::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
int nID=pScrollBar->GetDlgCtrlID();
if(nID==IDC_SLIDER1)
{
m_nGValue=m_Slider1.GetPos();
m_nEdit2=m_nGValue;
UpdateData(false);
}
if(nID==IDC_SCROLLBAR1)
{
switch(nSBCode)
{
case SB_LINELEFT:
m_nRValue--;
break;
case SB_LINERIGHT:
m_nRValue++;
break;
case SB_PAGELEFT:
m_nRValue-=10;
break;
case SB_PAGERIGHT:
m_nRValue+=10;
break;
case SB_THUMBTRACK:
m_nRValue=nPos;
break;
}
if(m_nRValue<0) m_nRValue=0;
if(m_nRValue>255) m_nRValue=255;
m_ScrlBar1.SetScrollPos(m_nRValue);
m_nEdit1=m_nRValue;
UpdateData(false);
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
BOOL CDlgOther::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_ScrlBar1.SetScrollRange(10,100);
m_ScrlBar1.SetScrollPos(m_nRValue);
m_Slider1.SetRange(5,20);
m_Slider1.SetPos(m_nGValue);
m_Prgs1.SetRange(0,100);
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgOther::OnOK() //进展条
{
// TODO: Add extra validation here
UpdateData();
int nPercent=10;
nPercent=m_nEdit1;
int nCurPos=0;
int nInterval=10;
nInterval=m_nEdit2;
m_Prgs1.SetPos( 0 );
while( (nCurPos+=nPercent) < 100 )
{
m_Prgs1.OffsetPos( nPercent );
// m_Prgs1.StepIt();
Sleep( 1000 * nInterval / 100 );
}
m_Prgs1.SetPos( 100 );
// CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -