您的批评和鼓励都是我把编程无限办好的动力! 您编程时遇到困难,或遇到不顺心的事想发发牢骚尽管到这里来吧! 虽然本网力求全面,但也不能包罗万象,这些我筛选出的优秀网站连接就是对本站最好的补充! 学习编程当然也离不开书本了,这里收集大量编程书籍! 编程无限之源码超市,这里收集的代码令你意想不到的全面! 欢迎光临编程网校,这里专门收集VB/CB入门文章及技术文章! 欢迎光临编程无限!
     
       
 
当前位置:英文资料 >> Interface
Setting Video Resolution for Multiple Forms
  资料类型: Interface 上传时间: 2001-02-21 阅读次数: 2534



Following is a subroutine that will set the video resolution for multiple forms.

Load Form
Call SetDeviceIndependentWindow(Form)
Form.Show

The subroutine was in a different module and this has always worked for me but I also have never tried to call it from the Form Load Event.

As a side note, I had to make a change in the subroutine in order for it work with my machine. The subroutine relies on the fact that Screen.TwipsPerPixelX, Screen.TwipsPerPixelY will change according to whatever video resolution is selected. My problem may be due to the fact that the video drivers for the Cirrus Logic video chip have been written poorly but on my system irregardless of what video resolution I was in 640 x 480, 800 x 600, etc. the value for Screen.TwipsPerPixelX or Y never changed from 12 but I have worked on other machines with different video cards and the value did change. I have included a modified version of the routine.

Sub SetDeviceIndependentWindow (TheForm As Form)

Dim DesignX%
Dim DesignY%
Dim XFactor As Single
Dim YFactor As Single
Dim Z As Integer

' DesignX% = 12
' DesignY% = 12

' XFactor = DesignX% / Screen.TwipsPerPixelX
' YFactor = DesignY% / Screen.TwipsPerPixelY

'** This is what I changed, I design my screens to look appropriate for VGA and then resize the screen if the user is using a higher video resolution

XFactor = Screen.Width / 9600
YFactor = Screen.Height / 7200

If XFactor = 1 And YFactor = 1 Then
Exit Sub
End If

TheForm.Move TheForm.Left * XFactor, TheForm.Top * YFactor,
TheForm.Width * XFactor, TheForm.Height * YFactor

For Z = 0 To TheForm.Controls.Count - 1

'If TypeOf TheForm.Controls(Z) Is CommonDialog Then
If TypeOf TheForm.Controls(Z) Is Timer Then
ElseIf TypeOf TheForm.Controls(Z) Is Menu Then
ElseIf TypeOf TheForm.Controls(Z) Is Line Then
ElseIf TypeOf TheForm.Controls(Z) Is DriveListBox Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top, TheForm.Controls(Z).Width * YFactor
ElseIf TypeOf TheForm.Controls(Z) Is ComboBox Then
If TheForm.Controls(Z).Style <> 1 Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor
End If
Else
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor, TheForm.Controls(Z).Height * YFactor

If TypeOf TheForm.Controls(Z) Is TextBox Then
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
ElseIf TypeOf TheForm.Controls(Z) Is Label Then
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
End If
End If
Next Z

End Sub

推荐给朋友 点 评( 0 ) 返回前页 关闭此页
   
  本类最热文章排名:
  1.Minimize All Windows to Show Desktop
2.Create An Active Skin
3.Make MDI Child Forms Act Modal
4.clear all text in the form
5.Disable Enable the C...
6.Passing A Variable To A Form
7.Creates A form contr...
8.Gradient Color Trans...
9.Tile A Bitmap Accross A Form
10.Labeling your forms
   
   
  评论:
 
 
 

 

关于本站 版权声明 联系方法
编程无限 V4.1 Copyright © 1999-2008 21code.com

京ICP备05006938号