Click here to Skip to main content
15,893,161 members
Articles / Desktop Programming / MFC

Three Windows Demo

Rate me:
Please Sign up or sign in to vote.
2.29/5 (8 votes)
18 Apr 20042 min read 36K   1K   15  
Creates other processes (windows).
#if !defined(AFX_CONSOLEBOX_H__3D22F593_4E2E_49EC_8C5E_53257F0F5874__INCLUDED_)
#define AFX_CONSOLEBOX_H__3D22F593_4E2E_49EC_8C5E_53257F0F5874__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ConsoleBox.h
//

#include <afxtempl.h>
/////////////////////////////////////////////////////////////////////////////
// CConsoleBox

class CConsoleBox : public CEdit
{
public:
	CConsoleBox();

public:
	void SetCommandReceiver(HWND hReceiver, UINT uMsg) {
		m_hReceiver = hReceiver;
		m_uCallbackMsg = uMsg;
	}
	void SetPromptText(LPCTSTR lpszPromptText) {
		m_strPromptText = lpszPromptText;
		AppendText(lpszPromptText);
	}
	void SetHistorySize(int nMaxCommand) {
		m_aCommandHistory.SetSize(nMaxCommand);
	}

public:
	void CarryReturn(BOOL bLineFeed=TRUE);
	int PrintF(LPCTSTR fmt, ...);

	//{{AFX_VIRTUAL(CConsoleBox)
	protected:
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
	//}}AFX_VIRTUAL

public:
	virtual ~CConsoleBox();

protected:
	HWND m_hReceiver;
	UINT m_uCallbackMsg;
	CString m_strPromptText;

	CStringArray m_aCommandHistory;
	int m_nNewCmdPos, m_nCurCommand, m_nTotalCommand;

protected:
	void AppendText(LPCTSTR lpszText=NULL);
	void SetCaretPos(int pos=-1);
	void GetCaretPos(int& nLine, int& nPos);

	void SetCurCommand(LPCTSTR lpszCommand);
	BOOL IsEditingLine();
	BOOL HitPromptArea();
	void DoPaste();

	//{{AFX_MSG(CConsoleBox)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}

#endif // !defined(AFX_CONSOLEBOX_H__3D22F593_4E2E_49EC_8C5E_53257F0F5874__INCLUDED_)

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


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions