You are running Vista or Windows 7 (sorry XP users)
SlimDX SDK
The Tutorial:
This is written in C#, but if you understand programming, it's easily transferable to any other language. This only contains code to create the overlay, nothing on drawing the ESP itself, however there is plenty of tutorials and pieces of example code on the internet on how to do that.
Create a new form.
Set this form's BackColor as Black (we are going to use black as a transparency key)
As said before we're going to use SlimDX to make our overlay, so, after downloading the SDK, add a reference to it by Right Clicking on "References" -> "Add Reference". After that, add the following to your code:
Code:
using SlimDX.Direct3D9;
In the form's class add the following PInvokes and defintitions:
Code:
private Margins marg;
//this is used to specify the boundaries of the transparent area
internal struct Margins
{
public int Left, Right, Top, Bottom;
}
[DllImport("user32.dll", SetLastError = true)]
private static extern UInt32 GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
[DllImport("user32.dll")]
static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);
[DllImport("dwmapi.dll")]
static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMargins);
public const int GWL_EXSTYLE = -20;
public const int WS_EX_LAYERED = 0x80000;
public const int WS_EX_TRANSPARENT = 0x20;
public const int LWA_ALPHA = 0x2;
public const int LWA_COLORKEY = 0x1;
private Direct3D D3D = null;
private Device device = null;
In the form's constructor add:
Code:
//Make the window's border completely transparant
SetWindowLong(this.Handle, GWL_EXSTYLE,
(IntPtr)(GetWindowLong(this.Handle, GWL_EXSTYLE) ^ WS_EX_LAYERED ^ WS_EX_TRANSPARENT));
//Set the Alpha on the Whole Window to 255 (solid)
SetLayeredWindowAttributes(this.Handle, 0, 255, LWA_ALPHA);
//Init DirectX
//This initializes the DirectX device. It needs to be done once.
//The alpha channel in the backbuffer is critical.
PresentParameters presentParameters = new PresentParameters();
presentParameters.Windowed = true;
presentParameters.SwapEffect = SwapEffect.Discard;
presentParameters.BackBufferFormat = Format.A8R8G8B8;
this.device = new Device(0, DeviceType.Hardware, this.Handle,
CreateFlags.HardwareVertexProcessing, presentParameters);
Thread dx = new Thread(new ThreadStart(this.dxThread));
dx.IsBackground = true;
dx.Start();
Ok, now we create a basic DirectX thread (you'll need to insert your own logic and rendering code)
Code:
private void dxThread()
{
while (true)
{
//Place your update logic here
device.Clear(ClearFlags.Target, Color.FromArgb(0, 0, 0, 0), 1.0f, 0);
device.BeginScene();
//Place your rendering logic here
device.EndScene();
device.Present();
}
this.device.Dispose();
Application.Exit();
}
At this stage we have a maximised solid border less window with DirectX running in it (nothing special). This is where we change that window into an overlay - and the part which makes this Vista/7 only.
Add an Override to the "On Paint" method to the form and set put the following code in it;
Code:
//Create a margin (the whole form)
marg.Left = 0;
marg.Top = 0;
marg.Right = this.Width;
marg.Bottom = this.Height;
//Expand the Aero Glass Effect Border to the WHOLE form.
// since we have already had the border invisible we now
// have a completely invisible window - apart from the DirectX
// renders NOT in black.
DwmExtendFrameIntoClientArea(this.Handle, ref marg);
The End
If you have any doubts if your window really exists after this.. comment the following line on the code: