大侠帮忙啊~以前写的程序都是800*600,现在客户都换1024*768了,怎么办阿?

derris 2002-06-15 05:49:33
以前用过可以随窗口调整大小的服务对象,一时找不到了 :(
...全文
48 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
jimly 2002-06-17
  • 打赏
  • 举报
回复
sybase中国有
WorldMobile 2002-06-17
  • 打赏
  • 举报
回复
把这个写到窗口的resize事件中

Integer li_i, li_width, li_count, li_height
Datawindow ldw_toolbar
UserObject luo_toolbar
For li_i = 1 To UpperBound ( Control )
if not isvalid(control[li_i]) then return
If Lower ( Control [ li_i ].ClassName ( ) ) = "cb_toolbar" Then
If Control [ li_i ].TypeOf ( ) = datawindow! Then
ldw_toolbar = Control [ li_i ]
li_width = This.WorkSpaceWidth ( )
ldw_toolbar.Width = li_width
Else
luo_toolbar = Control [ li_i ]
li_width = newwidth
luo_toolbar.Resize ( li_width , luo_toolbar.Height )
luo_toolbar.Dynamic Event ext_Resize ( )
End If
Exit
End If
Next

DragObject ldo_object
GraphicObject lgo_parent
UserObject luo_Parent
Window lw_parent
Datawindow ldw_object
li_count = UpperBound ( istr_position )
For li_i = 1 To li_count
// Get parent coordinate
ldo_object = istr_position [ li_i ].Object
lgo_parent = ldo_object.GetParent ( )
Choose Case lgo_parent.TypeOf ( )
Case Window!
lw_parent = lgo_parent
li_width = newwidth
li_height = newheight
Case UserObject!
luo_parent = lgo_parent
li_width = luo_parent.Width
li_height = luo_parent.Height
End Choose

If Lower ( istr_position [ li_i ].Object.ClassName ( ) ) = "cb_toolbar" Then continue
Choose Case istr_position [ li_i ].Method
Case "fixedtoright"
li_width = li_width - istr_position [ li_i ].right - istr_position [ li_i ].Object.Width
li_height = istr_position [ li_i ].Object.Y
istr_position [ li_i ].Object.Move ( li_width, li_height )
Case "fixedtobottom"
li_width = istr_position [ li_i ].Object.X
li_height = li_height - istr_position [ li_i ].bottom - istr_position [ li_i ].Object.Height
istr_position [ li_i ].Object.Move ( li_width, li_height )
Case "fixedtoright&bottom"
li_width = li_width - istr_position [ li_i ].right - istr_position [ li_i ].Object.Width
li_height = li_height - istr_position [ li_i ].bottom - istr_position [ li_i ].Object.Height
istr_position [ li_i ].Object.Move ( li_width, li_height )
Case "scaletoright"
li_width = li_width - ( istr_position [ li_i ].Left + istr_position [ li_i ].right )
li_height = istr_position [ li_i ].Object.Height
istr_position [li_i].Object.Resize ( li_width, li_height )
Case "scaletobottom"
li_width = istr_position [ li_i ].Object.Width
li_height = li_height - ( istr_position [ li_i ].Top + istr_position [ li_i ].Bottom )
istr_position [li_i].Object.Resize ( li_width, li_height )
Case "scaletoright&bottom"
li_width = li_width - ( istr_position [ li_i ].Left + istr_position [ li_i ].right )
li_height = li_height - ( istr_position [ li_i ].Top + istr_position [ li_i ].Bottom )
istr_position [li_i].Object.Resize ( li_width, li_height )
Case "fixedtoright&scaletobottom"
Case "fixedtobottom&scaletoright"
End Choose
Next


然后定义一个函数integer of_registerzoom(dragobject ado_source, string method)

// 使控件随窗口缩放
//
//"FixedToRight" or FIXEDRIGHT?
//"FixedToBottom" or FIXEDBOTTOM?
//"FixedToRight&Bottom" or FIXEDRIGHTBOTTOM?
//"Scale" or SCALE?
//"ScaleToRight" or SCALERIGHT?
//"ScaleToBottom" or SCALEBOTTOM?
//"ScaleToRight&Bottom" or SCALERIGHTBOTTOM?
//"FixedToRight&ScaleToBottom" or FIXEDRIGHT_SCALEBOTTOM?
//"FixedToBottom&ScaleToRight" or FIXEDBOTTOM_SCALERIGHT


PowerObject lpo_parent
Window lw_parent
UserObject luo_parent
Integer li_i
lpo_parent = ado_source.GetParent ( )
Integer li_parentwidth, li_parentheight, li_right, li_bottom
// 判断parent对象类型
Choose Case lpo_parent.typeOf ( )
Case Window!
lw_parent = lpo_parent
li_parentwidth = lw_parent.WorkSpaceWidth ( )
li_parentHeight = lw_parent.WorkSpaceHeight ( )
Case UserObject!
luo_parent = lpo_parent
li_parentWidth = luo_parent.Width
li_parentHeight = luo_parent.Height
End Choose
Method = Lower ( Method )
If Method <> "scaletobottom" And Method <> "fixedtoright" And Method <> "fixedtobottom"&
AND Method <> "fixedtoright&bottom" &
And Method <> "scaletoright" And Method <> "scaletobottom" And Method <> "scaletoright&bottom" &
And Method <> "FixedToRight&ScaleToBottom" And Method <> "FixedToBottom&ScaleToRight" Then
gnv_app.of_Message ( "程序设计错误:传入of_registerzoom参数出错!" )
Return -1
End If

li_right = li_parentWidth - ( ado_source.X + ado_source.Width )
li_bottom = li_parentheight - ( ado_source.Y + ado_source.Height )

li_i = UpperBound ( istr_position ) + 1
istr_position [ li_i ].left = ado_source.X
istr_position [ li_i ].Top = ado_source.Y
istr_position [ li_i ].object = ado_source
istr_position [ li_i ].right = li_right
istr_position [ li_i ].bottom = li_bottom
istr_position [ li_i ].method = Method
Return 1

在窗口中这么调用
of_registerzoom(cb_1, "ScaleToRight")即可
derris 2002-06-17
  • 打赏
  • 举报
回复
好的,最好有PB的源码,我现在忙死了,实在没有时间写了
lws0472 2002-06-17
  • 打赏
  • 举报
回复
我这里有段程序,还有算法解释,与我联系,qq :5824127
derris 2002-06-17
  • 打赏
  • 举报
回复
nnd, 我自己写的,现在只能在窗口中用阿.还凑服着吧,谁写完了给我EMAIL一份.(把在userobject,tab中的写完就好了.)
使用说明:窗口布局

ORIGNAL:dh

1.定义实例变量: 
uo_resize io_resize
2.在窗口的open事件中:
io_resize = create uo_resize
io_resize.setowner(this)
io_resize.regiester()
3.在窗口的close事件中:
destroy io_resize
4.在窗口的resize事件中:
io_resize.resize()
-----------------------
$PBExportHeader$uo_resize.sru
forward
global type uo_resize from nonvisualobject
end type
end forward

type shape from structure
long x
long y
long width
long height
end type

global type uo_resize from nonvisualobject
event zmemo ( )
end type
global uo_resize uo_resize

type variables
shape is_shape[], is_ownershape
DragObject is_control[]

integer ii_arrange

boolean ib_registered

window io_wowner
userobject io_uowner
tab io_towner
integer ii_ownertype

integer ii_ctrlnum
end variables

forward prototypes
public function integer regiester ()
public function boolean unregister ()
public subroutine resize ()
public function boolean setowner (window ao_owner)
public function boolean setowner (userobject ao_onwer)
public function boolean setowner (tab ao_owner)
end prototypes

event zmemo;/*

使用说明:窗口布局

ORIGNAL:dh

1.定义实例变量: 
uo_resize io_resize
2.在窗口的open事件中:
io_resize = create uo_resize
io_resize.setowner(this)
io_resize.regiester()
3.在窗口的close事件中:
destroy io_resize
4.在窗口的resize事件中:
io_resize.resize()

*/
end event

public function integer regiester ();if ib_registered then return 0

// 按照缩放模式对所有的窗口控件进行按比例缩放.
ii_arrange = 1

//window io_wowner
//userobject io_uowner
//tab io_towner
//integer ii_ownertype


integer li_for


choose case ii_ownertype
case 1
ii_ctrlnum = upperbound(io_wowner.control[])

is_ownershape.x = io_wowner.x
is_ownershape.y = io_wowner.y
is_ownershape.width = io_wowner.width
is_ownershape.height = io_wowner.height

for li_for = ii_ctrlnum to 1 step -1

is_control[li_for] = io_wowner.control[li_for]

is_shape[li_for].x = is_control[li_for].x
is_shape[li_for].y = is_control[li_for].y
is_shape[li_for].width = is_control[li_for].width
is_shape[li_for].height = is_control[li_for].height

next

ib_registered = true



case 2
ii_ctrlnum = upperbound(io_uowner.control[])

case 3
ii_ctrlnum = upperbound(io_towner.control[])
end choose //


return 0
end function
public function boolean unregister ();DragObject ls_control[]

is_control = ls_control

ib_registered = false

// 缩放模式
ii_arrange = 0

ii_ctrlnum = 0

return true
end function

public subroutine resize ();if not ib_registered then return

integer li_for
double ld_xscale, ld_yscale


choose case ii_ownertype
case 1

ld_xscale = io_wowner.width / is_ownershape.width
ld_yscale = io_wowner.height / is_ownershape.height

is_ownershape.width = io_wowner.width
is_ownershape.height = io_wowner.height

for li_for = ii_ctrlnum to 1 step -1

is_control[li_for].x = round(is_shape[li_for].x * ld_xscale, 0)

is_control[li_for].y = round(is_shape[li_for].y * ld_yscale, 0)

is_control[li_for].width = round(is_shape[li_for].width * ld_xscale, 0)

is_control[li_for].height = round(is_shape[li_for].height * ld_yscale, 0)


is_shape[li_for].x = is_control[li_for].x
is_shape[li_for].y = is_control[li_for].y
is_shape[li_for].width = is_control[li_for].width
is_shape[li_for].height = is_control[li_for].height
next

case 2

case 3

end choose //
//
//
//return 0
end subroutine
public function boolean setowner (window ao_owner);if not ib_registered then

io_wowner = ao_owner
ii_ownertype = 1

else
return false
end if


return true
end function

public function boolean setowner (userobject ao_onwer);if not ib_registered then

io_uowner = ao_onwer
ii_ownertype = 2

else
return false
end if


return true
end function

public function boolean setowner (tab ao_owner);

if not ib_registered then

io_towner = ao_owner
ii_ownertype = 3

else
return false
end if


return true
end function

on uo_resize.create
TriggerEvent( this, "constructor" )
end on

on uo_resize.destroy
TriggerEvent( this, "destructor" )
end on

derris 2002-06-17
  • 打赏
  • 举报
回复
昏~我如果要这么遍码就直接在窗口里写了啊。
hammlet 2002-06-17
  • 打赏
  • 举报
回复
to derris(深水鱼):
不行啊?给我分我就把帮你考虑那个“分割条”的,嘿嘿
xiongxiao 2002-06-17
  • 打赏
  • 举报
回复
哈!
hammlet 2002-06-17
  • 打赏
  • 举报
回复

to lzp_lrp(lzp):你的怎么和我的一样?嘿嘿,认识吗?
nthb2001 2002-06-17
  • 打赏
  • 举报
回复
呵呵~
derris 2002-06-17
  • 打赏
  • 举报
回复
哎呀,写的这样也要分阿. :)
hammlet 2002-06-17
  • 打赏
  • 举报
回复
我发到你信箱了!!
可要给我分哦!!
shadowno 2002-06-17
  • 打赏
  • 举报
回复
我有一个函数送给你pb6.5

-----------------
$PBExportHeader$changesize.srf
$PBExportComments$动态改变mdi窗口中数据窗口的位置,以适应不同的分辨率
global type changesize from function_object
end type

forward prototypes
global subroutine changesize (datawindow padw, window paw, integer pnumber, datawindow padw1, integer pa_y)
end prototypes

global subroutine changesize (datawindow padw, window paw, integer pnumber, datawindow padw1, integer pa_y);padw.setredraw(false)
paw.setredraw(false)
padw1.setredraw(false)

if pnumber = 1 then
padw.x=8
padw.y= + 112 + pa_y
padw.height= paw.workspaceHeight() -112 -pa_y
padw.width = paw.workspaceWidth() -8
end if

if pnumber = 2 then
padw.x=8
padw1.x=(paw.workspaceWidth() / 2) + 115
padw.y= + 112 + pa_y
padw1.y= + 112 + pa_y
padw.height= paw.workspaceHeight() -112 - pa_y
padw.width = paw.workspaceWidth() /2 - 115 -8
padw1.height= paw.workspaceHeight() -112 - pa_y
padw1.width = paw.workspaceWidth() /2 - 115
end if

if pnumber = 3 then
padw.x=8
padw1.x=8
padw.height= paw.workspaceHeight() / 2 - 112 - pa_y
padw.width = paw.workspaceWidth() -8
padw1.height= paw.workspaceHeight()/2 + 60
padw1.width = paw.workspaceWidth() -8
padw.y=112 + pa_y
padw1.y=paw.workspaceHeight() - padw.height - 180
end if

padw.setredraw(true)
paw.setredraw(true)
padw1.setredraw(true)
end subroutine
---------------------

该函数有5个参数,支持两个数据窗口竖排,和一个数据窗口横排
changesize(dw_1,this,1,dw_1,0)
第一个参数:窗体中的第一个数据窗口名称;
第二个参数:窗体名称
第三个参数:数据窗口的数量,
第四个参数:第二个数据窗口名称,
第五个参数:竖排时两个数据窗口之间的宽度。



使用方法:

你把虚线内部的代码copy到文本文件中,然后把改文件名称改为hangesize.srf
再到pb中的(library)库面板中import。。即可

别忘了给分!
derris 2002-06-16
  • 打赏
  • 举报
回复
PFC的层数太多了啊,我们重新写过,编成了相对独立的模块,可惜没有珍惜(改行写DELPHI了,谁想到又改回来了,昏。。。)
xiangyan 2002-06-15
  • 打赏
  • 举报
回复
GZ
xjbs 2002-06-15
  • 打赏
  • 举报
回复
如果是用PFC写的把RESIZE服务启动就是了,,



blink1 2002-06-15
  • 打赏
  • 举报
回复
看了很多控件_Resize 但没一个好用的.

没有办法,只有在窗口Resize事件中一个个改.

swjtu95 2002-06-15
  • 打赏
  • 举报
回复
www.helpwork.com
这个网上有个“控件_Resize 2.5.zip”,下载回去看能不能用。
xiaoxianhe 2002-06-15
  • 打赏
  • 举报
回复
帮你UP,这段程序我也见过,可就是没珍惜!呵呵,现在找不到了!
唉,等待在此重逢。
derris 2002-06-15
  • 打赏
  • 举报
回复
谁有可以注册窗口中组件,随窗体变化而位置大小跟着变化的服务提供?就是可以适应不同的分辨率的拉。最好还有分割条提供 :)

1,079

社区成员

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

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