📄 stkui.cpp.svn-base
字号:
return m_pRecentFileList;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CXFDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CButton m_btnOK;
CStatic m_staticVersion;
CStatic m_staticSoftNO;
CStatic m_staticRegCode;
CStatic m_staticUser;
CHyperLink m_linkMailMe;
CHyperLink m_linkProductURL;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CXFDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CXFDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
DDX_Control(pDX, IDOK, m_btnOK);
DDX_Control(pDX, IDC_VERSION, m_staticVersion);
DDX_Control(pDX, IDC_SOFTNO, m_staticSoftNO);
DDX_Control(pDX, IDC_REGCODE, m_staticRegCode);
DDX_Control(pDX, IDC_USER, m_staticUser);
DDX_Control(pDX, IDC_URL_MAILME, m_linkMailMe);
DDX_Control(pDX, IDC_URL_ADDRESS, m_linkProductURL);
//}}AFX_DATA_MAP
}
BOOL CAboutDlg::OnInitDialog()
{
CXFDialog::OnInitDialog();
CString strMailMe = AfxGetProfile().GetSupportMailto();
m_linkMailMe.SetURL( strMailMe );
CString strURL = AfxGetProfile().GetProductURL();
m_linkProductURL.SetWindowText( strURL );
m_linkProductURL.SetURL( strURL );
CString strVersion = AfxGetVersionString( );
if( strVersion.GetLength() > 0 )
m_staticVersion.SetWindowText( strVersion );
CString strUser = AfxGetSView().GetU();
if( strUser.IsEmpty() )
strUser.LoadString( IDS_AUTHORIZEDUSER_UNKNOWN );
m_staticUser.SetWindowText( strUser );
CString strHD = AfxGetSView().GetS();
if( !strHD.IsEmpty() )
m_staticSoftNO.SetWindowText( strHD );
CString strRegCode = AfxGetSView().GetR();
if( strRegCode.IsEmpty() )
strRegCode.LoadString( IDS_REGCODE_UNPURCHASED );
m_staticRegCode.SetWindowText( strRegCode );
return TRUE;
}
BEGIN_MESSAGE_MAP(CAboutDlg, CXFDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CStkUIApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CStkUIApp message handlers
int CStkUIApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
SaveLastOpenedStrategy( );
CloseAllStrategy( TRUE );
AfxGetDB().StoreCodetable( AfxGetStockContainer() );
AfxGetProfile().StoreProfile( );
AfxGetSView().Store( AfxGetProfile().GetSViewFile() );
AfxReleaseDB( );
if( m_pStaticDoc )
{
m_pStaticDoc->OnCloseDocument();
delete m_pStaticDoc;
m_pStaticDoc = NULL;
}
return CWinApp::ExitInstance();
}
void CStkUIApp::OnFileNew()
{
// TODO: Add your command handler code here
// OpenStrategyFile( NULL );
}
void CStkUIApp::OnFileOpen()
{
// TODO: Add your command handler code here
CString newName;
if( m_pRecentFileList && m_pRecentFileList->GetSize() > 0 )
newName = (*m_pRecentFileList)[0];
if (!AfxDoPromptFileName(newName, IDS_OPENFILE,
OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ENABLESIZING, TRUE))
return; // open cancelled
if( NULL != OpenStrategyFile(newName) )
AfxSwitchToStaticView( RUNTIME_CLASS(CSimuView) );
// if returns NULL, the user has already been alerted
}
BOOL CStkUIApp::SaveAllModified()
{
// TODO: Add your specialized code here and/or call the base class
CStrategy * pActiveStrategy = AfxGetActiveStrategy();
if( pActiveStrategy )
pActiveStrategy->DoFileSave();
/*
POSITION pos = GetFirstStrategyPosition();
while (pos != NULL)
{
CStrategy* pStrategy = GetNextStrategy(pos);
if (!pStrategy->DoFileSave() ) // >SaveModified())
return FALSE;
}
*/
return TRUE;
}
void CStkUIApp::OnStrategyNew()
{
// TODO: Add your command handler code here
CStrategy * pStrategy = new CStrategy();
if( NULL == pStrategy )
{
AfxMessageBox( IDS_STRATEGY_FAILED, MB_OK | MB_ICONINFORMATION );
return;
}
CSetPrpt firstPage( NULL, IDS_STRATEGY_SETPRPT, NULL );
firstPage.m_dwButtonFlags = PSWIZB_NEXT | PSWIZB_DISABLEDFINISH;
firstPage.SetStrategy( pStrategy );
CSelectStk selectStk(NULL, IDS_STRATEGY_SELECTSTK, NULL);
selectStk.m_dwButtonFlags = PSWIZB_BACK | PSWIZB_NEXT | PSWIZB_DISABLEDFINISH;
CSetRule setrule(NULL, IDS_STRATEGY_SETRULE, NULL);
setrule.m_dwButtonFlags = PSWIZB_BACK | PSWIZB_NEXT | PSWIZB_DISABLEDFINISH;
setrule.SetTechParameters( &(pStrategy->GetTechParametersBuy()), &(pStrategy->GetSelectedTechsBuy()) );
CSetRate setrate(NULL, IDS_STRATEGY_SETRATE, NULL);
setrate.m_dwButtonFlags = PSWIZB_BACK | PSWIZB_FINISH;
setrate.SetStrategy( pStrategy );
CXFPropertySheetEx sht;
sht.AddPage( &firstPage );
sht.AddPage( &selectStk );
sht.AddPage( &setrule );
sht.AddPage( &setrate );
sht.SetWizardMode( );
sht.m_psh.dwFlags |= ( PSH_WIZARD97 | PSH_WIZARDHASFINISH /* | PSH_HEADER /*Header Bitmap*/ );
CBitmap bmp;
bmp.LoadBitmap( IDB_BALANG );
sht.SetBitmap( (HBITMAP)bmp.GetSafeHandle() );
if( ID_WIZFINISH == sht.DoModal() )
{
pStrategy->SetStocks( selectStk.m_domainTemp );
pStrategy->SaveStrategyFile( firstPage.GetPathName() );
AddStrategy( pStrategy );
AfxSwitchToStaticView( RUNTIME_CLASS(CSimuView) );
}
else
{
delete pStrategy;
}
}
void CStkUIApp::OnStrategySave()
{
// TODO: Add your command handler code here
// CStrategy * pStrategy = GetActiveStrategy();
// if( pStrategy )
// pStrategy->DoFileSave( );
}
void CStkUIApp::OnUpdateStrategySave(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
CStrategy * pActive = GetActiveStrategy( );
pCmdUI->Enable( FALSE ); // NULL != pActiveStrategy );
}
void CStkUIApp::OnStrategySaveAs()
{
// TODO: Add your command handler code here
CStrategy * pStrategy = GetActiveStrategy();
if( pStrategy )
{
CString newName = AfxGetFileTitleNoExt(pStrategy->GetPathName());
// check for dubious filename
int iBad = newName.FindOneOf(_T(" #%;/\\"));
if (iBad != -1)
newName.ReleaseBuffer(iBad);
// append the default suffix if there is one
newName += AfxGetStrategyFileExt( );
if( !AfxDoPromptFileName(newName, IDS_SAVEFILE,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_ENABLESIZING, FALSE ) )
return;
pStrategy->SetPathName(newName);
pStrategy->SetName( AfxGetFileTitleNoExt(newName) );
pStrategy->DoFileSave( );
AfxOnStrategyUpdated( pStrategy, FALSE );
}
}
void CStkUIApp::OnUpdateStrategySaveAs(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable( NULL != GetActiveStrategy( ) );
}
void CStkUIApp::OnStrategySaveall()
{
// TODO: Add your command handler code here
SaveAllModified();
}
void CStkUIApp::OnUpdateStrategySaveall(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable( NULL != GetFirstStrategyPosition() );
}
void CStkUIApp::OnStrategyClose()
{
// TODO: Add your command handler code here
CSimuView * pSimuView = AfxGetSimuView();
CStrategy * pActive = AfxGetActiveStrategy();
CStrategyView * pStrategyView = AfxGetStrategyView();
CCloseStrategyDlg dlg;
if( IDOK == dlg.DoModal() )
{
BOOL bOldValue = m_bAutoUpdateViews;
m_bAutoUpdateViews = FALSE;
POSITION pos = dlg.GetFirstCloseStrategyPosition( );
while( NULL != pos )
{
CStrategy * pStrategy = dlg.GetNextCloseStrategy( pos );
if( pSimuView && pStrategy == pActive && !pSimuView->CanChangeActiveStrategy() )
continue;
if( pStrategy == pActive && pStrategyView )
{
pStrategyView->SetActiveStrategy( NULL );
if( pSimuView )
pSimuView->OnActiveStrategyChanged( );
}
RemoveStrategy( pStrategy );
pStrategy->OnClose( );
delete pStrategy;
}
m_bAutoUpdateViews = bOldValue;
if( m_bAutoUpdateViews )
{
::SendMessage( AfxGetStrategyView()->GetSafeHwnd(), WM_USER_REMOVESTRATEGY, 0, 0 );
AfxGetStaticDoc()->UpdateAllViews( NULL, UPDATE_HINT_WIZARDVIEW, NULL );
}
}
}
void CStkUIApp::OnUpdateStrategyClose(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable( NULL != GetFirstStrategyPosition() );
}
void CStkUIApp::WinHelp(DWORD dwData, UINT nCmd)
{
// TODO: Add your specialized code here and/or call the base class
// CWinApp::WinHelp(dwData, nCmd);
}
void CStkUIApp::GetVersionNumber()
{
TCHAR szPath[MAX_PATH];
DWORD dwSize;
m_nVersion[0] = m_nVersion[1] = m_nVersion[2] = m_nVersion[3] = 0;
GetModuleFileName( NULL, szPath, MAX_PATH );
dwSize = GetFileVersionInfoSize( szPath, &dwSize );
if ( dwSize )
{
BYTE* pBuffer = new BYTE[ dwSize ];
if ( GetFileVersionInfo( szPath, NULL, dwSize, pBuffer ) )
{
VS_FIXEDFILEINFO* pTable;
if ( VerQueryValue( pBuffer, _T("\\"), (VOID**)&pTable, (UINT*)&dwSize ) )
{
m_nVersion[0] = (WORD)( pTable->dwFileVersionMS >> 16 );
m_nVersion[1] = (WORD)( pTable->dwFileVersionMS & 0xFFFF );
m_nVersion[2] = (WORD)( pTable->dwFileVersionLS >> 16 );
m_nVersion[3] = (WORD)( pTable->dwFileVersionLS & 0xFFFF );
}
}
delete [] pBuffer;
}
m_sVersion.Format( _T("%i.%i.%i.%i"),
m_nVersion[0], m_nVersion[1], m_nVersion[2], m_nVersion[3] );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -