1234567891011121314151617181920212223242526272829 |
- using System;
- using System.Drawing;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- namespace ScreenSaverEf
- {
- public partial class PreviewForm : Form
- {
- [DllImport("user32.dll")]
- private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
- [DllImport("user32.dll")]
- private static extern bool GetClientRect(IntPtr hWnd, out Rectangle lpRect);
- public PreviewForm(IntPtr hWndParent)
- {
- InitializeComponent();
- SetParent(this.Handle, hWndParent);
- GetClientRect(hWndParent, out var parentRect);
- this.Location = new Point(0, 0);
- this.Size = parentRect.Size;
- }
- }
- }
|