Guest User

Untitled

a guest
Jun 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. IntPtr desktopDC = GetWindowDC(desktopListView);
  2. Graphics g = Graphics.FromHwnd(desktopDC); <-- fails on out of memory error
  3.  
  4. public void SetDesktopWindows()
  5. {
  6. Thread.Sleep(0);
  7. while (this.Count < Screen.AllScreens.Length)
  8. {
  9. OrangeGuava.Desktop.DesktopWindow.DesktopControl dtc = new OrangeGuava.Desktop.DesktopWindow.DesktopControl();
  10. User32.SetParent(dtc.Handle, User32.FindWindow("ProgMan", null));
  11. this.Add(dtc);
  12.  
  13. }
  14.  
  15. int minx = 0;
  16. int miny = 0;
  17.  
  18. foreach (Screen screen in Screen.AllScreens)
  19. {
  20. if (screen.Bounds.Left < minx) minx = screen.Bounds.Left;
  21. if (screen.Bounds.Top < miny) miny = screen.Bounds.Top;
  22. }
  23.  
  24. for (int i = Screen.AllScreens.Length; i < Count; i++)
  25. {
  26. OrangeGuava.Desktop.DesktopWindow.DesktopControl dtc = (OrangeGuava.Desktop.DesktopWindow.DesktopControl)this[i];
  27. dtc.Hide();
  28. }
  29.  
  30. for (int i = 0; i < Screen.AllScreens.Length; i++)
  31. {
  32. OrangeGuava.Desktop.DesktopWindow.DesktopControl dtc = (OrangeGuava.Desktop.DesktopWindow.DesktopControl)this[i];
  33. dtc.DeviceId = i.ToString();
  34.  
  35.  
  36. Rectangle r = Screen.AllScreens[i].WorkingArea;
  37. r.X -= minx;
  38. r.Y -= miny;
  39.  
  40.  
  41.  
  42. dtc.SetBounds(r.X, r.Y, r.Width, r.Height);
  43.  
  44. dtc.displaySettingsChanged(null, null);
  45.  
  46.  
  47. }
  48.  
  49. }
Add Comment
Please, Sign In to add comment