Skip to main content
GameDev.net gamedev.net
🔒 Locked

Custom Edit control (WinAPI)

Started by Guyveri Apr 7, 2012 at 8:24 PM 7 replies 4.2k views
Original Post
Guyveri
Guyveri
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!
Guyveri
Guyveri
Ooops, my apologies!!!
Guyveri
Guyveri
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!!
mrbastard
mrbastard
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"]
Guyveri
Guyveri
Great!!!
Thank you very mush for the advice!! I'll try it!!
Amr0
Amr0
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()).
Guyveri
Guyveri
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!!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.