// ClientPlusDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ClientPlus.h"
#include "ClientPlusDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CClientPlusDlg dialog
CClientPlusDlg::CClientPlusDlg(CWnd* pParent /*=NULL*/)
: CDialog(CClientPlusDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CClientPlusDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CClientPlusDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CClientPlusDlg)
DDX_Control(pDX, IDC_STATIC_IMAGE, m_Image);
DDX_Control(pDX, IDC_IPADDRESS1, m_IPCtrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CClientPlusDlg, CDialog)
//{{AFX_MSG_MAP(CClientPlusDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CClientPlusDlg message handlers
BOOL CClientPlusDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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
this->InitNetWork();
return TRUE; // return TRUE unless you set the focus to a control
}
void CClientPlusDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CClientPlusDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CClientPlusDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CClientPlusDlg::InitNetWork()
{
::AfxSocketInit();
this->m_ClientStreamSock.Create(0,SOCK_STREAM,FD_CONNECT|FD_READ|FD_WRITE);
this->m_ClientCtrlSock.Create(0,SOCK_STREAM,FD_CONNECT|FD_READ|FD_WRITE);
}
void CClientPlusDlg::OnButton1()
{
BYTE Field0,Field1,Field2,Field3;
int NonBlank=this->m_IPCtrl.GetAddress(Field0,Field1,Field2,Field3);
if (NonBlank!=4)
{
MessageBox("Please enter the complete IP Address!");
return;
}
m_strIPAddr.Format("%d.%d.%d.%d",Field0,Field1,Field2,Field3);
this->m_ClientStreamSock.Connect(m_strIPAddr,5555);
}
void CClientPlusDlg::ExcuteServerCommand(SERVER_CTRL_MSG msg)
{
if (strcmp(msg.strCommand,"Set Bitmap Info")==0)
{
memcpy(&m_InInfo,msg.strContent,sizeof(BITMAPINFO));
afxDump<<m_InInfo.bmiHeader.biHeight<<"\n"<<m_InInfo.bmiHeader.biBitCount<<"\n";
}
if (strcmp(msg.strCommand,"Set COMPVARS")==0)
{
memcpy(&this->m_CV,msg.strContent,sizeof(COMPVARS));
afxDump<<m_CV.cbSize<<"\n";
//m_CV.hic=ICDrawOpen(m_CV.fccType,m_CV.fccHandler,&m_InInfo.bmiHeader);
m_CV.hic=ICOpen(m_CV.fccType,m_CV.fccHandler,ICMODE_DECOMPRESS);
if (m_CV.hic==NULL)
{
afxDump<<m_CV.fccType<<"\n";
MessageBox("please install the proper decompressor!");
return;
}
else
{
// draw the compressed data
/* CPalette* pPalette=this->GetDC()->GetCurrentPalette();
int Result;
Result=ICDrawBegin(m_CV.hic,ICDRAW_HDC,NULL,this->GetSafeHwnd(),
this->GetDC()->GetSafeHdc(),0,0,200,200,&m_InInfo.bmiHeader,0,0,m_InInfo.bmiHeader.biWidth,
m_InInfo.bmiHeader.biHeight,m_CV.lDataRate,m_CV.lDataRate/m_CV.lKey);
if (Result==ICERR_UNSUPPORTED)
MessageBox("ICERR_UNSUPPORTED");
*/
//determin the ouput format
this->m_OutFormatSize=ICDecompressGetFormatSize(this->m_CV.hic,&this->m_InInfo.bmiHeader);
this->m_pOutInfo=(BITMAPINFO*)new BYTE[this->m_OutFormatSize];
ICDecompressGetFormat(this->m_CV.hic, &this->m_InInfo, this->m_pOutInfo);
afxDump<<"out format:"<<this->m_pOutInfo->bmiHeader.biHeight<<"\n";
this->m_OutBufSize=this->m_pOutInfo->bmiHeader.biSizeImage;
this->m_pOutBuf=new BYTE[this->m_OutBufSize];
memset(this->m_pOutBuf,0,this->m_OutBufSize);
afxDump<<"out buffer size="<<this->m_OutBufSize<<"\n";
ICDecompressBegin(this->m_CV.hic,&this->m_InInfo, this->m_pOutInfo);
}
}
}
void CClientPlusDlg::UnInitDecompressor()
{
if (m_CV.hic!=NULL)
{
delete[] this->m_pOutInfo;
delete[] this->m_pOutBuf;
// ICDrawEnd(m_CV.hic);
ICClose(m_CV.hic);
}
}
void CClientPlusDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
UnInitDecompressor();
}
void CClientPlusDlg::ShowImage(BYTE *Buf)
{
/* CFile theFile("d:\\ok.bmp",CFile::modeWrite|CFile::modeCreate);
BITMAPFILEHEADER FileHeader;
FileHeader.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
FileHeader.bfReserved1=FileHeader.bfReserved2=0;
FileHeader.bfSize=FileHeader.bfOffBits+this->m_OutBufSize;
FileHeader.bfType=0x4d42;
theFile.Write(&FileHeader,sizeof(BITMAPFILEHEADER));
theFile.Write(m_pOutInfo,sizeof(BITMAPINFOHEADER));
theFile.Write(Buf,m_OutBufSize);
theFile.Close();
*/
afxDump<<"k="<<Buf[150]<<"\n";
/* CDC* pDC=GetDC();
void* pData=NULL;
HBITMAP hBitmap=CreateDIBSection(0,this->m_pOutInfo,DIB_RGB_COLORS,&pData,NULL,0);
pData=Buf;
m_Image.SetBitmap(hBitmap);
CDC MemDC;
GdiFlush();
MemDC.CreateCompatibleDC(pDC);
MemDC.SelectObject(hBitmap);
pDC->BitBlt(0,0,m_pOutInfo->bmiHeader.biWidth,m_pOutInfo->bmiHeader.biHeight,&MemDC,0,0,SRCCOPY);
MemDC.DeleteDC();
*
没有合适的资源?快使用搜索试试~ 我知道了~
c++ socket编程tcp
共45个文件
h:13个
cpp:11个
dsw:2个
需积分: 16 8 下载量 61 浏览量
2010-03-09
10:04:41
上传
评论
收藏 57KB RAR 举报
温馨提示
tcp编程 vc++ 服务器和客户端都有 vc6.0
资源推荐
资源详情
资源评论
收起资源包目录
服务器客户端代码.rar (45个子文件)
35212875
server
StdAfx.cpp 212B
ServerPlus.clw 2KB
ServerCtrlSock.cpp 1015B
ServerPlus.opt 50KB
ServerPlus.h 1KB
ServerPlus.aps 20KB
Debug
ServerPlus.cpp 2KB
ServerPlus.plg 1KB
StdAfx.h 1KB
ServerPlusDlg.cpp 8KB
ServerStreamSock.h 1KB
ServerPlus.ncb 177KB
Resource.h 581B
ListenSock.h 1KB
ServerPlus.dsw 545B
ServerStreamSock.cpp 773B
res
ServerPlus.ico 1KB
ServerPlus.rc2 402B
ServerPlus.dsp 5KB
ServerPlusDlg.h 2KB
ServerCtrlSock.h 1KB
ServerPlus.rc 5KB
ListenSock.cpp 2KB
client
ClientPlus.opt 49KB
StdAfx.cpp 212B
ClientStreamSock.h 1KB
ClientCtrlSock.h 1KB
ClientPlus.ncb 129KB
ClientCtrlSock.cpp 1KB
ClientPlus.dsp 4KB
ClientPlus.clw 2KB
ClientPlus.h 1KB
StdAfx.h 1KB
ClientPlus.rc 5KB
ClientPlus.aps 21KB
ClientPlus.plg 2KB
ClientPlusDlg.cpp 8KB
Resource.h 825B
ClientPlusDlg.h 2KB
res
ClientPlus.ico 1KB
ClientPlus.rc2 402B
ClientPlus.dsw 543B
ClientStreamSock.cpp 2KB
ClientPlus.cpp 2KB
下载说明.htm 5KB
共 45 条
- 1
资源评论
贾晓凯2008
- 粉丝: 76
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功