Tooltip and track

Just starting out? Need help? Post your questions and find answers here.
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Tooltip and track

Post by Nico »

This code works only on XP with theme and I do not understand why!

Can you help me!

Code: Select all

#TTF_TRANSPARENT=$100 
#TTF_TRACK=$20 
#TTF_ABSOLUTE=$80 

Global hToolTip,ti.TOOLINFO 

Procedure CreateToolTip(hParent) 
     icex.INITCOMMONCONTROLSEX 
     ti.TOOLINFO 
     icex\dwSize = SizeOf(icex) 
     icex\dwICC  = #ICC_WIN95_CLASSES 
      
     InitCommonControlsEx_(@icex) 
      
     sczTipText.s="Texte" 
     sczTipTitle.s="Title" 
      
     hToolTip = CreateWindowEx_(#WS_EX_TOPMOST, "ToolTips_Class32", "",#WS_POPUP| #TTS_NOPREFIX | #TTS_ALWAYSTIP,#CW_USEDEFAULT, #CW_USEDEFAULT,#CW_USEDEFAULT, #CW_USEDEFAULT,#Null,0, GetModuleHandle_(0),#Null) 
      
     ti\cbSize = SizeOf(TOOLINFO) 
     ti\uFlags = #TTF_IDISHWND | #TTF_TRACK | #TTF_ABSOLUTE ;| #TTF_TRANSPARENT 
     ti\hwnd   = hParent 
     ti\uId    = hParent 
     ti\hinst  = GetModuleHandle_(0) 
     ti\lpszText  = @sczTipText 
      
     SendMessage_(hToolTip,#TTM_ADDTOOL,0,@ti) 
     SendMessage_(hToolTip, #TTM_SETMAXTIPWIDTH, 0, 300) 
      
     If sczTipTitle>"" 
          SendMessage_(hToolTip, #TTM_SETTITLE, 1, sczTipTitle) 
     EndIf 
     SendMessage_(hToolTip,#TTM_TRACKACTIVATE,1,@ti) 
EndProcedure 
                                              

If OpenWindow(0, 100, 100, 400, 300,  #PB_Window_SystemMenu | #PB_Window_TitleBar, "BallonTip") 
      
     CreateToolTip(WindowID(0)) 
      
     Repeat 
          EventID.l=WaitWindowEvent() 
          Select EventID 
               Case #WM_MOUSEMOVE 
                    point.POINT\x=EventlParam()& $FFFF 
                    point.POINT\y=EventlParam() >>16 
                    ClientToScreen_(WindowID(0),@point) 
                    SendMessage_(hToolTip, #TTM_TRACKPOSITION, 0,((point\y+14)<<16)+point\x+14) 
          EndSelect 
          
     Until EventID = #PB_EventCloseWindow 
EndIf 
End
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

It works with XP without theme here. (If it's supposed to display a square balloontip following the cursor inside window.)
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

XP with theme= works
XP no theme = doesnt work.

I was going to say "it might be a theme feature" now if trond is 100% sure it was running with out xp theme then trash those words (Or I'll eat them, depends on the weather! -todays sunny- ) :lol:
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Post by Nico »

It's ok, I found the error; it's the structure TOOLINFO of PB!

Code: Select all

Structure TOOLINFO1
     cbSize.l
     uFlags.l
     hwnd.l
     uId.l
     rect.RECT
     hinst.l
     lpszText.l
     lParam.l
EndStructure 

Code: Select all

Debug SizeOf(TOOLINFO) 48 octets - error
Debug SizeOf(TOOLINFO1) 44 octets - good

In PB there is a parametre in more.
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

:? :!: Nasty one
Aye, so it does work now, you really spent many time debugging this, dont you? :) Thats the friggin' spirit!

:lol:
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
tomijan
Enthusiast
Enthusiast
Posts: 107
Joined: Sun Dec 11, 2005 1:32 pm

Post by tomijan »

Nico, there is very usefull code!
thx

tom
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Ok, now I found out:
I have turned off XP theming in Windows, and it still works IF:
I have checked XP theme in the compiler settings.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Very nice.

Code: Select all

;
; ToolTip following the cursor [by Nico]
;

#TTF_TRANSPARENT=$100 
#TTF_TRACK=$20 
#TTF_ABSOLUTE=$80 

Structure TOOLINFO1 
  cbSize.l 
  uFlags.l 
  hwnd.l 
  uID.l 
  rect.RECT 
  hInst.l 
  lpszText.l 
  lParam.l 
EndStructure
; TOOLINFO is PB is false

Global hToolTip,ti.TOOLINFO1

Procedure CreateToolTip(hParent) 
  icex.INITCOMMONCONTROLSEX 
  ti.TOOLINFO1
  icex\dwSize = SizeOf(icex) 
  icex\dwICC  = #ICC_WIN95_CLASSES 
  
  InitCommonControlsEx_(@icex) 
  
  sczTipText.s="Texte" 
  sczTipTitle.s="Title" 
  
  hToolTip = CreateWindowEx_(#WS_EX_TOPMOST, "ToolTips_Class32", "",#WS_POPUP| #TTS_NOPREFIX | #TTS_ALWAYSTIP,#CW_USEDEFAULT, #CW_USEDEFAULT,#CW_USEDEFAULT, #CW_USEDEFAULT,#Null,0, GetModuleHandle_(0),#Null) 
  
  ti\cbSize = SizeOf(TOOLINFO1) 
  ti\uFlags = #TTF_IDISHWND | #TTF_TRACK | #TTF_ABSOLUTE ;| #TTF_TRANSPARENT 
  ti\hwnd   = hParent 
  ti\uID    = hParent 
  ti\hInst  = GetModuleHandle_(0) 
  ti\lpszText  = @sczTipText 
  
  SendMessage_(hToolTip,#TTM_ADDTOOL,0,@ti) 
  SendMessage_(hToolTip, #TTM_SETMAXTIPWIDTH, 0, 300) 
  
  If sczTipTitle>"" 
    SendMessage_(hToolTip, #TTM_SETTITLE, 1, sczTipTitle) 
  EndIf 
  SendMessage_(hToolTip,#TTM_TRACKACTIVATE,1,@ti) 
EndProcedure 
                                              

If OpenWindow(0, 100, 100, 400, 300,  #PB_Window_SystemMenu | #PB_Window_TitleBar, "BallonTip") 
  
  CreateToolTip(WindowID(0)) 
  
  Repeat 
    EventID.l=WaitWindowEvent() 
    Select EventID 
      Case #WM_MOUSEMOVE 
        point.POINT\x=EventlParam()& $FFFF 
        point.POINT\y=EventlParam() >>16 
        ClientToScreen_(WindowID(0),@point) 
        SendMessage_(hToolTip, #TTM_TRACKPOSITION, 0,((point\y+14)<<16)+point\x+14) 
    EndSelect 
    
  Until EventID = #PB_EventCloseWindow 
EndIf 
End
Tested OK with WinNT4sp6
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Post by Nico »

With #TTS_BALLOON dosen'twork! :roll:
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

#TTF_TRANSPARENT does nothing.
Post Reply