Click here to Skip to main content
15,903,203 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionConstructor Exception Pin
hpjchobbes3-Jul-09 9:08
hpjchobbes3-Jul-09 9:08 
AnswerRe: Constructor Exception Pin
Stuart Dootson3-Jul-09 9:26
professionalStuart Dootson3-Jul-09 9:26 
QuestionIE automation [modified] Pin
eoloe3-Jul-09 8:08
eoloe3-Jul-09 8:08 
AnswerRe: IE automation Pin
Stuart Dootson3-Jul-09 8:47
professionalStuart Dootson3-Jul-09 8:47 
Questionsimple template question Pin
minkowski3-Jul-09 6:53
minkowski3-Jul-09 6:53 
QuestionRe: simple template question Pin
CPallini3-Jul-09 7:56
mveCPallini3-Jul-09 7:56 
AnswerRe: simple template question Pin
Stuart Dootson3-Jul-09 8:39
professionalStuart Dootson3-Jul-09 8:39 
QuestionSockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 5:07
Manmohan293-Jul-09 5:07 
I' m a learner in visual c++ developing environment.
Here's m problem . . .
------------------------>

I am using a tutorial to make a simple program to send messages to another program using CAsyncSocket class.
I wrote complete application's code as given in the example(in visual studio 6 IDE). I compiled the application and the program run successfully without any errors. Smile | :)
Then I compiled same program in visual studio 2008(Professional Edition) and It also run as expected. Smile | :)

But When I wrote the same program from scratch in visual studio 2008 it showed some misbehavior while receiving data.Confused | :confused:
The main problem with the code given below is that it sends data(as shown in the code below) but on the receiving application only first byte is received(When project is written from scratch in VS 2008 Pro).
But if application is written in Visual studio 6 then there is no such problem.
I' m totally confused what to do? where is the problem actually residing? Please send any suggestion.

-->I have VC++ 2008 FeaturePack installed.
-->Create an MFC Application named "Sockets" and link MFC as statically.
-->then use files below to make the application.
The individual codes of my complete application's source files is given here:-

//---------------------------------------------------------------------------------------------------
// MySocket.h
#pragma once

// CMySocket command target

class CMySocket : public CAsyncSocket
{
public:
	CMySocket();
	virtual ~CMySocket();
private:
	CDialog* m_pWnd;
public:
	void SetParent(CDialog* pWnd);
protected:
	virtual void OnAccept(int nErrorCode);
	virtual void OnConnect(int nErrorCode);
	virtual void OnClose(int nErrorCode);
	virtual void OnReceive(int nErrorCode);
	virtual void OnSend(int nErrorCode);
};
//---------------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------------
// MySocket.cpp : implementation file
//

#include "stdafx.h"
#include "Sockets.h"
#include "MySocket.h"

#include "SocketsDlg.h"


// CMySocket

CMySocket::CMySocket()
: m_pWnd(NULL)
{
}

CMySocket::~CMySocket()
{
}


// CMySocket member functions

void CMySocket::SetParent(CDialog* pWnd)
{
	m_pWnd = pWnd;
}

void CMySocket::OnAccept(int nErrorCode)
{
	if(nErrorCode == 0)
		((CSocketsDlg*)m_pWnd)->OnAccept();
}

void CMySocket::OnConnect(int nErrorCode)
{
	if(nErrorCode == 0)
		((CSocketsDlg*)m_pWnd)->OnConnect();
}

void CMySocket::OnClose(int nErrorCode)
{
	if(nErrorCode == 0)
		((CSocketsDlg*)m_pWnd)->OnClose();
}

void CMySocket::OnReceive(int nErrorCode)
{
	if(nErrorCode == 0)
		((CSocketsDlg*)m_pWnd)->OnReceive();
}

void CMySocket::OnSend(int nErrorCode)
{
	if(nErrorCode == 0)
		((CSocketsDlg*)m_pWnd)->OnSend();
}

//---------------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------------

// SocketsDlg.h : header file
//

#pragma once
#include "afxwin.h"
#include "mysocket.h"


// CSocketsDlg dialog
class CSocketsDlg : public CDialog
{
// Construction
public:
	CSocketsDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_SOCKETS_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	CButton m_ctlConnect;
	CString m_strMessage;
	CString m_strName;
	int m_iPort;
	CListBox m_ctlRecvd;
	CListBox m_ctlSent;
	int m_iType;
	afx_msg void OnRType();
private:
	CMySocket m_sListenSocket;
	CMySocket m_sConnectSocket;
public:
	afx_msg void OnBnClickedBconnect();
	void OnAccept(void);
	void OnConnect(void);
	void OnSend(void);
	void OnReceive(void);
	void OnClose(void);
	afx_msg void OnBnClickedBsend();
	afx_msg void OnBnClickedBclose();
};

//---------------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------------

// SocketsDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Sockets.h"
#include "SocketsDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// CSocketsDlg dialog




CSocketsDlg::CSocketsDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSocketsDlg::IDD, pParent)
	, m_strMessage(_T(""))
	, m_strName(_T(""))
	, m_iPort(0)
	, m_iType(0)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CSocketsDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_BCONNECT, m_ctlConnect);
	DDX_Text(pDX, IDC_EMSG, m_strMessage);
	DDX_Text(pDX, IDC_ESERVNAME, m_strName);
	DDX_Text(pDX, IDC_ESERVPORT, m_iPort);
	DDX_Control(pDX, IDC_LRECVD, m_ctlRecvd);
	DDX_Control(pDX, IDC_LSENT, m_ctlSent);
	DDX_Radio(pDX, IDC_RCLIENT, m_iType);
}

BEGIN_MESSAGE_MAP(CSocketsDlg, CDialog)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_RCLIENT, &CSocketsDlg::OnRType)
	ON_BN_CLICKED(IDC_BCONNECT, &CSocketsDlg::OnBnClickedBconnect)
	ON_BN_CLICKED(IDC_BSEND, &CSocketsDlg::OnBnClickedBsend)
	ON_BN_CLICKED(IDC_BCLOSE, &CSocketsDlg::OnBnClickedBclose)
END_MESSAGE_MAP()


// CSocketsDlg message handlers

BOOL CSocketsDlg::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)
	{
		BOOL bNameValid;
		CString strAboutMenu;
		bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
		ASSERT(bNameValid);
		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
	// Initialize control variables
	m_iType = 0;
	m_strName = "loopback";
	m_iPort = 4000;
	// Update the controls
	UpdateData(FALSE);
	m_sConnectSocket.SetParent(this);
	m_sListenSocket.SetParent(this);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CSocketsDlg::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 CSocketsDlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<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 function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CSocketsDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}


void CSocketsDlg::OnRType()
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(m_iType == 0)
		m_ctlConnect.SetWindowTextW(_T("Connect"));
	else
		m_ctlConnect.SetWindowTextW(_T("Listen"));
}

void CSocketsDlg::OnBnClickedBconnect()
{
	// TODO: Add your control notification handler code here
	// Sync controls with variables
	UpdateData(TRUE);
	// Disable connection and type controls
	GetDlgItem(IDC_BCONNECT)->EnableWindow(FALSE);
	GetDlgItem(IDC_ESERVNAME)->EnableWindow(FALSE);
	GetDlgItem(IDC_ESERVPORT)->EnableWindow(FALSE);
	GetDlgItem(IDC_STATICNAME)->EnableWindow(FALSE);
	GetDlgItem(IDC_STATICPORT)->EnableWindow(FALSE);
	GetDlgItem(IDC_RCLIENT)->EnableWindow(FALSE);
	GetDlgItem(IDC_RSERVER)->EnableWindow(FALSE);
	GetDlgItem(IDC_STATICTYPE)->EnableWindow(FALSE);
	// Are we running as client as or server
	if(m_iType == 0)
	{
		// CLient, create default socket
		m_sConnectSocket.Create();
		m_sConnectSocket.Connect(m_strName, m_iPort);
	}
	else
	{
		// Server, create a socket bound to a specific port
		m_sListenSocket.Create(m_iPort);
		m_sListenSocket.Listen();
	}
}

void CSocketsDlg::OnAccept(void)
{
	// Accept the connection request
	m_sListenSocket.Accept(m_sConnectSocket);
	// Enable text and message controls
	GetDlgItem(IDC_EMSG)->EnableWindow(TRUE);
	GetDlgItem(IDC_BSEND)->EnableWindow(TRUE);
	GetDlgItem(IDC_STATICMSG)->EnableWindow(TRUE);
}

void CSocketsDlg::OnConnect(void)
{
	// Enable message and text controls
	GetDlgItem(IDC_EMSG)->EnableWindow(TRUE);
	GetDlgItem(IDC_BSEND)->EnableWindow(TRUE);
	GetDlgItem(IDC_STATICMSG)->EnableWindow(TRUE);
	GetDlgItem(IDC_BCLOSE)->EnableWindow(TRUE);
}

void CSocketsDlg::OnSend(void)
{
}

void CSocketsDlg::OnReceive(void)
{
	char *pBuf = new char[1025];
	int iBufSize = 1024;
	int iRcvd;
	CString strRecvd;

	// Receive the message
	iRcvd = m_sConnectSocket.Receive(pBuf, iBufSize);
	if(iRcvd == SOCKET_ERROR)
	{
	}
	else
	{
		// Truncate the end of message
		pBuf[iRcvd] = NULL;
		strRecvd = pBuf;
		m_ctlRecvd.AddString(strRecvd);
		UpdateData(FALSE);
	}
}

void CSocketsDlg::OnClose(void)
{
	// Close connected socket
	m_sConnectSocket.Close();
	// Disable message sending controls
	GetDlgItem(IDC_EMSG)->EnableWindow(FALSE);
	GetDlgItem(IDC_BSEND)->EnableWindow(FALSE);
	GetDlgItem(IDC_STATICMSG)->EnableWindow(FALSE);
	GetDlgItem(IDC_BCLOSE)->EnableWindow(FALSE);
	// Are we running in client mode
	if(m_iType == 0)
	{
		// Enable connection controls
		GetDlgItem(IDC_BCONNECT)->EnableWindow(TRUE);
		GetDlgItem(IDC_ESERVNAME)->EnableWindow(TRUE);
		GetDlgItem(IDC_ESERVPORT)->EnableWindow(TRUE);
		GetDlgItem(IDC_STATICNAME)->EnableWindow(TRUE);
		GetDlgItem(IDC_STATICPORT)->EnableWindow(TRUE);
		GetDlgItem(IDC_RCLIENT)->EnableWindow(TRUE);
		GetDlgItem(IDC_RSERVER)->EnableWindow(TRUE);
		GetDlgItem(IDC_STATICTYPE)->EnableWindow(TRUE);
	}
}

void CSocketsDlg::OnBnClickedBsend()
{
	// TODO: Add your control notification handler code here
	int iLen;
	int iSent;
	// Sync variables with controls
	UpdateData(TRUE);
	// Is there a message to be sent
	if(m_strMessage != "")
	{
		// Get lenght of message
		iLen = m_strMessage.GetLength();
		iSent = m_sConnectSocket.Send(LPCTSTR(m_strMessage), iLen);
		if(iSent == SOCKET_ERROR)
		{
		}
		else
		{
			m_ctlSent.AddString(m_strMessage);
			UpdateData(FALSE);
		}
	}
}

void CSocketsDlg::OnBnClickedBclose()
{
	// TODO: Add your control notification handler code here
	OnClose();
}

//---------------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------------
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Sockets.rc
//
#define IDM_ABOUTBOX                    0x0010
#define IDD_ABOUTBOX                    100
#define IDS_ABOUTBOX                    101
#define IDD_SOCKETS_DIALOG              102
#define IDP_SOCKETS_INIT_FAILED         103
#define IDR_MAINFRAME                   128
#define IDC_BCONNECT                    1000
#define IDC_BCLOSE                      1001
#define IDC_BSEND                       1002
#define IDC_EMSG                        1003
#define IDC_ESERVNAME                   1004
#define IDC_ESERVPORT                   1005
#define IDC_LSENT                       1006
#define IDC_LRECVD                      1007
#define IDC_RCLIENT                     1008
#define IDC_RSERVER                     1009
#define IDC_STATICNAME                  1010
#define IDC_STATICPORT                  1011
#define IDC_STATICMSG                   1012
#define IDC_STATICTYPE                  1013
#define IDC_STATICSENT                  1014

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        129
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1015
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

//---------------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------------
// Sockets Resoure Script
// Microsoft Visual C++ generated resource script.
// Sockets.rc
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE 
BEGIN
    "#ifndef APSTUDIO_INVOKED\r\n"
    "#include ""targetver.h""\r\n"
    "#endif\r\n"
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE 
BEGIN
    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
    "#define _AFX_NO_OLE_RESOURCES\r\n"
    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
    "\r\n"
    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
    "LANGUAGE 9, 1\r\n"
    "#pragma code_page(1252)\r\n"
    "#include ""res\\Sockets.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
    "#include ""afxres.rc""     // Standard components\r\n"
    "#endif\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME           ICON                    "res\\Sockets.ico"

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About Sockets"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
    ICON            IDR_MAINFRAME,IDC_STATIC,14,14,21,20
    LTEXT           "Sockets, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX
    LTEXT           "Copyright (C) 2009",IDC_STATIC,42,26,114,8
    DEFPUSHBUTTON   "OK",IDOK,113,41,50,14,WS_GROUP
END

IDD_SOCKETS_DIALOG DIALOGEX 0, 0, 280, 198
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Sockets"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
    PUSHBUTTON      "Connect",IDC_BCONNECT,223,16,50,14
    PUSHBUTTON      "Close",IDC_BCLOSE,223,35,50,14,WS_DISABLED
    PUSHBUTTON      "Send",IDC_BSEND,223,58,50,14,WS_DISABLED
    EDITTEXT        IDC_EMSG,61,57,156,14,ES_AUTOHSCROLL | WS_DISABLED
    LTEXT           "Server Name :",IDC_STATICNAME,64,15,47,8
    LTEXT           "Server Port :",IDC_STATICPORT,69,36,42,8
    LTEXT           "Message :",IDC_STATICMSG,22,59,34,8,WS_DISABLED
    EDITTEXT        IDC_ESERVNAME,113,14,104,14,ES_AUTOHSCROLL
    EDITTEXT        IDC_ESERVPORT,113,33,52,14,ES_AUTOHSCROLL
    LTEXT           "Sent :",IDC_STATIC,36,81,20,8
    LTEXT           "Received :",IDC_STATIC,21,135,35,8
    LISTBOX         IDC_LSENT,61,79,212,55,LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL
    LISTBOX         IDC_LRECVD,61,136,212,55,LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL
    GROUPBOX        "Socket Type",IDC_STATICTYPE,7,7,51,47
    CONTROL         "Client",IDC_RCLIENT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,16,23,34,10
    CONTROL         "Server",IDC_RSERVER,"Button",BS_AUTORADIOBUTTON,15,38,37,10
END


/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904e4"
        BEGIN
            VALUE "CompanyName", "TODO: <Company name>"
            VALUE "FileDescription", "TODO: <File description>"
            VALUE "FileVersion", "1.0.0.1"
            VALUE "InternalName", "Sockets.exe"
            VALUE "LegalCopyright", "TODO: (c) <Company name>.  All rights reserved."
            VALUE "OriginalFilename", "Sockets.exe"
            VALUE "ProductName", "TODO: <Product name>"
            VALUE "ProductVersion", "1.0.0.1"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1252
    END
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO 
BEGIN
    IDD_ABOUTBOX, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 163
        TOPMARGIN, 7
        BOTTOMMARGIN, 55
    END

    IDD_SOCKETS_DIALOG, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 273
        TOPMARGIN, 7
        BOTTOMMARGIN, 191
    END
END
#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// String Table
//

STRINGTABLE 
BEGIN
    IDS_ABOUTBOX            "&About Sockets..."
    IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed."
END

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1252)
#include "res\Sockets.rc2"  // non-Microsoft Visual C++ edited resources
#include "afxres.rc"     // Standard components
#endif

/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED


//---------------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------------

// Sockets.h : main header file for the PROJECT_NAME application
//

#pragma once

#ifndef __AFXWIN_H__
	#error "include 'stdafx.h' before including this file for PCH"
#endif

#include "resource.h"		// main symbols


// CSocketsApp:
// See Sockets.cpp for the implementation of this class
//

class CSocketsApp : public CWinAppEx
{
public:
	CSocketsApp();

// Overrides
	public:
	virtual BOOL InitInstance();

// Implementation

	DECLARE_MESSAGE_MAP()
};

extern CSocketsApp theApp;
//---------------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------------

// Sockets.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "Sockets.h"
#include "SocketsDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CSocketsApp

BEGIN_MESSAGE_MAP(CSocketsApp, CWinAppEx)
	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()


// CSocketsApp construction

CSocketsApp::CSocketsApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}


// The one and only CSocketsApp object

CSocketsApp theApp;


// CSocketsApp initialization

BOOL CSocketsApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinAppEx::InitInstance();

	if (!AfxSocketInit())
	{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	CSocketsDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

//---------------------------------------------------------------------------------------------------


Manmohan Bishnoi

AnswerRe: Sockets trouble in Visual Studio 2008 Pin
«_Superman_»3-Jul-09 5:10
professional«_Superman_»3-Jul-09 5:10 
AnswerRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 5:31
professionalStuart Dootson3-Jul-09 5:31 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 9:10
Manmohan293-Jul-09 9:10 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 9:21
professionalStuart Dootson3-Jul-09 9:21 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 9:39
Manmohan293-Jul-09 9:39 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 9:53
professionalStuart Dootson3-Jul-09 9:53 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 10:21
Manmohan293-Jul-09 10:21 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 10:28
professionalStuart Dootson3-Jul-09 10:28 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Stuart Dootson3-Jul-09 10:31
professionalStuart Dootson3-Jul-09 10:31 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
Manmohan293-Jul-09 10:48
Manmohan293-Jul-09 10:48 
GeneralRe: Sockets trouble in Visual Studio 2008 Pin
SquiZZlo31-Aug-09 14:48
SquiZZlo31-Aug-09 14:48 
AnswerRe: Sockets trouble in Visual Studio 2008 Pin
SquiZZlo1-Sep-09 5:11
SquiZZlo1-Sep-09 5:11 
QuestionMake print dialog for CHtmlView modal? Pin
Keith Worden3-Jul-09 4:58
Keith Worden3-Jul-09 4:58 
Questionhow to show a .ico file at the window title bar Pin
Rajib Podder3-Jul-09 4:35
Rajib Podder3-Jul-09 4:35 
AnswerRe: how to show a .ico file at the window title bar Pin
Roger Stoltz3-Jul-09 5:02
Roger Stoltz3-Jul-09 5:02 
GeneralRe: how to show a .ico file at the window title bar Pin
Rajib Podder5-Jul-09 17:00
Rajib Podder5-Jul-09 17:00 
GeneralRe: how to show a .ico file at the window title bar Pin
Roger Stoltz5-Jul-09 20:10
Roger Stoltz5-Jul-09 20:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.