Advertisement
Lirbo

Overlay

Apr 16th, 2020
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Diagnostics;
  11. using System.Threading;
  12. using System.Runtime.InteropServices;
  13.  
  14. namespace MapleLegends_Overlay
  15. {
  16.     public partial class Overlay : Form
  17.     {
  18.         [DllImport("user32.dll", SetLastError = true)]
  19.         static extern int GetWindowLong(IntPtr hWnd, int nIndex);
  20.  
  21.         [DllImport("user32.dll")]
  22.         static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
  23.  
  24.         [DllImport("user32.dll")]
  25.         static extern IntPtr SetParent(IntPtr hwc, IntPtr hwp);
  26.  
  27.         public Overlay()
  28.         {
  29.             InitializeComponent();
  30.         }
  31.  
  32.         private void Overlay_Load(object sender, EventArgs e)
  33.         {
  34.             this.TransparencyKey = Color.Wheat;
  35.             this.TopMost = true;
  36.            
  37.         }
  38.  
  39.         private void button1_Click(object sender, EventArgs e)
  40.         {
  41.             int pidint = Convert.ToInt32(textBox1.Text);
  42.             Process p = Process.GetProcessById(pidint);
  43.             Thread.Sleep(1000);
  44.             p.WaitForInputIdle();
  45.             SetParent(p.MainWindowHandle, panel1.Handle);
  46.             int initialStyle = GetWindowLong(this.Handle, -20);
  47.             SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);
  48.             //Form1 frm = new Form1();
  49.             //Size s = frm.Size;
  50.             //this.WindowState = FormWindowState.Maximized;
  51.             /*this.Size = new Size(1366, 768);
  52.             this.BackColor = Color.Green;
  53.             panel1.Size = new Size(1366, 768);
  54.             panel2.Size = new Size(1366, 768);
  55.             panel2.Top += 200;*/
  56.  
  57.  
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement