Guest User

Untitled

a guest
Jan 17th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. ----------------------------------------------------------------------------------------------------------
  2. TO WORK WITH THE HUDFORM CLASS, REMEMBER TO SPECIFY THE CLASS INHERITANCE IN YOUR AUTOGENERATED FORM CODE:
  3. ----------------------------------------------------------------------------------------------------------
  4. Imports Elektro.Application.ThirdParty.SharpDX.Types
  5.  
  6. <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
  7. Partial Class Form1 : Inherits HUDForm ' < HERE
  8. ' Autogenerated code here...
  9. End Class
  10.  
  11.  
  12. ----------------------------------------------------------------------------------------------------------
  13.  
  14. Imports System
  15. Imports Elektro.Application.ThirdParty.SharpDX.Types
  16. Imports Elektro.Interop.Win32
  17. Imports Elektro.Processes.Extensions.Process
  18. Imports DxColor = SharpDX.Color
  19.  
  20. Public Class Form1 : Inherits HUDForm
  21.  
  22. Private renderT As New Thread(New ParameterizedThreadStart(AddressOf Me.RenderWork))
  23. Private proc As Process ' The target process.
  24.  
  25. Private Sub Form1_Shown(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Shown
  26.  
  27. Me.proc = Process.GetProcessesByName("MyGame").SingleOrDefault()
  28.  
  29. If (Me.proc Is Nothing) Then
  30. Application.Exit()
  31.  
  32. Else
  33. Me.HwndTarget = Me.proc.MainWindowHandle
  34. Me.proc.Activate() ' Activates the target window.
  35.  
  36. With Me.renderT
  37. .Priority = ThreadPriority.Normal
  38. .IsBackground = True
  39. .Start()
  40. End With
  41.  
  42. End If
  43.  
  44. End Sub
  45.  
  46. ' Your custom SharpDX's renderization logic goes inside this method block. I just wrote a very simple example.
  47. Private Sub RenderWork(ByVal sender As Object)
  48.  
  49. While True
  50.  
  51. Me.Invoke(Sub() Me.Visible = NativeMethods.IsWindowVisible(Me.HwndTarget))
  52.  
  53. If (Me.Visible) Then
  54. ' Call this method repeteadlly to overlap the HUDForm to the target window.
  55. Me.OverlapToWindow(Me.HwndTarget)
  56.  
  57. With Me.Render
  58. .BeginDraw()
  59. .Clear(DxColor.Transparent)
  60. .Flush()
  61. .EndDraw()
  62. End With
  63. End If
  64.  
  65. End While
  66.  
  67. End Sub
  68.  
  69. End Class
Advertisement
Add Comment
Please, Sign In to add comment