问个问题,dw中有一列数据很长,如果让设置成自动行高很影响版面美观,我想实现用鼠标只上去就想tooltip一样显示其全部内容,可以实现吗?
先谢过了^_^
[解决办法]
- VB.NET code
//================================================================================// Script - ue_display_column for u_dw_base // Reason: 显示列值//--------------------------------------------// Modified By: qin_phoenix Date: 2009.10.15//--------------------------------------------////================================================================================If ii_DwId = 0 Then Return 0if lb_set_column_display then if lower(dwo.type) = 'column' then Integer li_X, li_Y String ls_Text //根据数据窗口列的位置和名称设置ToolTip控件 If dwo.Type = "column" Then If String( dwo.Name ) <> is_ColName Then li_X = UnitsToPixels( Integer( dwo.X ),XUnitsToPixels! ) li_Y = UnitsToPixels( Integer( dwo.Y ), YUnitsToPixels! ) //更新ToolTip控件窗口 inv_ToolTip.of_UpdatetipRect( This, ii_dwID, li_X, li_Y, & li_X + UnitsToPixels( Integer( dwo.Width ), XUnitsToPixels! ), & li_Y + UnitsToPixels( Integer( dwo.Height ), YUnitsToPixels! ) ) //引用各列的列名作为提示文本 is_ColName = String( dwo.Name ) ls_Text = This.Describe( is_ColName + "_t.Text" ) inv_ToolTip.of_settiptext( This, ii_dwID, "请输入" + ls_Text ) End IfEnd IfReturn 0 end if end if
[解决办法]
主要是要解决在mousemove 事件中如何获取到该行的数据。
用行高和xpos 计算鼠标所在行试试。
[解决办法]
pb9的tooltip
forward
global type nvo_tooltips from nonvisualobject
end type
type point from structure within nvo_tooltips
end type
type msg from structure within nvo_tooltips
end type
type rect from structure within nvo_tooltips
end type
type toolinfo from structure within nvo_tooltips
end type
end forward
type point from structure
longx
longy
end type
type msg from structure
longhwnd
longmessage
longwparam
longlparam
longtime
pointpt
end type
type rect from structure
longleft
longtop
longright
longbottom
end type
type toolinfo from structure
longcbsize
longuflags
longhwnd
longuid
rectrect
longhinstance
longlpsztext
end type
global type nvo_tooltips from nonvisualobject autoinstantiate
end type
type prototypes
SubRoutine InitCommonControls() library "comctl32.dll"
Function long CreateWindowExA(ulong dwExStyle, string ClassName, &
long WindowName, ulong dwStyle, ulong X, ulong Y, ulong nWidth, &
ulong nHeight, ulong hWndParent, ulong hMenu, ulong hInstance, &
ulong lpParam) library "user32.dll"
Function integer DestroyWindow(long hWnd) library "user32.dll"
Function integer ToolTipMsg(long hWnd, long uMsg, long wParam, &
REF TOOLINFO ToolInfo) library "user32.dll" Alias For "SendMessageA"
Function integer RelayMsg(long hWnd, long uMsg, long wParam, &
REF MSG Msg) library "user32.dll" Alias For "SendMessageA"
Function long LocalAlloc(long Flags, long Bytes) library "kernel32.dll"
Function long LocalFree(long MemHandle) library "kernel32.dll"
Function long lstrcpy(long Destination, string Source) library "kernel32.dll"
end prototypes
type variables
//私有常量
Private:
//常量
CONSTANT stringTOOLTIPS_CLASS = 'tooltips_class32'
CONSTANT ulongCW_USEDEFAULT = 2147483648
CONSTANT longWM_USER = 1024
CONSTANT longWS_EX_TOPMOST = 8
CONSTANT longWM_SETFONT = 48
// ToolTips消息
CONSTANT long TTM_ADDTOOL = WM_USER + 4
CONSTANT long TTM_NEWTOOLRECT = WM_USER + 6
CONSTANT long TTM_RELAYEVENT = WM_USER + 7
CONSTANT long TTM_UPDATETIPTEXT= WM_USER + 12
CONSTANT long TTM_TRACKACTIVATE = WM_USER + 17
CONSTANT long TTM_TRACKPOSITION= WM_USER + 18
//公共变量和常量
Public:
long hWndTT// Tooltip control window handle
long ToolID = 1// Tooltip internal ID
//Tooltips标记
CONSTANT integer TTF_CENTERTIP = 2
CONSTANT integer TTF_RTLREADING = 4
CONSTANT integer TTF_SUBCLASS= 16
CONSTANT integer TTF_TRACK = 32
CONSTANT integer TTF_ABSOLUTE= 128
CONSTANT integer TTF_TRANSPARENT= 256
CONSTANT integer TTF_DI_SETITEM = 32768
end variables
forward prototypes
public subroutine of_relaymsg (dragobject object)
public subroutine of_setfont (long hfont)
public subroutine of_settipposition (integer x, integer y)
public subroutine of_settiptext (dragobject object, long uid, long tiptext)
public subroutine of_settiptext (dragobject object, long uid, string tiptext)
public subroutine of_settrack (dragobject object, integer uid, boolean status)
public subroutine of_updatetiprect (dragobject object, long uid, long left, long top, long right, long bottom)
public function integer of_addtool (dragobject object, string tiptext, integer flags)
end prototypes
public subroutine of_relaymsg (dragobject object);//此函数用于向显示ToolTips窗口发送控制消息
MSG Msg
Msg.hWnd = Handle(Object)
Msg.Message= 512// WM_MOUSEMOVE
Msg.WParam = Message.WordParm
Msg.LParam = Message.LongParm
RelayMsg(hWndTT,TTM_RELAYEVENT, 0, Msg)
end subroutine
public subroutine of_setfont (long hfont);//此函数用于设置ToolTips窗口的字体
Send(hWndTT,WM_SETFONT,hFont,1)
end subroutine
public subroutine of_settipposition (integer x, integer y);//此函数用于设置ToolTips的位置
Send(hWndTT,TTM_TRACKPOSITION,0,Long(X,Y))
end subroutine
public subroutine of_settiptext (dragobject object, long uid, long tiptext);//此函数用于为ToolTips窗口设置新文本
TOOLINFO ToolInfo
ToolInfo.hWnd = Handle(Object)
ToolInfo.uID = uID
ToolInfo.lpszText = TipText
ToolTipMsg(hWndTT,TTM_UPDATETIPTEXT, 0, ToolInfo)
end subroutine
public subroutine of_settiptext (dragobject object, long uid, string tiptext);//此函数用于为ToolTips窗口设置新文本
long lpszText
lpszText = LocalAlloc(0,255)
lStrCpy(lpszText,Left(TipText,255))
of_settiptext(Object,uId,lpszText)
LocalFree(lpszText)
end subroutine
public subroutine of_settrack (dragobject object, integer uid, boolean status);//此函数用于激活或取消ToolTips窗口设置新文本
//参数Status为True时激活,为False时取消
TOOLINFO ToolInfo
ToolInfo.cbSize = 40
ToolInfo.hWnd = Handle(Object)
ToolInfo.uID = uID
If Status Then
ToolTipMsg(hWndTT,TTM_TRACKACTIVATE,1,ToolInfo)
Else
ToolTipMsg(hWndTT,TTM_TRACKACTIVATE,0,ToolInfo)
End If
end subroutine
public subroutine of_updatetiprect (dragobject object, long uid, long left, long top, long right, long bottom);//此函数用于更新ToolTips的矩形框
TOOLINFO ToolInfo
ToolInfo.hWnd= Handle(Object)
ToolInfo.uID= uID
ToolInfo.Rect.Left= Left
ToolInfo.Rect.Top= Top
ToolInfo.Rect.Right= Right
ToolInfo.Rect.Bottom= Bottom
ToolTipMsg(hWndTT,TTM_NEWTOOLRECT,0,ToolInfo)
end subroutine
public function integer of_addtool (dragobject object, string tiptext, integer flags);//此函数用于注册要显示ToolTips的控件
//参数:
//object : 要注册的控件
//tiptext: Tooltips文本
//Flags: 标志位
TOOLINFO ToolInfo
ToolInfo.cbSize = 40
ToolInfo.uFlags = Flags
ToolInfo.hWnd = Handle(Object)
ToolInfo.hInstance = 0
ToolInfo.uID = ToolID
ToolID++
ToolInfo.lpszText = LocalAlloc(0,80)
POST LocalFree(ToolInfo.lpszText) //释放分配的内存
LStrCpy(ToolInfo.lpszText,Left(tiptext,80))
ToolInfo.Rect.Left= 0
ToolInfo.Rect.Top = 0
ToolInfo.Rect.Right= UnitsToPixels(Object.Width,XUnitsToPixels!)
ToolInfo.Rect.Bottom = UnitsToPixels(Object.Height,YUnitsToPixels!)
If ToolTipMsg(hWndTT,TTM_ADDTOOL, 0, ToolInfo) = 0 Then
MessageBox("提示信息","注册控件出错!",StopSign!,Ok!)
Return(-1)
End If
Return(ToolID - 1)
end function
on nvo_tooltips.create
call super::create
TriggerEvent( this, "constructor" )
end on
on nvo_tooltips.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on
event constructor;InitCommonControls()
hWndTT = CreateWindowExA(WS_EX_TOPMOST,TOOLTIPS_CLASS,0, &
TTF_CENTERTIP, CW_USEDEFAULT, CW_USEDEFAULT, &
CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, Handle(GetApplication()),0)
end event
event destructor;DestroyWindow(hWndTT)
end event
[解决办法]
邮箱
[解决办法]
datawindow的mousemvoe
integer li_X, li_Y
string ls_Text
If dwo.Type = "column" Then //如果为输入域
If String(dwo.Name) <> is_ColName Then
li_X = UnitsToPixels(Integer(dwo.X),XUnitsToPixels!)
li_Y = UnitsToPixels(Integer(dwo.Y),YUnitsToPixels!)
//设置矩形
invo_ToolTip.Of_UpdatetipRect(This,ii_dwID, &
li_X, &
li_Y, &
li_X + UnitsToPixels(Integer(dwo.Width),XUnitsToPixels!), &
li_Y + UnitsToPixels(Integer(dwo.Height),YUnitsToPixels!))
is_ColName = String(dwo.Name)
ls_Text = This.Describe(is_ColName + "_t.text") //得到标题文本
//显示ToolTips
invo_ToolTip.Of_SetTipText(This,ii_dwID, "请输入" + ls_Text)
End If
End If
[解决办法]
可以用tooltip或者自己写个窗口也可
事件可以写在mousemove里