Solved

Better edit control

Posted on 1997-06-23
11
161 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
ID: 1302245
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
ID: 1302246
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
ID: 1302247
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
ID: 1302248
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
ID: 1302249
"If you don't ask you don't get"
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:The Master
ID: 1302250
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
ID: 1302251
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
ID: 1302252
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
ID: 1302253
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
ID: 1302254
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
ID: 1302255
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Separate into files by filename 12 75
fizzArray  challenge 1 58
either24  challenge 19 90
canBalance challenge 34 69
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

919 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

16 Experts available now in Live!

Get 1:1 Help Now