Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

How to write a simple but effective TCP/IP port scanner for Win32

, 27 Oct 2001
An article on how to write a TCP/IP port scanner with a GUI, based on the MFC's property sheet paradigm
/*
	CPropertyPageDialog.h
	Classe base per la pagina del dialogo basato sul property sheet (MFC).
	Luca Piergentili, 14/07/99
	lpiergentili@yahoo.com
	http://www.geocities.com/lpiergentili/
*/
#ifndef _CPROPERTYPAGEOPTIONS_H
#define _CPROPERTYPAGEOPTIONS_H 1

#include <stdio.h>
#include <stdlib.h>
#include "strcpyn.h"
#include "window.h"
#include "CPropertyPageList.h"
#include "CPropertySheetDialogMessages.h"

//#define HAVE_STATUSBAR 1

// testo per i bottoni dello sheet
#define IDOK_PROMPT				"&Ok"
#define IDCANCEL_CANCEL_PROMPT	"&Cancel"
#define IDCANCEL_EXIT_PROMPT		"E&xit"
#define MAX_BUTTON_PROMPT		32

class CPropertyPageDialog : public CPropertyPage
{
	DECLARE_DYNCREATE(CPropertyPageDialog)

public:
	// costruttore/distruttore
	CPropertyPageDialog();
	CPropertyPageDialog(int nID);
	~CPropertyPageDialog() {}

	// gestori
	virtual BOOL	OnInitDialog		(void);			// inizializzazione dialogo (pagina)
	virtual BOOL	OnSetActive		(void);			// attivazione pagina
	virtual BOOL	OnKillActive		(void);			// disattivazione pagina
	virtual void	OnKillSheet		(void);			// chiusura sheet
	virtual void	OnOk				(void) {}			// click su IDOK dello sheet
	virtual void	OnCancel			(void) {}			// click su IDCANCEL dello sheet

	// membri
	void			Reset					(void);

	inline void	SetTitle					(LPCSTR lpcszTitle) {::SetWindowText(AfxGetMainWnd()->m_hWnd,lpcszTitle);}
	inline void	SetStatusBarId				(int nID) {m_nStatusBarId = nID;}
#ifdef HAVE_STATUSBAR
	BOOL			SetStatusBar				(LPCSTR lpcszText);
	BOOL			GetStatusBar				(LPSTR lpszText,int nSize);
	LPCSTR		GetStatusBar				(void);
#else
	inline BOOL	SetStatusBar				(LPCSTR /*lpcszText*/) {return(FALSE);}
	inline BOOL	GetStatusBar				(LPSTR /*lpszText*/,int /*nSize*/) {return(FALSE);}
	inline LPCSTR	GetStatusBar				(void) {return(NULL);}
#endif
	inline void	SetPageList				(CPropertyPageList* pPropertyPageList) {m_pPropertyPageList = pPropertyPageList;}
	inline void	SetPropertySheetWnd			(CWnd* pWnd) {m_pPropertySheetWnd = pWnd;}

	inline void	ActivatePage				(int nID) {if(m_pPropertySheetWnd) ::SendMessage(m_pPropertySheetWnd->m_hWnd,WM_ACTIVATEPAGE,nID,0);}
	PROPERTYPAGE*	FindPage					(int nID);
	BOOL			EnterPageBusyState			(int nID);
	BOOL			LeavePageBusyState			(int nID);
	BOOL			LookForBusyPages			(int nID);
	BOOL			LookForPageBusy			(int nID);

	inline void	SetPropertyPageOkButton		(LPCSTR lpcszText) {strcpyn(m_szOkButtonText,lpcszText,MAX_BUTTON_PROMPT);}
	inline LPCSTR	GetPropertyPageOkButton		(void) {return(m_szOkButtonText);}

	inline void	SetPropertySheetOkButton		(LPCSTR lpcszText)	{if(m_pPropertySheetWnd) ::SendMessage(m_pPropertySheetWnd->m_hWnd,WM_SETPROPERTYSHEET_IDOKBUTTON,WM_SETPROPERTYSHEET_IDOKBUTTON,(LONG)lpcszText);}
	inline void	GetPropertySheetOkButton		(LPCSTR lpcszText)	{if(m_pPropertySheetWnd) ::SendMessage(m_pPropertySheetWnd->m_hWnd,WM_GETPROPERTYSHEET_IDOKBUTTON,WM_GETPROPERTYSHEET_IDOKBUTTON,(LONG)lpcszText);}
	inline void	SetPropertySheetCancelButton	(LPCSTR lpcszText)	{if(m_pPropertySheetWnd) ::SendMessage(m_pPropertySheetWnd->m_hWnd,WM_SETPROPERTYSHEET_IDCANCELBUTTON,WM_SETPROPERTYSHEET_IDCANCELBUTTON,(LONG)lpcszText);}
	inline void	GetPropertySheetCancelButton	(LPCSTR lpcszText)	{if(m_pPropertySheetWnd) ::SendMessage(m_pPropertySheetWnd->m_hWnd,WM_GETPROPERTYSHEET_IDCANCELBUTTON,WM_GETPROPERTYSHEET_IDCANCELBUTTON,(LONG)lpcszText);}

	inline void	EnablePropertySheetOkButton	(void)			{if(m_pPropertySheetWnd) ::SendMessage(m_pPropertySheetWnd->m_hWnd,WM_ENABLEPROPERTYSHEET_IDOKBUTTON,WM_ENABLEPROPERTYSHEET_IDOKBUTTON,0);}
	inline void	DisablePropertySheetOkButton	(void)			{if(m_pPropertySheetWnd) ::SendMessage(m_pPropertySheetWnd->m_hWnd,WM_DISABLEPROPERTYSHEET_IDOKBUTTON,WM_DISABLEPROPERTYSHEET_IDOKBUTTON,0);}

	inline void	EnablePropertySheetCancelButton(void)			{if(m_pPropertySheetWnd) ::SendMessage(m_pPropertySheetWnd->m_hWnd,WM_ENABLEPROPERTYSHEET_IDCANCELBUTTON,WM_ENABLEPROPERTYSHEET_IDCANCELBUTTON,0);}
	inline void	DisablePropertySheetCancelButton(void)			{if(m_pPropertySheetWnd) ::SendMessage(m_pPropertySheetWnd->m_hWnd,WM_DISABLEPROPERTYSHEET_IDCANCELBUTTON,WM_DISABLEPROPERTYSHEET_IDCANCELBUTTON,0);}

	inline BOOL	Dirty					(void)			{return(m_bDirty);}
	inline BOOL	KillPage					(void)			{return(m_bKillPage);}

private:
	BOOL			m_bDirty;							// flag per pagina visualizzata
	BOOL			m_bKillPage;						// flag per cambio pagina
	char			m_szOkButtonText[MAX_BUTTON_PROMPT+1];	// testo bottone IDOK dello sheet
	int			m_nStatusBarId;					// id del controllo
	CPropertyPageList* m_pPropertyPageList;				// lista per le pagine dello sheet
	CWnd*		m_pPropertySheetWnd;				// puntatore allo sheet

	DECLARE_MESSAGE_MAP()
};

#endif // _CPROPERTYPAGEOPTIONS_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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Luca Piergentili
Web Developer
Italy Italy
I like C and C++, Acid Jazz, James Brown, gli Spaghetti Aglio e Olio, alla Bolognesa, alla Puttanesca e le Fettuccine alla Matriciana ('Maccaroni' over the world). Of course I like beautiful big tits girls too, my little car, Frank Zappa, the art of Zen, italian coffee and much more...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141220.1 | Last Updated 28 Oct 2001
Article Copyright 2001 by Luca Piergentili
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid