Solved

How to get lines in background of CRichEditCtrl?

Posted on 2000-04-26
16
341 Views
Last Modified: 2013-11-20
I would like a CRichEditCtrl to have lines in the background, like a sheet of lined paper.  I haven't had much luck doing this in ::OnEraseBkgnd() or ::OnPaint().  Does anyone know the best way to get this effect?  Thanks.
0
Comment
Question by:Mournblade
  • 6
  • 5
  • 3
  • +1
16 Comments
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2754053
What (if anything) were you able to do with the OnEraseBkgnd and OnPaint ???
0
 

Author Comment

by:Mournblade
ID: 2754265
I've never been able to use OnEraseBkgnd effectively.  I'm probably doing it wrong.  I just draw in there, and return TRUE.  This is supposed to keep Windows from erasing it later, but it seems to get erased anyway.  I'm not sure if this is the best way for me to do what I am trying to do, but if you know how to get OnEraseBkgnd to work right, it might do the job...
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2756105
The rich edit control doesn't allow you to use WM_ERASEBKGND for this kind fo thing. It paints fully and opaquely in its WM_PAINT handler, and you can't have things bleed thru.

..B ekiM
0
 

Author Comment

by:Mournblade
ID: 2757472
Adjusted points from 75 to 100
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
ID: 2757703
How handling the WM_PAINT yourself

Call the Default first to let the richedit control do its thing, and then paint your lines on top.  If you're worried about drawing lines over text, you could always refine this to use bitblting with masking to only draw the lines where the richedit control is white.

Another thought is to make your own window that paints lines only (and doesn't draw anyhting else .. leaves everything else untouched).  Then place one of these objects over the richedit control.  You'd need to synchronise the scrolling ot these two controls, though.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2757910
> You'd need to synchronise the scrolling ot these two controls, though.


I don't think that would be easy to get right. The control scrolls its own area, which can take a long time--before you could scroll your extra client area, the user would probably notice flicker.

The merged bitblt approach seems the most viable to me.

..B ekiM
0
 

Author Comment

by:Mournblade
ID: 2758555
I agree with that - though I'm still hoping for an even better solution.  It seems there ought to be one...but probably isn't.  hehe.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2762573
> an even better solution

Even better in what way?  What would make the solution better?  Are you worried about difficulty of implemnetation, or runtime performance, or what metric?  What leads you to believe there ought to be a better way?

..B ekiM
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Mournblade
ID: 2763214
This really seems to bother you.  Is there nothing on television or something? Anyway, you're right.  I need to stop thinking, and accept any idea that solves my immediate need, no matter how inflexible or kludgy it is.
Shame on me for not throwing the confetti.
0
 

Author Comment

by:Mournblade
ID: 2763218
Oh, anyhow, RONSLOW, it seems the idea will probably work, though I haven't got to trying it yet.  Thanks for the thought.  In the meantime, I figured I'd just see if there were other ideas.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2764000
> This really seems to bother you.  

I think RONSLOW is sending you down the right path.

What bothers me is that you're asking for something "better", and you feel that there really should be some "better" solution. But you can't indicate what "better" is.  Maybe we _could_ suggest something better for you, if you could tell us what facet of the suggested solution you wish to be improved.

Otherwise, we're just guessing at what would make you happy. When you go to a restraunt, you're not going to get good service by telling the server to "bring me something I like". They don't know what will make you happy--they don't know what attributes you're looking for in your meal. Similarly, neither do we know what you think would be a "better" solution.

 > I need to stop thinking,

I'm not asking you to stop thinking; I'm asking you to share your thoughts. (In the meantime, I'm not sure why you're overreacting so.)

 > no matter how inflexible or kludgy it is.

Unfortunately, you've got no choice beyond a kludge because the control itself doesn't support what you want to do. To implement the requirement you've put forth, you'll be fighting upstream against the control's design.

I'm not sure what's so inflexible about the solution we've presented; maybe you could elaborate on why you feel it is unyielding. What varation on your question do you think it will not accomodate?

..B ekiM
0
 
LVL 7

Expert Comment

by:Slimfinger
ID: 2764140
Your thoughts, in their substance, are good ones, and I appreciate them and basically agree.
  I was merely remarking about your "delivery" and apparent shock that someone would actually question a proposal that you happen to like.  If I feel that I'd like to wait a bit to see if another suggestion comes along, better or worse, you aren't going to stop me.
  As far as pointing out exactly what isn't loveable about the solution, every situation is different. In this one, you would have to be a fool to not already know what is uncomfortable about it.
  You would find you learn a whole lot more by listening, and by asking, than you do by talking, and asking others why they bother asking questions.
  As far as "what is inflexible about this solution" - did I say this solution was "inflexible".  Anyhow, every situation is different, and in this particular case, one would be quite a bonehead to not instantly see what parts of it are uncomfortable.

0
 
LVL 7

Expert Comment

by:Slimfinger
ID: 2764145
And you would also have to be a bonehead to type the same statement twice without realizing it.

And now that I'm on this kick, I've also just realized I'm logged in under my roommate's name.  I think I need a drink.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2764174
> "delivery" and apparent shock

You've grossly misinterpreted my posting.

 > You would find you learn a whole lot more by listening, and by asking [...]
 > In this one, you would have to be a fool to not already know
 > what is uncomfortable about it.

What's uncomfortable to me might be an acceptable compromise to you. That's why I'm asking the questions I've asked; I don't know how to gague what you think is acceptable, uncomfortable, or unacceptable.  I don't fully understand your application, so I'm not licensend

If you reread my posting, you'll find that I _am_ asking. I'm asking you what you would consider a better solution so I can learn what it is you want and try to provide more tailored assistance.

 > you aren't going to stop me.

I'm not trying to. I'm just trying to discover what it is you're looking for. If you can spell out what's bothering you about the suggestions, isn't it possible that I, or someone else here, might provide a suggestion that reduces those concerns or avoids them, altogether?

In response to my efforts at helping you find a solution that makes you happy, you've given me a taunting, backhanded little lecture.

..B ekiM
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2764700
I think we are observing one of the basic problems / dangers with this sort of on-line discussion .. it is difficult (if not impossible) to interpret the tone, emotion and inflection with which a comment is made.

If Mike and Mournblade were standing in the same room talking with each other, this sort of 'heated' exchange would not have happened .. Mournblade would have realised from ikes tone of voice etc that he was just after some clarification about the ways in which the answer could be improved etc.
0
 

Author Comment

by:Mournblade
ID: 2790568
Thanks for the idea.  I tried several, all had plus/minus to them.  If I find anything better, I'll let you know.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

759 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

23 Experts available now in Live!

Get 1:1 Help Now