Main Page | File List

ipaddr.h

00001 #ifndef _IPADDR_H                                                       // Only include this file once
00002 #define _IPADDR_H
00003 
00004 #pragma title("IP Address Custom Control Definitions")
00005 
00006 // Created by Joseph A. Dziedzic, September 1997
00007 // Revised April 1998
00008 // Thanks to Dan Anderson, Kenny Goers, Kevin Lussier, and Doug Miller for their suggestions
00009 // and code enhancements.
00010 // Mail comments to dziedzic@ma.ultranet.com
00011 
00012 
00013 // The structure we use to pass addresses around
00014 typedef struct tagIPA_ADDR {
00015         unsigned char   nAddr1; // The four bytes of the IP address
00016         unsigned char   nAddr2;
00017         unsigned char   nAddr3;
00018         unsigned char   nAddr4;
00019         UINT    nInError;               // Address byte with erroroneous/missing data (1..4)
00020 } IPA_ADDR;
00021 
00022 // IP Address control style bits
00023 
00024 #define IPAS_NOVALIDATE 0x0001  // Don't validate fields as they are input
00025 
00026 // Messages to/from the IP Address control
00027 enum IPAM {
00028         IPAM_GETADDRESS = WM_USER,
00029         IPAM_SETADDRESS,
00030         IPAM_SETREADONLY
00031 };
00032 
00033 // Resource IDs for our edit controls
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 // CIPAddrEdit window
00048 
00049 class CIPAddrEdit : public CEdit
00050 {
00051 // Construction
00052 public:
00053         CIPAddrEdit();
00054 
00055 // Attributes
00056 public:
00057         friend class CIPAddrCtl;
00058 
00059         // Operations
00060 public:
00061 
00062 // Overrides
00063         // ClassWizard generated virtual function overrides
00064         //{{AFX_VIRTUAL(CIPAddrEdit)
00065         //}}AFX_VIRTUAL
00066 
00067 // Implementation
00068 public:
00069         virtual ~CIPAddrEdit();
00070 
00071         // Generated message map functions
00072 protected:
00073         CIPAddrCtl* m_pParent;
00074         void SetParent(CIPAddrCtl* pParent);
00075         //{{AFX_MSG(CIPAddrEdit)
00076         afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
00077         afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00078         //}}AFX_MSG
00079 
00080         DECLARE_MESSAGE_MAP()
00081 };
00082 
00085 // CIPAddrCtl window
00086 
00087 class CIPAddrCtl : public CWnd
00088 {
00089     DECLARE_DYNCREATE(CIPAddrCtl)
00090 // Construction
00091 public:
00092         static BOOL Register();
00093         CIPAddrCtl();
00094 
00095 // Attributes
00096 public:
00097         friend class CIPAddrEdit;
00098 
00099 // Operations
00100 public:
00101         BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, DWORD dwExStyle=0);
00102 
00103 // Overrides
00104         // ClassWizard generated virtual function overrides
00105         //{{AFX_VIRTUAL(CIPAddrCtl)
00106         //}}AFX_VIRTUAL
00107 
00108 // Implementation
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         // Generated message map functions
00120 protected:
00121         void OnChildChar(UINT nChar, UINT nRepCnt, UINT nFlags, CIPAddrEdit& child);
00122         //{{AFX_MSG(CIPAddrCtl)
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         //}}AFX_MSG
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 // WNDPROC
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

Generated on Mon May 8 22:27:08 2006 by  doxygen 1.3.9.1