简体   繁体   English

VB表单大小调整事件有问题吗?

[英]VB Form Resize Event Problem?

Using VB6 使用VB6

Using MDI Forms, sub Forms also 使用MDI表单,子表单也

When I run the Software in More than 15 Inch Screen, Crviewer Control, Frame Control, Everything is appearing in 75% of the screen, I Wrote the code for Crviewer Control in the form resize event. 当我在15英寸以上的屏幕,Crviewer控件,框架控件中运行该软件时,所有内容都出现在75%的屏幕中,我在窗体调整大小事件中编写了Crviewer控件的代码。

Code

Private Sub Form_Resize()
    CRviewer2.Top = 1450
    CRviewer2.Left = 0
    CRviewer2.Height = ScaleHeight - 1450
    CRviewer2.Width = ScaleWidth
End Sub

Sometimes It is showing error, and sometimes it is executing, So there is any other code is available for all the control should appear in all types of windows screen Size 有时它显示错误,有时它正在执行,因此对于所有控件,应该在所有类型的Windows屏幕上显示任何其他代码

Please can any one help to solve the issues. 请提供任何帮助解决问题。

There are a couple things you should modify about this code. 关于此代码,您需要修改几件事。

First, you should check the window state to make sure the window is not minimized. 首先,您应该检查窗口状态以确保未将窗口最小化。 If it is minimized, the user cannot see the screen anyway, so you don't need to resize. 如果将其最小化,则用户无论如何都看不到屏幕,因此您无需调整大小。

Second, you need to make sure you are not setting any of the properties to a value less than or equal to 0. 其次,您需要确保没有将任何属性设置为小于或等于0的值。

Third, you should have error handling in this code. 第三,您应该在此代码中进行错误处理。

Private Sub Form_Resize()

    On Error Resume Next

    If Me.WindowState = vbMinimized Then
        Exit Sub
    End If

    CRviewer2.Top = 1450
    CRviewer2.Left = 0
    If ScaleHeight > 1450 Then
        CRviewer2.Height = ScaleHeight - 1450
    End If

    CRviewer2.Width = ScaleWidth
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM