I only know a little about c# and most of my code is off google. The thing I'm trying is moving a window, I got this working by using SetWindowPos
. However, I want the window partically outside the screen, but Microsoft Windows doesn't allow it. The code below is what I got so far. Of course I searched on google for the answer, and found the answer, the only thing I don't know is how to put this into my program.
Could somebody explain me how I would put this into my application?
Google answer: Move a window partially off the top of the screen
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace WindowMover
{
static class Logic
{
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);
public static void Main()
{
const short SWP_NOSIZE = 1;
const short SWP_NOZORDER = 0X4;
const int SWP_NOACTIVATE = 0x0010;
Process[] processes = Process.GetProcesses("DeviceEmulator");
foreach (var process in processes)
{
if (process.ProcessName == "DeviceEmulator")
{
var handle = process.MainWindowHandle;
SetWindowPos(handle, 0, 0, 0, -100, -100, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
}
}
}
}
}