It is currently Sun Sep 22, 2019 9:29 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Remove CheckboxGadget focus rectangle?
PostPosted: Sun Jun 23, 2019 6:34 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 448
Hi,

Image

Is it possible to remove the focus rectangle from a CheckboxGadget?


Top
 Profile  
Reply with quote  
 Post subject: Re: Remove CheckboxGadget focus rectangle?
PostPosted: Sun Jun 23, 2019 7:56 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 275
The easiest (hack) way is just to resize the checkbox width to something like 15 with no text:

Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Remove CheckboxGadget focus rectangle?
PostPosted: Sun Jun 23, 2019 8:54 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon May 09, 2011 9:36 am
Posts: 464
Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Remove CheckboxGadget focus rectangle?
PostPosted: Sun Jun 23, 2019 3:39 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 448
Thank you both!


Top
 Profile  
Reply with quote  
 Post subject: Re: Remove CheckboxGadget focus rectangle?
PostPosted: Mon Jun 24, 2019 12:06 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 275
For Windows, there's also the #UISF_HIDE­FOCUS flag with a callback:

https://devblogs.microsoft.com/oldnewthing/20171206-00/?p=97526


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye