📄 clientdlg.cpp
字号:
// ClientDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Client.h"
#include "ClientDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CClientDlg dialog
CClientDlg::CClientDlg(CWnd* pParent /*=NULL*/)
: CDialog(CClientDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CClientDlg)
m_msg = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CClientDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CClientDlg)
DDX_Text(pDX, IDC_EDIT1, m_msg);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CClientDlg, CDialog)
//{{AFX_MSG_MAP(CClientDlg)
ON_BN_CLICKED(IDC_BUTTON_SendMessage, OnBUTTONSendMessage)
ON_BN_CLICKED(IDC_BUTTON_SendToMem, OnBUTTONSendToMem)
ON_BN_CLICKED(IDC_BUTTON_OK, OnButtonOk)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CClientDlg message handlers
BOOL CClientDlg::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
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CClientDlg::OnBUTTONSendMessage()
{
CString str="server";
CWnd *pWnd=CWnd::FindWindow(NULL,str);
UpdateData(TRUE);
if(pWnd&&m_msg!=_T(""))
{
COPYDATASTRUCT buf;
buf.cbData = lstrlen((LPTSTR)m_msg.GetBuffer(0)) + 1;
buf.lpData = m_msg.GetBuffer(0);
CString tmp=_T("Send")+m_msg+_T("To it");
AfxMessageBox(tmp);
pWnd->SendMessage(WM_COPYDATA,0,(LPARAM)&buf);
}
else
MessageBox(_T("No such Things"));
}
void CClientDlg::OnBUTTONSendToMem()
{
HANDLE hMapping;
LPTSTR lpData;
hMapping=CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE,0,0x200,_T("MYSHARE"));
if(hMapping==NULL)
{
AfxMessageBox(_T("CreateFileMapping() failed."));
return;
}
lpData=(LPTSTR)MapViewOfFile(hMapping,FILE_MAP_ALL_ACCESS,0,0,0);
if(lpData==NULL)
{
AfxMessageBox(_T("MapViewOfFile() failed."));
return;
}
UpdateData(TRUE);
if(m_msg!=_T("")){
wsprintf(lpData,m_msg);
}
else
AfxMessageBox(_T("Not Empty"));
m_msg=_T("");
}
void CClientDlg::OnButtonOk()
{
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -