File: n_svc_tooltip.sru
Size: 47489
Date: Mon, 07 Apr 2008 21:32:10 +0200
$PBExportHeader$n_svc_tooltip.sru
$PBExportComments$Tooltip service
forward
global type n_svc_tooltip from n_svc_base
end type
end forward

shared variables
long hWndTT // Tooltip control window handle
long hWndBTT //Balloon Tooltip Handle
long ToolID = 1   // Tooltip internal ID
long BalloonToolID = 2000  // Tooltip internal ID
long Usage, UsageB
end variables

global type n_svc_tooltip from n_svc_base
boolean #pooled = true
end type
global n_svc_tooltip n_svc_tooltip

type variables
Public:
CONSTANT integer TTF_SUBCLASS = 16
CONSTANT integer TTF_IDISHWND = 0
Protected:
CONSTANT string TOOLTIPS_CLASS = "tooltips_class32"
end variables

forward prototypes
public subroutine of_setmaxtipwidth (readonly integer ai_maxwidth)
public function integer of_addtool (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly string as_tiptext, readonly integer ai_flags, readonly boolean ab_balloon)
public function integer of_addtool (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly string as_tiptext, readonly integer ai_flags)
public function integer of_geticontoint (readonly icon a_icon)
public function integer of_geticontoint (readonly string as_icon)
public function long of_create (ref n_svc_mgr anv_svc, readonly long al_style)
public function integer of_create (ref n_svc_mgr anv_svc)
public subroutine of_relaymsg (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly boolean ab_balloon)
public subroutine of_relaymsg (ref n_svc_mgr anv_svc, readonly dragobject ado_object)
public subroutine of_remove (readonly boolean ab_balloon)
public subroutine of_remove ()
public subroutine of_setballoontitle (ref n_svc_mgr anv_svc, readonly string as_title, readonly string as_icon)
public subroutine of_setballoontitle (ref n_svc_mgr anv_svc, readonly string as_title, readonly icon ai_icon)
public subroutine of_setfont (readonly long al_hfont)
public subroutine of_settipposition (readonly integer ai_x, readonly integer ai_y, readonly boolean ab_balloon)
public subroutine of_settipposition (readonly integer ai_x, readonly integer ai_y)
public subroutine of_settiptext (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly long al_tiptext, readonly boolean ab_balloon)
public subroutine of_settiptext (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly long al_tiptext)
public subroutine of_settiptext (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly string as_tiptext, readonly boolean ab_balloon)
public subroutine of_settiptext (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly string as_tiptext)
public subroutine of_settrack (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly integer ai_uid, readonly boolean ab_status, readonly boolean ab_balloon)
public subroutine of_settrack (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly integer ai_uid, readonly boolean ab_status)
public subroutine of_updatetiprect (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly long al_left, readonly long al_top, readonly long al_right, readonly long al_bottom, readonly boolean ab_balloon)
public subroutine of_updatetiprect (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly long al_left, readonly long al_top, readonly long al_right, readonly long al_bottom)
public subroutine of_dwmousemove (ref n_svc_mgr anv_svc, readonly u_dw adw, readonly dwobject adwo, ref string as_tip, ref string as_lastdwo, readonly long al_ttbid, readonly long al_ttid, ref boolean ab_hittest, ref boolean ab_balloon)
public function integer of_addtool (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly string as_tiptext)
public subroutine of_remove (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly boolean ab_balloon)
public function integer of_addtool (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly string as_tiptext, readonly boolean ab_balloon)
public subroutine of_remove (ref n_svc_mgr anv_svc, readonly dragobject ado_object)
public function integer of_addtool (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly string as_tiptext, readonly integer ai_flags, readonly boolean ab_balloon, readonly boolean ab_idishwnd)
public subroutine of_remove (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly boolean ab_balloon, readonly integer ai_id)
public subroutine of_remove (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly integer ai_id)
public subroutine of_scantooltips (ref n_svc_mgr anv_svc, readonly powerobject apo, readonly boolean ab_add)
public function string of_geticontostring (readonly icon a_icon)
end prototypes

public subroutine of_setmaxtipwidth (readonly integer ai_maxwidth);//===========================================================================
// Function: of_Setmaxtipwidth (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  readonly Integer ai_maxwidth
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
Send(hWndTT, CWin32.TTM_SETMAXTIPWIDTH, 0, ai_maxwidth)
end subroutine

public function integer of_addtool (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly string as_tiptext, readonly integer ai_flags, readonly boolean ab_balloon);//===========================================================================
// Function: of_Addtool (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly String as_tiptext
//  readonly Integer ai_flags
//  readonly Boolean ab_balloon
//---------------------------------------------------------------------------
// Returns: Integer
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
RETURN of_AddTool(anv_svc, ado_object, as_tiptext, ai_flags, ab_balloon, FALSE)
end function

public function integer of_addtool (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly string as_tiptext, readonly integer ai_flags);//===========================================================================
// Function: of_Addtool (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly String as_tiptext
//  readonly Integer ai_flags
//---------------------------------------------------------------------------
// Returns: Integer
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
n_svc_bit lnb
long ll_flags

anv_svc.of_LoadSvc(lnb, CSvc.BIT)
lnb.of_BitwiseOR({CWin32.TTF_IDISHWND, ai_flags})

RETURN of_AddTool(anv_svc, ado_object, as_tiptext, ll_flags, FALSE, TRUE)
end function

public function integer of_geticontoint (readonly icon a_icon);//===========================================================================
// Function: of_Geticontoint (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  readonly Icon a_icon
//---------------------------------------------------------------------------
// Returns: Integer
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
integer li_ret

CHOOSE CASE a_icon
   CASE none!
      li_ret = 0
   CASE information!
      li_ret = 1
   CASE exclamation!
      li_ret = 2
   CASE StopSign!
      li_ret = 3
   CASE Question!
      li_ret = 1
END CHOOSE

RETURN li_ret
end function

public function integer of_geticontoint (readonly string as_icon);//===========================================================================
// Function: of_Geticontoint (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  readonly String as_icon
//---------------------------------------------------------------------------
// Returns: Integer
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
integer li_ret

CHOOSE CASE lower(as_icon)
   CASE "none", ""
      li_ret = 0
   CASE "information"
      li_ret = 1
   CASE "exclamation"
      li_ret = 2
   CASE "stopsign"
      li_ret = 3
   CASE "question"
      li_ret = 1
END CHOOSE

RETURN li_ret
end function

public function long of_create (ref n_svc_mgr anv_svc, readonly long al_style);//===========================================================================
// Function: of_Create (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly Long al_style
//---------------------------------------------------------------------------
// Returns: Long
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
n_svc_win32 lnv_win32
long ll_h

//load service
anv_svc.of_loadsvc(lnv_win32, CSvc.WIN32)

lnv_win32.InitCommonControls()

ll_h = lnv_win32.CreateWindowEx(CWin32.WS_EX_TOPMOST, TOOLTIPS_CLASS, "", CWin32.TTF_CENTERTIP + CWin32.TTS_ALWAYSTIP + al_style, &
         CWin32.CW_USEDEFAULT, CWin32.CW_USEDEFAULT, CWin32.CW_USEDEFAULT, CWin32.CW_USEDEFAULT,  &
         0, 0, Handle(GetApplication()),0)
//set tooltipwidth to 240 pixels
this.of_setmaxtipwidth(240)

RETURN ll_h
end function

public function integer of_create (ref n_svc_mgr anv_svc);//===========================================================================
// Function: of_Create (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//---------------------------------------------------------------------------
// Returns: Integer
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
RETURN of_Create(anv_svc, 0)
end function

public subroutine of_relaymsg (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly boolean ab_balloon);//===========================================================================
// Function: of_Relaymsg (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly Boolean ab_balloon
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
// This function will send the control message to the toolwindow control
MSG Msg
n_svc_win32 lnw

//load services
anv_svc.of_loadsvc(lnw, CSvc.WIN32)

Msg.hWnd    = Handle(ado_object)
Msg.Message = 512 // WM_MOUSEMOVE
Msg.WParam  = Message.WordParm
Msg.LParam  = Message.LongParm

IF ab_balloon THEN
   lnw.RelayMsg(hWndbTT, CWin32.TTM_RELAYEVENT, 0, Msg)
ELSE
   lnw.RelayMsg(hWndTT, CWin32.TTM_RELAYEVENT, 0, Msg)
END IF
end subroutine

public subroutine of_relaymsg (ref n_svc_mgr anv_svc, readonly dragobject ado_object);//===========================================================================
// Function: of_Relaymsg (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
of_RelayMsg(anv_svc, ado_object, FALSE)
end subroutine

public subroutine of_remove (readonly boolean ab_balloon);//===========================================================================
// Function: of_Remove (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  readonly Boolean ab_balloon
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
long lhwnd

IF ab_balloon THEN
   UsageB --
   lhwnd = hwndbtt
ELSE
   Usage -- 
   lhwnd = hwndtt
END IF
n_svc_mgr lnsvc
n_svc_win32 lnw

IF Usage <= 0 THEN
   //destroy tooltip control
// lnsvc.of_loadsvc(lnw, CSvc.WIN32)   
// lnw.DestroyWindow(hwndtt)
END IF
IF UsageB <= 0 THEN
   //destroy tooltip control
// lnsvc.of_loadsvc(lnw, CSvc.WIN32)   
// lnw.DestroyWindow(hwndbtt)
END IF
end subroutine

public subroutine of_remove ();//===========================================================================
// Function: of_Remove (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
of_Remove(FALSE)
end subroutine

public subroutine of_setballoontitle (ref n_svc_mgr anv_svc, readonly string as_title, readonly string as_icon);//===========================================================================
// Function: of_Setballoontitle (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly String as_title
//  readonly String as_icon
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
long lpszText
n_svc_win32 lnw

//load services
anv_svc.of_loadsvc(lnw, CSvc.WIN32)

lpszText = lnw.LocalAlloc(0,255)
lnw.LStrCpy(lpszText,Left(as_title,255))

Send(hwndbtt, CWin32.TTM_SETTITLEA, this.of_geticontoint(as_icon), lpsztext)
lnw.LocalFree(lpszText)
end subroutine

public subroutine of_setballoontitle (ref n_svc_mgr anv_svc, readonly string as_title, readonly icon ai_icon);//===========================================================================
// Function: of_Setballoontitle (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly String as_title
//  readonly Icon ai_icon
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
long lpszText
n_svc_win32 lnw

//load services
anv_svc.of_loadsvc(lnw, CSvc.WIN32)

lpszText = lnw.LocalAlloc(0,255)
lnw.LStrCpy(lpszText,Left(as_title,255))

Send(hwndbtt, CWin32.TTM_SETTITLEA, this.of_geticontoint(ai_icon), lpsztext)
lnw.LocalFree(lpszText)
end subroutine

public subroutine of_setfont (readonly long al_hfont);//===========================================================================
// Function: of_Setfont (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  readonly Long al_hfont
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
// Sets the font used in the tooltip window
Send(hWndTT, CWin32.WM_SETFONT, al_hfont, 1)
end subroutine

public subroutine of_settipposition (readonly integer ai_x, readonly integer ai_y, readonly boolean ab_balloon);//===========================================================================
// Function: of_Settipposition (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  readonly Integer ai_x
//  readonly Integer ai_y
//  readonly Boolean ab_balloon
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================

long lhwnd
IF ab_balloon THEN
   lhwnd = hwndbtt
ELSE
   lhwnd = hwndtt
END IF
Send(lhwnd, CWin32.TTM_TRACKPOSITION, 0, Long(ai_x, ai_y))
end subroutine

public subroutine of_settipposition (readonly integer ai_x, readonly integer ai_y);//===========================================================================
// Function: of_Settipposition (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  readonly Integer ai_x
//  readonly Integer ai_y
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
of_Settipposition(ai_x, ai_y, FALSE)
end subroutine

public subroutine of_settiptext (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly long al_tiptext, readonly boolean ab_balloon);//===========================================================================
// Function: of_Settiptext (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly Long al_uid
//  readonly Long al_tiptext
//  readonly Boolean ab_balloon
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================

TOOLINFO ToolInfo
n_svc_win32 lnw
n_svc_sizeof lns
long lhwnd

IF ab_balloon THEN
   lhwnd = hwndbtt
ELSE
   lhwnd = hwndtt
END IF

//load services
anv_svc.of_loadsvc(lnw, CSvc.WIN32)
anv_svc.of_loadsvc(lns, CSvc.SIZEOF)

ToolInfo.cbsize = lns.sizeof(ToolInfo)
ToolInfo.hWnd     = Handle(ado_object)
ToolInfo.uID      = al_uid
ToolInfo.lpszText = al_tiptext

lnw.ToolTipMsg(lhwnd, CWin32.TTM_UPDATETIPTEXT, 0, ToolInfo)
end subroutine

public subroutine of_settiptext (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly long al_tiptext);//===========================================================================
// Function: of_Settiptext (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly Long al_uid
//  readonly Long al_tiptext
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
of_SetTipText(anv_svc, ado_object, al_uid, al_tiptext, FALSE)
end subroutine

public subroutine of_settiptext (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly string as_tiptext, readonly boolean ab_balloon);//===========================================================================
// Function: of_Settiptext (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly Long al_uid
//  readonly String as_tiptext
//  readonly Boolean ab_balloon
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================

long lpszText
n_svc_win32 lnw

//load services
anv_svc.of_loadsvc(lnw, CSvc.WIN32)

lpszText = lnw.LocalAlloc(0, 255)
lnw.LStrCpy(lpszText,Left(as_tiptext, 255))
this.of_SetTipText(anv_svc, ado_object, al_uid, lpszText, ab_balloon)

lnw.LocalFree(lpszText)
end subroutine

public subroutine of_settiptext (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly string as_tiptext);//===========================================================================
// Function: of_Settiptext (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly Long al_uid
//  readonly String as_tiptext
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
of_settiptext(anv_svc, ado_object, al_uid, as_tiptext, FALSE)
end subroutine

public subroutine of_settrack (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly integer ai_uid, readonly boolean ab_status, readonly boolean ab_balloon);//===========================================================================
// Function: of_Settrack (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly Integer ai_uid
//  readonly Boolean ab_status
//  readonly Boolean ab_balloon
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================

TOOLINFO ToolInfo
n_svc_win32 lnw
n_svc_sizeof lns
long lhwnd

IF ab_balloon THEN
   lhwnd = hwndbtt
ELSE
   lhwnd = hwndtt
END IF

//load services
anv_svc.of_loadsvc(lnw, CSvc.WIN32)
anv_svc.of_loadsvc(lns, CSvc.SIZEOF)

ToolInfo.cbSize   = lns.sizeof(ToolInfo)
ToolInfo.hWnd     = Handle(ado_object)
ToolInfo.uID      = ai_uid

If ab_status Then 
   lnw.ToolTipMsg(lhwnd, CWin32.TTM_TRACKACTIVATE, 1, ToolInfo)
Else
   lnw.ToolTipMsg(lhwnd, CWin32.TTM_TRACKACTIVATE, 0, ToolInfo)
End If
end subroutine

public subroutine of_settrack (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly integer ai_uid, readonly boolean ab_status);//===========================================================================
// Function: of_Settrack (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly Integer ai_uid
//  readonly Boolean ab_status
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
of_Settrack(anv_svc, ado_object, ai_uid, ab_status, FALSE)
end subroutine

public subroutine of_updatetiprect (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly long al_left, readonly long al_top, readonly long al_right, readonly long al_bottom, readonly boolean ab_balloon);//===========================================================================
// Function: of_Updatetiprect (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly Long al_uid
//  readonly Long al_left
//  readonly Long al_top
//  readonly Long al_right
//  readonly Long al_bottom
//  readonly Boolean ab_balloon
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================

TOOLINFO ToolInfo
n_svc_win32 lnw
n_svc_sizeof lns
long lhwnd

IF ab_balloon THEN
   lhwnd = hwndbtt
ELSE
   lhwnd = hwndtt
END IF

//load services
anv_svc.of_loadsvc(lns, CSvc.SIZEOF)
anv_svc.of_loadsvc(lnw, CSvc.WIN32)

ToolInfo.cbsize = lns.sizeof(ToolInfo)
ToolInfo.hWnd  = Handle(ado_object)
ToolInfo.uID   = al_uid

ToolInfo.Rect.Left   = UnitsToPixels(al_Left, XUnitstoPixels!)
ToolInfo.Rect.Top    = UnitsToPixels(al_Top, YUnitstoPixels!)
ToolInfo.Rect.Right  = UnitsToPixels(al_Right, XUnitstoPixels!)
ToolInfo.Rect.Bottom = UnitsToPixels(al_Bottom, YUnitstoPixels!)

lnw.ToolTipMsg(lhwnd, CWin32.TTM_NEWTOOLRECT, 0, ToolInfo)

end subroutine

public subroutine of_updatetiprect (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly long al_uid, readonly long al_left, readonly long al_top, readonly long al_right, readonly long al_bottom);//===========================================================================
// Function: of_Updatetiprect (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly Long al_uid
//  readonly Long al_left
//  readonly Long al_top
//  readonly Long al_right
//  readonly Long al_bottom
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
of_updatetiprect(anv_svc, ado_object, al_uid, al_left, al_top, al_right, al_bottom, FALSE)
end subroutine

public subroutine of_dwmousemove (ref n_svc_mgr anv_svc, readonly u_dw adw, readonly dwobject adwo, ref string as_tip, ref string as_lastdwo, readonly long al_ttbid, readonly long al_ttid, ref boolean ab_hittest, ref boolean ab_balloon);//===========================================================================
// Function: of_Dwmousemove (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly u_dw adw
//  readonly DWObject adwo
//  reference String as_tip
//  reference String as_lastdwo
//  readonly Long al_ttbid
//  readonly Long al_ttid
//  reference Boolean ab_hittest
//  reference Boolean ab_balloon
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
n_svc_dw lnv_dw
n_svc_isempty lnc
string lsd, lsbt, lsbi
long ll_id, ll_offx, ll_offy

ab_hittest = FALSE
//exit if datawindow
IF STRING(adwo.Type) = Cdwobj.DATAWINDOW THEN   
   as_lastdwo = ""
   RETURN
END IF
//exit if same DWO
IF as_lastdwo = STRING(adwo.name) THEN RETURN
//load service
lsd = STRING(adwo.name)
anv_svc.of_loadsvc(lnv_dw, CSvc.DW)
anv_svc.of_loadsvc(lnc, CSvc.ISEMPTY)
as_tip = lnv_dw.of_gettagkeyword(anv_svc, adw, lsd, CTooltip.KEY_TOOLTIP)
IF lnc.of_isempty(as_tip) THEN 
   ab_hittest = FALSE
   as_lastdwo = ""
   RETURN
ELSE
   ab_hittest = TRUE
END IF
IF lnv_dw.of_gettagkeyword(anv_svc, adw, lsd, CTooltip.KEY_BALLOON) = "1" THEN
   ab_balloon = TRUE
   lsbt = lnv_dw.of_gettagkeyword(anv_svc, adw, lsd, CTooltip.KEY_BALLOON_TITLE)
   lsbi = lnv_dw.of_gettagkeyword(anv_svc, adw, lsd, CTooltip.KEY_BALLOON_ICON)
   this.of_setballoontitle(anv_svc, lsbt, lsbi)
   ll_id = al_ttbid
ELSE
   ab_balloon = FALSE
   ll_id = al_ttid
END IF
//save last dwo
as_lastdwo = lsd
this.of_settiptext(anv_svc, adw, ll_id, as_tip, ab_balloon)

//get scrollbar offsets
ll_offx = LONG(adw.Describe("DataWindow.HorizontalScrollPosition"))
ll_offy = LONG(adw.Describe("DataWindow.VerticalScrollPosition"))

this.of_updatetiprect(anv_svc, adw, ll_id, LONG(adwo.X) - ll_offx, LONG(adwo.Y) - ll_offy, LONG(adwo.X) + LONG(adwo.Width), LONG(adwo.Y) + LONG(adwo.Height), ab_balloon)
end subroutine

public function integer of_addtool (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly string as_tiptext);//===========================================================================
// Function: of_Addtool (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly String as_tiptext
//---------------------------------------------------------------------------
// Returns: Integer
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
RETURN of_AddTool(anv_svc, ado_object, as_tiptext, TTF_SUBCLASS, FALSE)
end function

public subroutine of_remove (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly boolean ab_balloon);//===========================================================================
// Function: of_Remove (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly Boolean ab_balloon
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
of_Remove(anv_svc, ado_object, ab_balloon, 0)
end subroutine

public function integer of_addtool (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly string as_tiptext, readonly boolean ab_balloon);//===========================================================================
// Function: of_Addtool (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly String as_tiptext
//  readonly Boolean ab_balloon
//---------------------------------------------------------------------------
// Returns: Integer
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
RETURN of_AddTool(anv_svc, ado_object, as_tiptext, TTF_SUBCLASS, ab_balloon, TRUE)
//RETURN of_AddTool(anv_svc, ado_object, as_tiptext, 0, ab_balloon, FALSE)
end function

public subroutine of_remove (ref n_svc_mgr anv_svc, readonly dragobject ado_object);//===========================================================================
// Function: of_Remove (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
of_Remove(anv_svc, ado_object, FALSE)
end subroutine

public function integer of_addtool (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly string as_tiptext, readonly integer ai_flags, readonly boolean ab_balloon, readonly boolean ab_idishwnd);//===========================================================================
// Function: of_Addtool (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly String as_tiptext
//  readonly Integer ai_flags
//  readonly Boolean ab_balloon
//  readonly Boolean ab_idishwnd
//---------------------------------------------------------------------------
// Returns: Integer
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================

TOOLINFO ToolInfo
n_svc_win32 lnw
n_svc_sizeof lns
long lhwnd
//load services
anv_svc.of_loadsvc(lnw, CSvc.WIN32)
anv_svc.of_loadsvc(lns, CSvc.SIZEOF)
//Create Tooltip Class If not Valid
IF ab_balloon THEN
   IF lnw.IsWindow(hwndbtt) = 0 THEN hWndbTT = this.of_create(anv_svc, CWin32.TTS_BALLOON)
   lhwnd = hWndbTT
ELSE
   IF lnw.IsWindow(hwndtt) = 0 THEN hWndTT = this.of_create(anv_svc)
   lhwnd = hWndTT
END IF

ToolInfo.cbSize   = lns.sizeof(ToolInfo)
ToolInfo.uFlags   = ai_flags
ToolInfo.hWnd     = Handle(ado_object)
ToolInfo.hInstance= 0 // Not used 
IF ab_idishwnd THEN
   ToolInfo.uID = Handle(ado_object)
ELSE
   IF ab_balloon THEN
      ToolInfo.uID      = BalloonToolID
      BalloonToolID++
   ELSE
      ToolInfo.uID      = ToolID
      ToolID++
   END IF
END IF
ToolInfo.lpszText = lnw.LocalAlloc(0,80)
lnw.Lstrcpy(ToolInfo.lpszText, Left(as_tiptext,80))

ToolInfo.Rect.Left   = 0
ToolInfo.Rect.Top    = 0
ToolInfo.Rect.Right  = UnitsToPixels(ado_object.Width, XUnitsToPixels!)
ToolInfo.Rect.Bottom = UnitsToPixels(ado_object.Height, YUnitsToPixels!)

IF lnw.ToolTipMsg(lhwnd, CWin32.TTM_ADDTOOL, 0, ToolInfo) = 0 THEN
   MessageBox("Error","Cannot register object in the toolwindow control!",StopSign!,Ok!)
   lnw.LocalFree(ToolInfo.lpszText) // Free Allocated Memory
   RETURN CRet.FAILURE
END IF

//increment
IF ab_balloon THEN
   UsageB ++
ELSE
   Usage ++
END IF

lnw.LocalFree(ToolInfo.lpszText) // Free Allocated Memory

IF ab_balloon THEN
   Return (BalloonToolID - 1)
ELSE
   Return (ToolID - 1)
END IF
end function

public subroutine of_remove (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly boolean ab_balloon, readonly integer ai_id);//===========================================================================
// Function: of_Remove (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly DragObject ado_object
//  readonly Boolean ab_balloon
//  readonly Integer ai_id
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
TOOLINFO ToolInfo
n_svc_win32 lnw
n_svc_sizeof lns
long lhwnd
//load services
anv_svc.of_loadsvc(lnw, CSvc.WIN32)
anv_svc.of_loadsvc(lns, CSvc.SIZEOF)

IF ab_balloon THEN
   lhwnd = hWndbTT
ELSE
   lhwnd = hWndTT
END IF

ToolInfo.cbSize   = lns.sizeof(ToolInfo)
ToolInfo.hWnd     = Handle(ado_object)
IF ai_id > 0 THEN
   ToolInfo.uID      = ai_id
ELSE
   ToolInfo.uID      = Handle(ado_object)
END IF

lnw.ToolTipMsg(lhwnd, CWin32.TTM_DELTOOL, 0, ToolInfo)

of_Remove(ab_balloon)
end subroutine

public subroutine of_remove (ref n_svc_mgr anv_svc, readonly dragobject ado_object, readonly integer ai_id);of_Remove(anv_svc, ado_object, FALSE, ai_id)
end subroutine

public subroutine of_scantooltips (ref n_svc_mgr anv_svc, readonly powerobject apo, readonly boolean ab_add);//===========================================================================
// Function: of_Scantooltips (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  reference n_svc_mgr anv_svc
//  readonly PowerObject apo
//  readonly Boolean ab_add
//---------------------------------------------------------------------------
// Returns: (none)
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
long ll_count, n
windowobject lwo[]
n_svc_powerbuilder lnv_pb

anv_svc.of_LoadSvc(lnv_pb, CSvc.POWERBUILDER)

ll_count = lnv_pb.of_GetWindowObjects(apo, lwo)
FOR n = 1 to ll_count
   CHOOSE CASE lwo[n].TypeOf()
      CASE CommandButton!
         IF lnv_pb.of_isdescendant(CFBase.CommandButton, lwo[n].ClassDefinition) THEN
            u_cb lcb
            
            lcb = lwo[n]
            IF lcb.#Tooltip THEN
               IF ab_add THEN
                  of_AddTool(anv_svc, lcb, lcb.#TooltipText, lcb.#BalloonTooltip)
               ELSE
                  of_Remove(anv_svc, lcb)
               END IF
            END IF
         END IF
      CASE Checkbox!
         IF lnv_pb.of_isdescendant(CFBase.CheckBox, lwo[n].ClassDefinition) THEN
            u_cbx lcbx
            
            lcbx = lwo[n]
            IF lcbx.#Tooltip THEN
               IF ab_add THEN
                  of_AddTool(anv_svc, lcbx, lcbx.#TooltipText, lcbx.#BalloonTooltip)
               ELSE
                  of_Remove(anv_svc, lcbx)
               END IF
            END IF
         END IF
      CASE DropdownListbox!
         IF lnv_pb.of_isdescendant(CFBase.DropdownListbox, lwo[n].ClassDefinition) THEN
            u_ddlb lddlb
            
            lddlb = lwo[n]
            IF lddlb.#Tooltip THEN
               IF ab_add THEN
                  of_AddTool(anv_svc, lddlb, lddlb.#TooltipText, lddlb.#BalloonTooltip)
               ELSE
                  of_Remove(anv_svc, lddlb)
               END IF
            END IF
         END IF
      CASE DropdownPictureListbox!
         IF lnv_pb.of_isdescendant(CFBase.DropdownPictureListbox, lwo[n].ClassDefinition) THEN
            u_ddplb lddplb
            
            lddplb = lwo[n]
            IF lddplb.#Tooltip THEN
               IF ab_add THEN
                  of_AddTool(anv_svc, lddplb, lddplb.#TooltipText, lddplb.#BalloonTooltip)
               ELSE
                  of_Remove(anv_svc, lddplb)
               END IF
            END IF
         END IF
      CASE Editmask!
         IF lnv_pb.of_isdescendant(CFBase.Editmask, lwo[n].ClassDefinition) THEN
            u_em lem
            
            lem = lwo[n]
            IF lem.#Tooltip THEN
               IF ab_add THEN
                  of_AddTool(anv_svc, lem, lem.#TooltipText, lem.#BalloonTooltip)
               ELSE
                  of_Remove(anv_svc, lem)
               END IF
            END IF
         END IF
      CASE Picture!
         IF lnv_pb.of_isdescendant(CFBase.Picture, lwo[n].ClassDefinition) THEN
            u_p lp
            
            lp = lwo[n]
            IF lp.#Tooltip THEN
               IF ab_add THEN
                  of_AddTool(anv_svc, lp, lp.#TooltipText, lp.#BalloonTooltip)
               ELSE
                  of_Remove(anv_svc, lp)
               END IF
            END IF
         END IF
      CASE RadioButton!
         IF lnv_pb.of_isdescendant(CFBase.RadioButton, lwo[n].ClassDefinition) THEN
            u_rb lrb
            
            lrb = lwo[n]
            IF lrb.#Tooltip THEN
               IF ab_add THEN
                  of_AddTool(anv_svc, lrb, lrb.#TooltipText, lrb.#BalloonTooltip)
               ELSE
                  of_Remove(anv_svc, lrb)
               END IF
            END IF
         END IF
      CASE StaticHyperlink!
         IF lnv_pb.of_isdescendant(CFBase.StaticHyperlink, lwo[n].ClassDefinition) THEN
            u_shl lshl
            
            lshl = lwo[n]
            IF lshl.#Tooltip THEN
               IF ab_add THEN
                  of_AddTool(anv_svc, lshl, lshl.#TooltipText, lshl.#BalloonTooltip)
               ELSE
                  of_Remove(anv_svc, lshl)
               END IF
            END IF
         END IF
      CASE SingleLineEdit!
         IF lnv_pb.of_isdescendant(CFBase.SingleLineEdit, lwo[n].ClassDefinition) THEN
            u_sle lsle
            
            lsle = lwo[n]
            IF lsle.#Tooltip THEN
               IF ab_add THEN
                  of_AddTool(anv_svc, lsle, lsle.#TooltipText, lsle.#BalloonTooltip)
               ELSE
                  of_Remove(anv_svc, lsle)
               END IF
            END IF
         END IF
      CASE StaticText!
         IF lnv_pb.of_isdescendant(CFBase.StaticText, lwo[n].ClassDefinition) THEN
            u_st lst
            
            lst = lwo[n]
            IF lst.#Tooltip THEN
               IF ab_add THEN
                  of_AddTool(anv_svc, lst, lst.#TooltipText, lst.#BalloonTooltip)
               ELSE
                  of_Remove(anv_svc, lst)
               END IF
            END IF
         END IF
      CASE Userobject!
         IF lnv_pb.of_isdescendant(CFBase.Icon, lwo[n].ClassDefinition) THEN
            u_icon luo_icon
            
            luo_icon = lwo[n]
            IF luo_icon.#Tooltip THEN
               IF ab_add THEN
                  of_AddTool(anv_svc, luo_icon.uo_pbnicanvas, luo_icon.#TooltipText, luo_icon.#BalloonTooltip)
               ELSE
                  of_Remove(anv_svc, luo_icon.uo_pbnicanvas)
               END IF
            END IF
         END IF         
   END CHOOSE
NEXT
end subroutine

public function string of_geticontostring (readonly icon a_icon);//===========================================================================
// Function: of_Geticontostring (public )
// Object: n_svc_tooltip
//---------------------------------------------------------------------------
// Description:
// Note:
//---------------------------------------------------------------------------
// Parameters:
//  readonly Icon a_icon
//---------------------------------------------------------------------------
// Returns: String
//---------------------------------------------------------------------------
// Author: (Yeyi) Gabriel B. Abulencia
//===========================================================================
string ls_ret

CHOOSE CASE a_icon
   CASE none!
      ls_ret = "none"
   CASE information!
      ls_ret = "information"
   CASE exclamation!
      ls_ret = "exclamation"
   CASE StopSign!
      ls_ret = "stopsign"
   CASE Question!
      ls_ret = "question"
END CHOOSE

RETURN ls_ret
end function

on n_svc_tooltip.create
call super::create
end on

on n_svc_tooltip.destroy
call super::destroy
end on