如何让form居中.... 只有多文档开发环境有效!无法mx=x/screen.TwipsPerPixelX my=x/screen.TwipsPerPixelY 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Private Sub Form_Load()'设置 Form 的 StartUpPosition = 1'或Move (Screen.Width - Width) \ 2, (Screen.Height - Width) \ 2End Sub Private Sub Form_Load() '在中间'设置 Form 的 StartUpPosition = 1'或Move (Screen.Width - Width) \ 2, (Screen.Height - Width) \ 2End SubPrivate Sub Command1_Click() '发病率Print Screen.Height / Screen.TwipsPerPixelX, Screen.Width / Screen.TwipsPerPixelYEnd Sub Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2如果能用别忘了给分啊:) 有更绝的方法,而且支持MDI,支持各种分辩率。Public Function center(formcenter As Form)If (Form1.Height - formcenter.Height - Form1.Toolbar1.Height - Form1.StatusBar1.Height - Screen.Height * 7 / 90) < 0 Then str0 = Form1.Width - formcenter.Width str1 = 0Else If Form1.Width - formcenter.Width < 0 Then str0 = 0 str1 = Form1.Height - formcenter.Height - Form1.Toolbar1.Height - Form1.StatusBar1.Height - Screen.Height * 7 / 90 Else str0 = Form1.Width - formcenter.Width str1 = Form1.Height - formcenter.Height - Form1.Toolbar1.Height - Form1.StatusBar1.Height - Screen.Height * 7 / 90 End IfEnd Ifformcenter.Move str0 / 2, str1 / 2, formcenter.Width, formcenter.HeightEnd Function调用的时候用下列语句即可。a = center(Me)以上程序支持MDI,如果想让支持一般方式的话用上面他们的即可喽。 3.screen.Width/screen.TwipsPerPixelXscreen.Height/screen.TwipsPerPixelY VB里面不是可以设置form的位置吗?就是右下的那个“电脑屏幕” 以下方式绝对可以居中窗口:Form1.Top = Screen.Height / 2 - Form1.Height / 2Form1.Left = Screen.Width / 2 - Form1.Width / 2以下是得到像素(屏幕分辨率)最易的方法:Screen.Height / 15 '纵screen.width /15 '横 VB同一程序打开打开2个不同Excel文件的问题 mscomct2.ocx哪儿下载 有个问题,请大家帮我解决一下好吗? 求助(有高手没??有就站出来!!) VB项目打包后,出现加载DLL出错情况 关于iNet控件的icExecuting错误,大家来帮忙看看~~ 怎么把指定路径下的jpg插入到excel单元格?? 打印问题 打印的记录字段较多,横打都不够怎么才能打到多张纸上? 使用CreateFontIndirect创建字体时如何指定字体 新人求助输入导出TXT 如何让一个窗体在一个已经打开的Word窗体之上形成模式窗体 VS.Net 简体中文版好像出现了 ...
'设置 Form 的 StartUpPosition = 1
'或
Move (Screen.Width - Width) \ 2, (Screen.Height - Width) \ 2
End Sub
'设置 Form 的 StartUpPosition = 1
'或
Move (Screen.Width - Width) \ 2, (Screen.Height - Width) \ 2
End Sub
Private Sub Command1_Click() '发病率
Print Screen.Height / Screen.TwipsPerPixelX, Screen.Width / Screen.TwipsPerPixelY
End Sub
如果能用别忘了给分啊:)
Public Function center(formcenter As Form)
If (Form1.Height - formcenter.Height - Form1.Toolbar1.Height - Form1.StatusBar1.Height - Screen.Height * 7 / 90) < 0 Then
str0 = Form1.Width - formcenter.Width
str1 = 0
Else
If Form1.Width - formcenter.Width < 0 Then
str0 = 0
str1 = Form1.Height - formcenter.Height - Form1.Toolbar1.Height - Form1.StatusBar1.Height - Screen.Height * 7 / 90
Else
str0 = Form1.Width - formcenter.Width
str1 = Form1.Height - formcenter.Height - Form1.Toolbar1.Height - Form1.StatusBar1.Height - Screen.Height * 7 / 90
End If
End If
formcenter.Move str0 / 2, str1 / 2, formcenter.Width, formcenter.HeightEnd Function
调用的时候用下列语句即可。
a = center(Me)
以上程序支持MDI,如果想让支持一般方式的话用上面他们的即可喽。
screen.Width/screen.TwipsPerPixelX
screen.Height/screen.TwipsPerPixelY
Form1.Top = Screen.Height / 2 - Form1.Height / 2
Form1.Left = Screen.Width / 2 - Form1.Width / 2
以下是得到像素(屏幕分辨率)最易的方法:
Screen.Height / 15 '纵
screen.width /15 '横