敬业的IT人 >> 编程开发 >> VB >> VisualBasic让表单一开始就显示在荧幕中央(不含工作列)

VisualBasic让表单一开始就显示在荧幕中央(不含工作列)

敬业的IT人 互联网 佚名 2008-4-17 17:53:30

以下之程序在计算时会扣除工作列所占的高度(或宽度),如果有启动MicrosoftOffice的快捷列的话,也会扣除快捷列所占的高度(或宽度)。

PublicConstSM_CXFULLSCREEN=16
PublicConstSM_CYFULLSCREEN=17

#IfWin32Then
DeclareFunctionGetSystemMetricsLib"user32"(ByValnIndexAsLong)AsLong
#Else
DeclareFunctionGetSystemMetricsLib"User"(ByValnIndexAsInteger)AsInteger
#EndIf

PublicSubCenterForm(frmAsForm)
frm.Left=Screen.TwipsPerPixelX*GetSystemMetrics(SM_CXFULLSCREEN)/2-frm.Width/2
frm.Top=Screen.TwipsPerPixelY*GetSystemMetrics(SM_CYFULLSCREEN)/2-frm.Height/2
EndSub

只要在Form_Load中使用CenterFormMe即可

粤ICP备06119539号
Copyright CiscoSky.Org,Some Rights Reserved.
Email:me1228#tom.com