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

ClassLib, A C++ class library

Rate me:
Please Sign up or sign in to vote.
4.80/5 (32 votes)
25 May 2005CPOL8 min read 400.1K   11.5K   141  
C++ class library.
#ifndef _IPADDRESS_H_
#define _IPADDRESS_H_
//
// ipaddress.h
//
// (C) Copyright 2000 Jan van den Baard.
//     All Rights Reserved.
//

#include "commoncontrol.h"

// A wrapper for the IP Adress common control.
class ClsIPAddress : public ClsCommonControl
{
	_NO_COPY_PARAM( ClsIPAddress, ClsCommonControl );
public:
	// Constructor.
	ClsIPAddress() : ClsCommonControl( ICC_INTERNET_CLASSES )
	{;}

	// Destructor.
	virtual ~ClsIPAddress()
	{;}

	// Create an IP address control.
	inline BOOL Create( ClsWindow *parent, ClsRect& rBounds, UINT nID, DWORD dwStyle = WS_VISIBLE | WS_CHILD )
	{
		_ASSERT( m_hWnd == NULL ); // May not be valid.

		// Create the control.
		return ClsCommonControl::Create( 0, WC_IPADDRESS, NULL, dwStyle, rBounds, parent ? parent->GetSafeHWND() : NULL, ( HMENU )( UINT_PTR )nID );
	}

	// Clear the address.
	inline void ClearAddress()
	{
		_ASSERT_VALID( GetSafeHWND() ); // Must be valid.

		// Clear the address.
		SendMessage( IPM_CLEARADDRESS );
	}

	// Get the address.
	inline int GetAddress( DWORD& dwAddress ) const
	{
		_ASSERT_VALID( GetSafeHWND() ); // Must be valid.

		// Get the address.
		return ( int )::SendMessage( m_hWnd, IPM_GETADDRESS, 0, ( LPARAM )&dwAddress );
	}

	// Is the address blank.
	inline BOOL IsBlank() const
	{
		_ASSERT_VALID( GetSafeHWND() ); // Must be valid.

		// Return the contents state.
		return ( BOOL )::SendMessage( m_hWnd, IPM_ISBLANK, 0, 0 );
	}

	// Set the address.
	inline void SetAddress( DWORD dwAddress )
	{
		_ASSERT_VALID( GetSafeHWND() ); // Must be valid.

		// Set the address.
		SendMessage( IPM_SETADDRESS, 0, dwAddress );
	}

	// Set the focus to the specified field.
	inline void SetFieldFocus( int nField )
	{
		_ASSERT_VALID( GetSafeHWND() ); // Must be valid.

		// Set the focus.
		SendMessage( IPM_SETFOCUS, nField );
	}

	// Set the range for the specified field.
	inline BOOL SetRange( int nField, WORD wRange )
	{
		_ASSERT_VALID( GetSafeHWND() ); // Must be valid.

		// Set the range.
		return ( BOOL )SendMessage( IPM_SETRANGE, nField, wRange );
	}

protected:
	// Overidables.
	virtual LRESULT OnFieldChanged( LPNMIPADDRESS pAddress, BOOL& bNotifyParent )
	{ return 0; }

	// Reflected notification handler which will call
	// the virtual notification handlers.
	virtual LRESULT OnReflectedNotify( LPNMHDR pNMHDR, BOOL& bNotifyParent )
	{
		// Evaluate notification code.
		if ( pNMHDR->code == IPN_FIELDCHANGED )
			return OnFieldChanged(( LPNMIPADDRESS )pNMHDR, bNotifyParent );
	
		// Call the base class.
		return ClsCommonControl::OnReflectedNotify( pNMHDR, bNotifyParent );
	}
};

#endif // _IPADDRESS_H_

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 Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Netherlands Netherlands
I have been programming for a hobby since 1985. I have started programming on the C= 64. After that I migrated to the C= Amiga which I traded in for a PC back in 1997 I believe. Back in 2000 I decided to lose a hobby and start developing software for a living.

Currently I am working mainly in developing software for building security and access control systems.

Comments and Discussions