가 그렇게 어렵지 않다 밝혀, 게임에서 리소스를 훔치거나 자발적인 지연 (약간 눈에 띄는)을 유발하고 게임을 완벽하게 작동시키는 등의 바람직하지 않은 부작용을 초래할 수 있지만 다소 시간이 걸릴 수 있습니다.
내가 수행 한 작업은 새 Form
으로 만들어지고 ResizeEnd
이벤트에 이벤트 처리기가 할당되었습니다. 이벤트 처리기는 public static Rectangle fakeWindowRect
을 Form.RectangleToScreen()
메서드를 사용하여 계산 된 위조 창 클라이언트 영역의 새 사각형으로 설정합니다. 여기
는 일부 코드 조각입니다 :
static void Main(string[] args)
{
System.Windows.Forms.Form f = new System.Windows.Forms.Form();
f.ClientSize = new System.Drawing.Size(800, 600);
f.TransparencyKey = f.BackColor;
((Action)(() => System.Windows.Forms.Application.Run(f))).BeginInvoke(
null, null);
using (Game1 game = new Game1())
{
f.ResizeEnd += new EventHandler(game.f_LocationChanged);
game.Run();
}
}
public class Game1 : Microsoft.Xna.Framework.Game
{
public static Rectangle windowRect;
/* ... */
protected override void Update(GameTime gameTime)
{
if (windowRect.X != this.Window.ClientBounds.X ||
windowRect.Y != this.Window.ClientBounds.Y ||
windowRect.Width != this.Window.ClientBounds.Width ||
windowRect.Height != this.Window.ClientBounds.Height)
{
// this method sets the game window size, but not location
InitGraphicsMode(windowRect.Width, windowRect.Height,
this.graphics.IsFullScreen);
var win = System.Windows.Forms.Control.FromHandle(
this.Window.Handle) as
System.Windows.Forms.Form;
win.SetBounds(windowRect.X,
windowRect.Y,
windowRect.Width,
windowRect.Height);
win.Activate();
}
}
public void f_LocationChanged(object sender, EventArgs e)
{
var FakeWindow = sender as System.Windows.Forms.Form;
var drawClientArea = FakeWindow.RectangleToScreen(
FakeWindow.ClientRectangle);
windowRect = new Rectangle(
drawClientArea.X,
drawClientArea.Y,
drawClientArea.Width,
drawClientArea.Height);
}
}
구현이 잘못된 모든 주위 끔찍한 및 수도 있지만 게임이 일부 프레임을 삭제 가짜 폼의 크기를 조정하는 경우에도, 게임에서 모든 자원을 훔치는없이 작동하지만, 멈추지 않는다.
나는 그것을 시험해 보았지만 효과가 있었지만, 주로 과학을위한 것이었고, 나는이 접근법을 조만간 사용할 생각이 없다. 어쩌면 내가 정말로 필요할 때.