Author Topic: Tooltips with toolbar buttons?  (Read 3002 times)

0 Members and 1 Guest are viewing this topic.

Aurel

  • Guest
Tooltips with toolbar buttons?
« on: September 10, 2013, 05:42:44 AM »
I ask same question on thinbasic forum in hope that maybe Eros have a idea how to do this on api level.
I can create on easy way tooltip for any control , but with toolbar buttons i have a problem.
it looks that tti.uID (member of tooltip structure) -
don't respond on toolbar button ID, or in another word how to extract or get toolbar button handler
and then add this handler to tootip structure ID ?
any help...


PS. I try in a DLib way but it looks again that oxygen do not respond on that way like in case
of tab control to... ???

JRS

  • Guest
Re: Tooltips with toolbar buttons?
« Reply #1 on: September 10, 2013, 10:58:09 AM »
Try using Google to get you on the right path. Here is a PureBasic thread on the subject.

Change tooltip for 'minimize' button?

Aurel

  • Guest
Re: Tooltips with toolbar buttons?
« Reply #2 on: September 10, 2013, 12:17:36 PM »
It looks that i finally get it what i need and understand how the tooltip on toolbar button is created
in DLib,so i will use this method because is far simplier than classic C way with *pNMHDR
which require event triggering.

Aurel

  • Guest
Re: Tooltips with toolbar buttons?
« Reply #3 on: September 10, 2013, 11:43:24 PM »
And now adding toolbar buttons is ...
Code: [Select]
'TBUTTONS & TOOLTIPS -------------------------------------------------
INT tooltip
tooltip = SetToolTip(htbar)

AddTButton(htbar, 100, 0, "New File")
AddTButton(htbar, 101, 1, "Open File")
AddTButton(htbar, 102, 2, "Save As...")
AddTButton(htbar, 103, 3, "Save File")
AddTButton(htbar, 104, 4, "Close File")
AddTButton(htbar, 105, 5, "Copy -->")

Frankolinox

  • Guest
Re: Tooltips with toolbar buttons?
« Reply #4 on: September 12, 2013, 03:08:50 AM »
hi aurel, my "one euro" for you ;) perhpas this can be a help for your tooltip feature..

Code: [Select]
'
'help code snippet for aurel for tooltip
'
include "minwin.inc"

%TTN_FIRST           = 0-520    
%TTN_GETDISPINFOA    = %TTN_FIRST - 0
%TTN_NEEDTEXT        = %TTN_GETDISPINFOA
%TTN_NEEDTEXTA       = %TTN_GETDISPINFOA
%TTN_NEEDTEXTW       = %TTN_GETDISPINFOW
%TCM_FIRST           = &H1300
%TCM_HITTEST         = %TCM_FIRST + 13

%IDM_NEW   = 2001
%IDM_OPEN  = 2002
%IDM_SAVE  = 2003
%IDM_SAVEAS = 2004

dim ghtabmdi as sys

Type PointApi
 x as sys
 y as sys
End Type

TYPE TBBUTTON
iBitmap    as long
idCommand  as long
fsState    as byte
fsStyle    as byte
     bReserved[0] as byte
     bReserved[1] as byte
dwData     as long
    iString     as long
END TYPE

TYPE TC_HITTESTINFO 'DWORD
   pt as pointapi
   flags as long
END TYPE

TYPE NMHDR  
   hwndFrom AS LONG
   idfrom   AS LONG
   code     AS LONG
END TYPE

TYPE TOOLTIPTEXTA
   hdr       AS NMHDR        
   lpszText  AS STRING 'ASCIIZ PTR ' WSTRING
   szText    AS STRING 'ASCIIZ * 80 ' WSTRING
   hInst     AS LONG
   uFlags    AS LONG        
   lParam    AS LONG        
END TYPE

TYPE TBNOTIFYA
   hdr      AS NMHDR
   iItem    AS LONG
   tbButton AS TBBUTTON
   cchText  AS LONG    
   pszText  AS STRING 'ASCIIZ PTR
   rcButton AS RECT        
END TYPE

DECLARE FUNCTION GetCursorPos LIB "USER32.DLL" ALIAS "GetCursorPos" ( _
   BYREF lpPoint AS POINTAPI _  
 ) AS LONG                      

DECLARE FUNCTION ScreenToClient LIB "USER32.DLL" ALIAS "ScreenToClient" ( _
   BYVAL hWnd AS DWORD _          
 , BYREF lpPoint AS POINTAPI _        
 ) AS LONG                        

FUNCTION TabCtrl_HitTest (BYVAL hwndTab AS DWORD, BYREF pinfo AS TC_HITTESTINFO) AS LONG
   FUNCTION = SendMessage(hwndTab, %TCM_HITTEST, 0, @pinfo) 'VARPTR(pinfo))
END FUNCTION

Function WndProc(byval hWnd as long,byval wMsg as long, byval wParam as long,byval lparam as sys) as sys callback
'..code as known
END FUNCTION

FUNCTION OnNotify (BYVAL hWnd AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS DWORD) AS LONG

   LOCAL tbn         AS TBNOTIFYA
   LOCAL lpToolTip   AS TOOLTIPTEXTA
   LOCAL rc          AS RECT        
   LOCAL szText      AS STRING
   LOCAL hPopupMenu  AS LONG  
   LOCAL i           AS LONG  
   LOCAL TabIdx      AS LONG  
   LOCAL pInfo       AS TC_HITTESTINFO
   LOCAL szCaption   AS STRING
   LOCAL NumFiles    AS LONG
   LOCAL szPath      AS STRING
   LOCAL nTab        AS LONG  
   LOCAL lpNmh       AS NMHDR
   LOCAL strTabTxt   AS STRING

   ' Retrieves the coordinates of the window's client area
   GetClientRect hWnd, rc

   ' Toolbar notification messages
   tbn = lParam
   ' Need text for tooltips
   IF @tbn.hdr.code = %TTN_NEEDTEXT THEN
      lpToolTip = lParam
      szText = ""
      SELECT CASE @lpToolTip.hdr.idFrom
         CASE %IDM_NEW           : szText = " New File "
         CASE %IDM_OPEN          : szText = " Open File "
         CASE %IDM_SAVE          : szText = " Save File "
         CASE %IDM_SAVEAS        : szText = " Save File As..."
         '..
      END SELECT
      @lpToolTip.lpszText = szText 'VARPTR(szText)
      ' Tab tooltip
      GetCursorPos pInfo.pt
      ScreentoClient ghTabMdi, pInfo.pt
      TabIdx = TabCtrl_HitTest(ghTabMdi, pInfo)
      IF TabIdx = 0 THEN '=>
         szCaption = ""
         '--------------- UBOUND ----------------- //
         'IF UBOUND(g_TabFilePaths) => TabIdx THEN
         '   szCaption = g_TabFilePaths(TabIdx) ' & " | " & "Tab #" & format$(TabIdx)
         'END IF
         '--------------- UBOUND ----------------- //
         lpToolTip = lParam
         @lpToolTip.lpszText = szCaption 'VARPTR(szCaption)
      END IF
    END IF
End function

'command for "ubound" for oxy is unknown here ;)

print "ok"

the command "Ubound" is still missing here, but other parts are working, I have tested.
the code part is converted from jose's old sed editor. the equates I have picked up seperately.

best regards, frank

Aurel

  • Guest
Re: Tooltips with toolbar buttons?
« Reply #5 on: September 12, 2013, 03:32:25 AM »
hi frank...
yes i know for this type of code and looks to me to complex, my method is used from api functions
which are built in DLib interpreter and which are quite easier to use.
« Last Edit: September 12, 2013, 04:13:11 AM by Aurel »