I can't figure out why the following code doesn't produce a transparent sdk label since I use the ws_ex_transparent style. I paint the background with a gradient.
First, am I doing the 'static' control correctly. Secondly, is it required to use a null_brush in the dialog call back to get it to go transparent?
I've started looking at ownerdrawn but don't see how I can remove the drawtext or textout output.
First, am I doing the 'static' control correctly. Secondly, is it required to use a null_brush in the dialog call back to get it to go transparent?
I've started looking at ownerdrawn but don't see how I can remove the drawtext or textout output.
Code:
#DIM ALL #REGISTER ALL #INCLUDE "win32api.inc" GLOBAL ghMain AS DWORD CALLBACK FUNCTION dlgMain SELECT CASE CBMSG CASE %WM_PAINT CALL PaintBg(CBHNDL,0,0,0) END SELECT END FUNCTION FUNCTION PBMAIN %LBL_LABEL = 1001 DIM hWndControl AS DWORD,szControlText AS STRING DIALOG NEW 0, "Transparent sdk style label ", 0,0,150,170, %WS_OVERLAPPEDWINDOW OR %DS_CENTER TO ghMain szControlText = "Sample Text" hWndControl = CreateWindowEx(%WS_EX_TRANSPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING , _ "Static", _ ' window class name BYCOPY szControlText, _ ' window caption %SS_LEFT OR %WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN, _ 10, 10, 150, 15, _ ghMain, %LBL_LABEL, GetModuleHandle(BYVAL 0&), BYVAL %Null) DIALOG SHOW MODAL ghMain CALL dlgMain END FUNCTION FUNCTION SetColor (BYVAL tCOLOR AS BYTE) AS WORD ' the windows api GradientFill routine wants r/g/b colors to be ' 16 bit words with the 8 bit color values left shifted 8 bits. ' this takes care of that. LOCAL clr AS WORD clr = tCOLOR SHIFT LEFT clr, 8 FUNCTION = clr END FUNCTION SUB PaintBg(BYVAL hDialog AS LONG, BYVAL r AS LONG, BYVAL g AS LONG, BYVAL b AS LONG) ' this is to paint the background of the dialog ' it's all straight out of the MSDN help file. We can change the values ' if we like. LOCAL ps AS PAINTSTRUCT LOCAL rc AS Rect LOCAL hDc AS DWORD LOCAL Xin& LOCAL Yin&,Temp&,cRed&,cGreen&,cBlue& DIM vert(1) AS TRIVERTEX DIM gRect AS GRADIENT_RECT hDC = BeginPaint(hDialog, ps) ' Tile the background GetClientRect hdialog, rc Xin = rc.nRight - rc.nLeft Yin = rc.nBottom - rc.nTop Xin = rc.nRight - rc.nLeft Yin = rc.nBottom - rc.nTop Temp& = RGB(205,214,255) IF Temp& <> 0 THEN cRed& = Temp& MOD 256 cGreen& = (Temp& \ 256) MOD 256 cBlue& = ((Temp& \ 256) \ 256) MOD 256 ELSE cRed& = 192 cGreen& = 224 cBlue& = 192 END IF vert(0).x = 0 vert(0).y = 0 vert(0).Red = SetColor(cRed& - 90) vert(0).Green = SetColor(cGreen& - 90) vert(0).Blue = SetColor(cBlue& - 90) vert(0).Alpha = &h0000 vert(1).x = xin vert(1).y = yin vert(1).Red = SetColor(cRed&) vert(1).Green = SetColor(cGreen&) vert(1).Blue = SetColor(cBlue&) vert(1).Alpha = &h0000 gRect.UpperLeft = 0 gRect.LowerRight = 1 GradientFill hDc, vert(0), 2, gRect, 1, %GRADIENT_FILL_RECT_v EndPaint hDialog, ps END SUB
Comment