Hi,
Is it possible to remove the focus rectangle from a CheckboxGadget?
Remove CheckboxGadget focus rectangle?
Re: Remove CheckboxGadget focus rectangle?
The easiest (hack) way is just to resize the checkbox width to something like 15 with no text:
Code: Select all
If OpenWindow(0, 0, 0, 200, 100, "CheckBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CheckBoxGadget(0, 10, 10, 15, 20, "") ; Won't show a focus rectangle when you Tab to it.
CheckBoxGadget(1, 10, 40, 250, 20, "CheckBox checked")
SetGadgetState(1, #PB_Checkbox_Checked)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
- VB6_to_PBx
- Enthusiast
- Posts: 625
- Joined: Mon May 09, 2011 9:36 am
Re: Remove CheckboxGadget focus rectangle?
Code: Select all
Procedure No_Focus_Rectangle(HWnd, Msg, WParam, LParam)
;===== HWnd : a handle to the window to process the message for.
;===== Msg : the message to process.
;===== WParam : additional information about the message.
;===== LParam : additional information about the message.
Static oldproc
oldproc = GetProp_(HWnd, "oldproc")
Select Msg
Case #WM_NCDESTROY
RemoveProp_(HWnd, "oldproc")
Case #WM_SETFOCUS
ProcedureReturn 0
EndSelect
ProcedureReturn CallWindowProc_(oldproc, HWnd, Msg, WParam, LParam)
EndProcedure
If OpenWindow(0, 0, 0, 200, 100, "CheckBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CheckBoxGadget(0, 10, 10, 250, 20, "#0 CheckBox")
SetProp_(GadgetID(0), "oldproc", SetWindowLongPtr_(GadgetID(0), #GWL_WNDPROC, @No_Focus_Rectangle())) ;<<--- No Focus Rectangle
CheckBoxGadget(1, 10, 40, 250, 20, "#1 CheckBox")
SetGadgetState(1, #PB_Checkbox_Checked)
SetProp_(GadgetID(1), "oldproc", SetWindowLongPtr_(GadgetID(1), #GWL_WNDPROC, @No_Focus_Rectangle())) ;<<--- No Focus Rectangle
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
PureBasic .... making tiny electrons do what you want !
"With every mistake we must surely be learning" - George Harrison
Re: Remove CheckboxGadget focus rectangle?
Thank you both!
Re: Remove CheckboxGadget focus rectangle?
For Windows, there's also the #UISF_HIDEFOCUS flag with a callback:
https://devblogs.microsoft.com/oldnewth ... 0/?p=97526
https://devblogs.microsoft.com/oldnewth ... 0/?p=97526