I searched all over the forum and tried some codes, but it didn't work as expected.
Any option to remove checkbox background white color ( my window has a dark background image ) ?
How to make the background color of a checkbox transparent ?
How to make the background color of a checkbox transparent ?
PB 5.x + 6.x + Win10. Feel the ...Pure... Power.
Re: How to make the background color of a checkbox transparent ?
If a checkbox gadget colour can be changed and you can change the background colour, then you should set the colour to RGBA(R,G,B,0) - noting that his colour is RGBA and not RGB - then you should set the drawing mode to DrawingMode( #PB_2DDrawing_AlphaBlend) - I'm not certain those things are possible to do though. So you could use the RGBA() value to draw your own, it shouldn't be too hard to code.hdt888 wrote: Sat Jul 20, 2024 3:19 pm I searched all over the forum and tried some codes, but it didn't work as expected.
Any option to remove checkbox background white color ( my window has a dark background image ) ?
Re: How to make the background color of a checkbox transparent ?
Changing the background colours of Checkboxes is not natively supported, you either need Windows API and custom drawing (if you are on Windows, I guess the others sStmes provide comething similar) or simulate the checkbox, e.g. with a canvas. Take a look at ChrisR's ObjectTheme.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: How to make the background color of a checkbox transparent ?
Here (for Windows only) -> https://www.purebasic.fr/english/viewto ... 96#p624596hdt888 wrote: Sat Jul 20, 2024 3:19 pmAny option to remove checkbox background white color ( my window has a dark background image ) ?
Re: How to make the background color of a checkbox transparent ?
Thank you BarryG.
The results show like that, right ? (Test by PB 6.10 + win10)

If so, it's not really transparent. This is to set the background color for the CheckBox.
The results show like that, right ? (Test by PB 6.10 + win10)

If so, it's not really transparent. This is to set the background color for the CheckBox.
PB 5.x + 6.x + Win10. Feel the ...Pure... Power.
Re: How to make the background color of a checkbox transparent ?
Code: Select all
Global Bkgcolor
Bkgcolor = GetStockObject_(#NULL_BRUSH)
CreateImage(0, 400, 300)
StartDrawing(ImageOutput(0))
For x = 0 To 399
For y = 0 To 299
Plot(x,y, RGB(x,y,x*y))
Next
Next
StopDrawing()
hBrush = CreatePatternBrush_(ImageID(0))
Procedure WindowProc(hwnd, uMsg, wParam, lParam)
Select uMSG
Case #WM_CTLCOLORSTATIC
Select GetProp_(lParam, "PB_ID");GetDlgCtrlID_(lParam)
Case 1 , 2
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam,#Yellow)
ProcedureReturn Bkgcolor
EndSelect
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0,0,0,400,300,"test",#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
SetClassLongPtr_(WindowID(0), #GCL_HBRBACKGROUND, hBrush)
SetWindowCallback(@WindowProc())
CheckBoxGadget(1,10,10,125,20,"CheckBox # 1")
SetWindowTheme_(GadgetID(1), @null.w, @null.w)
CheckBoxGadget(2,10,40,125,20,"CheckBox # 2")
SetWindowTheme_(GadgetID(2), @null.w, @null.w)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1,2
GetWindowRect_(GadgetID(EventGadget()),r.RECT)
MapWindowPoints_(0,WindowID(0),r,2)
InvalidateRect_(WindowID(0),r,1)
EndSelect
EndSelect
Until Quit = 1
DeleteObject_(Bkgcolor)
DeleteObject_(hBrush)
Egypt my love
Re: How to make the background color of a checkbox transparent ?
Great RASHAD !!
The code works smoothly, as expected.
The code works smoothly, as expected.
PB 5.x + 6.x + Win10. Feel the ...Pure... Power.
Re: How to make the background color of a checkbox transparent ?
You said you want to change the white of the checkbox, but Rashad's code doesn't do that (it's still white). I don't get the request.