我有 Userform1,它的大小适合在 2560 x 1440 的监视器中全屏显示。 Userform1 包含 FrameA,其 .Width 也是 2560,并且缩放到 10%。
FrameA 包含一个子 FrameB,其 .Width 为 8000,其 .Left 为 1000(在 FrameA 缩放坐标中)。FrameB 在屏幕上完全可见。
我想将 FrameB 向右移动,使其右边缘位于显示器的右边缘。有人可以告诉我这样做的算法吗?
I do not recall every having so much trouble getting a form to look the way I wanted.
I ended up moving lots of things around that did not, perhaps, need moving. However, I have finally got the effect I believe you seek so I have not tried to move code back to where it was.
The first key change appears to be:
Property StartUpPosition of UserForm1 = 0 - Manual`
without this, I could not set the form's height to the full available height. Setting .Top had no effect.
The second key change appears to be use of:
Application.DisplayFullScreen = True
I do not recall needing this command before but maximizing the window state would not give the full screen height.
I discarded your routines Sub maximizeWindows()
and Sub UserForm_initialize()
either because I did things differently or because I moved the code. I am sure you could move the code back but I have not tried.
I added a new control cmdExit
with the following event routine:
Private Sub cmdExit_Click()
Unload Me
End Sub
Sub runDemo()
has become:
Sub runDemo()
Application.DisplayFullScreen = True
Load UserForm1
With UserForm1
.Top = 2
.Left = 0
.Width = Application.UsableWidth
.Height = Application.UsableHeight - 2
.Frame1.Move 0, 0, .InsideWidth, 300
.Frame2.Left = .Frame1.Left + .Frame1.InsideWidth - .Frame2.InsideWidth
.Show
End With
Application.DisplayFullScreen = False
End Sub
The effect of the above for me was:
Hope this works for you.
我终于找到了方法。
回顾一下问题并稍微简化一下:Frame2 完全包含在缩放的 Frame1 中,需要向右移动,使其右侧与 Frame1 的右侧齐平。Frame2的左侧应该移到哪里?
Sub move_Frame2_Hard_Right_Inside_Frame1()
Dim zoomPct!
zoomPct! = Frame1.Zoom / 100
Frame2.Left = Frame1.Width / zoomPct! - Frame2.Width
End Sub