|
■No12409 (○ さん) に返信
> ご提示のものでも大丈夫そうですが、GetCursorPosがなぜ使えないかも知りたい感じです。
Declare 宣言を「ByVal POINTAPI」にしたいなら、こんな感じ。
Imports system.Runtime.InteropServices
Public Class Form1
<StructLayout(LayoutKind.Sequential, Pack:=4)> Class POINTAPI
Public X As Integer
Public Y As Integer
Public Shared Widening Operator CType(ByVal o As POINTAPI) As String
Return String.Format("(X, Y)=({0}, {1})", o.X, o.Y)
End Operator
End Class
Declare Function GetCursorPos Lib "user32" (ByVal lpPoint As POINTAPI) _
As <MarshalAs(UnmanagedType.Bool)> Boolean
Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
Dim A As New POINTAPI()
GetCursorPos(A)
Me.Text = A
End Sub
Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
End Class
|