home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
WILDASS
/
SOURCE
/
APPDLG.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-14
|
5KB
|
188 lines
// appdlg.cpp : implementation file
//
//#include "stdafx.h"
//#include "morespac.h"
#include <afxwin.h>
#include <afxext.h>
#include <ctl3d.h>
#include "resource.h"
#include "appdlg.h"
#include "grpdlg.h"
#include "appinfo.h"
#include "xfiledlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
/////////////////////////////////////////////////////////////////////////////
// CAppDlg dialog
CAppDlg::CAppDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAppDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAppDlg)
m_strAppArgs = "";
m_strAppDir = "";
m_strAppPath = "";
m_strAppTitle = "";
m_nRunState = 2;
//}}AFX_DATA_INIT
}
void CAppDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAppDlg)
DDX_Control(pDX, IDC_ICONPOS, m_Icon);
DDX_Text(pDX, IDC_APP_ARGS, m_strAppArgs);
DDV_MaxChars(pDX, m_strAppArgs, 128);
DDX_Text(pDX, IDC_APP_DIR, m_strAppDir);
DDV_MaxChars(pDX, m_strAppDir, 255);
DDX_Text(pDX, IDC_APP_PATH, m_strAppPath);
DDV_MaxChars(pDX, m_strAppPath, 255);
DDX_Text(pDX, IDC_APP_TITLE, m_strAppTitle);
DDV_MaxChars(pDX, m_strAppTitle, 128);
DDX_Radio(pDX, IDC_MAXIMIZED, m_nRunState);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAppDlg, CDialog)
//{{AFX_MSG_MAP(CAppDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnClickedButton2)
ON_EN_KILLFOCUS(IDC_APP_PATH, OnKillfocusAppPath)
ON_BN_CLICKED(IDC_HELP, OnClickedHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAppDlg message handlers
BOOL CAppDlg::OnInitDialog()
{
// TODO: Add extra initialization here
// CenterWindow();
// get a pointer to the CApplication to display
CAppGrpDlg * pParent = (CAppGrpDlg*)GetParent();
const CApplication * pApp = pParent->CurrentApplication();
// set the values to the member vars
m_strAppArgs = pApp->Args();
m_strAppDir = pApp->InitialDir();
m_strAppPath = pApp->Path();
m_strAppTitle = pApp->Title();
m_nRunState = pApp->RunState();
// if we have a path, set the icon
if ( ! m_strAppPath.IsEmpty() )
{
// try to get an icon
HICON hIcon = ExtractIcon( AfxGetInstanceHandle(), m_strAppPath, 0 );
if ( hIcon!=NULL )
m_Icon.SetIcon( hIcon );
}
// do the original initialization (incudling ddx)
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
}
void CAppDlg::OnClickedButton1()
{
// TODO: Add your control notification handler code here
XFileDialog dlg("Select a tool", TRUE, "*.exe",
NULL, OFN_HIDEREADONLY,
"executables(*.exe)|*.exe|"
"cp/m model files(*.com)|"
"*.com|program information files(*.pif)|*.pif|"
"all files(*.*)|*.*||", this );
if ( dlg.DoModal() == IDOK )
{
m_strAppPath = dlg.GetPathName();
// great. now we have a file to extract an icon from
// further, if no title is set yet, lets set this programs name
// as a title
// try to get an icon
HICON hIcon = ExtractIcon( AfxGetInstanceHandle(), m_strAppPath, 0 );
if ( hIcon!=NULL )
m_Icon.SetIcon( hIcon );
if ( m_strAppTitle.IsEmpty() )
{
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath( m_strAppPath, drive, dir, fname, ext );
m_strAppTitle = fname;
}
UpdateData( FALSE );
}
}
void CAppDlg::OnClickedButton2()
{
// TODO: Add your control notification handler code here
XDirectoryDialog dlg( "Select Initial Directory" );
if ( dlg.DoModal() == IDOK )
{
m_strAppDir = dlg.GetPathName();
UpdateData( FALSE );
}
}
void CAppDlg::OnKillfocusAppPath()
{
// TODO: Add your control notification handler code here
UpdateData();
// if title is empty, need to set title
if ( m_strAppTitle.IsEmpty() )
{
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath( m_strAppPath, drive, dir, fname, ext );
m_strAppTitle = fname;
}
// try to get an icon
HICON hIcon = ExtractIcon( AfxGetInstanceHandle(), m_strAppPath, 0 );
if ( hIcon!=NULL )
m_Icon.SetIcon( hIcon );
UpdateData( FALSE );
}
void CAppDlg::OnClickedHelp()
{
AfxGetApp()->WinHelp( 0L, HELP_CONTENTS );
}
void CAppDlg::OnOK()
{
// TODO: Add extra validation here
if ( m_strAppPath.IsEmpty() )
{
AfxMessageBox( "You need to at least specify a program path.\n"
"To just discard the dialog, use the cancel button." );
return;
}
CDialog::OnOK();
}