SocketClientDlg.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include <afxwin.h>
  3. #include <atlbase.h>
  4. #include "SocketHandle.h"
  5. #include "SocketClientImpl.h"
  6. // CSocketClientDlg dialog
  7. class CSocketClientDlg : public CDialog,
  8. public ISocketClientHandler
  9. {
  10. // Construction
  11. typedef SocketClientImpl<ISocketClientHandler> CSocketClient;
  12. friend CSocketClient;
  13. public:
  14. CSocketClientDlg(CWnd* pParent = NULL); // standard constructor
  15. virtual ~CSocketClientDlg();
  16. // Dialog Data
  17. enum { IDD = IDD_SOCKETCLIENT_DIALOG };
  18. protected:
  19. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  20. // SocketClient Interface handler
  21. virtual void OnThreadBegin(CSocketHandle* pSH);
  22. virtual void OnThreadExit(CSocketHandle* pSH);
  23. virtual void OnDataReceived(CSocketHandle* pSH, const BYTE* pbData, DWORD dwCount, const SockAddrIn& addr);
  24. virtual void OnConnectionDropped(CSocketHandle* pSH);
  25. virtual void OnConnectionError(CSocketHandle* pSH, DWORD dwError);
  26. // Implementation
  27. protected:
  28. HICON m_hIcon;
  29. CString m_strPort;
  30. int m_nMode;
  31. int m_nSockType;
  32. CEdit m_ctlMessage;
  33. CEdit m_ctlMsgList;
  34. CSocketClient m_SocketClient;
  35. void EnableControl(UINT nCtrlID, BOOL bEnable);
  36. void SyncControls();
  37. void GetAddress(const SockAddrIn& addrIn, CString& rString) const;
  38. void _cdecl AppendText(LPCTSTR lpszFormat, ...);
  39. bool GetDestination(SockAddrIn& addrIn) const;
  40. bool SetupMCAST();
  41. // Generated message map functions
  42. virtual BOOL OnInitDialog();
  43. virtual BOOL PreTranslateMessage(MSG* pMsg);
  44. afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
  45. afx_msg void OnPaint();
  46. afx_msg HCURSOR OnQueryDragIcon();
  47. afx_msg void OnDestroy();
  48. DECLARE_MESSAGE_MAP()
  49. public:
  50. afx_msg void OnModeSelected(UINT nId);
  51. afx_msg void OnBnClickedBtnStart();
  52. afx_msg void OnBnClickedBtnStop();
  53. afx_msg void OnBnClickedBtnSend();
  54. };