【问题标题】:Migration of positioning code from vb6 to vb.net定位代码从vb6迁移到vb.net
【发布时间】:2012-03-31 20:39:00
【问题描述】:

我有以下代码在 16 位显示器中设置光标位置:

linCursor.x1 = VB6.PixelsToTwipsX(lblDisplay(pintCursorPos).Left) + 10
linCursor.x1 = VB6.PixelsToTwipsX(lblDisplay(pintCursorPos).Left) + 10

linCursor.X2 = VB6.PixelsToTwipsX(lblDisplay(pintCursorPos).Left) + VB6.PixelsToTwipsX(lblDisplay(pintCursorPos).Width) - 10

我需要将此代码转换为 vb.net。谁能帮我开始?

【问题讨论】:

  • 我认为它们在不同的容器中,因为一个具有 twip 协调,另一个是像素。如果不是,那么它正在做一些奇怪的事情。

标签: vb.net vb6 vb6-migration


【解决方案1】:

最简单的转换只是完全放弃缇的东西; those don't exist in the world of .NET 直接使用像素。

linCursor.x1 = lblDisplay(pintCursorPos).Left + 10
linCursor.x1 = lblDisplay(pintCursorPos).Left + 10

linCursor.X2 = lblDisplay(pintCursorPos).Left + lblDisplay(pintCursorPos).Width - 10

【讨论】:

  • +1 尽管您可能希望将 10 值更改为 01,因为它们现在以像素而不是缇为单位。这取决于屏幕分辨率,但 10 缇在我的屏幕上大约是 0.6 像素。
  • “X1 不是 windows.forms.label 的成员”开始起作用了……告诉我如何解决这个问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多