Home       Company       Articles       Buy Now       Contact Us 
 
 

Background drawing with LEdit

by Andrey B. Yastrebov

Articles about LEdit Standard Windows Edit control doesn't allow drawing behind the text. Many people want such a feature and therefore it was implementd in LEdit. However using this feature isn't very much effective.

When you're going to draw behind the text, LEdit sends you special message EM_DRAW each time it redraws its window. Object oriented wrappers get this message and fire corresponding event. With the parameters of the message or with arguments of event-handling procedure, LEdit gives you a handle of Windows' Device Context (hDC). You may then use it with Windows API calls to draw what you really want. So, even if you're writing your application with Visual Basic or with some similar development system, you'll need to use Windows API directly.

LEdit doesn't fill its window with any background, so if you need to draw something behind the text, you need to draw all the background by yourselves. It may slow down LEdit considerably, but if you don't redraw all the background, any holes in your drawing will have unpredictable (usually very noisy) appearence.

LEdit allows you to draw directly on the screen, in which case screen blinks each time LEdit redraws it because you first draw your picture and LEdit draws over it. This way of doing things is fast but may be extremely annoying to the user.

Alternatively you may draw on Memory Device Context and tell LEdit to draw on it after you do. In this case, after drawing in the memory, LEdit puts the whole picture (that includes your drawing and LEdit's text). It gives smooth appearence and blinking is totally eliminated, but it needs copying large pictures from the memory to the screen. Moreover, drawing into the memory doesn't allow using advantages of accelerating video cards. Therefore this method is inherently very slow.

So, drawing behind the text seems to be uneffective way of doing things and is not recommended unless you can't find any other solution. You may consider drawing near edit control in some enclosing window, using syntax highlight or colored bookmarks. All these solutions seems much more effective.



 
 

 

LEdit Links

Home
Tech Notes
Download
Order

 
 Home       Company       Articles       Buy Now       Contact Us 

Last Modified on June 10, 2003 - © 1995-2007 AY Software Corporation All Rights Reserved