Guest User

Untitled

a guest
Jan 9th, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.06 KB | None | 0 0
  1. Imports DxColor = SharpDX.Color
  2.  
  3. Imports Elektro.Imaging.Tools
  4. Imports Elektro.Interop.Win32
  5. Imports Elektro.Interop.Win32.Enums
  6.  
  7. Public NotInheritable Class Form1 : Inherits Form
  8.  
  9.     Private hudForm As HUDForm
  10.     Private renderT As Thread = Nothing
  11.     Friend WithEvents HudButton1 As Button
  12.  
  13.     Private Sub Form1_Load() Handles MyBase.Shown
  14.  
  15.         Dim hwnd As IntPtr = Process.GetProcessesByName("my_fullscreen_game").Single().MainWindowHandle
  16.         Me.hudForm = New HUDForm(hwnd)
  17.  
  18.         ' Build the HUD user-interface.
  19.         Me.HUDButton1 = New Button
  20.         Me.hudForm.Form.Controls.Add(Me.HUDButton1)
  21.  
  22.         Me.hudForm.Show()
  23.  
  24.         Me.renderT = New Thread(New ParameterizedThreadStart(AddressOf Me.RenderWork))
  25.         Me.renderT.Priority = ThreadPriority.Normal
  26.         Me.renderT.IsBackground = True
  27.         Me.renderT.Start()
  28.  
  29.     End Sub
  30.  
  31.     Private Sub HudButton1_Click(sender As Object, e As EventArgs) Handles HUDButton1.Click
  32.         MsgBox("Hello World")
  33.     End Sub
  34.  
  35.     Private Sub RenderWork(ByVal sender As Object)
  36.  
  37.         While True
  38.             Me.OverlapToWindow(Me.hudForm.HwndSource, Me.hudForm.HwndTarget)
  39.             With Me.hudForm.Render
  40.                 .BeginDraw()
  41.                 .Clear(DxColor.Transparent)
  42.                 .Flush()
  43.                 .EndDraw()
  44.             End With
  45.         End While
  46.  
  47.     End Sub
  48.  
  49.     '<summary>
  50.     ''Overlaps a source window to a target window.
  51.     '</summary>
  52.     Protected Sub OverlapToWindow(ByVal srcHwnd As IntPtr, ByVal dstHwnd As IntPtr)
  53.  
  54.         Gets the (non-client) Rectangle of the windows, taking into account a borderless window of Windows 10.
  55.         Dim srcRect As Rectangle = ImageUtil.GetRealWindowRect(srcHwnd)
  56.         Dim dstRect As Rectangle = ImageUtil.GetRealWindowRect(dstHwnd)
  57.  
  58.         NativeMethods.SetWindowPos(srcHwnd, dstHwnd,
  59.                                    dstRect.X, dstRect.Y, dstRect.Top, dstRect.Left,
  60.                                    SetWindowPosFlags.IgnoreZOrder Or SetWindowPosFlags.IgnoreResize)
  61.     End Sub
  62.  
  63. End Class
Advertisement
Add Comment
Please, Sign In to add comment