Making a DirectX9 application redraw

Trying to run multiple instance of a program on one screen and need to basically scale the program down to size. That I can do not problem but the game screen itself does not redraw when I scale the window using SetWindowPos(). Someone mentioned it may be part of the directX drawing look and I was wondering if there is a way to force another application's directX to redraw or resize itself. Here is what I have so far. The application seems to scale itself correctly if the user manually scales or resizes the window. It just wont do that if I do SetWindowPos() or MoveWindow()

Process firstGame = Process.GetProcessesByName("gameprocessname").ElementAt(0); if (firstGame != null) { try { IntPtr firstGameHandle = firstGame.MainWindowHandle; //get handle of game win IntPtr mainFormHandle = this.Handle; // store handle of my app SetWindowLong(firstGameHandle, GWL_STYLE, WS_BORDER); // get rid of borders // move the window where we want SetWindowPos( firstGameHandle, (IntPtr)0, gb.Location.X, gb.Location.Y, gb.Width, gb.Height, SHOWWINDOW); // make my application parent of the game SetParent(firstGameHandle, mainFormHandle); // child handle was lost on SetParent(); get Game handle again IntPtr childHandle = FindWindowEx( this.Handle, IntPtr.Zero, "gamewndclass", "titlecaption"); SetWindowText(childHandle, gameTitle); //Rename gamewindow SetForegroundWindow(childHandle); //set game window as active boxhandle = childHandle; //store the game windows handle // last thing I tried to get window to redraw and reset RedrawWindow( this.Handle, IntPtr.Zero, IntPtr.Zero, RedrawWindowFlags.Frame | RedrawWindowFlags.UpdateNow | RedrawWindowFlags.Invalidate); } catch (Exception er) { MessageBox.Show("Error: " + er.ToString()); } 

by atreyal via /r/csharp

Leave a Reply