Click here to Skip to main content
15,886,788 members
Articles / Desktop Programming / MFC

How to create a chat client using a set of communication classes

,
Rate me:
Please Sign up or sign in to vote.
3.71/5 (6 votes)
25 Aug 2003Apache4 min read 79.5K   2.5K   37  
A pair of classes (no mfc) that can be used for tcp/ip _and_ serial communication.
// ChatClientDlg.h : header file
//

#pragma once
#include "afxwin.h"

#include "ChatClientSocket.h"

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

// Dialog Data
	enum { IDD = IDD_CHATCLIENT_DIALOG };

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


// Implementation
protected:
	HICON m_hIcon;
	CChatSocket chat;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	CEdit m_edtLog;
	CEdit m_edtChat;
	CListBox m_lstUsers;
	CButton m_btnSend;

	CString m_strUsername;

	afx_msg LRESULT OnChatConnect(WPARAM wp, LPARAM lp);
	afx_msg LRESULT OnChatDisconnect(WPARAM wp, LPARAM lp);
	afx_msg LRESULT OnChatTrans(WPARAM wp, LPARAM lp);

	void AddMessage(char* szBuffer);
	void ListUsers(char* szBuffer);

	afx_msg void OnBnClickedButtonSend();
	afx_msg void OnDestroy();
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Founder 1TCompany AB
Sweden Sweden

Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions