How to get lines in background of CRichEditCtrl?

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.
MournbladeAsked:
Who is Participating?
 
RONSLOWConnect With a Mentor Commented:
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
 
RONSLOWCommented:
What (if anything) were you able to do with the OnEraseBkgnd and OnPaint ???
0
 
MournbladeAuthor Commented:
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
mikeblasCommented:
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
 
MournbladeAuthor Commented:
Adjusted points from 75 to 100
0
 
mikeblasCommented:
> 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
 
MournbladeAuthor Commented:
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
 
mikeblasCommented:
> 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
 
MournbladeAuthor Commented:
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
 
MournbladeAuthor Commented:
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
 
mikeblasCommented:
> 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
 
Bill NolanOwner, Lead Technology ProgrammerCommented:
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
 
Bill NolanOwner, Lead Technology ProgrammerCommented:
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
 
mikeblasCommented:
> "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
 
RONSLOWCommented:
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
 
MournbladeAuthor Commented:
Thanks for the idea.  I tried several, all had plus/minus to them.  If I find anything better, I'll let you know.
0
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.