Page 1 of 1

ToolTips possible for disabled gadgets?

Posted: Sun Feb 28, 2021 5:17 am
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).

Re: ToolTips possible for disabled gadgets?

Posted: Sun Feb 28, 2021 6:20 am
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

Re: ToolTips possible for disabled gadgets?

Posted: Sun Feb 28, 2021 9:36 am
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.

Re: ToolTips possible for disabled gadgets?

Posted: Sun Feb 28, 2021 10:00 am
by RASHAD
Hi BarryG
You need SetWindowLongPtr_( GadgetID(1), #GWL_HWNDPARENT,GadgetID(0))
To be able to use the StringGadget() as usual

Re: ToolTips possible for disabled gadgets?

Posted: Sun Feb 28, 2021 10:19 am
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).

Re: ToolTips possible for disabled gadgets?

Posted: Sun Feb 28, 2021 11:01 am
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

Re: ToolTips possible for disabled gadgets?

Posted: Sun Feb 28, 2021 11:25 am
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

Re: ToolTips possible for disabled gadgets?

Posted: Sun Feb 28, 2021 11:31 am
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 :)

Re: ToolTips possible for disabled gadgets?

Posted: Sun Feb 28, 2021 11:46 am
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.