Help with MoveWindow

  • Thread starter Thread starter Tom Tra
  • Start date Start date
T

Tom Tra

Guest
Hello,

I am a newbie to PINVOKE. I am just trying to learn the MoveWindow command and I have encounter this error

Cannot convert argument "hWnd", with value: "", for "MoveWindow" to type "System.IntPtr": "Cannot convert null to type "System.IntPtr"."


I am just trying to figure out what it meant , and how to fix it. Please let me know if you have any comments or suggestions.

Thanks so much for all of the helps.

Attached is my simple program that gave me the above error message

Add-Type -AssemblyName System.Windows.FormsAdd-Type @"using System;using System.Collections;using System.Collections.Generic;using System.Runtime.InteropServices;using System.Text; public class Win32 { [DllImport("user32.dll", SetLastError = true)] public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint); [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, ExactSpelling = true, SetLastError = true)] public static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect); } public struct RECT { public int Left; // x position of upper-left corner public int Top; // y position of upper-left corner public int Right; // x position of lower-right corner public int Bottom; // y position of lower-right corner }"@#[Win32]::GetWindowRect$Handle = (Get-Process -Name audiodg).MainWindowHandle$Rectangle = New-Object RECT[Win32]::GetWindowRect($Handle,[ref]$Rectangle)$Rectangle$retVal = [Win32]::MoveWindow($Handle, 200, 150, 175, 300, 1)








Student at Georgia Tech

Continue reading...
 
Back
Top