www.pudn.com > IE1.rar > HtmlClockView.cpp


// HtmlClockView.cpp : implementation of the CHtmlClockView class 
// 
 
#include "stdafx.h" 
#include "HtmlClock.h" 
 
 
#include "HtmlClockDoc.h" 
#include "HtmlClockView.h" 
#include "DlgUrl.h" 
 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CHtmlClockView 
 
IMPLEMENT_DYNCREATE(CHtmlClockView, CHtmlView) 
 
BEGIN_MESSAGE_MAP(CHtmlClockView, CHtmlView) 
	//{{AFX_MSG_MAP(CHtmlClockView) 
	ON_COMMAND(ID_EDIT_URL, OnEditUrl) 
	ON_WM_TIMER() 
	ON_COMMAND(ID_FILE_SAVE, OnFileSave) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CHtmlClockView construction/destruction 
 
CHtmlClockView::CHtmlClockView() 
{ 
} 
 
CHtmlClockView::~CHtmlClockView() 
{ 
} 
 
BOOL CHtmlClockView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	return CHtmlView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CHtmlClockView drawing 
 
void CHtmlClockView::OnDraw(CDC* pDC) 
{ 
	CHtmlClockDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
} 
 
void CHtmlClockView::OnInitialUpdate() 
{ 
	CHtmlView::OnInitialUpdate(); 
 
	FILE *file; 
 
	if(!(file=fopen("setting.ini", "r"))) 
	{ 
	cur_time = 3;	 
 
	CString string; 
 
	TCHAR szPath[MAX_PATH]; 
	::GetModuleFileName (NULL, szPath, sizeof (szPath) / sizeof (TCHAR)); 
 
 
	string = szPath; 
 
	int nIndex = string.ReverseFind (_T ('\\')); 
	ASSERT (nIndex != -1); 
	string = string.Left (nIndex + 1) + _T ("test.html"); 
	cur_url = string; 
 
	} 
 
	else 
	{ 
//		CString temp; 
		fscanf(file, "%d %s", &cur_time, cur_url); 
		fclose(file); 
 
//		cur_url = temp; 
 
		 
	} 
//	MessageBox(cur_url,NULL,MB_OK); 
	 
 
 
	SetTimer(1, cur_time * 1000, NULL); 
	Navigate (cur_url); 
	 
 
 
 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CHtmlClockView diagnostics 
 
#ifdef _DEBUG 
void CHtmlClockView::AssertValid() const 
{ 
	CHtmlView::AssertValid(); 
} 
 
void CHtmlClockView::Dump(CDumpContext& dc) const 
{ 
	CHtmlView::Dump(dc); 
} 
 
CHtmlClockDoc* CHtmlClockView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHtmlClockDoc))); 
	return (CHtmlClockDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CHtmlClockView message handlers 
 
void CHtmlClockView::OnTitleChange(LPCTSTR lpszText)  
{ 
	CHtmlView::OnTitleChange(lpszText); 
	AfxGetMainWnd ()->SetWindowText (lpszText); 
} 
 
void CHtmlClockView::OnEditUrl()  
{ 
	// TODO: Add your command handler code here 
 
	CString string; 
	const CString temp = cur_url;  
 
 
//	MessageBox(temp,NULL,MB_OK); 
	 
	CDlgURL dlg; 
	 
 
//	cur_url="file:///F:/¹²Ïí/ÍøÕ¾¾µÏñ/www.heroworld.com.cn/heroes3site/index.htm"; 
 
 
 
	dlg.m_url = temp; 
	dlg.m_time = cur_time; 
	cur_url = temp; 
	 
	if(dlg.DoModal()==IDOK)		 
	{ 
 
 
 
		cur_url = string = dlg.m_url; 
		SetTimer(1, dlg.m_time * 1000,NULL); 
		cur_time = dlg.m_time; 
 
 
		Navigate (string); 
		Invalidate(FALSE); 
 
	} 
	 
	 
	 
} 
 
void CHtmlClockView::OnTimer(UINT nIDEvent)  
{ 
	// TODO: Add your message handler code here and/or call default 
	 
	CHtmlView::OnTimer(nIDEvent); 
	 
	 
 
	Navigate (cur_url); 
	Invalidate(FALSE);	 
	 
 
} 
 
//DEL void CHtmlClockView::OnEditTime()  
//DEL { 
//DEL 	// TODO: Add your command handler code here 
//DEL 	 
//DEL } 
 
void CHtmlClockView::OnFileSave()  
{ 
	// TODO: Add your command handler code here 
	FILE *file; 
	 
	 
 
 
	if(file=fopen("setting.ini", "w+")) 
	{ 
		fprintf(file, "%d %s", cur_time, cur_url); 
 
 
		 
//		MessageBox("hehe",NULL,MB_OK); 
 
	} 
 
	fclose(file); 
 
	 
}