private void StartInternalWork() { Toolkit.TraceWriteLine("특정 스크린 프로세스 창 이동 방지를 시작합니다."); _isStartWindowWorker = true; Screen preventScreen = Screen.AllScreens[PreventMoveSceenIndex]; while (_isStartWindowWorker) { foreach (Process process in Process.GetProcesses()) { if (ExceptProcessNames.Contains(process.ProcessName)) { continue; } // 프로세스의 모든 윈도우 핸들 찾아서 처리할지 여부 if (_processAllWindowsHandleSetPosProcessNames.Contains(process.ProcessName)) { // TODO: 특정 프로세스의 모든 윈도우 핸들을 찾아서 처리할지 여부도 이벤트핸들러로 정의 필요 foreach (IntPtr windowHandle in WindowManager.GetProcessWindowHandles(process.Id)) { string windowText = WindowManager.GetWindowText(windowHandle); WindowPlacement wp = new WindowPlacement(); if (User32.GetWindowPlacement(windowHandle, ref wp)) { RECT rect = RECT.Empty; User32.GetWindowRect(windowHandle, out rect); // TODO: WindowPlacement ShowCmd.Maximize, ShowCmd.ShowMaximized 크기 20정도 줄이기 if (wp.ShowCmd == ShowWindowCommand.Maximize || wp.ShowCmd == ShowWindowCommand.ShowMaximized) { // outRect 사이즈를 줄여야 함 rect.Deflate(20, 20); } if (IsNearPreventScreenStartPositionOrEndPosition(preventScreen, ref rect)) { } if (ProcessAllWindowsHandleSetPos.Invoke(this, new ProcessAllSetWindowPosEventArgs(process, windowHandle, wp, windowText))) { if (preventScreen.BoundsContains(rect.ToPoints())) { ProcessSetWindowPos(windowHandle, rect); string text = String.Format("ProcessSetWindowPos ProcessName={0}, Handle={1}, ShowWindowCommand={2}, Text={3}", process.ProcessName, windowHandle, wp.ShowCmd.ToString(), windowText); Toolkit.TraceWriteLine(text); } } } } } else { WindowPlacement wp = new WindowPlacement(); if (User32.GetWindowPlacement(process.MainWindowHandle, ref wp)) { RECT rect; User32.GetWindowRect(process.MainWindowHandle, out rect); // TODO: WindowPlacement ShowCmd.Maximize, ShowCmd.ShowMaximized 크기 20정도 줄이기 if (wp.ShowCmd == ShowWindowCommand.Maximize || wp.ShowCmd == ShowWindowCommand.ShowMaximized) { // outRect 사이즈를 줄여야 함 rect.Deflate(20, 20); } if (IsNearPreventScreenStartPositionOrEndPosition(preventScreen, ref rect)) { } if (preventScreen.BoundsContains(rect.ToPoints())) { ProcessSetWindowPos(process.MainWindowHandle, rect); string text = String.Format("ProcessSetWindowPos ProcessName={0}, Handle={1}, ShowWindowCommand={2}, Title={3}", process.ProcessName, process.MainWindowHandle, wp.ShowCmd.ToString(), process.MainWindowTitle); Toolkit.TraceWriteLine(text); } } } } } }