前提・実現したいこと
環境:Windows10Home、VisualStudio2017(VB.NET)
以下のソースで、通常であればrect1とrect2にそれぞれ座標と画面サイズが入るのですが、一部のソフト(TeraPad)において取得値が座標が-100、サイズが0となります。
正しく取得できない原因または取得方法について教えてください。
該当のソースコード
VB.NET
1'はじめの宣言 2Public Class Form1 3 Inherits Form 4 5 Enum DWMWINDOWATTRIBUTE As UInteger 6 NCRenderingEnabled = 1 7 NCRenderingPolicy 8 TransitionsForceDisabled 9 AllowNCPaint 10 CaptionButtonBounds 11 NonClientRtlLayout 12 ForceIconicRepresentation 13 Flip3DPolicy 14 ExtendedFrameBounds 15 HasIconicBitmap 16 DisallowPeek 17 ExcludedFromPeek 18 Cloak 19 Cloaked 20 FreezeRepresentation 21 End Enum 22 23 <StructLayout(LayoutKind.Sequential)> 24 Private Structure RECT 25 Public left As Integer 26 Public top As Integer 27 Public right As Integer 28 Public bottom As Integer 29 End Structure 30 31 Private Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As IntPtr, ByRef lpRect As RECT) As Boolean 32 Private Declare Function DwmGetWindowAttribute Lib "dwmapi.dll" (ByVal hwnd As IntPtr, ByVal dwAttribute As DWMWINDOWATTRIBUTE, ByRef pvAttribute As RECT, ByVal cbAttribute As Integer) As Integer 33 34 35'該当箇所 36System.Diagnostics.Process() 37Dim p As System.Diagnostics.Process 38For Each p In System.Diagnostics.Process.GetProcesses() 39 Dim rect1 = New RECT 40 Form1.GetWindowRect(p.MainWindowHandle, rect1) 41 Dim rect2 = New RECT 42 Form1.DwmGetWindowAttribute(p.MainWindowHandle, DWMWINDOWATTRIBUTE.ExtendedFrameBounds, rect2, Marshal.SizeOf(rect2)) 43 'ここで何かやる 44Next

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/07 23:24
2019/06/08 02:49