www.pudn.com > SafeClean.rar > SafeCleanDlg.cpp


// SafeCleanDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "SafeClean.h" 
#include "SafeCleanDlg.h" 
#include "DiskClean.h" 
#include "credits.h" 
#include "DetectDrive.h" 
#include "Direct.h" 
#include "String.h" 
 
#include "StaticFader.h" 
#include "HyperLink.h" 
#include "Options.h" 
#include  
 
#include "PowerButton.h" 
 
  
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
#define	WM_ICON_NOTIFY			WM_APP+10 
#define NIIF_WARNING 0 
 
#include "HoverButton.h" 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CAboutDlg dialog used for App About 
char *PATHr = "C:\\Windows\\notepad.exe "; 
char *PATHQr = "C:\\Windows\\System\\Viewers\\QuikView.exe "; 
char *PATHBr = "Explorer.exe "; 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
 
// Dialog Data 
	//{{AFX_DATA(CAboutDlg) 
	enum { IDD = IDD_ABOUTBOX }; 
	//}}AFX_DATA 
 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CAboutDlg) 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	//{{AFX_MSG(CAboutDlg) 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 
{ 
	//{{AFX_DATA_INIT(CAboutDlg) 
	//}}AFX_DATA_INIT 
 
} 
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CAboutDlg) 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
	//{{AFX_MSG_MAP(CAboutDlg) 
		// No message handlers 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSafeCleanDlg dialog 
 
CSafeCleanDlg::CSafeCleanDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CSafeCleanDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CSafeCleanDlg) 
	//}}AFX_DATA_INIT 
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 
   HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME));  // Icon to use 
//#endif 
 
	// Create the tray icon 
#ifdef USING_NONMFC_TRAY  // This is set in project settings 
	if (!m_SystemTray.Create(AfxGetInstanceHandle(), 
#else 
	if (!m_SystemTray.Create( 
#endif 
                        NULL,                            // Let icon deal with its own messages 
                        WM_ICON_NOTIFY,                  // Icon notify message to use 
                        _T("Safe-Clean"),  // tooltip 
                        hIcon, 
                        IDR_MENU1,                  // ID of tray icon 
                        FALSE, 
                        _T("Here's a cool new Win2K balloon!"), // balloon tip 
                        _T("Look at me!"),               // balloon title 
                        NIIF_WARNING,                    // balloon icon 
                        20 ))                            // balloon timeout 
    //{ 
	//	return -1; 
    //} 
 
	// MFC version of CSystemTray automatically sends messages to the main app window 
#ifdef USING_NONMFC_TRAY  // This is set in project settings 
	m_TrayIcon.SetTargetWnd(GetSafeHwnd());		// Send all menu messages here. 
#endif 
 
    m_SystemTray.SetMenuDefaultItem(3, TRUE); 
	 
 
 
 
	//m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 
 
   m_Mail.SetURL(_T("mailto:balkrishnatalele@yahoo.com")); 
 
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 
} 
 
void CSafeCleanDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CSafeCleanDlg) 
	DDX_Control(pDX, IDC_OK, m_eXit); 
	DDX_Control(pDX, IDC_EMAIL, m_Email); 
	DDX_Control(pDX, IDC_UPDATES, m_Updates); 
	DDX_Control(pDX, IDC_TRACK, m_Track); 
	DDX_Control(pDX, IDC_SWEEP, m_Sweep); 
	DDX_Control(pDX, ID_HELP, m_Help); 
	DDX_Control(pDX, IDC_OPTION, m_Option); 
	DDX_Control(pDX, IDCANCEL, m_Suspend); 
	DDX_Control(pDX, IDOK, m_Power); 
	DDX_Control(pDX, IDC_MAIL, m_Mail); 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CSafeCleanDlg, CDialog) 
	//{{AFX_MSG_MAP(CSafeCleanDlg) 
	ON_WM_SYSCOMMAND() 
	ON_WM_DESTROY() 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	ON_COMMAND(ID_MENU_MAXIMISE, OnMenuMaximise) 
	ON_COMMAND(ID_MENU_MINIMISE, OnMenuMinimise) 
	ON_COMMAND(ID_MENU_EXIT, OnMenuExit) 
	ON_COMMAND(ID_MENU_CLEAN, OnMenuClean) 
	ON_COMMAND(ID_MENU_ABOUT, OnMenuAbout) 
	ON_BN_CLICKED(IDC_TRACK, OnTrack) 
	ON_BN_CLICKED(ID_HELP, OnHelp) 
	ON_BN_CLICKED(IDC_OPTION, OnOption) 
	ON_BN_CLICKED(IDC_SWEEP, OnSweep) 
	ON_BN_CLICKED(IDC_UPDATES, OnUpdates) 
	ON_BN_CLICKED(IDC_EMAIL, OnEmail) 
	ON_COMMAND(ID_PROPERTIES_EDIT, OnPropertiesEdit) 
	ON_COMMAND(ID_PROPERTIES_QUICKVIEW, OnPropertiesQuickview) 
	ON_COMMAND(ID_PROPERTIES_BROSWEFILE, OnPropertiesBroswefile) 
	ON_BN_CLICKED(IDC_OK, OnOk) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSafeCleanDlg message handlers 
 
BOOL CSafeCleanDlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
 
	// Add "About..." menu item to system menu. 
 
 
  
//  aSound.Play(0,TRUE);   
 
  m_Help.LoadBitmap(IDB_HELP); 
  CString text=_T("Need Help,it's here"); 
  m_Help.SetToolTipText(&text);  
 
  m_Option.LoadBitmap(IDB_OPTION); 
   
  m_Power.LoadBitmap(IDB_POWER); 
  CString text2=_T("Power OFF"); 
  m_Power.SetToolTipText(&text2);  
 
  m_Suspend.LoadBitmap(IDB_SUSPEND);  
  CString text3=_T("Minimise me!"); 
  m_Suspend.SetToolTipText(&text3);  
 
  m_Track.LoadBitmap(IDB_TRACK); 
  CString text4=_T("Cleaning the tracks of my foots."); 
  m_Track.SetToolTipText(&text4);  
 
  m_Sweep.LoadBitmap(IDB_SWEEP); 
  CString text5=_T("Clean the disk."); 
  m_Sweep.SetToolTipText(&text5);  
 
  m_Updates.LoadBitmap(IDB_UPDATES);  
  CString text6=_T("For Recent Updates / New Version. Click Me."); 
  m_Updates.SetToolTipText(&text6);  
 
  m_Email.LoadBitmap(IDB_EMAIL); 
  CString text7=_T("Credits."); 
  m_Email.SetToolTipText(&text7);  
 
  CString text8 = _T("Option enables you the custom scan rules."); 
  m_Option.SetToolTipText(&text8); 
   
  m_eXit.LoadBitmap(IDB_EXIT); 
    
  
	// IDM_ABOUTBOX must be in the system command range. 
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 
	ASSERT(IDM_ABOUTBOX < 0xF000); 
 
	CMenu* pSysMenu = GetSystemMenu(FALSE); 
	if (pSysMenu != NULL) 
	{ 
		CString strAboutMenu; 
		strAboutMenu.LoadString(IDS_ABOUTBOX); 
		if (!strAboutMenu.IsEmpty()) 
		{ 
			pSysMenu->AppendMenu(MF_SEPARATOR); 
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 
		} 
	} 
 
	// Set the icon for this dialog.  The framework does this automatically 
	//  when the application's main window is not a dialog 
	SetIcon(m_hIcon, TRUE);			// Set big icon 
	SetIcon(m_hIcon, FALSE);		// Set small icon 
	 
	// TODO: Add extra initialization here 
 
	_unlink("c:\\~Safe.nct"); 
	_unlink("C:\\~Path.nct"); 
	_unlink("C:\\long.nct"); 
	_unlink("C:\\tmp.nct"); 
	_unlink("C:\\TLong.nct"); 
	_unlink("C:\\edit.nct"); 
	 
	return TRUE;  // return TRUE  unless you set the focus to a control 
} 
 
void CSafeCleanDlg::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
    if ((nID & 0xFFF0) == IDM_ABOUTBOX) 
	{ 
		/*CAboutDlg dlgAbout; 
		dlgAbout.DoModal(); 
		CCredits dlgCredits; 
        dlgCredits.DoModal();*/ 
		CCredits dlgCredits; 
    dlgCredits.DoModal(); 
	} 
 
        if(nID == SC_CLOSE) 
	{ 
      m_SystemTray.RemoveIcon();	 
	  CSafeCleanDlg::OnClose(); 
	  CSafeCleanDlg::OnCancel(); 
	  exit(0); 
	} 
 
	if(nID == SC_MINIMIZE) 
	{ 
      #ifndef _WIN32_WCE 
         #ifdef USING_NONMFC_TRAY  // This is set in project settings 
    CSystemTray::MinimiseToTray(GetSafeHwnd()); 
       #else 
    CSystemTray::MinimiseToTray(this); 
       #endif 
    m_SystemTray.SetMenuDefaultItem(ID_DEMO_MAXIMISE, FALSE); 
       #endif 
	 
	} 
	if(nID ==SC_MAXIMIZE ) 
	{ 
            #ifndef _WIN32_WCE 
     #ifdef USING_NONMFC_TRAY  // This is set in project settings 
    CSystemTray::MaximiseFromTray(GetSafeHwnd()); 
     #else 
    CSystemTray::MaximiseFromTray(this); 
     #endif 
    m_SystemTray.SetMenuDefaultItem(ID_DEMO_MINIMISE, FALSE); 
     #endif 
	} 
	else 
	{ 
		CDialog::OnSysCommand(nID, lParam); 
	} 
 
} 
 
void CSafeCleanDlg::OnDestroy() 
{ 
	WinHelp(0L, HELP_QUIT); 
	CDialog::OnDestroy(); 
} 
 
// 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 CSafeCleanDlg::OnPaint()  
{ 
CPaintDC dc( this ); // Device context for painting 
 
         CBitmap bmp, *poldbmp; 
         CDC memdc; 
 
         // Load the bitmap resource 
         bmp.LoadBitmap( IDB_BLUE ); 
 
         // Create a compatible memory DC 
         memdc.CreateCompatibleDC( &dc ); 
 
         // Select the bitmap into the DC 
         poldbmp = memdc.SelectObject( &bmp ); 
 
         // Copy (BitBlt) bitmap from memory DC to screen DC 
         dc.BitBlt( -10, -10, 860, 1600, &memdc, 0, 0, SRCCOPY ); 
		 //dc.BitBlt ( 
 
         memdc.SelectObject( poldbmp ); 
} 
 
// The system calls this to obtain the cursor to display while the user drags 
//  the minimized window. 
HCURSOR CSafeCleanDlg::OnQueryDragIcon() 
{ 
	return (HCURSOR) m_hIcon; 
} 
 
void CSafeCleanDlg::OnMenuMaximise()  
{ 
	// TODO: Add your command handler code here 
	#ifndef _WIN32_WCE 
#ifdef USING_NONMFC_TRAY  // This is set in project settings 
    CSystemTray::MaximiseFromTray(GetSafeHwnd()); 
#else 
    CSystemTray::MaximiseFromTray(this); 
#endif 
    m_SystemTray.SetMenuDefaultItem(ID_DEMO_MINIMISE, FALSE); 
#endif 
} 
 
void CSafeCleanDlg::OnMenuMinimise()  
{ 
	// TODO: Add your command handler code here 
/*	#ifndef _WIN32_WCE 
#ifdef USING_NONMFC_TRAY  // This is set in project settings 
    CSystemTray::MinimiseToTray(GetSafeHwnd()); 
#else 
    CSystemTray::MinimiseToTray(this); 
#endif 
    m_SystemTray.SetMenuDefaultItem(ID_DEMO_MAXIMISE, FALSE); 
#endif*/ 
	 WinExec("Explorer http://talele.50megs.com/",SW_SHOW); 
} 
 
void CSafeCleanDlg::OnMenuExit()  
{ 
	// TODO: Add your command handler code here 
	m_SystemTray.RemoveIcon();	 
	CSafeCleanDlg::OnClose(); 
	CSafeCleanDlg::OnCancel(); 
	exit(0); 
} 
 
void CSafeCleanDlg::OnMenuClean()  
{ 
	// TODO: Add your command handler code here 
	DetectDrive aDrive; 
	aDrive.DoModal();  
	 
} 
 
void CSafeCleanDlg::OnMenuAbout()  
{ 
	// TODO: Add your command handler code here 
	  
/*	CAboutDlg aDlg; 
	 
	aDlg.DoModal(); */ 
	CCredits dlgCredits; 
    dlgCredits.DoModal(); 
	 
	 
} 
 
void CSafeCleanDlg::OnCancel()  
{ 
	// TODO: Add extra cleanup here 
	#ifndef _WIN32_WCE 
#ifdef USING_NONMFC_TRAY  // This is set in project settings 
    CSystemTray::MinimiseToTray(GetSafeHwnd()); 
#else 
    CSystemTray::MinimiseToTray(this); 
#endif 
    m_SystemTray.SetMenuDefaultItem(ID_DEMO_MAXIMISE, FALSE); 
#endif 
	//CDialog::OnCancel(); 
} 
 
void CSafeCleanDlg::OnTrack()  
{ 
	// TODO: Add your control notification handler code here 
	DiskClean aDlg; 
	aDlg.DoModal();  
	 
} 
 
void CSafeCleanDlg::OnHelp()  
{ 
	// TODO: Add your control notification handler code here 
	WinExec("Winhlp32.exe Safe-Clean.hlp",SW_SHOW); 
} 
 
void CSafeCleanDlg::OnOption()  
{ 
	// TODO: Add your control notification handler code here 
	//CCredits dlgCredits; 
    //dlgCredits.DoModal(); 
	Options aOption; 
	aOption.DoModal();  
	 
} 
 
void CSafeCleanDlg::OnSweep()  
{ 
	// TODO: Add your control notification handler code here 
 
//GetDlgItem(IDC_DRIVEC)->ShowWindow(SW_SHOW); 
	DetectDrive aDrive; 
	aDrive.DoModal();  
	 
	 
} 
 
void CSafeCleanDlg::OnUpdates()  
{ 
	// TODO: Add your control notification handler code here 
	 
	WinExec("Explorer http://talele.50megs.com/Installer/safe.zip",SW_SHOW); 
 
} 
 
 
 
 
void CSafeCleanDlg::OnEmail()  
{ 
	// TODO: Add your control notification handler code here 
 	CCredits dlgCredits; 
    dlgCredits.DoModal(); 
	 
} 
 
 
 
 
void CSafeCleanDlg::OnPropertiesEdit()  
{ 
	// TODO: Add your command handler code here 
fcloseall(); 
 FILE *editr; 
   int get; 
  	 editr=fopen("c:\\Temp\\edit.nct","r"); 
	    if(editr==NULL){AfxMessageBox("Unable to edit the specific file.");exit(0);} 
	       fscanf(editr,"%d",&get); 
 
             FILE *editingr; 
               char msgr[256],*getmer,pathr[256]; 
               int Lenghtr; 
            editingr=fopen("c:\\Temp\\~Path.nct","r"); 
            if(editingr==NULL){AfxMessageBox("File Failed to open.");exit(0);} 
            int countr=-1; 
        while(!feof(editingr)) 
		{ 
          fgets(msgr,_MAX_PATH, editingr); 
		  countr+=1; 
             if(countr == get) 
			 { 
	           Lenghtr=strlen(msgr); 
               msgr[Lenghtr-1]='\0'; 
               strcpy(pathr,PATHr); 
               getmer=strcat(pathr,msgr); 
			   WinExec(getmer,SW_SHOW); 
			 } 
 
		} 
 
} 
 
void CSafeCleanDlg::OnPropertiesQuickview()  
{ 
	// TODO: Add your command handler code here 
	fcloseall(); 
	FILE *editr; 
	  int get; 
	editr=fopen("c:\\Temp\\edit.nct","r"); 
	   if(editr==NULL){AfxMessageBox("Unable to edit the specific file.");exit(0);} 
	      fscanf(editr,"%d",&get); 
 
    FILE *editingr; 
      char msgr[256],*getmer,pathr[256]; 
      int Lenghtr; 
      editingr=fopen("c:\\Temp\\~Path.nct","r"); 
        if(editingr==NULL){AfxMessageBox("File Failed to open.");} 
          int countr=-1; 
            while(!feof(editingr)) 
			{ 
              fgets(msgr,_MAX_PATH, editingr); 
		       countr+=1; 
                if(countr == get) 
				{ 
	             Lenghtr=strlen(msgr); 
                 msgr[Lenghtr-1]='\0'; 
                 strcpy(pathr,PATHQr); 
                 getmer=strcat(pathr,msgr); 
	             WinExec(getmer,SW_SHOW); 
				} 
 
			} 
 
} 
 
void CSafeCleanDlg::OnPropertiesBroswefile()  
{ 
	// TODO: Add your command handler code here 
	fcloseall(); 
	FILE *editr; 
	FILE *editingr,*minusfile; 
	int get,countr=-1; 
	char msgr[256],Mmsg[256],*getmer,pathr[256],fin[100]; 
    int Lenghtr,MLen,finlen; 
	editr=fopen("c:\\Temp\\edit.nct","r"); 
	if(editr==NULL){AfxMessageBox("Unable to edit the specific file.");exit(0);} 
	fscanf(editr,"%d",&get); 
       editingr=fopen("c:\\Temp\\~Path.nct","r"); 
	   minusfile=fopen("c:\\Temp\\Long.nct","r"); 
         if(editingr==NULL || minusfile==NULL){AfxMessageBox("File Failed to open.");exit(0);} 
            while(!feof(editingr)) 
			{ 
              fgets(msgr,_MAX_PATH, editingr); 
			  fgets(Mmsg,_MAX_PATH,minusfile); 
		      countr+=1; 
              if(countr == get) 
			  { 
	            Lenghtr=strlen(msgr); 
				MLen = strlen(Mmsg); 
				finlen = Lenghtr - MLen; 
                msgr[Lenghtr-1]='\0'; 
				strncpy(fin,msgr,finlen); 
				fin[finlen]='\0'; 
				//AfxMessageBox(fin); 
 
                strcpy(pathr,PATHBr); 
                getmer=strcat(pathr,fin); 
	            WinExec(getmer,SW_SHOW); 
			  } 
			} 
} 
 
 
 
 
 
 
 
void CSafeCleanDlg::OnOK()  
{ 
	// TODO: Add extra validation here 
//	PowerButton PButton; 
//	PButton.DoModal();  
	CDialog::OnOK(); 
	 
} 
 
void CSafeCleanDlg::OnOk()  
{ 
	// TODO: Add your control notification handler code here 
	  
}