pb_pfc_窗体居中

来源:互联网 发布:北京知金教育论坛 编辑:程序博客网 时间:2024/06/07 05:36

pfc中,窗体居中,可以直接使用窗体的服务,代码如下:

of_SetBase(True)inv_base.of_Center()
十分简单。第一句启用窗体服务,第二句,调用服务的居中函数,如果不使用pfc,我们可以直接把of_Center函数拷贝出来,自己建一个函数用,代码如下:

Integerli_screenheightIntegerli_screenwidthIntegerli_rcIntegerli_x = 1Integerli_y = 1environmentlenv_obj//Check for a window association with this objectIf IsNull(iw_requestor) Or Not IsValid (iw_requestor) ThenReturn -1End If// Get environmentIf GetEnvironment (lenv_obj) = -1 ThenReturn -1End If// Determine current screen resolution and validateli_screenheight = PixelsToUnits (lenv_obj.screenheight, YPixelsToUnits!)li_screenwidth = PixelsToUnits (lenv_obj.screenwidth, XPixelsToUnits!)If Not (li_screenheight > 0) or Not (li_screenwidth > 0) ThenReturn -1End If// Get center pointsIf li_screenwidth > iw_requestor.Width Thenli_x = (li_screenwidth / 2) - (iw_requestor.Width / 2)End IfIf li_screenheight > iw_requestor.Height Thenli_y = (li_screenheight / 2) - (iw_requestor.Height / 2)End If// Center windowli_rc = iw_requestor.Move (li_x, li_y)


原创粉丝点击