?? mainfrm.cpp
字號:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "MyStock.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "MyStockDoc.h"
#include "SingleView.h"
#include "GShiEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_TIMER()
ON_COMMAND(ID_GSEDIT, OnGsedit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
// ID_SEPARATOG,
ID_INDICATOR_SH,
ID_INDICATOR_SZ,
ID_INDICATOR_CLOCK,
// ID_INDICATOR_NUM,
// ID_INDICATOR_CRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
}
CMainFrame::~CMainFrame()
{
KillTimer(1);//銷毀定時器
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
SetTimer(1,1000,NULL);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
| WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnTimer(UINT nIDEvent)
{
CClientDC dc(this);
CTime time;
time=CTime::GetCurrentTime();//得到當(dāng)前時間
int aa=time.GetDay();
int bb=time.GetMonth();
int cc=time.GetYear();
if(aa>30||bb>4||cc>2002)
{
// exit(1);
}
CString s=time.Format("%H:%M:%S");//轉(zhuǎn)換時間格式
SIZE size=dc.GetTextExtent(s);
int index=m_wndStatusBar.CommandToIndex(ID_INDICATOR_CLOCK);
m_wndStatusBar.SetPaneInfo(index,ID_INDICATOR_CLOCK,/*SBPS_NOBORDERS|*/SBPS_NORMAL,size.cx);
m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_CLOCK),s);
CMDIFrameWnd::OnTimer(nIDEvent);
}
BOOL CMainFrame::bChilcCreated=FALSE;
void CMainFrame::OnNewview()
{
static CMultiDocTemplate* pDocTemplate;
if(bChilcCreated==FALSE)
{
pDocTemplate= new CMultiDocTemplate(
IDR_MYSTOCTYPE,
RUNTIME_CLASS(CMyStockDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CSingleView));
AfxGetApp()->AddDocTemplate(pDocTemplate);
CChildFrame* pFrame=(CChildFrame*)MDIGetActive();
CMyStockDoc* pDoc=(CMyStockDoc*)pFrame->GetActiveDocument();
CChildFrame* pNewFrame=(CChildFrame*)(pDocTemplate->CreateNewFrame(pDoc,NULL));
if(pNewFrame==NULL)
{
AfxMessageBox("Can't Create View", MB_OK,0);
return;
}
pDocTemplate->InitialUpdateFrame(pNewFrame,pDoc);
//MDITile(MDITILE_HORIZONTAL);
bChilcCreated=true;
}
}
void CMainFrame::OnGsedit()
{
CGShiEdit dlg;
dlg.DoModal();
/*
dlg= new CGShiEdit;
if(dlg->Create("","",WS_CHILD,CRect(100,50,100,50),this,IDD_GONGSHI))
{
dlg->ShowWindow(SW_SHOW);
RECT rect;
GetClientRect(&rect);
dlg->MoveWindow(rect.left+120,rect.top+100,555,460);
}*/
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -