I'm making a subliminal images program for me and to put it for free online, I want the pics to show fast on the screen (say one every 5 seconds, for the duration of 300 ms), I know how to do all except that the way I know to draw on the screen doesn't have another way of removing what the program drew on the screen and showing what was behind it except by redrawing the whole screen, also I want that if the user clicked by mistake a mouse click on the image which appears and fades fast, the program doesn't take the mouse click and passes it down to the thing in screen just below it.
If I make a borderless form it would take the mouse clicks and maybe the keyboard focus (maybe I can make it not able to be focused on as I remember maybe there's a way)
What I have tried:
[DllImport("User32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("User32.dll")]
public static extern void ReleaseDC(IntPtr hwnd, IntPtr dc);
[DllImport("user32.dll")]
public static extern bool InvalidateRect(IntPtr hwnd, IntPtr lpRect, bool bErase);
IntPtr desktopPtr;
Graphics g;
desktopPtr = GetDC(IntPtr.Zero);
g = Graphics.FromHdc(desktopPtr);
g.DrawImage(...)
Thread.Sleep(300);
InvalidateRect(IntPtr.Zero, IntPtr.Zero, true);
I solved it, but this draws the pic on the screen very slowly from top to bottom and I want an instant drawing of it...
I need to pass the mouse click down to the next windows just below it if the user mouse clicks on the form by mistake, the form gets closed immediately and the mouse click should be ordered in that exact place, this is for knowing the scaling factor of the display to order the mouse click in the correct position:
private float getScalingFactor()
{
Graphics g = Graphics.FromHwnd(IntPtr.Zero);
IntPtr desktop = g.GetHdc();
int LogicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.VERTRES);
int PhysicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES);
float ScreenScalingFactor = (float)PhysicalScreenHeight / (float)LogicalScreenHeight;
return ScreenScalingFactor;
}
[DllImport("gdi32.dll")]
static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
public enum DeviceCap
{
VERTRES = 10,
DESKTOPVERTRES = 117,
}
whether it's a right or left or middle click should be taken in consideration too.