📄 miniservermfcdlg.cpp
字号:
// MiniServerMFCDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MiniServerMFC.h"
#include "MiniServerMFCDlg.h"
#include "trace.h"
#include "MySocket.h"
#include "SockCommon.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CMiniServerMFCDlg dialog
CMiniServerMFCDlg::CMiniServerMFCDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMiniServerMFCDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMiniServerMFCDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CMiniServerMFCDlg, CDialog)
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
ON_WM_SIZE()
#endif
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_BUTTON1, &CMiniServerMFCDlg::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, &CMiniServerMFCDlg::OnBnClickedButton2)
END_MESSAGE_MAP()
// CMiniServerMFCDlg message handlers
BOOL CMiniServerMFCDlg::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
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
void CMiniServerMFCDlg::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
{
if (AfxIsDRAEnabled())
{
DRA::RelayoutDialog(
AfxGetResourceHandle(),
this->m_hWnd,
DRA::GetDisplayMode() != DRA::Portrait ?
MAKEINTRESOURCE(IDD_MINISERVERMFC_DIALOG_WIDE) :
MAKEINTRESOURCE(IDD_MINISERVERMFC_DIALOG));
}
}
#endif
SOCKET listenSock;
void CMiniServerMFCDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CMySocket sock;
listenSock = sock.initSock();
log("main function");
//unsigned long myID;
AfxBeginThread(ServerListenThread,(LPVOID)&listenSock,THREAD_PRIORITY_NORMAL);
this->GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
this->GetDlgItem(IDC_BUTTON2)->EnableWindow(TRUE);
}
void CMiniServerMFCDlg::OnBnClickedButton2()
{
// TODO: Add your control notification handler code here
//closesocket( listenSock );
this->GetDlgItem(IDC_BUTTON1)->EnableWindow(true);
this->GetDlgItem(IDC_BUTTON2)->EnableWindow(false);
exit(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -