My Blog is open :). Talk about the DD that I recently write transparent components (transparent controls). Methods provided by users: / transparent controls, general inheritance from TGRAPHICCONTROL (is those who don't have a Handle property, can't have FOCUS, have transparent properties. For the TWINControl class, you want to achieve the following four steps Basically, it will be .1. Sets ControlStyle: = ControlStyle: = ControlStyle - [CSopaque];) 2. Override It's CreateParams method, exstyle plus WS_EX_TRANSPARENT.3. Modify its Parent's Window Style, remove WS_ClipChildren. Inherited CreateParams (params); with params do begin {complete redraw} style: = style and not ws_clipchildren; style: = style and not ws_clipsiblings; {Add transparent} exstyle: = exstyle or ws_ex_transparent; end;
4. Intercepted WM_ERASEBKGND, nothing to return directly 1. (Do not remove background) Generally there is 3 steps to be successful. Some controls, such as TPANEL, using FillRect in its Paint, so to achieve transparent, Override It Paint method, painting yourself. Buttons transparently need further processing. CreateParams plus style: = style or bs_ownerdraw; then draw in WM_DRAWITEM yourself // My study found style: = style and not ws_clipchildren; style: = style and not ws_clipsiblings ;No effect. If you want to change the control position and color, intercept the WM_MOVE, and the CN_CTLCOLOREDIT message, call the InvaliDate method in it, and redraw the components. Read the INSIDE VCL and Fiti Components Development Books. Learn how to choose the appropriate base class to inherit and then expand into your own class. Friends who recommend writing controls should first understand this knowledge, do not start from TOBJECT. ControlStyle: = ControlStyle - [csopaque];) It is critical to see the source code to find it affects the painting method of the entire control. The transparent component has now been implemented, but the component is not refreshed enough, background confusion. Now I am reading the TIMAGE source code to see how it is implemented. Want to discuss this technical friend please email: wenjunwu430@163.com