www.pudn.com > PhoneReaderSrc.rar > GotoDlg.cpp


// GotoDlg.cpp: implementation of the CGotoDlg class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "GotoDlg.h" 
#include "math.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CGotoDlg::CGotoDlg() 
{ 
	m_WindowTitle.Empty(); 
	m_GotoPageNo = -1; 
	m_RecentPage = 0; 
	m_TotalPage  = 0; 
} 
 
CGotoDlg::~CGotoDlg() 
{ 
 
} 
LRESULT CGotoDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 
{ 
	g_hWndLast = m_hWnd; 
	LoadSHMenuBar(MAKEINTRESOURCE(IDR_DONEMENU)); 
	SetWindowText(m_WindowTitle); 
	CEdit PageNoEdit; 
	PageNoEdit.Attach(GetDlgItem(IDC_GOTOPAGE)); 
	if (PageNoEdit.m_hWnd != NULL) 
		PageNoEdit.SetFocus(); 
	CStatic RecentPageStatic; 
	RecentPageStatic.Attach(GetDlgItem(IDC_RECENTPAGE)); 
	CString NowStr,PageNoStr; 
	NowStr.LoadString(NOW_TXT); 
	PageNoStr.Format(_T("%d / %d"),m_RecentPage,m_TotalPage); 
	RecentPageStatic.SetWindowText(NowStr + PageNoStr); 
	return 0; 
} 
LRESULT CGotoDlg::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 
{ 
	CEdit PageNo; 
	PageNo.Attach(GetDlgItem(IDC_GOTOPAGE)); 
	TCHAR str[32]; 
	memset(str,0,sizeof(str)); 
	PageNo.GetWindowText(str,sizeof(str)); 
	if (wcscmp(str, L"") == 0) 
	{ 
		g_hWndLast = NULL; 
		EndDialog(IDCANCEL);  
	} 
	else 
	{ 
		PageNo.SetSel(0, -1); 
		PageNo.Clear(); 
	} 
 
	return 0; 
} 
LRESULT CGotoDlg::OnDone(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 
{ 
	//set specific page 
	TCHAR str[32]; 
	m_GotoPageNo = -1; 
	CEdit PageNo; 
	PageNo.Attach(GetDlgItem(IDC_GOTOPAGE));	 
	memset(str,0,sizeof(str)); 
	PageNo.GetWindowText(str,sizeof(str)); 
	RedrawWindow(); 
	g_hWndLast = NULL; 
	if (wcscmp(str,_T("")) != 0) 
	{ 
//		CString LeftStr(str); 
//		if (LeftStr.GetLength() > 14) 
//			wcscpy(str,LeftStr.Left(14)); 
		m_GotoPageNo = _wtoi(str); 
		EndDialog(IDOK);  
	} 
	return 0; 
}