📄 setcommpage.cpp
字号:
// SetCommPage.cpp : implementation file
//
#include "stdafx.h"
#include "KSComDlg.h"
#include "SetCommPage.h"
#include "ExampleDlg.h"
#include "Help_VerCtl.h"
#include <winsock.h>
#include <wsipx.h>
#include <wsnwlink.h>
#include <stdio.h>
WSADATA WSAData;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSetCommPage property page
IMPLEMENT_DYNCREATE(CSetCommPage, CPropertyPage)
CSetCommPage::CSetCommPage() : CPropertyPage(CSetCommPage::IDD)
{
//{{AFX_DATA_INIT(CSetCommPage)
m_EditDns = _T("kingseechina.vicp.net");
//}}AFX_DATA_INIT
}
CSetCommPage::~CSetCommPage()
{
}
void CSetCommPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSetCommPage)
DDX_Control(pDX, IDC_IPADDRESS1, m_IPAddrCtl);
DDX_Control(pDX, IDC_BUTTON_GETIP, m_GetIpB);
DDX_Text(pDX, IDC_EDIT_DNS, m_EditDns);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSetCommPage, CPropertyPage)
//{{AFX_MSG_MAP(CSetCommPage)
ON_BN_CLICKED(IDOK, OnSetExit)
ON_WM_CLOSE()
ON_WM_SIZE()
ON_BN_CLICKED(IDC_BUTTON_GETIP, OnButtonGetip)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSetCommPage message handlers
void CSetCommPage::OnSetExit()
{
CPropertyPage::OnOK();
}
void CSetCommPage::OnClose()
{
// CKSComDlgDlg DlgShow;
}
BOOL CSetCommPage::OnInitDialog()
{
// CRect crect;
CPropertyPage::OnInitDialog();
HICON hIcon1 = AfxGetApp()->LoadIcon(IDI_ICON7);
HCURSOR hHand = AfxGetApp()->LoadCursor(IDC_CURSOR1);
m_GetIpB.m_hCursor = hHand;
m_GetIpB.m_hIcon_Enable = hIcon1;
m_GetIpB.m_hIcon_Active = hIcon1;
m_GetIpB.m_IconSize = CSize(32,32);
m_IPAddrCtl.SetAddress(0x00,0x00,0x00,0x00);
/* cExDlg = (CExampleDlg*)GetDlgItem(IDD_EXAMPLEDLG);
cExDlg->GetWindowRect(&crect);
ScreenToClient( &crect );
int width = crect.right - crect.left;
int height = crect.bottom - crect.top;
cExDlg->m_Prosheet.MoveWindow(0,0,width,height);*/
return TRUE;
}
void CSetCommPage::OnSize(UINT nType, int cx, int cy)
{
CPropertyPage::OnSize(nType, cx, cy);
/* CExampleDlg dlg;
CRect rect;
dlg.GetWindowRect(&rect);
//ScreenToClient( &rect );
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
MoveWindow(0,0,width,height);
//m_Prosheet.MoveWindow(rect);*/
}
LRESULT CSetCommPage::OnWizardBack()
{
return CPropertyPage::OnWizardBack();
}
LRESULT CSetCommPage::OnWizardNext()
{
return CPropertyPage::OnWizardNext();
}
BOOL CSetCommPage::OnSetActive()
{
return CPropertyPage::OnSetActive();
}
void CSetCommPage::OnButtonGetip()
{
struct hostent * pHost;
int WSA_return;
WSA_return = WSAStartup(0x0101,&WSAData);
if(WSA_return == 0)
{
UpdateData(TRUE);
m_GetIpB.EnableWindow(FALSE);
pHost = gethostbyname(m_EditDns);
m_GetIpB.EnableWindow(TRUE);
//--------------------------------------------------------------------
/*for(int i = 0; pHost!= NULL && pHost->h_addr_list[i]!= NULL; i++ )
{
LPCSTR psz=inet_ntoa (*(struct in_addr *)pHost->h_addr_list[i]);
m_IpAddr = psz;
}*/
CString str = "";
if(pHost != NULL)
{
LPCSTR psz=inet_ntoa (*(struct in_addr *)pHost->h_addr_list[0]);
str = psz;
m_IPAddrCtl.SetAddress(pHost->h_addr_list[0][0], pHost->h_addr_list[0][1],
pHost->h_addr_list[0][2], pHost->h_addr_list[0][3]);
str = "\r\nServer IP Addr:" + str ;
//========================================================================
}
else
{
str = "\r\nIt is Failing that Get Server IP Addr ";
AfxMessageBox("获得服务器IP地址失败!");
}
//...
int nLength;
nLength = str.GetLength();
LPSTR lpFrame = (LPSTR)LocalAlloc(LPTR, nLength + 1);
if (NULL == lpFrame)// Out of memory
{
UpdateData(FALSE);
return ;
}
MoveMemory(lpFrame, str, nLength);
lpFrame[nLength] = 0x00; // 0
GetParent()->SendMessage(WM_HELP_VERVIEW,
WPARAM(nLength), LPARAM(lpFrame));
//...
UpdateData(FALSE);
}
WSACleanup();
}
BOOL CSetCommPage::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
return CWnd::CreateEx(0, TOOLBARCLASSNAME,
NULL, WS_CHILD, 0,0,0,0,
pParentWnd->GetSafeHwnd(), 0, NULL);
//return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -