0

2560 x 1440のモニターにフルスクリーンに収まるサイズのUserform1があります。Userform1には、.Widthも2560で、10%にズームされたFrameAが含まれています。

FrameAには、.Widthが8000で、.Leftが1000(FrameAズーム座標)の子FrameBが含まれています。FrameBは画面に完全に表示されます。

FrameBを右に移動して、その右端がモニターの右端に沿って配置されるようにします。誰かが私にそれをするための算術を見せてもらえますか?

4

2 に答える 2

0

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:

  • UserForm1 occupied the entire screen apart from the Windows Task bar along the bottom.
  • Frame1 was at the top, occupied the full width of the screen and had a height of 300.
  • Frame2 was right aligned with Frame1.
  • The maximized/normal/minimized state of Excel was not changed.

Hope this works for you.

于 2012-02-06T14:23:14.823 に答える
0

私はついにそれを行う方法を見つけました。

問題を要約して少し単純化すると、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
于 2012-02-07T02:43:27.473 に答える