home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
WILDASS
/
SOURCE
/
TASKDLG.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-14
|
5KB
|
195 lines
// taskdlg.cpp : implementation file
//
// #include "stdafx.h"
#include <afxwin.h>
#include <afxext.h>
#include <ctl3d.h>
#include "resource.h"
#include "tasks.h"
#include "taskdlg.h"
#include "taskinfo.h"
#include "desktop.h"
#include "app.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTaskDlg dialog
CTaskDlg::CTaskDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTaskDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTaskDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CTaskDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTaskDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTaskDlg, CDialog)
//{{AFX_MSG_MAP(CTaskDlg)
ON_BN_CLICKED(IDC_KILLTASK, OnClickedKilltask)
ON_BN_CLICKED(IDC_CLOSETASK, OnClickedClosetask)
ON_BN_CLICKED(IDC_REFRESHTASK, OnClickedRefreshtask)
ON_BN_CLICKED(IDC_TASKINFO, OnClickedTaskinfo)
ON_BN_CLICKED(IDC_EXIT_WINDOWS, OnClickedExitWindows)
ON_BN_CLICKED(IDC_HELP, OnClickedHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTaskDlg message handlers
BOOL CTaskDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// center to parent
CenterWindow();
// clear&reset the listbox
CListBox * pLst = (CListBox*)GetDlgItem( IDC_LSTTASKS );
pLst->SetTabStops( 60 );
// populate the task list from the m_lstTaks member
ListTasks();
return TRUE;
}
void CTaskDlg::OnClickedRefreshtask()
{
// build a new task list from scratch
m_lstTasks.Rebuild();
// populate the task list
ListTasks();
}
void
CTaskDlg::ListTasks()
{
// clear&reset the listbox
CListBox * pLst = (CListBox*)GetDlgItem( IDC_LSTTASKS );
pLst->ResetContent();
// build a new tasklist
// do a new tasklist
for ( POSITION pos = m_lstTasks.GetHeadPosition(); pos!= NULL; )
{
CTask * pTask = m_lstTasks.GetNext( pos );
int index = pLst->AddString( CString( pTask->ModuleName()) + "\t[" + CString( pTask->ExeName()) +"]" );
// add a pointer to this task for later retrival
pLst->SetItemDataPtr( index, (void*)pTask );
}
}
void CTaskDlg::OnClickedKilltask()
{
// TODO: Add your control notification handler code here
CTask * pTask = GetSelectedTask();
// if nothing was selected, skip the rest
if ( pTask )
{
// let the task die; the CTask::Die fxn takes care _not_
// to kill the task if its no longer valid
m_lstTasks.CloseDirty( pTask );
// take care of listbox refreshing
ListTasks();
}
}
void CTaskDlg::OnClickedClosetask()
{
// TODO: Add your control notification handler code here
CTask * pTask = GetSelectedTask();
if ( pTask )
{
m_lstTasks.CloseClean( pTask );
// just in case this tasks _can`t_ be closed this way, take
// care the correct task list is displayed
m_lstTasks.Rebuild();
// take care of listbox refreshing
ListTasks();
}
}
void CTaskDlg::OnClickedTaskinfo()
{
// TODO: Add your control notification handler code here
if ( ! GetSelectedTask() )
return;
CTaskInfoDlg dlg( this );
dlg.DoModal();
}
CTask *
CTaskDlg::GetSelectedTask()
{
CListBox * pLst = (CListBox*)GetDlgItem( IDC_LSTTASKS );
int index = pLst->GetCurSel();
if ( index == LB_ERR )
{
AfxMessageBox( "No Task selected" );
return 0;
}
CTask * pTask = (CTask*)pLst->GetItemDataPtr( index );
if ( ! pTask->IsTask() )
{
AfxMessageBox("Selected Task is no longer running\nRefreshing Tasklist ...");
// remove the task from the list and repaint the listbox
m_lstTasks.Remove( pTask );
ListTasks();
return 0;
}
return pTask;
}
void CTaskDlg::OnClickedExitWindows()
{
// store the current desktop to the profile
CDesktop desktop("DesktopOnExit");
desktop.Snapshot();
// store our current configuration
((CMyApp*)AfxGetApp())->WriteApplicationInfo();
// quit windows
ExitWindows( 0, 0 );
}
void CTaskDlg::OnClickedHelp()
{
AfxGetApp()->WinHelp( 0L, HELP_CONTENTS );
}