Transperent Edit Box

Creating a transparent edit box

Background of a window is not always white. Sometimes it may be green or gray. When we create a control like combo box or edit box the color of these controls turn out to be same as the background color of the window. This article seir background by default is white. White colored controls on green or gray background do not look very impressive. So instead of letting the edit box or the list box getting created in white color we can create them as controls with transparent background. When we do so the background knows how to create a transparent edit box so that it will get displayed in the color which is same as its parent window. You can use similar logic for other controls as well. An edit box is created using the object of CEdit class. The CWnd::OnCtlColor( ) function has been overridden in the view class CChildview. In this function a NULL brush has been created and returned. The OnCtlColor( ) function is called whenever the child control is to be drawn. Since a NULL brush is returned from the function the control is redrawn using the NULL brush thereby creating a transparent edit box.


Download

1 comment:

interval said...

Hi. I really appreciate your blog, I think your comments on OLE drag/drop can really help me in one particular project, but it seems like none of your example project are accessible. Is there some other url by which they can be accessed?