ToolTips possible for disabled gadgets?

Windows specific forum
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

ToolTips possible for disabled gadgets?

Post by BarryG »

Like the topic says... is there a way (in Windows) to force a tooltip for a disabled gadget? (I have a disabled StringGadget but it would nice to explain to the user what it's currently showing, since the content is dynamic. And no, making the StringGadget read-only is not an option).
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: ToolTips possible for disabled gadgets?

Post by RASHAD »

Hi BarryG

Code: Select all

If OpenWindow(0, 0, 0, 400, 300, "StringGadget Flags", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ImageGadget(0,8,10,300,24,0)
  GadgetToolTip(0,"String Gadget Disabled")
  StringGadget(1, 0,0, 300, 24, "Normal StringGadget...")   
  GadgetToolTip(1,"String Gadget")
  SetWindowLongPtr_( GadgetID(1), #GWL_HWNDPARENT,GadgetID(0))
  ButtonGadget(2,10,270,60,24,"RUN")
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
       
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 2
            Run ! 1
            If run = 1
              DisableGadget(1,1)
            Else
              DisableGadget(1,0)
            EndIf
        EndSelect
    EndSelect
  Until Quit = 1
EndIf
Egypt my love
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: ToolTips possible for disabled gadgets?

Post by BarryG »

Thanks, Rashad! Nice example, and it taught me that all I need to do is put an ImageGadget (with its own tooltip) over my disabled StringGadget to do it. I don't even need the #GWL_HWNDPARENT flag to be applied.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: ToolTips possible for disabled gadgets?

Post by RASHAD »

Hi BarryG
You need SetWindowLongPtr_( GadgetID(1), #GWL_HWNDPARENT,GadgetID(0))
To be able to use the StringGadget() as usual
Egypt my love
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: ToolTips possible for disabled gadgets?

Post by BarryG »

I see. In my case, the StringGadget is always disabled (it's just for show instead of a TextGadget, because TextGadgets can't have thin one-pixel borders).
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: ToolTips possible for disabled gadgets?

Post by RASHAD »

If TextGadget() is more suitable for you
TextGadget with 1 pix border and ToolTip

Code: Select all

If OpenWindow(0, 0, 0, 270, 160, "TextGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    StringGadget(0,10,10,250, 20, "TextGadget Center + Border")
    TextGadget(1, 10, 40, 250, 20, "TextGadget Center + Border", #SS_NOTIFY|#WS_BORDER)
    GadgetToolTip(1,"TEST")
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
Egypt my love
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: ToolTips possible for disabled gadgets?

Post by BarryG »

Sorry, I should've been more clear. Those thin borders are black, instead of gray like the borders of ButtonGadgets and other gadgets. So a thin TextGadget border looks visually different and out of place. Look:

Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: ToolTips possible for disabled gadgets?

Post by RASHAD »

OK In that case maybe you can use FrameGadget() default with no text and borderless TextGadget()
I do not remember which frame style is grayed :)
Egypt my love
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: ToolTips possible for disabled gadgets?

Post by BarryG »

RASHAD wrote:I do not remember which frame style is grayed
I've tried all styles before, which is why I settled with a disabled StringGadget, because it was closest.

But I might try your FrameGadget() idea as well. Thanks for the reminder about that approach.
Post Reply