网站首页

家园论坛

老版论坛

家园博客

业界新闻

技术文档

下载中心

速查中心

图片中心

硬件资讯
上一篇:数据窗口自适应打印纸张大小。 下一篇:程序间相互通讯问题的解决
根据显示器分辨率设置窗口显示位置

来源: 作者: 添加日期:2005-9-4 19:19:56 点击次数:

/*-----------------------------------------------------------------
    函数名: change_systemmetrics
  Written by Vial.Z
  参数:
     w_1 窗口变量
  作用:
    根据显示器分辨率设置窗口显示位置
  调用方法:
   在窗口的Open事件中,输入代码change_systemmetrics(this),
   如果窗口是继承的,请注意调用的位置。(在父窗口的open调用
   可能失效)
-----------------------------------------------------------------*/

integer li_1024bc = 50  /*1024分辨率下的编差值*/
integer li_800bc = 50  /*800分辨率下的编差值*/

Integer li_WS_Width     /*工作区宽度*/
Integer li_WS_Height  /*工作区高度*/
Integer li_my_Width  /*当前窗口宽度*/
Integer li_my_Height  /*当前窗口高度*/

integer li_system_metrics /*系统分辨率*/

/*w_main是MDI中的主窗口,这里取得其客户显示区的大小(做了适当调整)*/
li_WS_Width = w_main.WorkSpaceWidth() -8
li_WS_Height = w_main.WorkSpaceHeight() - w_main.dw_statebar.height -8
li_my_Width = w_1.Width
li_my_Height = w_1.Height
  
li_system_metrics = getsystemmetrics(0) /*取系统分辨率 */
choose case li_system_metrics
 case 640    /* 640×480  下所有窗口有最大化*/
  w_1.WindowState = maximized!
 case 800    /*  800×600*/
  if  li_my_Width + li_800bc >= li_WS_Width  or li_my_Height + li_800bc >= li_WS_Height  then
   w_1.WindowState = maximized!   
  else
   w_1.WindowState = normal!  /*居中*/
   w_1.X = ( li_WS_Width -  li_my_Width) /2
   w_1.Y = (li_WS_Height - li_my_Height ) /2
  end if   
 case else     /* 1024×768 ...*/
  if li_my_Width +li_1024bc >= li_WS_Width or  li_my_Height +li_1024bc >= li_WS_Height then 
   w_1.WindowState = maximized!   
  else  
   w_1.WindowState = normal!  /*居中*/
   w_1.X = ( li_WS_Width -  li_my_Width) /2
   w_1.Y = (li_WS_Height - li_my_Height ) /2   
  end if
end choose

 

 


 

 
设为首页 | 加入收藏 | 业务办理 | 友情链接 | 论坛版面 | 浙ICP备07502118号 |