m_list1.InsertItem(i,getstring,1);
}
}
int mode=AfxGetApp()->GetProfileInt("paper","dispmode",0);
m_dispmode.SetCurSel(mode);
//UpdateData(FALSE);
//////////////////////////////////////////when open the computer it can check if need
//////////////////////////////////////////change the wallpaper,if need ,will do it
m_curpaper=AfxGetApp()->GetProfileInt("paper","currentpaper",0);
if(m_curpaper>=nums)
m_curpaper=-1;
////////////
m_list1.SetHotItem(m_curpaper);
// OnPreviewPaper();
/////////////
int m_getcurpaperindex=0;
m_papertime=AfxGetApp()->GetProfileInt("papertime","updateperiod",1);
int m_lastupdatetime=AfxGetApp()->GetProfileInt("papertime","lastupdatetime",0);
//initialize viarable m_date
m_date=COleDateTime::GetCurrentTime();
m_currentdate=m_date.GetDayOfYear();
BOOL m_changeflag=FALSE;
if(m_currentdate-m_lastupdatetime>=m_papertime)
{
m_changeflag=TRUE;
}
if(m_currentdate-m_lastupdatetime<0)
{
int year=m_date.GetYear()-1;
if(year%1000==0)
{
if(year%400==0) year=366;
else year=365;
}
else
{
if(year%4==0) year=366;
else year=365;
}
if(year-m_lastupdatetime+m_currentdate>=m_papertime)
m_changeflag=TRUE;
}
if(m_changeflag)
{
AfxGetApp()->WriteProfileInt("papertime","lastupdatetime",m_currentdate);
m_getcurpaperindex=AfxGetApp()->GetProfileInt("paper","currentpaper",0);
CString m_curstring;
m_curstring.Format("wallpaperpath%d",m_getcurpaperindex);
CString m_getcurpaperpath=AfxGetApp()->GetProfileString("paperpath",m_curstring);
CString m_tile,m_style;
switch(m_dispmode.GetCurSel())
{
case 1:
m_tile.Format("%d",1);
m_style.Format("%d",0);
break;
case 2:
m_tile.Format("%d",0);
m_style.Format("%d",2);
break;
default:
m_tile.Format("%d",0);
m_style.Format("%d",0);
break;
}
TCHAR szData[MAX_PATH],szTile[MAX_PATH],szStyle[MAX_PATH];
wsprintf(szData,m_getcurpaperpath);
wsprintf(szTile,m_tile);
wsprintf(szStyle,m_style);
HKEY hkey1,hkey2;
::RegOpenKeyEx(HKEY_CURRENT_USER,"Control Panel",0,KEY_SET_VALUE,&hkey1);
::RegOpenKeyEx(hkey1,"desktop",0,KEY_SET_VALUE,&hkey2);
::RegSetValueEx(hkey2,"Wallpaper",0,REG_SZ,(LPBYTE)szData,lstrlen(szData)+1);
::RegSetValueEx(hkey2,"TileWallpaper",0,REG_SZ,(LPBYTE)szTile,lstrlen(szTile)+1);
::RegSetValueEx(hkey2,"WallpaperStyle",0,REG_SZ,(LPBYTE)szStyle,lstrlen(szStyle)+1);
::RegCloseKey(hkey2);
::RegCloseKey(hkey1);
mouseflag=TRUE;
++m_curpaper;
AfxGetApp()->WriteProfileInt("paper","currentpaper",m_curpaper);
SystemParametersInfo(SPI_SETDESKWALLPAPER,0,NULL,0);
::RegOpenKeyEx(HKEY_CURRENT_USER,"Control Panel",0,KEY_SET_VALUE,&hkey1);
::RegOpenKeyEx(hkey1,"desktop",0,KEY_SET_VALUE,&hkey2);
::RegSetValueEx(hkey2,"Wallpaper",0,REG_SZ,(LPBYTE)szData,lstrlen(szData)+1);
::RegSetValueEx(hkey2,"TileWallpaper",0,REG_SZ,(LPBYTE)szTile,lstrlen(szTile)+1);
::RegSetValueEx(hkey2,"WallpaperStyle",0,REG_SZ,(LPBYTE)szStyle,lstrlen(szStyle)+1);
::RegCloseKey(hkey2);
::RegCloseKey(hkey1);
}
return TRUE; // return TRUE unless you set the focus to a control
}
void CYaDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CYaDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);