|
すいません、Win10だとうまくいったのですが、
Win7でやると
DwmGetWindowAttributeで値を取得することができません。
特にエラーは出ないのですが、座標が全て0になってしまいます。
どうすれば良いですか?
コードは以下の通りです。
Private Enum DWMWINDOWATTRIBUTE
DWMWA_NCRENDERING_ENABLED = 1
DWMWA_NCRENDERING_POLICY
DWMWA_TRANSITIONS_FORCEDISABLED
DWMWA_ALLOW_NCPAINT
DWMWA_CAPTION_BUTTON_BOUNDS
DWMWA_NONCLIENT_RTL_LAYOUT
DWMWA_FORCE_ICONIC_REPRESENTATION
DWMWA_FLIP3D_POLICY
DWMWA_EXTENDED_FRAME_BOUNDS
DWMWA_LAST
End Enum
Private Declare Function DwmGetWindowAttribute Lib "dwmapi.dll" (
ByVal hwnd As IntPtr,
ByVal dwAttribute As DWMWINDOWATTRIBUTE,
ByRef pvAttribute As RECT,
ByVal cbAttribute As Int32) As Boolean
Private Structure RECT
Property Left As Integer
Property Top As Integer
Property Right As Integer
Property Bottom As Integer
End Structure
Dim wombat As RECT
DwmGetWindowAttribute(frm.Handle, DWMWINDOWATTRIBUTE.DWMWA_EXTENDED_FRAME_BOUNDS, wombat, Marshal.SizeOf(wombat))
Dim bmp As New Bitmap(wombat.Right - wombat.Left, wombat.Bottom - wombat.Top)
Dim g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(New Point(wombat.Left, wombat.Top), New Point(0, 0), bmp.Size)
g.Dispose()
bmp.Save(FileOutPath_PNG)
bmp.Dispose()
|