📄 chscwiz.cpp
字号:
/*----------------------------------------------------------------------------
_ _ _
/\ | | | (_)
/ \ _ __ __| |_ __ ___ _ __ ___ ___ __| |_ __ _
/ /\ \ | '_ \ / _` | '__/ _ \| '_ ` _ \ / _ \/ _` | |/ _` |
/ ____ \| | | | (_| | | | (_) | | | | | | __/ (_| | | (_| |
/_/ \_\_| |_|\__,_|_| \___/|_| |_| |_|\___|\__,_|_|\__,_|
The contents of this file are subject to the Andromedia Public
License Version 1.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.andromedia.com/APL/
Software distributed under the License is distributed on an
"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Pueblo client code, released November 4, 1998.
The Initial Developer of the Original Code is Andromedia Incorporated.
Portions created by Andromedia are Copyright (C) 1998 Andromedia
Incorporated. All Rights Reserved.
Andromedia Incorporated 415.365.6700
818 Mission Street - 2nd Floor 415.365.6701 fax
San Francisco, CA 94103
Contributor(s):
--------------------------------------------------------------------------
Chaco team: Dan Greening, Glenn Crocker, Jim Doubek,
Coyote Lussier, Pritham Shetty.
Wrote and designed original codebase.
------------------------------------------------------------------------------
Contains the implementation of the ChShortcutWizard class, which is
a Wizard for creating a desktop shortcut file.
----------------------------------------------------------------------------*/
// $Header: /home/cvs/chaco/modules/client/msw/ChWorld/ChSCWiz.cpp,v 2.14 1996/09/12 19:10:02 pritham Exp $
#if defined( CH_MSW )
#include "headers.h"
#include <sys/stat.h>
#include <ddeml.h>
#include <ChCore.h>
#include "ChSCWiz.h"
/*----------------------------------------------------------------------------
ChShortcutWizard class
----------------------------------------------------------------------------*/
IMPLEMENT_DYNAMIC( ChShortcutWizard, ChWizard )
ChShortcutWizard::ChShortcutWizard( CWnd* pParentWnd ) :
ChWizard(
#if defined( CH_PUEBLO_PLUGIN )
(chparam)AfxGetInstanceHandle(),
#else
(chparam)ChWorldDLL.hModule,
#endif
IDS_SHORTCUT_WIZARD,
pParentWnd ),
m_boolUseCurrWorld( false ),
m_boolEnableCurrWorld( false )
{
AddPages();
}
ChShortcutWizard::~ChShortcutWizard()
{
}
chint32 ChShortcutWizard::OnBack()
{
chint32 lReturn = 0;
if (m_boolUseCurrWorld &&
(GetActivePageID() == IDD_SHORTCUT_WIZ_USERNAME))
{
// Skip the server page
lReturn = IDD_SHORTCUT_WIZ_NAME;
}
return lReturn;
}
chint32 ChShortcutWizard::OnNext()
{
chint32 lReturn = 0;
if (m_boolUseCurrWorld &&
(GetActivePageID() == IDD_SHORTCUT_WIZ_NAME))
{
// Skip the server page
lReturn = IDD_SHORTCUT_WIZ_USERNAME;
}
return lReturn;
}
BEGIN_MESSAGE_MAP( ChShortcutWizard, ChWizard )
//{{AFX_MSG_MAP(ChShortcutWizard)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*----------------------------------------------------------------------------
ChShortcutWizard public methods
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
ChShortcutWizard protected methods
----------------------------------------------------------------------------*/
void ChShortcutWizard::AddPages()
{
this->AddPage( &m_namePage );
this->AddPage( &m_serverPage );
this->AddPage( &m_usernamePage );
this->AddPage( &m_optionsPage );
this->AddPage( &m_finishPage );
}
/*----------------------------------------------------------------------------
ChShortcutWizName class
----------------------------------------------------------------------------*/
IMPLEMENT_DYNCREATE( ChShortcutWizName, ChWizardPage )
ChShortcutWizName::ChShortcutWizName() :
ChWizardPage( ChShortcutWizName::IDD ),
m_pWiz( 0 )
{
//{{AFX_DATA_INIT(ChShortcutWizName)
m_strName = _T("");
m_boolCurrWorld = FALSE;
//}}AFX_DATA_INIT
}
ChShortcutWizName::~ChShortcutWizName()
{
}
bool ChShortcutWizName::OnInitPage()
{
bool boolSetFocus = ChWizardPage::OnInitPage();
m_pWiz = (ChShortcutWizard*)GetParent();
m_boolCurrWorld = m_pWiz->UseCurrWorld();
m_checkCurrWorld.EnableWindow( m_pWiz->EnableUseCurrWorld() );
m_editName.LimitText( constNameLimit );
UpdateData( false );
return boolSetFocus;
}
bool ChShortcutWizName::OnNext()
{
bool boolValid = true;
string strMessage;
UpdateData();
boolValid = !m_strName.IsEmpty();
if (!boolValid)
{
LOADSTRING( IDS_SHORTCUT_INVALID_NAME, strMessage );
MessageBox( strMessage, 0, MB_OK | MB_ICONEXCLAMATION );
}
else
{ // Update parent
m_pWiz->SetUseCurrWorld( m_boolCurrWorld );
}
return boolValid;
}
const string& ChShortcutWizName::GetFilename()
{
GetMangledFilename( m_strFilename );
return m_strFilename;
}
void ChShortcutWizName::DoDataExchange( CDataExchange* pDX )
{
ChWizardPage::DoDataExchange( pDX );
//{{AFX_DATA_MAP(ChShortcutWizName)
DDX_Control(pDX, IDC_CHECK_CURR_WORLD, m_checkCurrWorld);
DDX_Control(pDX, IDC_SHORTCUT_NAME, m_editName);
DDX_Text(pDX, IDC_SHORTCUT_NAME, m_strName);
DDX_Check(pDX, IDC_CHECK_CURR_WORLD, m_boolCurrWorld);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP( ChShortcutWizName, ChWizardPage )
//{{AFX_MSG_MAP(ChShortcutWizName)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*----------------------------------------------------------------------------
ChShortcutWizName protected methods
----------------------------------------------------------------------------*/
void ChShortcutWizName::GetMangledFilename( string& strFilename )
{
string strExtension;
struct _stat statInfo;
string strFilePath;
int iTry = 1;
string strTestName;
LOADSTRING( IDS_SHORTCUT_EXTENSION, strExtension );
strFilename = GetName();
strFilename = strFilename.Left( 30 );
/* Strip out characters in the name
that we don't want to allow.
This includes illegal filename
characters. */
StripChars( strFilename, "<>:\"/\\|." );
switch( ChUtil::GetSystemType() )
{
case CH_SYS_WIN32S:
case CH_SYS_WIN3X:
{ /* On older versions of Windows, we
also need to strip out more
characters and truncate to 8
chars long */
StripChars( strFilename, " ?*+&" );
strFilename = strFilename.Left( 8 );
break;
}
default:
{ // Don't need to do anything
break;
}
}
if (strFilename.IsEmpty())
{
strFilename = "ShtCut";
}
else if (isdigit( strFilename[0] ))
{
strFilename = "S" + strFilename;
switch( ChUtil::GetSystemType() )
{
case CH_SYS_WIN32S:
case CH_SYS_WIN3X:
{ /* On older versions of Windows, we
also need to strip out more
characters and truncate to 8
chars long */
strFilename = strFilename.Left( 8 );
break;
}
default:
{ // Don't need to do anything
break;
}
}
}
do
{
strTestName = strFilename;
if (1 == iTry)
{
strTestName += "." + strExtension;
}
else
{
char buffer[10];
sprintf( buffer, "%d", iTry );
switch( ChUtil::GetSystemType() )
{
case CH_SYS_WIN32S:
case CH_SYS_WIN3X:
{
int iLen;
iLen = strTestName.GetLength() + strlen( buffer );
if (iLen > 8)
{
int iNewLen = 8 - strlen( buffer );
strTestName = strTestName.Left( iNewLen );
}
strTestName += buffer;
break;
}
default:
{
strTestName += " ";
strTestName += buffer;
break;
}
}
strTestName += "." + strExtension;
}
strFilePath = GetPath() + "\\" + strTestName;
iTry++;
} while (_stat( strFilePath, &statInfo ) == 0);
strFilename = strTestName;
}
void ChShortcutWizName::StripChars( string& strData, const string& strChars )
{
int iIndex;
while (-1 != (iIndex = strData.FindOneOf( strChars )))
{
strData = strData.Left( iIndex ) + strData.Mid( iIndex + 1 );
}
}
/*----------------------------------------------------------------------------
ChShortcutWizName message handlers
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
ChShortcutWizServer class
----------------------------------------------------------------------------*/
IMPLEMENT_DYNCREATE( ChShortcutWizServer, ChWizardPage )
ChShortcutWizServer::ChShortcutWizServer() :
ChWizardPage( ChShortcutWizServer::IDD ),
m_type( undefinedType )
{
//{{AFX_DATA_INIT(ChShortcutWizServer)
m_strType = _T("");
m_strHost = _T("");
m_iPort = 0;
//}}AFX_DATA_INIT
}
ChShortcutWizServer::~ChShortcutWizServer()
{
}
bool ChShortcutWizServer::OnInitPage()
{
bool boolSetFocus = ChWizardPage::OnInitPage();
ChWorldType::FillTypeList( &m_comboTypes );
m_editHost.LimitText( constHostLimit );
m_editPort.LimitText( constPortLimit );
// Make sure the data is up-to-date
UpdateData( false );
return boolSetFocus;
}
bool ChShortcutWizServer::OnNext()
{
bool boolValid = true;
string strMessage;
string strCaption;
UpdateData();
boolValid = !m_strHost.IsEmpty() &&
(0 != m_iPort) &&
(m_type != undefinedType);
if (!boolValid)
{
LOADSTRING( IDS_SHORTCUT_INVALID_SERVER_CAPTION, strCaption );
}
if (m_strHost.IsEmpty())
{
LOADSTRING( IDS_SHORTCUT_INVALID_SERVER_HOST, strMessage );
MessageBox( strMessage, strCaption, MB_OK | MB_ICONEXCLAMATION );
}
else if (0 == m_iPort)
{
LOADSTRING( IDS_SHORTCUT_INVALID_SERVER_PORT, strMessage );
MessageBox( strMessage, strCaption, MB_OK | MB_ICONEXCLAMATION );
}
else if (m_type == undefinedType)
{
LOADSTRING( IDS_SHORTCUT_INVALID_SERVER_TYPE, strMessage );
MessageBox( strMessage, strCaption, MB_OK | MB_ICONEXCLAMATION );
}
return boolValid;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -