www.pudn.com > SafeClean.rar > PowerButton.cpp
// PowerButton.cpp : implementation file
//
#include "stdafx.h"
#include "SafeClean.h"
#include "PowerButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// PowerButton dialog
PowerButton::PowerButton(CWnd* pParent /*=NULL*/)
: CDialog(PowerButton::IDD, pParent)
{
//{{AFX_DATA_INIT(PowerButton)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void PowerButton::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(PowerButton)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(PowerButton, CDialog)
//{{AFX_MSG_MAP(PowerButton)
ON_BN_CLICKED(IDC_LOGOFF, OnLogoff)
ON_BN_CLICKED(IDC_REBOOT, OnReboot)
ON_BN_CLICKED(IDC_SHUTDOWN, OnShutdown)
ON_BN_CLICKED(IDC_POWER_HELP, OnPowerHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// PowerButton message handlers
void PowerButton::OnLogoff()
{
// TODO: Add your control notification handler code here
PFlag=0;
}
void PowerButton::OnReboot()
{
// TODO: Add your control notification handler code here
PFlag=1;
}
void PowerButton::OnShutdown()
{
// TODO: Add your control notification handler code here
PFlag=2;
}
void PowerButton::OnOK()
{
// TODO: Add extra validation here
//CSystemTray::Remove
//CSafeCleanDlg::OnMe
PowerButton::m_Tray.RemoveIcon();
switch(PFlag)
{
case 0: ExitWindowsEx(EWX_LOGOFF ,0);exit(0);break;
case 1: ExitWindowsEx(EWX_REBOOT ,0);exit(0);break;
case 2: ExitWindowsEx(EWX_SHUTDOWN ,0);exit(0);break;
default:AfxMessageBox("What action should be taken ?");break;
}
}
void PowerButton::OnPowerHelp()
{
// TODO: Add your control notification handler code here
WinExec("Winhlp32.exe Safe-Clean.hlp",SW_SHOW);
}