Programmer:)

[Unity] user32.dll을 이용한 윈도우 컨트롤 (feat.최대화, 최소화) 본문

DEV/Unity

[Unity] user32.dll을 이용한 윈도우 컨트롤 (feat.최대화, 최소화)

ryeggg 2022. 10. 21. 12:13
반응형

 

딱히 설명할 부분이 없넹..:)

 

using System;
using System.Runtime.InteropServices;

public static class User32DII
{
    #region 윈도우 화면 이동
    [DllImport("user32.dll")]
    private static extern IntPtr GetActiveWindow();

    [DllImport("user32.dll")]
    private static extern bool GetWindowRect(IntPtr hwnd, out Rect lpRect);

    [DllImport("user32.dll")]
    private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool bRepaint);

    [DllImport("user32.dll")]
    private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

    private struct Rect { public int left, top, right, bottom; }


    public static void ShowWindowControl(int nCmdShow)
    {
        //0: 최소화 3 : 최대화
        var hwnd = GetActiveWindow();
        ShowWindowAsync(hwnd, nCmdShow);
    }

    #endregion
}

 

반응형
Comments