Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------------------------------------
- TO WORK WITH THE HUDFORM CLASS, REMEMBER TO SPECIFY THE CLASS INHERITANCE IN YOUR AUTOGENERATED FORM CODE:
- ----------------------------------------------------------------------------------------------------------
- Imports Elektro.Application.ThirdParty.SharpDX.Types
- <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
- Partial Class Form1 : Inherits HUDForm ' < HERE
- ' Autogenerated code here...
- End Class
- ----------------------------------------------------------------------------------------------------------
- Imports System
- Imports Elektro.Application.ThirdParty.SharpDX.Types
- Imports Elektro.Interop.Win32
- Imports Elektro.Processes.Extensions.Process
- Imports DxColor = SharpDX.Color
- Public Class Form1 : Inherits HUDForm
- Private renderT As New Thread(New ParameterizedThreadStart(AddressOf Me.RenderWork))
- Private proc As Process ' The target process.
- Private Sub Form1_Shown(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Shown
- Me.proc = Process.GetProcessesByName("MyGame").SingleOrDefault()
- If (Me.proc Is Nothing) Then
- Application.Exit()
- Else
- Me.HwndTarget = Me.proc.MainWindowHandle
- Me.proc.Activate() ' Activates the target window.
- With Me.renderT
- .Priority = ThreadPriority.Normal
- .IsBackground = True
- .Start()
- End With
- End If
- End Sub
- ' Your custom SharpDX's renderization logic goes inside this method block. I just wrote a very simple example.
- Private Sub RenderWork(ByVal sender As Object)
- While True
- Me.Invoke(Sub() Me.Visible = NativeMethods.IsWindowVisible(Me.HwndTarget))
- If (Me.Visible) Then
- ' Call this method repeteadlly to overlap the HUDForm to the target window.
- Me.OverlapToWindow(Me.HwndTarget)
- With Me.Render
- .BeginDraw()
- .Clear(DxColor.Transparent)
- .Flush()
- .EndDraw()
- End With
- End If
- End While
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment