.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
把表单放在屏幕的正中央

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

 

                                在 开 发VB 程 序 时, 一 般 希 望 将 表 单 放 在 屏 幕 可 利 用 区 域 的正 中 央, 下 面 的 代 码 段 实 现 了 在 每 次 启 动 应 用 程 序 时, 无 论 屏 幕 是 否 有 任 务 条, 表 单 都 会 处 于 屏 幕 可 利 用 区 域 的 正 中 央。 在 工 程 中 增 添 一 模 块, 在 模 块 中 加 上 如 下 的 代 码: 

                                Option Explicit
                                Private Const SPI_GETWORKAREA = 48
                                Private Declare Function SystemParametersInfo&
                              Lib "User32" Alias "SystemParametersInfoA" (ByVal
                              uAction As Long,ByVal uParam As Long, lpvParam As
                              Any, ByVal fuWinIni As Long)
                                Private Type RECT
                                Left As Long
                                Top As Long
                                Right As Long
                                Bottom As Long
                                End Type
                                
                                Public Function CenterForm32 (frm As Form)
                                Dim ScreenWidth&, ScreenHeight&, ScreenLeft&,
                              ScreenTop&
                                Dim DesktopArea As RECT
                                Call SystemParametersInfo (SPI_GETWORKAREA, 0,
                              DesktopArea, 0)
                                ScreenHeight = (DesktopArea.Bottom -
                              DesktopArea.Top) * Screen.TwipsPerPixelY
                                ScreenWidth = (DesktopArea.Right -
                              DesktopArea.Left) * Screen.TwipsPerPixelX
                                ScreenLeft = DesktopArea.Left *
                              Screen.TwipsPerPixelX
                                ScreenTop = DesktopArea.Top *
                              Screen.TwipsPerPixelY
                                frm.Move (ScreenWidth - frm.Width)\ 2 +
                              ScreenLeft, (ScreenHeight - frm.Height) \ 2 +
                              ScreenTop
                                End Function
                                
     要 调 用CenterForm32 函 数, 可 在 表 单 的Load 事 件 中 增 添 代 码CenterForm32 Me 即 可。 以 上 代 码 在VB6 中 实 现。 
 

   




相关文章

相关软件