Better edit control

Does anyone have an edit class that allows changing of colours, adding bold, underline, and different fonts.

I am using vc1.5 so I do do not have the luxury of a CRichEditView.

Who is Participating?
mbhaktaConnect With a Mentor Commented:
Now that you really need a clue and have not explained much of your problems. I have to start right from start. I have no idea how good you are at VC++ . But you can derive a class CMyEdit fro m CEdit . Now you will have to override calls like OnPaint() , OnEraseBkgnd() etc. to get your own background colours on the edit box. To get your own fonts etc. on the edit box you will have to make some 'smart' changes to the the OnPaint() message. This is tough to really explain on a web page, but you have to keep referring to a couple of articles (if any) on the MSDN and do some research. If you are so very desperate and want a easy way out check some of the programming magazines like WDJ, DDJ for some custom made tools available from some vendors.

If you plan to make something out of your own labour, well , get in touch with me with the code you have already developed and I can advice you how to build on top of that.
This forum is meant to answer programming queries and help resolve problems and issues you find while using MFC/ VC++. This is not a place where we exchange codes and spoon feed users. If you have made the efforts of doing some part of it yourselves and get stuck at some point , this is were experts-exchange comes into picture.
Try framing such questions in some newsgroup. Maybe some one might have a working solution.
Hi,Though Experts Exchange is not a good market for free code, there is a EditClass that changes the Bk and Text colors. It is in MFC 4 but should help you as a start. Check the Reflection - section in your help file for detailed info. (I think this code is based on MFC 4 Samples??)Hope it helps - come up with detailed question if it works under MFC 1.5Edgar// YellowEdit.h : header file///////////////////////////////////////////////////////////////////////////////// CYellowEdit windowclass CYellowEdit : public CEdit{// Constructionpublic:      CBrush m_brBkgnd;      COLORREF m_clrBkgnd;      COLORREF m_clrText;      CYellowEdit();// Attributespublic:// Operationspublic:// Overrides      // ClassWizard generated virtual function overrides      //{{AFX_VIRTUAL(CYellowEdit)      //}}AFX_VIRTUAL// Implementationpublic:      virtual ~CYellowEdit();      // Generated message map functionsprotected:      //{{AFX_MSG(CYellowEdit)      afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);      //}}AFX_MSG      DECLARE_MESSAGE_MAP()};/////////////////////////////////////////////////////////////////////////////// YellowEdit.cpp : implementation file//#include "stdafx.h"#include "YellowEdit.h"#include "Reflect.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CYellowEditCYellowEdit::CYellowEdit(){      m_clrText = RGB( 0, 0, 0 );      m_clrBkgnd = RGB( 255, 255, 0 );      m_brBkgnd.CreateSolidBrush( m_clrBkgnd );}CYellowEdit::~CYellowEdit(){}BEGIN_MESSAGE_MAP(CYellowEdit, CEdit)      //{{AFX_MSG_MAP(CYellowEdit)      ON_WM_CTLCOLOR_REFLECT()      //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CYellowEdit message handlersHBRUSH CYellowEdit::CtlColor(CDC* pDC, UINT nCtlColor) {      // TODO: Change any attributes of the DC here      pDC->SetTextColor( m_clrText );      // text      pDC->SetBkColor( m_clrBkgnd );      // text bkgnd      return m_brBkgnd;                        // ctl bkgnd            // TODO: Return a non-NULL brush if the parentÕs handler should not be called      return NULL;}
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

dd021197Author Commented:
Thanks for the effort but that's not really what I meant.
I have tried posting to newsgroup and I am currently writing
my own class, just wanted to same some development time - what's
the harm in that ??

There is no harm in asking MS for the Win32 source code either , but the simple answer is you can't get it. We all face deadlines and know how bad it is. I would expect a person so desperate to put up a more eloberate question ,  the issues he/she is stuck at , rather than an abrupt question like you have put up. The question you have displayed makes it look as if you are looking for a slave programmer who makes it sure you don't lift a finger.
Explain your problem , with more technical precision and I am sure one of us will be eager  to help you. Print some source code which might indicate to us what you are doing wrong.
dd021197Author Commented:
"If you don't ask you don't get"
The MasterCommented:
You know, mbhakta, I really have to take issue with your comments here.  I haven't said anything in the past, but this is different.  Unfortunately I couldn't find your email address anywhere, so I'll have to say this here.

Here you have somebody asking for help, and all you do is slam them for asking.  You say "this is not a place where we exchange codes and spoon feed users."  There was a question a while back concerning the creation of static splitter-windows dynamically.  One of your comments said that you tried it, and offered a completely different solution, with the words "go with the tide."  Well I have written a class that does exactly what that user wanted, and offered it to him for free.  If I had written a class such as dd wanted (started, but never finished - sorry dd) I would offer it to dd as well - unless of course it was owned by my employer.

You replied twice to dd without saying anything of use (unless you consider your newsgroup suggestion usefull) and came across quite offensively.  We all recognize that you have the most "expert" points, but if you're not going to say anything of value, why waste your time by saying anything at all?
The Master,
Thanks for opening my eyes. I apologize , you are Buddha the divine, I am nothing but a mere mortal. So forgive me , my lord.

I don't mind answering questions. In fact that is what we are here for. But if someone asks an abrupt question and expects you to send him some code without explaining how much effort or a 'try' he has put from his side, points don't really matter. Anyway, from now on I better overlook such questions.

BTW, Mr. Master why don't you answer this question yourselves.
dd021197Author Commented:
I seem to have started off a bit of a row between "experts" sorry. Thanks for taken time out to help me on my way.
I haev started to write the class, like you say dervied from
CScrollView, I am storing all the data in a GlobalAlloc'ed buffer
and moving a buffer left and right when the user hits the arrow
keys and on the on draw displaying everything ? Would I be better
keeping a line buffer and update that line when the user is on it
and changing line when the user moves up and down, because at the
moment I am having problems moving up and down !
What's the best way to store and manipulate the data, just some
ideas, please ??


Why are you using CScrollView, can't you get it working with CEDitView. Firstly, because , the buffer management will be done by Mr. Edit control. This will also, get rid of the problem of you trying to mangle with the key strokes, copy & paste , etc. etc.
dd021197Author Commented:
But if I use CEdit anything under VC 1.5 I am stuck with
the size limit of 64K am I not ??
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.