📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "afxdb.h"
#include "LaneSoft.h"
#include "MainFrm.h"
#include "NetComThread.h"
//#include "ListenSocket.h"
#include "NetSocket.h"
#include "datawritetread.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
extern UINT Com_Net_Start(LPVOID param);
extern CMainFrame * m_pMainFrame;
extern BOOL m_BClose;
extern BOOL m_BCloseTime;
extern BOOL m_BCloseTxj ;
extern BOOL m_BCloseTxjTime;
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_GETMINMAXINFO()
ON_WM_TIMER()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
m_bFullScreen = FALSE;
m_pMainFrame = this;
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::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);
GetWindowPlacement(&m_OldWndpl);
CRect WindowRect,ClientRect;
GetWindowRect(&WindowRect);
RepositionBars(0,0xffff,AFX_IDW_PANE_FIRST,reposQuery,&ClientRect);
ClientToScreen(&ClientRect);
int nFullWidth = GetSystemMetrics(SM_CXSCREEN);
int nFullHeight = GetSystemMetrics(SM_CYSCREEN);
m_FullScreenRect.left = WindowRect.left - ClientRect.left;
m_FullScreenRect.top = WindowRect.top - ClientRect.top;
m_FullScreenRect.right = WindowRect.right - ClientRect.right + nFullWidth;
m_FullScreenRect.bottom = WindowRect.bottom - ClientRect.bottom + nFullHeight;
m_bFullScreen = TRUE;
WINDOWPLACEMENT wndpl;
wndpl.length = sizeof(WINDOWPLACEMENT);
wndpl.flags = 0;
wndpl.showCmd = SW_SHOWNORMAL;
wndpl.rcNormalPosition = m_FullScreenRect;
SetWindowPlacement(&wndpl);
m_pNetManger = (CNetComThread *)AfxBeginThread(RUNTIME_CLASS(CNetComThread),THREAD_PRIORITY_BELOW_NORMAL);
m_pDatawrite = (CDatawriteTread *)AfxBeginThread(RUNTIME_CLASS(CDatawriteTread),THREAD_PRIORITY_BELOW_NORMAL);
// AfxBeginThread( Com_Net_Start,NULL,THREAD_PRIORITY_BELOW_NORMAL);
SetTimer(IDT_SECOND_PLUSE,1000,NULL);
SetTimer(IDT_THREE_PLUSE,3000,NULL);//hm
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
// TODO: Add your message handler code here and/or call default
if(m_bFullScreen)
{
lpMMI->ptMaxSize.x = m_FullScreenRect.Width();
lpMMI->ptMaxPosition.y = m_FullScreenRect.Height();
lpMMI->ptMaxPosition.x = m_FullScreenRect.left;
lpMMI->ptMaxPosition.y = m_FullScreenRect.top;
lpMMI->ptMaxTrackSize.x = m_FullScreenRect.Width();
lpMMI->ptMaxTrackSize.y = m_FullScreenRect.Height();
}
CFrameWnd::OnGetMinMaxInfo(lpMMI);
}
void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(nIDEvent == IDT_SECOND_PLUSE)
{
if(!m_BCloseTime)
{
m_BCloseTime = true ;//hyh 2001.09.26 原在下
m_pNetManger->PostThreadMessage(WM_TIME_COLOCK,0,0);
}
if (m_BClose)
{
// m_pDatawrite->PostThreadMessage(WM_TIMER_CLK,0,0); hm 2001.10.22 封住向服务器发数据
}
}
else
if (nIDEvent == IDT_THREE_PLUSE)
{
if (!m_BCloseTxjTime)
{
m_BCloseTxjTime = true ;//hyh 2001.09.26 原在下
m_pNetManger->PostThreadMessage(WM_TIMETXJ_COLOCK,0,0);
}
}
CFrameWnd::OnTimer(nIDEvent);
}
void CMainFrame::OnDestroy()
{
m_pNetManger->PostThreadMessage(WM_QUIT,0,0);
m_pDatawrite->PostThreadMessage(WM_QUIT,0,0);
Sleep(1500);
CFrameWnd::OnDestroy();
KillTimer(IDT_SECOND_PLUSE);
KillTimer(IDT_THREE_PLUSE);
// TODO: Add your message handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -