咨询个技术问题,顺便散点分

jdsnhan 2005-10-26 02:23:46
实现功能: 在窗体上动态增加控件,如st,cb,pic等,然后,客户可根据自己需求任意拖动控件,并保存位置。
问题所在,拖动释放后,控件移动的位置并不是拖动放置的原始位置,是pointerx(),pointery()这个位置。应该+(-)鼠标在控件中的相对偏移量,这个偏移量如何得到呢。在动态增加的控件中,老是为零,大家帮分析一下。
...全文
218 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
jdsnhan 2005-10-31
  • 打赏
  • 举报
回复
谢谢 leio((郁闷中...)) 的答复,问题是这样的,所添加的控件都是来自祖先,封装好的对象,这个时候,把il_oldx定义在祖先中,在lbuttondown判断时,取到的结果都是0,传递不出来。
虽然没解决根本问题,但给了我另外一个思路,万分感谢。
-------------------------------------------------------------
to 小鬼,呵呵,没做什么开发平台,不过是客户要求高了点,想实现的功能大点,原pb组的同事碰到了这样的问题,所以才弄弄看。
-------------------------------------------------------------
to 所有,来着有分,呵呵。
jdsnhan 2005-10-31
  • 打赏
  • 举报
回复
忙了一段时间别的,刚回来,谢谢大家这么热情。
wanghong_it 2005-10-30
  • 打赏
  • 举报
回复
学习
robert126 2005-10-30
  • 打赏
  • 举报
回复
早晚都学习!!!!!!!!!!!!!
「已注销」 2005-10-29
  • 打赏
  • 举报
回复
来晚了
bbdx2523 2005-10-29
  • 打赏
  • 举报
回复
技术不够,只能帮人顶一下,拿点分
cookjiang 2005-10-29
  • 打赏
  • 举报
回复
实力不够,哈哈
WorldMobile 2005-10-29
  • 打赏
  • 举报
回复
接分吧,问题楼上的都给回答了
pkyang 2005-10-28
  • 打赏
  • 举报
回复
曾分
cxy581ssx 2005-10-28
  • 打赏
  • 举报
回复
学习
jojophak 2005-10-28
  • 打赏
  • 举报
回复
留个记号来学习
给点分也不介意
mtu207 2005-10-27
  • 打赏
  • 举报
回复
学习!
li_d_s 2005-10-27
  • 打赏
  • 举报
回复
楼主用pb做开发平台啊?
Libra_Chen 2005-10-27
  • 打赏
  • 举报
回复
有人回了,就等接分~
lmby 2005-10-26
  • 打赏
  • 举报
回复
不潜水了?
我要求接10分,哈哈
lzheng2001 2005-10-26
  • 打赏
  • 举报
回复
分都给 leio((郁闷中...) 吧,难得这么热情回答
balloonman2002 2005-10-26
  • 打赏
  • 举报
回复
楼上答完了,:)
leio 2005-10-26
  • 打赏
  • 举报
回复
这个问题难吗?
随便做了个测试程序,没有任何问题,st,cb,pic动态创建出来,拖动后位置很准。

$PBExportHeader$w_main.srw
forward
global type w_main from window
end type
type cb_1 from commandbutton within w_main
end type
type cb_2 from commandbutton within w_main
end type
type cb_3 from commandbutton within w_main
end type
type st_1 from statictext within w_main
end type
type p_1 from picture within w_main
end type
type cb_4 from commandbutton within w_main
end type
end forward

global type w_main from window
integer width = 2030
integer height = 1440
boolean titlebar = true
string title = "Untitled"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
event ue_paint pbm_paint
cb_1 cb_1
cb_2 cb_2
cb_3 cb_3
st_1 st_1
p_1 p_1
cb_4 cb_4
end type
global w_main w_main

type prototypes

end prototypes

type variables
long il_oldx,il_oldy

end variables

on w_main.create
this.cb_1=create cb_1
this.cb_2=create cb_2
this.cb_3=create cb_3
this.st_1=create st_1
this.p_1=create p_1
this.cb_4=create cb_4
this.Control[]={this.cb_1,&
this.cb_2,&
this.cb_3,&
this.st_1,&
this.p_1,&
this.cb_4}
end on

on w_main.destroy
destroy(this.cb_1)
destroy(this.cb_2)
destroy(this.cb_3)
destroy(this.st_1)
destroy(this.p_1)
destroy(this.cb_4)
end on

event dragdrop;//windowobject lwo
//lwo = source
//p_1 luo_pic
//cb_1 luo_cb
//st_1 luo_st
//choose case lwo.typeof()
// case StaticText!
//end choose
//luo_p = source
//luo_p.x = this.pointerx() - il_oldx
//luo_p.y = this.pointery() - il_oldy
//

source.x = this.pointerx() - il_oldx
source.y = this.pointery() - il_oldy
end event

type cb_1 from commandbutton within w_main
event lbuttondown pbm_lbuttondown
integer x = 873
integer y = 1148
integer width = 457
integer height = 128
integer taborder = 60
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "button"
end type

event lbuttondown;il_oldx = this.pointerx()
il_oldy = this.pointery()
drag(begin!)

end event

type cb_2 from commandbutton within w_main
integer x = 1106
integer y = 540
integer width = 457
integer height = 128
integer taborder = 50
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "创建按钮"
end type

event clicked;cb_1 uo_cb
openuserobject(uo_cb,0,0)
end event

type cb_3 from commandbutton within w_main
integer x = 594
integer y = 540
integer width = 457
integer height = 128
integer taborder = 40
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "创建文本"
end type

event clicked;st_1 uo_st
openuserobject(uo_st,0,0)
end event

type st_1 from statictext within w_main
event lbuttondown pbm_lbuttondown
integer x = 329
integer y = 1208
integer width = 457
integer height = 72
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 67108864
string text = "文字文字"
boolean focusrectangle = false
end type

event lbuttondown;il_oldx = this.pointerx()
il_oldy = this.pointery()
drag(begin!)

end event

type p_1 from picture within w_main
event lbuttondown pbm_lbuttondown
integer x = 46
integer y = 1096
integer width = 229
integer height = 200
string picturename = "ApplicationIcon!"
boolean focusrectangle = false
end type

event lbuttondown;il_oldx = this.pointerx()
il_oldy = this.pointery()
drag(begin!)

end event

type cb_4 from commandbutton within w_main
integer x = 87
integer y = 540
integer width = 457
integer height = 128
integer taborder = 30
integer textsize = -12
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "创建PIC"
end type

event clicked;p_1 uo_p1
openuserobject(uo_p1,0,0)
end event



lzheng2001 2005-10-26
  • 打赏
  • 举报
回复
楼主能否发个源程序来让我改一下?
Binary Wang 2005-10-26
  • 打赏
  • 举报
回复
问题的确有难度,我解决不了,帮你顶一下。
加载更多回复(3)

1,076

社区成员

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

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