窗口居中显示的公用函数
在PB8.0之下的版本中,因为窗口没有属性‘Center’,必须自己编写程序,使窗口居中。下面这个公用函数考虑的比较全面,在PB8.0之前的版本中都还是非常有用的。
environment le_env
int li_ScreenHeight, li_ScreenWidth
long ll_posx,ll_posy
GetEnvironment(le_env)
if IsValid(w_main) then
li_ScreenHeight = w_main.MDI_1.Height
li_screenwidth = w_main.MDI_1.Width
else
li_ScreenHeight = PixelsToUnits(le_env.screenheight,YPixelsToUnits!)
li_screenwidth = PixelsToUnits(le_env.screenwidth,XPixelsToUnits!)
end if
if aw_window.width>li_ScreenWidth then//如果窗口过宽
ll_posx=1
else
ll_posx=(li_ScreenWidth - aw_window.Width) / 2
end if
if aw_window.height>li_ScreenHeight then//如果窗口过高
ll_posy=1
else
ll_posy=(li_ScreenHeight - aw_window.Height) / 2
end if
aw_window.Move(ll_posx ,ll_posy)