Координаты ячейки Excel относительно экрана - Visual Basic .NET
Формулировка задачи:
Всем привет! Помогите. пожалуйста. Есть ли способ определить координаты ячейки Excel? Абсолютные относительно монитора.
Можно определить ячейку под мышкой с помощью ActiveWindow.RangeFromPoint.
А есть ли способ определить ту самую Point из активной ячейки?
Решение задачи: «Координаты ячейки Excel относительно экрана»
textual
Листинг программы
Private Structure RECT Dim Left As Integer Dim Top As Integer Dim Right As Integer Dim Bottom As Integer End Structure Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Integer, ByRef lpRect As RECT) As Integer Private Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As Integer Sub GetWindowClientSize(ByVal hWnd As Integer) ', Width as integer, Height as integer) Dim rc As RECT Dim Width As Integer, Height As Integer GetClientRect(hWnd, rc) ' тут ошибка Width = rc.Right - rc.Left Height = rc.Bottom - rc.Top MsgBox(Width) MsgBox(Height) End Sub Public Sub test() Dim hWnd As IntPtr = GetForegroundWindow() GetWindowClientSize(hWnd) End Sub