Make an editor gadget transparent (richedit)

Share your advanced PureBasic knowledge/code with the community.
superadnim
Enthusiast
Enthusiast
Posts: 480
Joined: Thu Jul 27, 2006 4:06 am

Make an editor gadget transparent (richedit)

Post by superadnim »

The following procedure I happen to use on a little project of mine, where I have a richedit required to have a transparent background (because the window has an image background!)

Code: Select all

Procedure.l hWndTransparent( hWnd.l )
	Define.l lwTemp
	#WS_EX_TRANSPARENT = $20
	lwTemp = GetWindowLong_(hWnd, #GWL_STYLE)
	SetWindowLong_(hWnd, #GWL_EXSTYLE, lwTemp | #WS_EX_TRANSPARENT)
	ProcedureReturn lwTemp 
	
EndProcedure
It works just fine, make sure theres something on the back redrawing, if not your editor gadget won't have a background at all and thus it wont redraw.

(if someone could help me improve my function, that'd be nice!)

The old style is returned by the procedure, in case you want to revert it back.

Sorry if this was already posted, I just couldn't find it on the forums so I had to write my own. (I did find a code by Sparkie but it wasn't redrawing and it required quite a few hacks just to render a background image)
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

superadnim wrote:(I did find a code by Sparkie but it wasn't redrawing and it required quite a few hacks just to render a background image)
Yep, that sounds like it would be mine. :lol:

Do you have a link to that so I can see what the hell I did wrong :?: The code I found on my HD for a transparent Editorgadget works fine. :?
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply