Open a notebook in a specific place on the screen and to the right size?

I need to open the notebook to a certain size and at a certain position on the screen.

How can I do this with C #?

I would appreciate a sample code.

Thank!

+3
source share
5 answers

You can pinvoke MoveWindow. Like this:

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

class Program {
    static void Main(string[] args) {
        var prc = Process.Start("notepad.exe");
        prc.WaitForInputIdle();
        bool ok = MoveWindow(prc.MainWindowHandle, 0, 0, 300, 200, false);
        if (!ok) throw new System.ComponentModel.Win32Exception();
    }
    [DllImport("user32.dll", SetLastError = true)]
    private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint);
}
+9
source

to open it, you could use a call to Process.Start or the ShellExecute API to set its application window to a specific size and position, I would call the SetWindowsPos API.

+1
source

, . hwd FindWindow ( ), move/resize . - , . , http://pinvoke.net/

+1

, . :

System.Diagnostics.Process.Start("Notepad");

, ,

0

, , .

0

Source: https://habr.com/ru/post/1786156/


All Articles