www.pudn.com > NoteBookVC++.rar > EDITGOTO.cpp


// EDITGOTO.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "¼Çʱ¾.h" 
#include "EDITGOTO.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// EDITGOTO dialog 
 
 
EDITGOTO::EDITGOTO(CWnd* pParent /*=NULL*/) 
	: CDialog(EDITGOTO::IDD, pParent) 
{ 
	MaxLine=100; 
	//{{AFX_DATA_INIT(EDITGOTO) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
 
void EDITGOTO::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(EDITGOTO) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(EDITGOTO, CDialog) 
	//{{AFX_MSG_MAP(EDITGOTO) 
	ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER, OnCustomdrawSlider) 
	ON_EN_SETFOCUS(IDC_EDIT, OnSetfocusEdit) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// EDITGOTO message handlers 
 
BOOL EDITGOTO::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	MySlider.SubclassDlgItem(IDC_SLIDER,this); 
	MySlider.SetRange(1,MaxLine); 
	MySlider.SetLineSize(MaxLine/20); 
	MySlider.SetPos(1); 
	MyEdit.SubclassDlgItem(IDC_EDIT,this); 
	// 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 EDITGOTO::OnCustomdrawSlider(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	// TODO: Add your control notification handler code here 
	char temp[6]=""; 
	sprintf(temp,"%d",EDITGOTO::MySlider.GetPos()); 
	EDITGOTO::MyEdit.SetWindowText(temp); 
	*pResult = 0; 
} 
 
void EDITGOTO::OnSetfocusEdit()  
{ 
	// TODO: Add your control notification handler code here 
	int i=EDITGOTO::MaxLine; 
	int j=1; 
	while(i>9) 
	{ 
		j++; 
		i/=10; 
    } 
	EDITGOTO::MyEdit.SetLimitText(j); 
	char temp[6]=""; 
	EDITGOTO::MyEdit.GetWindowText(temp,j); 
	EDITGOTO::MySlider.SetPos(atoi(temp)); 
} 
 
void EDITGOTO::OnOK()  
{ 
	// TODO: Add extra validation here 
	EDITGOTO::GotoLine=EDITGOTO::MySlider.GetPos(); 
	CDialog::OnOK(); 
}