如何实现像使用Windows一样,当鼠标停在图标上时显示提示信息?

LRG315 2004-03-07 09:08:35
多谢指教!
...全文
186 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
LRG315 2004-04-19
  • 打赏
  • 举报
回复
小弟我的上面这种方法有缺陷

1:不是浮动窗口,
2:不是最顶层,
3:自动宽、高控制得不是好,
4:...还有的其它,就请各位朋友帮帮小弟我了,

大家一起进步,才是真正的进步!
LRG315 2004-04-19
  • 打赏
  • 举报
回复
楼上各位好,我来了,我说的那个问题于3月底完成了,已经给客户用了.
我要实现的功能是:当鼠标单击数据窗口,且有数据时,就调用函数显示信息.
方法是:用个Edit模仿Delphi中的Hint.
函数:返回值类型:integer,
参数1:Window->w_window 参数2:datawindow->dw_source 参数3:multilineedit-->m_edit
参数4:integer->is_x 参数5:integer->is_y 参数6:is_row
代码如下:
int i,j,numbertemp,ii,npoint
string bands,obj_clicked,str,str1,str2,str3,str4,coltype,title
datetime timetemp
date datetemp
string a,b,aa,bb
m_edit.x= dw_source.x +dw_source.pointerx()+50// is_x
m_edit.y= dw_source.y +dw_source.pointery()+50//is_y - 10
if m_edit.y + m_edit.height>=w_window.height then
m_edit.y= w_window.height - m_edit.height - 100
m_edit.SetRedraw(true)
for i=1 to long(dw_source.object.datawindow.column.count)
a="#"+ string(i) +".name"
b = dw_source.Describe(a)
aa="#"+ string(i) +".visible"
bb=dw_source.describe(aa)
if bb='0' then continue
str2="#" + string(i)+".dbname"
str3 = dw_source.Describe(str2)
npoint=pos(str3,'.')
if npoint>0 then str3=replace(str3,npoint,1,'_')
coltype=dw_source.Describe(b + ".ColType")
title=dw_source.Describe(str3 + "_t.text")
if title='!' then
title=dw_source.Describe(b + "_t.text")
end if
if title='!' then
title=b
end if
if len(coltype)<2 then continue
if lower(left(coltype,8)) ='datetime' then
str1=string(dw_source.getItemDateTime(is_row,i))
if str1='' or isnull(str1) then str1=' '
str=str+"【" + title + "】 " +str1+char(13)+char(10)
str1=' '
elseif lower(left(coltype,4))='char' then
str1=dw_source.getitemstring(is_row,i)
if str1='' or isnull(str1) then str1=' '
str=str+"【" + title + "】 " +str1+char(13)+char(10)
str1=' '
elseif lower(left(coltype,4))='long' or
lower(left(coltype,4))='real' or
lower(left(coltype,4))='inte' or
lower(left(coltype,4))='doub' or
lower(left(coltype,4))='deci' or
lower(left(coltype,4))='numb' then
str1=string(dw_source.getitemnumber(is_row,i))
if str1='' or isnull(str1) then str1=' '
str=str+"【" + title + "】 " +str1+char(13)+char(10)
str1=' '
elseif lower(left(coltype,4))='date' and
lower(left(coltype,8)) <>'datetime' then
str1=string(dw_source.getitemdate(is_row,i))
if str1='' or isnull(str1) then str1=' '
str=str+"【" + title + "】 " +str1+char(13)+char(10)
str1=' '
end if
coltype=''
next
m_edit.height=m_edit.linecount()*65
m_edit.text=str
m_edit.visible = TRUE
return 0
zhangchi0532 2004-04-12
  • 打赏
  • 举报
回复
public function integer uf_init (readonly boolean ab_isorgsize, readonly string as_picname, readonly string as_unenablepicname, readonly window aw_window, readonly statictext ast_pop, string as_poptext);
/*参数说明:
ib_isOrgSize :显示的图片是否按图片默认大小显示
is_picName:控件可用的时候的图片
is_unenabledpic:不可用的时候的图片
ist_pop:静态文本,用来显示提示文字
iw_window:控件的父窗口
as_poptext:提示文字
*/
this.ib_isOrgSize = ab_isOrgSize

this.is_picName = as_picName

this.is_unenabledpic = as_unenablepicname

this.ist_pop = ast_pop


this.iw_window = aw_window

this.is_poptext = as_poptext
if trim(is_poptext) ='' or isnull(is_poptext) then
messagebox('提示','提示文字不可为空!',stopsign!)
return -1
end if
return 0
end function

public subroutine uf_setenabled (boolean ab_enable);if ab_enable then
this.picturename = is_picname
else
this.picturename = is_unenabledpic
end if

this.triggerevent("ue_enable")
end subroutine

on u_cm_float_button.create
this.st_text=create st_text
this.ln_1=create ln_1
this.ln_3=create ln_3
this.ln_2=create ln_2
this.ln_4=create ln_4
this.p_1=create p_1
this.Control[]={this.st_text,&
this.ln_1,&
this.ln_3,&
this.ln_2,&
this.ln_4,&
this.p_1}
end on

on u_cm_float_button.destroy
destroy(this.st_text)
destroy(this.ln_1)
destroy(this.ln_3)
destroy(this.ln_2)
destroy(this.ln_4)
destroy(this.p_1)
end on

type st_text from statictext within u_cm_float_button
int X=187
int Y=24
int Width=55
int Height=64
boolean Enabled=false
boolean FocusRectangle=false
long TextColor=33554432
long BackColor=67108864
int TextSize=-9
int Weight=400
string FaceName="宋体"
FontCharSet FontCharSet=GB2312CharSet!
FontPitch FontPitch=Variable!
end type

type ln_1 from line within u_cm_float_button
boolean Enabled=false
int BeginX=5
int BeginY=4
int EndX=5
int EndY=132
int LineThickness=4
long LineColor=16777215
end type

type ln_3 from line within u_cm_float_button
boolean Enabled=false
int BeginX=169
int BeginY=4
int EndX=169
int EndY=132
int LineThickness=4
long LineColor=33554432
end type

type ln_2 from line within u_cm_float_button
boolean Enabled=false
int BeginX=5
int BeginY=4
int EndX=174
int EndY=4
int LineThickness=4
long LineColor=16777215
end type

type ln_4 from line within u_cm_float_button
boolean Enabled=false
int BeginX=5
int BeginY=128
int EndX=174
int EndY=128
int LineThickness=4
long LineColor=33554432
end type

type p_1 from picture within u_cm_float_button
event ue_mousemove pbm_mousemove
event ue_lbuttondown pbm_lbuttondown
event ue_lbuttonup pbm_lbuttonup
event type long ue_timer ( )
int X=14
int Y=12
int Width=151
int Height=112
string Tag="sdfsdf"
boolean FocusRectangle=false
end type
zhangchi0532 2004-04-12
  • 打赏
  • 举报
回复
$PBExportHeader$u_cm_float_button.sru
$PBExportComments$平面按钮
forward
global type u_cm_float_button from UserObject
end type
type st_text from statictext within u_cm_float_button
end type
type ln_1 from line within u_cm_float_button
end type
type ln_3 from line within u_cm_float_button
end type
type ln_2 from line within u_cm_float_button
end type
type ln_4 from line within u_cm_float_button
end type
type p_1 from picture within u_cm_float_button
end type
end forward

global type u_cm_float_button from UserObject
int Width=187
int Height=140
boolean Border=true
long BackColor=67108864
long PictureMaskColor=536870912
long TabTextColor=33554432
long TabBackColor=67108864
event ue_click ( )
event ue_enable pbm_enable
st_text st_text
ln_1 ln_1
ln_3 ln_3
ln_2 ln_2
ln_4 ln_4
p_1 p_1
end type
global u_cm_float_button u_cm_float_button

type prototypes
Function Long SetCapture(Long hwnd) library "user32"
FUNCTION ulong ReleaseCapture() LIBRARY "user32.dll"
SUBROUTINE Sleep(ulong milli) LIBRARY "Kernel32.dll"
end prototypes

type variables
private:
//是否适应图片大小
boolean ib_isOrgSize = true
//图片文件
string is_picName = ''
//不可用的时候图片文件
string is_unenabledpic = ''
//显示提示文字的文本框
StaticText ist_pop
//窗口
window iw_window
int i = 0

long il_second
long il_oldx=0, il_oldy=2
long il_newx, il_newy
long il_count = 0

uo_timer mytimer
boolean ib_mousebuttonStatus = false
string is_poptext

boolean ib_out = false
boolean ib_isHavaView = false

boolean ib_isViewText //是否在右边显示文字
end variables

forward prototypes
public function integer uf_init (readonly boolean ab_isorgsize, readonly string as_picname, readonly string as_unenablepicname, readonly window aw_window, readonly statictext ast_pop, string as_poptext)
public subroutine uf_setenabled (boolean ab_enable)
end prototypes

event ue_enable;if this.enabled = true then
p_1.picturename = is_picname
else
p_1.picturename = is_unenabledpic
end if
end event
zhangchi0532 2004-04-12
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=1929
这个链接的代码有点问题,就是鼠标事件的处理中,第一次点击没问题,但第二此没有反映,第三次没问题,依次类推!!!
小弟经过3个小时的奋战,终于搞定平面按钮的uo,就象ie的工具栏,鼠标在图标上的时候,图标凸出,并显示提示文字
//定时器
$PBExportHeader$uo_timer.sru
forward
global type uo_timer from timing
end type
end forward

global type uo_timer from timing
end type
global uo_timer uo_timer

type variables
picture ipb_picButton
end variables
forward prototypes
public function integer uf_init (readonly picture apb_picbutton)
end prototypes

public function integer uf_init (readonly picture apb_picbutton);this.ipb_picButton = apb_picbutton
return 0
end function
on uo_timer.create
call timing::create
TriggerEvent( this, "constructor" )
end on

on uo_timer.destroy
call timing::destroy
TriggerEvent( this, "destructor" )
end on

event timer;
ipb_picbutton.triggerevent("ue_timer")
end event
cmaboy 2004-04-12
  • 打赏
  • 举报
回复
就用PB本身的东西,完全可以实现,在陶清网站上有源代码,你搜索一下,我原来下载过,只是手头没有带。
原理很简单,就是在你需要显示的控件的mousemove中写代码,控制你那个提示文本框是否显示,以及显示的位置。一旦鼠标移开,就隐藏
yuhanchen 2004-04-12
  • 打赏
  • 举报
回复
同意楼上的观点,pb8已经支持这种功能了,不用在写代码了把
feixianzhi 2004-04-12
  • 打赏
  • 举报
回复
图标?
图片按钮和图片控件都有一个powertiptext属性,在此输入你想要显示得信息,在程序中鼠标放在控件上就显示。
如果是工具栏上得图标,可以设置toolbar的microhelp,也可以显示信息。
uoche 2004-04-12
  • 打赏
  • 举报
回复
不是有个mousemove事件中吗
你可以在那里写代码了
zhangchi0532 2004-04-12
  • 打赏
  • 举报
回复
终于贴完了!
zhangchi0532 2004-04-12
  • 打赏
  • 举报
回复
csdn禁止连续回复三次,所以都没机会说明一下,代码针对的是pb65,8以上就支持了,因此,是帮助继续使用pb65的苦难兄弟的。
event ue_mousemove;long ll_temp

SetCapture( handle( this ) )

if flags <> 0 then return 0

if xpos > 0 and xpos < this.width and ypos > 0 and ypos< this.height then
ln_1.linecolor = rgb(255,255,255)
ln_2.linecolor = rgb(255,255,255)
ln_3.linecolor = rgb(0,0,0)
ln_4.linecolor = rgb(0,0,0)
ln_1.visible = true
ln_2.visible = true
ln_3.visible = true
ln_4.visible = true

il_newx = xpos
il_newy = ypos
mytimer.start(0.1)
else
ReleaseCapture( )
ln_1.visible = false
ln_2.visible = false
ln_3.visible = false
ln_4.visible = false

ib_isHavaView = false
ib_out = true
il_count = 0
parent.width = this.width +30
parent.ist_pop.visible = false
ib_mousebuttonStatus = false
mytimer.stop()
end if

return 0

end event

event ue_lbuttondown;ln_1.visible = true
ln_2.visible = true
ln_3.visible = true
ln_4.visible = true

ln_1.linecolor = rgb(0,0,0)
ln_2.linecolor = rgb(0,0,0)
ln_3.linecolor = rgb(255,255,255)
ln_4.linecolor = rgb(255,255,255)


parent.ist_pop.visible = false
ib_mousebuttonStatus = true

mytimer.stop()

return 2
end event
event ue_lbuttonup;ln_1.visible = false
ln_2.visible = false
ln_3.visible = false
ln_4.visible = false

ib_mousebuttonStatus = true
parent.triggerevent("ue_click")



end event
event ue_timer;int li_num, li

li_num = 0
for li = 1 to len(is_poptext)
if asc(mid(is_poptext, li, 1)) > 128 then
li_num++
li++
end if
next
parent.ist_pop.width = 60*li_num
parent.ist_pop.text = is_poptext



parent.ist_pop.y = parent.y +parent.height + 20
if parent.ist_pop.y + parent.ist_pop.height > iw_window.workspaceheight() then
parent.ist_pop.y = parent.y + parent.height - parent.ist_pop.height
parent.ist_pop.x = parent.x + parent.width + 20
end if

parent.ist_pop.x = parent.x
if parent.ist_pop.x + parent.ist_pop.width > iw_window.workspacewidth() then
parent.ist_pop.x = iw_window.workspacewidth() - parent.ist_pop.width
if parent.ist_pop.x < 0 then parent.ist_pop.x = 0
end if

if il_oldx = il_newx and il_oldy = il_newy then
if ib_mousebuttonStatus = false then
il_count++
if parent.ist_pop.visible = false and ib_isHavaView = false then
parent.ist_pop.visible = true
ib_isHavaView = true

else
if il_count > 4 then
parent.ist_pop.visible = false
end if
end if
else
parent.ist_pop.visible = false
end if
else
parent.ist_pop.visible = false
end if
il_oldx = this.pointerx()
il_oldy = this.pointery()

return 0
end event

event constructor;int li, li_num

mytimer = create uo_timer
mytimer.uf_init(p_1)

if is_picName = '' or isnull(is_picname) or is_unenabledpic = '' or isnull(is_unenabledpic ) then
messagebox('错误','没有设置图片文件路径!~r~n请使用uf_init初始化图片文件路径!',stopsign!)
return 1
else
if parent.enabled = false then
this.picturename = is_unenabledpic
else
this.picturename = is_picname
end if

end if

//设置是否默认适应图片大小
this.OriginalSize = ib_isOrgSize


ln_1.visible = false
ln_2.visible = false
ln_3.visible = false
ln_4.visible = false

st_text.width = 240


parent.width = this.width + 30
parent.height = this.height + 30

this.x = 15
this.y = 15

ln_1.beginx = 5
ln_1.beginy = 5

ln_2.beginx = 5
ln_2.beginy = 5

ln_1.endx = 5
ln_2.endy = 5
//线的长宽应该比图片大20,一边留10
ln_1.endy = ln_1.beginy + this.height + 20
ln_2.endx = ln_2.beginx + this.width + 20


ln_3.beginx = ln_2.endx
ln_3.beginy = ln_1.beginy
ln_3.endx = ln_2.endx
ln_3.endy = ln_1.endy + 1

ln_4.beginx = ln_2.beginx
ln_4.beginy = ln_1.endy
ln_4.endx = ln_2.endx
ln_4.endy = ln_1.endy

parent.ist_pop.visible = false

if parent.enabled = false then
return 1
end if


end event
event destructor;destroy mytimer
end event
qlzgdzfl 2004-04-11
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=1929

看看这个对你有啥帮助
我不会,如果成功了告诉我一声,我也在找
lzheng2001 2004-04-11
  • 打赏
  • 举报
回复
TGWall(我到长城(岁岁花似人不同,过好今天)的方法可以, 能够不用API的话就不要用了!
dants 2004-04-11
  • 打赏
  • 举报
回复
我正在做。

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧