我可以使用screenLeft
和screenTop
获取窗口的X和Y坐标。
但是,我需要将像素值转换为百分比。这样做的公式是什么?
我在vb.net中为宽度和高度转换做了这个,
Dim widthpix As Integer = CType(sItems(0), Integer)
Dim heighpix As Integer = CType(sItems(1), Integer)
widthinpercent = CInt((widthpix / PrimaryScreen.Bounds.Width) * 100)
heightinpercent = CInt((heighpix / PrimaryScreen.Bounds.Height)*100)
以百分比形式转换window.screenLeft
和window.screenTop
的公式是什么?
答案 0 :(得分:0)
尝试:
Dim widthinpercent As Integer = CInt((Me.Location.X / Screen.PrimaryScreen.Bounds.Width) * 100)
Dim heightinpercent As Integer = CInt((Me.Location.Y / Screen.PrimaryScreen.Bounds.Height) * 100)
MsgBox(" X =" & widthinpercent.ToString() & "% | Y =" & heightinpercent.ToString() & "%")