Solved

Better edit control

Posted on 1997-06-23
11
160 Views
Last Modified: 2013-11-19
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.

Thankyou.
0
Comment
Question by:dd021197
11 Comments
 
LVL 4

Expert Comment

by:mbhakta
Comment Utility
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.
0
 

Expert Comment

by:EHaimerl
Comment Utility
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;}
0
 
LVL 1

Author Comment

by:dd021197
Comment Utility
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 ??

0
 
LVL 4

Expert Comment

by:mbhakta
Comment Utility
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.
0
 
LVL 1

Author Comment

by:dd021197
Comment Utility
"If you don't ask you don't get"
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 2

Expert Comment

by:The Master
Comment Utility
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?
0
 
LVL 4

Expert Comment

by:mbhakta
Comment Utility
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.
0
 
LVL 4

Accepted Solution

by:
mbhakta earned 250 total points
Comment Utility
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.
0
 
LVL 1

Author Comment

by:dd021197
Comment Utility
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 ??

Douglas

0
 
LVL 4

Expert Comment

by:mbhakta
Comment Utility
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.
0
 
LVL 1

Author Comment

by:dd021197
Comment Utility
But if I use CEdit anything under VC 1.5 I am stuck with
the size limit of 64K am I not ??
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now