Custom Edit control (WinAPI)

Started by
7 comments, last by Guyveri 11 years, 12 months ago
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!
Advertisement
Erm... your picture seems to be missing?

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Ooops, my apologies!!!
Why can't you do that via subclassing/owner draw?

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

In that case I have to handle at least 2 messages on my own: WM_PAINT and WM_ERASEBKGND[color="#000000"]. If I don't[font="arial, sans-serif"][size="2"] handle the [/font]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!!
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;.
[size="1"]
Great!!!
Thank you very mush for the advice!! I'll try it!!
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()).
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!!!

This topic is closed to new replies.

Advertisement