Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports DxColor = SharpDX.Color
- Imports Elektro.Imaging.Tools
- Imports Elektro.Interop.Win32
- Imports Elektro.Interop.Win32.Enums
- Public NotInheritable Class Form1 : Inherits Form
- Private hudForm As HUDForm
- Private renderT As Thread = Nothing
- Friend WithEvents HudButton1 As Button
- Private Sub Form1_Load() Handles MyBase.Shown
- Dim hwnd As IntPtr = Process.GetProcessesByName("my_fullscreen_game").Single().MainWindowHandle
- Me.hudForm = New HUDForm(hwnd)
- ' Build the HUD user-interface.
- Me.HUDButton1 = New Button
- Me.hudForm.Form.Controls.Add(Me.HUDButton1)
- Me.hudForm.Show()
- Me.renderT = New Thread(New ParameterizedThreadStart(AddressOf Me.RenderWork))
- Me.renderT.Priority = ThreadPriority.Normal
- Me.renderT.IsBackground = True
- Me.renderT.Start()
- End Sub
- Private Sub HudButton1_Click(sender As Object, e As EventArgs) Handles HUDButton1.Click
- MsgBox("Hello World")
- End Sub
- Private Sub RenderWork(ByVal sender As Object)
- While True
- Me.OverlapToWindow(Me.hudForm.HwndSource, Me.hudForm.HwndTarget)
- With Me.hudForm.Render
- .BeginDraw()
- .Clear(DxColor.Transparent)
- .Flush()
- .EndDraw()
- End With
- End While
- End Sub
- '<summary>
- ''Overlaps a source window to a target window.
- '</summary>
- Protected Sub OverlapToWindow(ByVal srcHwnd As IntPtr, ByVal dstHwnd As IntPtr)
- Gets the (non-client) Rectangle of the windows, taking into account a borderless window of Windows 10.
- Dim srcRect As Rectangle = ImageUtil.GetRealWindowRect(srcHwnd)
- Dim dstRect As Rectangle = ImageUtil.GetRealWindowRect(dstHwnd)
- NativeMethods.SetWindowPos(srcHwnd, dstHwnd,
- dstRect.X, dstRect.Y, dstRect.Top, dstRect.Left,
- SetWindowPosFlags.IgnoreZOrder Or SetWindowPosFlags.IgnoreResize)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment