Sign in to follow this  
Guyveri

Custom Edit control (WinAPI)

Recommended Posts

Hi everyone!!

I need to make an edit control that looks like the one on the picture, that I have attached!
I couldn't achieve that goal by subclassing the common edit control.
So I guess I need to create my own edit contol from scratch.
I have never done it. Are there any technics or tutorials for that?
I can't figure out how to implement the carriage!

Share this post


Link to post
Share on other sites
In that case I have to handle at least 2 messages on my own: WM_PAINT and WM_ERASEBKGND[color="#000000"][b]. [/b]If I don't[font="arial, sans-serif"][size="2"] handle the [/size][/font][/color]WM_ERASEBKGND message the image will be drawn one upon another and the shadow on the left will become darker and darker!!! So i need to erase the previous image and draw the new one! I couldn't find the way to erase an image. So I guess the only way is to use the FillRect function with the background brush. But that makes edit control window opaque. But I need it transparent because of the rounded corners!

Hope that makes sense!!

Share this post


Link to post
Share on other sites
You need to fill using an alpha value of zero, without blending. I can't remember OTOH what you use in win32/gdi to do that, except that if you can create an empty (with zero alpha) bitmap in memory you can blit (NOT blend) it onto your control's DC to 'erase to transparent background'.

Edit: IIRC you can't to this with the stock NULL_BRUSH, HOLLOW_BRUSH, as they are blended. You don't want to blend to you want to blit or fill with a colour with alpha = 0;.

Share this post


Link to post
Share on other sites
DO NOT write your own custom edit control. It's much more work than you seem to think if it's going to be decent. Instead, subclass the edit control and just replace all painting code with code that draws an image. For drawing images which have an alpha channel, use an image list and associated functions (ImageList_DrawEx()).

Share this post


Link to post
Share on other sites
Thank you for the answer! I haven't really had time to get back to this task, but I will definitely try both advices, and post the result here!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this