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

How To Build A Simple Text Editor? A Tutorial

, 7 Aug 2011 CPOL
This article illustrates the application of ATL/WTL by building a simple text editor based on the WTL objects
Article_demo.zip
Article_demo
EditEx1.exe
EditEx2.exe
Article_src.zip
Article_src
EditEx_v1
EditEx
EditEx.suo
Debug
EditEx.exe
res
EditEx.ico
toolbar.bmp
EditEx_v2
EditEx
EditEx.suo
Debug
EditEx.exe
res
EditEx.ico
toolbar.bmp
// EditExView.h : interface of the CEditExView class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include <atlctrls.h>

#define FMT_TXT			0x0001
#define FMT_XTE			0x0002

class CEditExView : public CWindowImpl<CEditExView, CEdit>
{
	TCHAR m_path[_MAX_PATH];
	TCHAR m_name[_MAX_FNAME];

public:
	CEditExView();
	~CEditExView();

	DECLARE_WND_SUPERCLASS(NULL, CEdit::GetWndClassName())

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		pMsg;
		return FALSE;
	}

	BEGIN_MSG_MAP(CEditExView)
	END_MSG_MAP()

// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

public:
	bool Load(const TCHAR* path, UINT uiFlag = 0);	
	bool Save(const TCHAR* path, UINT uiFlag = 0);	
	bool hasPath() { return m_path[0] == 0 ? false : true; }
	TCHAR* GetPath() { return m_path; }
private:		
	void SetNamePath(const TCHAR* path);		
	bool DoLoad(const TCHAR* sPath, UINT uiFlag = 0);
	bool DoSave(const TCHAR* sPath, UINT uiFlag = 0);
	int  GetType(const TCHAR* sPath) const;

public:
	static const TCHAR* RFind (const TCHAR* str, const TCHAR ch);
	static const TCHAR* RFind (const TCHAR* str, const TCHAR* ss);

};

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)

Share

About the Author

forest.house

China China
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411019.1 | Last Updated 7 Aug 2011
Article Copyright 2011 by forest.house
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid