根據(jù)顯示器分辨率設(shè)置窗口顯示位置

字號(hào):

函數(shù)名: change_systemmetrics
    Written by Vial.Z
    參數(shù):
     w_1 窗口變量
     作用:
     根據(jù)顯示器分辨率設(shè)置窗口顯示位置
     調(diào)用方法:
     在窗口的Open事件中,輸入代碼change_systemmetrics(this),
     如果窗口是繼承的,請(qǐng)注意調(diào)用的位置。(在父窗口的open調(diào)用
     可能失效)
    -----------------------------------------------------*/
    integer li_1024bc = 50 /*1024分辨率下的編差值*/
    integer li_800bc = 50 /*800分辨率下的編差值*/
    Integer li_WS_Width /*工作區(qū)寬度*/
    Integer li_WS_Height /*工作區(qū)高度*/
    Integer li_my_Width /*當(dāng)前窗口寬度*/
    Integer li_my_Height /*當(dāng)前窗口高度*/
    integer li_system_metrics /*系統(tǒng)分辨率*/
    /*w_main是MDI中的主窗口,這里取得其客戶顯示區(qū)的大小(做了適當(dāng)調(diào)整)*/
    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) /*取系統(tǒng)分辨率 */
    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