马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- ''' <summary>
- ''' 以真实比例尺查看
- ''' </summary>
- ''' <param name="dScale">比例尺大小 如 2000 1000 等(大于0 的一个数)</param>
- ''' <remarks></remarks>
- Public Sub ViewWithRealScale(ByVal dScale As Double, ByVal cPt As Point2d)
- If dScale <= 0 Then
- Exit Sub
- End If
- Dim VtrRec As Point2d = Application.GetSystemVariable("screensize")
- Dim newVtr As New ViewTableRecord
- newVtr.CenterPoint = cPt
- Dim PixelHeight As Integer = 0, PixelWidth As Integer = 0
- GetPhysicalScreenSize(PixelWidth, PixelHeight)
- newVtr.Height = (PixelHeight * VtrRec.Y / My.Computer.Screen.Bounds.Height) * dScale / 1000.0
- Doc.Editor.SetCurrentView(newVtr)
- Doc.Editor.UpdateScreen()
- End Sub
- ''' <summary>
- ''' 访问使用设备描述表的设备数据
- ''' </summary>
- ''' <param name="hdc">设备上下文环境的句柄</param>
- ''' <param name="nIndex">指定返回项</param>
- ''' <returns></returns>
- ''' <remarks></remarks>
- <DllImport("GDI32.dll")> _
- Public Shared Function GetDeviceCaps(ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
- End Function
- <DllImport("user32.dll")> _
- Public Shared Function GetDC(ByVal hwnd As Integer) As Integer
- End Function
- <DllImport("user32.dll")> _
- Public Shared Function ReleaseDC(ByVal hwnd As Integer, ByVal hdc As Integer) As Long
- End Function
- ''' <summary>
- ''' 返回桌面窗口的句柄
- ''' </summary>
- ''' <returns></returns>
- ''' <remarks></remarks>
- <DllImport("user32.dll")> _
- Public Shared Function GetDesktopWindow() As Integer
- End Function
- ''' <summary>
- ''' 获取显示器的物理尺寸
- ''' </summary>
- ''' <param name="iWidth">屏幕的宽度</param>
- ''' <param name="iHeight">屏幕的高度</param>
- ''' <remarks>单位:毫米</remarks>
- Public Shared Sub GetPhysicalScreenSize(ByRef iWidth As Integer, ByRef iHeight As Integer)
- '状态:20121106-1512测试通过
- Dim hDesktopWnd As Integer = GetDesktopWindow()
- Dim hdcCaps As Integer = GetDC(hDesktopWnd)
- iWidth = GetDeviceCaps(hdcCaps, 4)
- iHeight = GetDeviceCaps(hdcCaps, 6)
- ReleaseDC(hDesktopWnd, hdcCaps)
- End Sub
|