No visual ButtonGadget focus with XP skins

Just starting out? Need help? Post your questions and find answers here.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

No visual ButtonGadget focus with XP skins

Post by Sparkie »

I've probably missed something obvious because I find nothing in a search here in regards to this.

When tabbing through gadgets with XP skins disabled, I get visual confirmation that gadget focus has changed. With XP skins enabled, the ButtonGadgets seem lifeless with no visual change?

In addition to that, using the ampersand(&) in the ButtonGadget text, for underlining an associated accelerator key, doesn't seem to work with XP skins enabled.

Who amongst this great group will guide me to my sanity?

Code: Select all

If OpenWindow(0, 100, 100, 220, 170, #PB_Window_SystemMenu, "Tab Test") 
  If CreateGadgetList(WindowID(0)) 
    StringGadget(0, 10, 10, 200, 20, "") 
    StringGadget(1, 10, 40, 200, 20, "") 
    ButtonGadget(2, 10, 70, 200, 20, "Button&1") 
    StringGadget(3, 10, 100, 200, 20, "") 
    ButtonGadget(4, 10, 130, 200, 20, "Button&2") 
    ActivateGadget(0)
  EndIf 
EndIf 
Repeat 
  Event = WaitWindowEvent() 
Until Event = #PB_Event_CloseWindow 
End
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Post by plouf »

works here here is an example i have use TAB to go to 'button1'
http://homepages.pathfinder.gr/ploufus/Clipboard02.png
Christos
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

the buttons dont get selected here.
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Post by Nico »

Don't work for me! 8O
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Hum...

When i was finishing the Lib_Installer i noticed that if i enabled XP skin Support all TextGadgets would get weird background colors under some skins :(

Could it be a manifest problem ???
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

i try to awoid using xp skin if i can. I like flat gadgets and flatbuttons and flat textboxes are looking great, and works under all operation systems. (btw im using your flatgadget lib num3. makes it faster to flatter all gadgets on a big form.). but sometimes the winxp skin is prettiest
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

@plouf - Thanks for having proof of a working example and
@ everyone else who had the same results as me. :)

The partial solution is to go to

Display Properties
Appearance
Effects

Un-check the *Hide underlined letters for keyboard navigation until I press the Alt key*
results:
Underline letter shows up as expected
I get a visual that the button has focus


Check the *Hide underlined letters for keyboard navigation until I press the Alt key*
results:
No underline letters when pressing the Alt key
No visual button focus

(edited to add) : having the *Hide underlined letters for keyboard navigation until I press the Alt key* checked works fine in other apps, it's just the PB apps that don't react as expected to the Alt key
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
sverson
Enthusiast
Enthusiast
Posts: 286
Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany

Post by sverson »

Sparkie wrote:...having the *Hide underlined letters for keyboard navigation until I press the Alt key* checked works fine in other apps, it's just the PB apps that don't react as expected to the Alt key
I still have this problem :cry:
>>underlined letters appear in debugger mode - but not in exe-files<< :?
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

After further investigation (Googling), it appears that this behavior is by design in XP :shock: :? :twisted:

This bit of code makes things work as expected if XP Skins is enabled and Hide underlined letters for keyboard navigation until I press the Alt key is turned on in XP Display Properties --> Appearance --> Effects.

Code: Select all

#WM_QUERYUISTATE = $129
#WM_UPDATEUISTATE = $128
#UIS_CLEAR = 2
#UIS_SET = 1
#UISF_HIDEACCEL = 2
#UISF_HIDEFOCUS = 1

Procedure MakeLong(low.w, high.w) 
  ProcedureReturn (high * $10000) | (low & $FFFF) 
EndProcedure
Procedure myWindowCallback(hWnd, msg, wParam, lParam)
  Shared uiState
  result = #PB_ProcessPureBasicEvents
  Select msg
    ;--> Entering Menu Loop, turn on accelerator underlining
    Case #WM_ENTERMENULOOP 
      ;--> Check if underlining is turned off
      uiState = SendMessage_(WindowID(0), #WM_QUERYUISTATE, 0, 0)
      ;--> if so, turn it on
      If uiState &#UISF_HIDEACCEL
        SendMessage_(WindowID(0), #WM_UPDATEUISTATE, MakeLong(#UIS_CLEAR, #UISF_HIDEACCEL), 0)
      EndIf
    ;--> Exiting Menu Loop, turn off accelerator underlining
    Case #WM_EXITMENULOOP 
      If uiState &#UISF_HIDEACCEL
        SendMessage_(WindowID(0), #WM_UPDATEUISTATE, MakeLong(#UIS_SET, #UISF_HIDEACCEL), 0)             
      EndIf
  EndSelect
  ProcedureReturn result
EndProcedure
If OpenWindow(0, 100, 100, 220, 170, #PB_Window_SystemMenu, "Tab Test") And CreateGadgetList(WindowID(0)) 
  SetWindowCallback(@myWindowCallback())
  If CreateMenu(0, WindowID())    ; here the menu creating starts....
    MenuTitle("&Project")
    MenuItem(1, "&Open"   +Chr(9)+"Ctrl+O")
    MenuItem(2, "&Save"   +Chr(9)+"Ctrl+S")
    MenuItem(3, "Save &As"+Chr(9)+"Ctrl+A")
    MenuItem(4, "&Close"  +Chr(9)+"Ctrl+C")
  EndIf
  StringGadget(0, 10, 10, 200, 20, "") 
  ButtonGadget(1, 10, 70, 200, 20, "Button&1") 
  StringGadget(2, 10, 100, 200, 20, "") 
  ButtonGadget(3, 10, 130, 200, 20, "Button&2")
  ActivateGadget(0) 
  ;--> Check if focus is turne off
  uiState = SendMessage_(WindowID(0), #WM_QUERYUISTATE, 0, 0)
  ;--> If so, turn it on
  If uiState &#UISF_HIDEFOCUS
    SendMessage_(WindowID(0), #WM_UPDATEUISTATE, MakeLong(#UIS_CLEAR, #UISF_HIDEFOCUS), 0)
  EndIf
  Repeat 
    event = WaitWindowEvent() 
  Until event = #PB_Event_CloseWindow 
EndIf
End
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
sverson
Enthusiast
Enthusiast
Posts: 286
Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany

Post by sverson »

Sparkie wrote:After further investigation (Googling), it appears that this behavior is by design in XP :shock: :? :twisted:
THX Sparkie :D

Do you know why it works in debugger mode without this callback?
You can disable SetWindowCallback(@myWindowCallback())

Code: Select all

...
If OpenWindow(0, 100, 100, 220, 170, #PB_Window_SystemMenu, "Tab Test") And CreateGadgetList(WindowID(0)) 
  ;SetWindowCallback(@myWindowCallback()) 
  If CreateMenu(0, WindowID())    ; here the menu creating starts.... 
...
In debugger mode underlined letters are allways swicted on and button focus is visible -> PB compiler bug?!? :?

:wink: sverson
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

sverson wrote:In debugger mode underlined letters are allways swicted on and button focus is visible
That's not the case for me. The only way that works here is by sending the #WM_UPDATEUISTATE messages.

XP skins enabled (PB Compiler options)
Hide underlined letters for keyboard navigation until I press the Alt key enabled (WinXP Display properties)

Debugger on
I don't see focus rect or underlined accelerators

Debugger off
Same results

Do you have any code for me to test?
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
sverson
Enthusiast
Enthusiast
Posts: 286
Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany

Post by sverson »

Sorry :oops: my mistake!
It's not a debugger - it's a jaPBe problem!

When I press F5 to start your demo from jaPBe the buttons allways have underlined letters (and selection is shown) even if I disable all your additional code. Menus are not affected! - ALT still works there!

Code: Select all

If OpenWindow(0, 100, 100, 220, 170, #PB_Window_SystemMenu, "Tab Test") And CreateGadgetList(WindowID(0))
  ;SetWindowCallback(@myWindowCallback())
  If CreateMenu(0, WindowID())    ; here the menu creating starts....
    MenuTitle("&Project")
    MenuItem(1, "&Open"   +Chr(9)+"Ctrl+O")
    MenuItem(2, "&Save"   +Chr(9)+"Ctrl+S")
    MenuItem(3, "Save &As"+Chr(9)+"Ctrl+A")
    MenuItem(4, "&Close"  +Chr(9)+"Ctrl+C")
  EndIf
  StringGadget(0, 10, 10, 200, 20, "")
  ButtonGadget(1, 10, 70, 200, 20, "Button&1")
  StringGadget(2, 10, 100, 200, 20, "")
  ButtonGadget(3, 10, 130, 200, 20, "Button&2")
  ActivateGadget(0)
  ; ;--> Check if focus is turne off
  ; uiState = SendMessage_(WindowID(0), #WM_QUERYUISTATE, 0, 0)
  ; ;--> If so, turn it on
  ; If uiState &#UISF_HIDEFOCUS
    ; SendMessage_(WindowID(0), #WM_UPDATEUISTATE, MakeLong(#UIS_CLEAR, #UISF_HIDEFOCUS), 0)
  ; EndIf
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
When I start the same exe from ...\PureBasic\Compilers\PureBasic9762296.exe (where jaPBe stores the exe started via F5) buttons have no underlined letters and selection is not shown but ALT still works on menus.

:? very strange thing! :?:

XP skins enabled (PB Compiler options) OK
Hide underlined letters for keyboard navigation until I press the Alt key enabled (WinXP Display properties) OK

ImageImage
It's supposed to be the same exe?!?!
left: jaPBe-F5 / right: ...\PureBasic\Compilers\PureBasic9762296.exe
Button2 is selected in both cases.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Ok, now I see what you mean. I have no idea why it's doing that, maybe GPI will come along and shed some light on this. :?
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

I just tried your code within PB IDE and same results as jaPBe.

Something else I noticed in both jaPBe and PB IDE is that if you select Compile / Run from the menu, the focus is lost and no underlines for accelerators. The shortcut for this menu item is F5. So why different results with the same menu item?

I also noticed that memory consumption is about 4k less when using F5 shortcut. :?
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
sverson
Enthusiast
Enthusiast
Posts: 286
Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany

...it's getting mysterious...

Post by sverson »

Now it's getting mysterious! :twisted:

The same exe behaves different depending on the way you call it!
Image Image
In both cases CheckBox1 is selected!
left: call via EnterKey -> underlined letters and selection OK
right: call via MouseKlick -> underlined letters and selection NOT OK

So it seems not to be GPIs problem. The jaPBe call is like a EnterKey call.

Code: Select all

If OpenWindow(0, 100, 100, 220, 170, #PB_Window_SystemMenu, "Tab Test") And CreateGadgetList(WindowID(0)) 
  If CreateMenu(0, WindowID())
    MenuTitle("&Project") 
    MenuItem(1, "&Open"   +Chr(9)+"Ctrl+O") 
    MenuItem(2, "&Save"   +Chr(9)+"Ctrl+S") 
    MenuItem(3, "Save &As"+Chr(9)+"Ctrl+A") 
    MenuItem(4, "&Close"  +Chr(9)+"Ctrl+C") 
  EndIf 
  StringGadget(0, 10, 10, 200, 20, "") 
  CheckBoxGadget(1, 10, 40,200, 20, "&CheckBox1")
  ButtonGadget(2, 10, 70, 200, 20, "Button&1") 
  StringGadget(3, 10, 100, 200, 20, "") 
  ButtonGadget(4, 10, 130, 200, 20, "Button&2") 
  ActivateGadget(0) 
  Repeat 
    Event = WaitWindowEvent() 
  Until Event = #PB_Event_CloseWindow 
EndIf 
End 
My system: WIN XP - PB 3.93

:wink: sverson
Post Reply