📄 recvdlg.cpp
字号:
// RecvDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Recv.h"
#include "RecvDlg.h"
/////////////////////////////////////////////////////////////////////////////
// CRecvDlg dialog
CRecvDlg::CRecvDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRecvDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRecvDlg)
m_strText = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
CRecvDlg::~CRecvDlg()
{
// Unmap view of file.
if(m_hMapObject){
if (!UnmapViewOfFile(m_pszMapView))
AfxMessageBox("Unable to unmap view of file");
// Close the shared memory file.
CloseHandle(m_hMapObject);
}
}
void CRecvDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRecvDlg)
DDX_Text(pDX, IDC_DATA_TEXT, m_strText);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRecvDlg, CDialog)
//{{AFX_MSG_MAP(CRecvDlg)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRecvDlg message handlers
BOOL CRecvDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// Open memory mapped file.
m_hMapObject=OpenFileMapping(FILE_MAP_READ,FALSE,_TEXT("shared_memory"));
if(!m_hMapObject){
AfxMessageBox("Can't open shared memory file,please run 'Send' first.");
SendMessage(WM_CLOSE);
return FALSE;
}
// Get pointer to shared data.
m_pszMapView=(LPSTR)MapViewOfFile
(m_hMapObject,FILE_MAP_READ, 0, 0,0);
if(!m_pszMapView){
AfxMessageBox("Can't map view of shared memory file.");
return FALSE;
}
SetTimer(0x10,900,NULL);
return TRUE; // return TRUE unless you set the focus to a control.
}
void CRecvDlg::OnTimer(UINT nIDEvent)
{
m_strText=m_pszMapView;
UpdateData(FALSE);
CDialog::OnTimer(nIDEvent);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -