楼上各位好,我来了,我说的那个问题于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
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
$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
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
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