home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
WILDASS
/
SOURCE
/
ICONDLG.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-14
|
4KB
|
148 lines
// icondlg.cpp : implementation file
//
#include <afxwin.h>
#include <afxext.h>
#include <ctl3d.h>
#include "resource.h"
//#include "stdafx.h"
//#include "morespac.h"
#include "icondlg.h"
#include "xfiledlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
/////////////////////////////////////////////////////////////////////////////
// CIconDlg dialog
CIconDlg::CIconDlg(CWnd* pParent /*=NULL*/)
: CDialog(CIconDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CIconDlg)
m_strIconFile = "(none)";
//}}AFX_DATA_INIT
// m_nIcon; // only used for the transfer down
}
void CIconDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CIconDlg)
DDX_Control(pDX, IDC_THE_ICON, m_Icon);
DDX_Text(pDX, IDC_ICONFILE, m_strIconFile);
DDV_MaxChars(pDX, m_strIconFile, 256);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CIconDlg, CDialog)
//{{AFX_MSG_MAP(CIconDlg)
ON_BN_CLICKED(IDC_BUTTONLEFT, OnClickedButtonleft)
ON_BN_CLICKED(IDC_BROWSE, OnClickedBrowse)
ON_BN_CLICKED(IDC_BUTTONRIGHT, OnClickedButtonright)
ON_BN_CLICKED(IDC_HELP, OnClickedHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIconDlg message handlers
BOOL CIconDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// CenterWindow();
return TRUE; // return TRUE unless you set the focus to a control
}
void CIconDlg::OnClickedButtonleft()
{
// TODO: Add your control notification handler code here
UINT nIcon = GetDlgItemInt( IDC_ICON_NUMBER );
if ( nIcon )
nIcon--;
HICON hIcon = ExtractIcon( AfxGetInstanceHandle(), m_strIconFile, nIcon );
if ( hIcon!=NULL && hIcon!=(HICON)1 )
{
m_Icon.SetIcon( hIcon );
SetDlgItemInt( IDC_ICON_NUMBER, nIcon );
}
}
void CIconDlg::OnClickedBrowse()
{
// TODO: Add your control notification handler code here
XFileDialog dlg( "Select a file to load an icon from", TRUE, "*.exe;*.dll",
NULL, OFN_HIDEREADONLY,
"executables(*.exe)|*.exe|"
"dynamic link libraries(*.dll)|*.dll|"
"all files(*.*)|*.*||", this );
if ( dlg.DoModal() == IDOK )
{
m_strIconFile = dlg.GetPathName();
// try to get an icon
HICON hIcon = ExtractIcon( AfxGetInstanceHandle(), m_strIconFile, 0 );
if ( hIcon==NULL || hIcon==(HICON)1 )
{
AfxMessageBox("There is no icon in this file");
m_Icon.SetIcon( AfxGetApp()->LoadIcon( IDI_NOAPPLICATION ) );
}
else
{
m_Icon.SetIcon( hIcon );
}
SetDlgItemInt( IDC_ICON_NUMBER, 0 );
UpdateData( FALSE );
}
}
void CIconDlg::OnClickedButtonright()
{
// TODO: Add your control notification handler code here
UINT nIcon = GetDlgItemInt( IDC_ICON_NUMBER );
nIcon++;
HICON hIcon = ExtractIcon( AfxGetInstanceHandle(), m_strIconFile, nIcon );
if ( hIcon!=NULL && hIcon!=(HICON)1 )
{
m_Icon.SetIcon( hIcon );
SetDlgItemInt( IDC_ICON_NUMBER, nIcon );
}
}
void CIconDlg::OnOK()
{
// TODO: Add extra validation here
m_nIcon = GetDlgItemInt( IDC_ICON_NUMBER );
// make sure this is a vliad file/icon
HICON hIcon = ExtractIcon( AfxGetInstanceHandle(), m_strIconFile, m_nIcon );
if ( hIcon==NULL || hIcon==(HICON)1 )
{
m_strIconFile="";
m_nIcon = 0;
}
CDialog::OnOK();
}
void CIconDlg::OnClickedHelp()
{
AfxMessageBox("You might select a file containing an icon with the browse button.\n"
"From this file you are than able to select an icon with the < and > buttons");
}