表单的 Width 属性不是它设置的值,尽管看起来不错

发布于 2024-11-02 19:25:17 字数 637 浏览 0 评论 0原文

表单的边框样式是“固定单一”,因此用户无法手动更改表单的尺寸。

有一个菜单项允许用户为表单选择 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉梦枕江山 2024-11-09 19:25:17

我建议使用表单级布尔变量而不是特定数字。如果您想让它更容易理解,您也可以将其包装在属性中。加载应用程序时使用数据库值初始化变量,并在单击按钮选择表单大小时切换该值。

Private m_blnExpanded As Boolean

Private Property Let Expanded(ByVal vExpanded As Boolean)

       m_blnExpanded = vExpanded

End Property
Private Property Get Expanded() As Boolean

       Expanded = m_blnExpanded

End Property

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.

Private m_blnExpanded As Boolean

Private Property Let Expanded(ByVal vExpanded As Boolean)

       m_blnExpanded = vExpanded

End Property
Private Property Get Expanded() As Boolean

       Expanded = m_blnExpanded

End Property
孤者何惧 2024-11-09 19:25:17

如果要对宽度进行硬编码,则必须选择小字体的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文