表单的 Width 属性不是它设置的值,尽管看起来不错
表单的边框样式是“固定单一”,因此用户无法手动更改表单的尺寸。
有一个菜单项允许用户为表单选择 2 个宽度设置中的 1 个,选择宽(宽度 = 11715)会显示额外的控件。
在加载事件期间,调用子程序来设置各种值,其中包含以下代码:
If rs.Fields("ShowAll").Value = True then
Me.Width = 11715
在表单卸载事件期间,调用子程序来记录下一次的设置,其中包含以下代码:
If Me.Width = 11715 Then
rs.Fields("ShowAll").Value = True
Else
rs.Fields("ShowAll").Value = False
End If
一位用户报告了一种情况,即使他总是以“宽”的形式结束,而总是以“窄”的形式打开。
我以前从未见过这种情况发生,也没有人报告过这种情况,这并不是说其他地方没有发生这种情况。
他的机器是 Windows 7,屏幕分辨率是 1280 X 1024。
编辑: 另外,当我检查他的数据库时,“ShowAll”的值为 False。
The form's borderstyle is "fixed single" so the user cannot alter the form's dimensions manually.
There is a menu item that allows the user to select 1 of 2 width settings for the form, choosing wide (width = 11715) displays extra controls.
During the load event a sub is called to set various values and which includes this code:
If rs.Fields("ShowAll").Value = True then
Me.Width = 11715
During the form unload event a sub is called to record the settings for the next time and which includes this code:
If Me.Width = 11715 Then
rs.Fields("ShowAll").Value = True
Else
rs.Fields("ShowAll").Value = False
End If
One user has reported a situation where even though he always closes with the form "wide" it always opens "narrow".
I have never seen this happen before and nobody has ever reported it either, which is not to say it's not happening elsewhere.
His machine is windows 7 and his screen resolution is 1280 X 1024.
Edit :
Also when I checked his database the value for "ShowAll" is False.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议使用表单级布尔变量而不是特定数字。如果您想让它更容易理解,您也可以将其包装在属性中。加载应用程序时使用数据库值初始化变量,并在单击按钮选择表单大小时切换该值。
I suggest using a form level boolean variable rather than a specific number. You can also wrap it in a property if you like to make it easier to understand. Initialize the variable with the database value when you load your app and toggle the value when the button is clicked to choose the form size.
如果要对宽度进行硬编码,则必须选择小字体的 15 倍数和大字体的 12 倍数的缇数。两者的最小倍数都是 60,因此最接近硬编码值的是 11700,即小字体中的 780px,大字体中的 975px。
请注意,除了 96(又名“小字体”)和 120(又名“大字体”)之外,win7 还提供了更多的 DPI 尺寸,这完全使 VB6 表单子系统失败。因此,您可以放心地假设 VB6 中的像素大小为 15 或 12 缇。
If you are going to hard-code the width then you have to choose a number of twips that is multiple of 15 for small-fonts and multiple of 12 for large-fonts. The least multiple of both is 60, so the closest to your hard-coded value is 11700 which is 780px in small-fonts and 975px in large-fonts exactly.
Mind that win7 comes with more DPI sizes besides 96 (aka "small-fonts") and 120 (aka "large-fonts"), which totally fail VB6 forms subsystem. So you are safe to assume that in VB6 pixel size is either 15 or 12 twips.