저는 C#에 대해서만 알고 있으며 대부분 코드가 Google과 다릅니다. 내가 노력하고있는 일은 창문을 움직이는 것이다. 나는 SetWindowPos
을 사용하여이 작업을한다. 그러나 화면을 부분적으로 화면 외부에 표시하고 싶지만 Microsoft Windows에서는 허용하지 않습니다. 아래 코드는 지금까지 내가 가진 것입니다. 물론 Google에서 답변을 검색하고 답변을 찾았습니다.이 프로그램을 내 프로그램에 넣는 방법은 내가 모르는 유일한 방법입니다.화면 외부에 SetWindowPos가 있습니다.
누군가 내 응용 프로그램에 이것을 어떻게 넣을지 설명 할 수 있습니까?
구글 응답 : 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);
}
}
}
}
}
코드가 의미가 없기 때문에 창 크기를 음수로 지정하려고합니다. 물론 불가능합니다. 또한 SWP_NOSIZE를 지정하여 SetWindowPos()에 크기를 변경하지 말 것을 지정합니다. 대신 위치를 변경하십시오. 화면의 왼쪽 상단 모서리에 (0, 0)을 전달하지 마십시오. 화면의 일부분이 아니라 정의에 의해 나타납니다. –
고마워요, 적어도 하나의 신비가 풀 렸습니다! – user2097402