00001 #ifndef _IPADDR_H // Only include this file once
00002 #define _IPADDR_H
00003
00004 #pragma title("IP Address Custom Control Definitions")
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 typedef struct tagIPA_ADDR {
00015 unsigned char nAddr1;
00016 unsigned char nAddr2;
00017 unsigned char nAddr3;
00018 unsigned char nAddr4;
00019 UINT nInError;
00020 } IPA_ADDR;
00021
00022
00023
00024 #define IPAS_NOVALIDATE 0x0001 // Don't validate fields as they are input
00025
00026
00027 enum IPAM {
00028 IPAM_GETADDRESS = WM_USER,
00029 IPAM_SETADDRESS,
00030 IPAM_SETREADONLY
00031 };
00032
00033
00034 enum RID {
00035 IDC_ADDR1 = 1,
00036 IDC_ADDR2,
00037 IDC_ADDR3,
00038 IDC_ADDR4
00039 };
00040
00041 class CIPAddrCtl;
00042
00043 void DDX_IPAddr(CDataExchange* pDX, int nIDC, unsigned char* nAddr);
00044 void DDX_IPAddr(CDataExchange* pDX, int nIDC, CString& szAddr);
00045
00047
00048
00049 class CIPAddrEdit : public CEdit
00050 {
00051
00052 public:
00053 CIPAddrEdit();
00054
00055
00056 public:
00057 friend class CIPAddrCtl;
00058
00059
00060 public:
00061
00062
00063
00064
00065
00066
00067
00068 public:
00069 virtual ~CIPAddrEdit();
00070
00071
00072 protected:
00073 CIPAddrCtl* m_pParent;
00074 void SetParent(CIPAddrCtl* pParent);
00075
00076 afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
00077 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00078
00079
00080 DECLARE_MESSAGE_MAP()
00081 };
00082
00085
00086
00087 class CIPAddrCtl : public CWnd
00088 {
00089 DECLARE_DYNCREATE(CIPAddrCtl)
00090
00091 public:
00092 static BOOL Register();
00093 CIPAddrCtl();
00094
00095
00096 public:
00097 friend class CIPAddrEdit;
00098
00099
00100 public:
00101 BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, DWORD dwExStyle=0);
00102
00103
00104
00105
00106
00107
00108
00109 public:
00110 virtual ~CIPAddrCtl();
00111 BOOL GetAddress(BOOL bPrintErrors, IPA_ADDR* lpIPAddr)
00112 { return (BOOL) ::SendMessage(m_hWnd, IPAM_GETADDRESS, (WPARAM) bPrintErrors, (LPARAM) lpIPAddr); };
00113 BOOL SetAddress(IPA_ADDR* lpIPAddr)
00114 { return (BOOL) ::SendMessage(m_hWnd, IPAM_SETADDRESS, 0, (LPARAM) lpIPAddr); };
00115 BOOL SetReadOnly(BOOL bReadOnly = TRUE)
00116 { return (BOOL) ::SendMessage(m_hWnd, IPAM_SETREADONLY, (WPARAM) bReadOnly, 0); };
00117 CIPAddrEdit* GetEditControl(int nIndex);
00118
00119
00120 protected:
00121 void OnChildChar(UINT nChar, UINT nRepCnt, UINT nFlags, CIPAddrEdit& child);
00122
00123 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
00124 afx_msg void OnNcDestroy();
00125 afx_msg void OnSize(UINT nType, int cx, int cy);
00126 afx_msg void OnSetFocus(CWnd* pOldWnd);
00127 afx_msg void OnPaint();
00128 afx_msg void OnEnable(BOOL bEnable);
00129 afx_msg LONG OnSetFont(UINT wParam, LONG lParam);
00130 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00131 afx_msg LONG OnGetAddress(UINT wParam, LONG lParam);
00132 afx_msg LONG OnSetAddress(UINT wParam, LONG lParam);
00133 afx_msg LONG OnSetReadOnly(UINT wParam, LONG lParam);
00134
00135
00136 DECLARE_MESSAGE_MAP()
00137 private:
00138 CIPAddrEdit m_Addr[4];
00139 CRect m_rcAddr[4];
00140 CRect m_rcDot[3];
00141
00142 BOOL ParseAddressPart(CEdit& edit, int& n);
00143
00144 BOOL m_bEnabled;
00145 BOOL m_bReadOnly;
00146 BOOL m_bNoValidate;
00147
00148 static BOOL m_bRegistered;
00149 };
00150
00151
00152
00153 #ifdef __cplusplus
00154 extern "C" {
00155 #endif
00156 LRESULT CALLBACK IPAddrWndProc(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
00157 #ifdef __cplusplus
00158 }
00159 #endif
00160
00162
00163 #endif // _IPADDR_H