Wednesday, March 11, 2020

Four hack in one


C#

You know, you paint or spray something the Graphics on screen monitor i.e. display. Then want fresh screen that to get rid of it. Here some hacks::

HACK 1&4

Instead: 

[StructLayout(LayoutKind.Sequential)]
public struct RECT
        {

public int Left;
            public int Top;
            public int Right;
            public int Bottom;
        }
add there constructor function so you can the “new” it like this:
RECT rECT= new RECT(100, 100, 100, 100);
Constructor I mean like this:
[StructLayout(LayoutKind.Sequential)] 
public struct RECT
        {

       

            private int Left;
            private int Top;
            private int Right;
            private int Bottom;
         

            public RECT(int left, int top, int right, int bottom) {
            Left=left;
            Top=top;
            Right=right;
            Bottom=bottom;

                }
        }

HACK 2

Instead this way to over load using “IntPtr lpRect
[DllImport("user32.dll")]
        static extern bool InvalidateRect(IntPtr hWnd, IntPtr lpRect, bool bErase);
.... and then later:
InvalidateRect(IntPtr.Zero, IntPtr.Zero, true);

That above it refresh whole screen, use “ref RECT lpRect” instead “IntPtr lpRect” like this:
[DllImport("user32.dll")]
static extern bool InvalidateRect(IntPtr hWnd, ref RECT lpRect, bool bErase);

.... Now! You can fresh certain Rectangular instead it all.
RECT rECT= new RECT(100, 100, 100, 100);
InvalidateRect(IntPtr.Zero, ref rECT, true);

HACK 3

You can use same numbers at Rectangle and RECT this way
new Rectangle(400, 450, 192, 180)
new RECT(400, 450, 192+400, 180+450)
You see other need upper right corner and width and high, and the other just need the bounds.

That [StructLayout(LayoutKind.Sequential)]

means or it not like mean nothing, it is just like, you know cargo cult I mean there no particular reason to add it. It little bit the robustivines.

No comments:

Post a Comment

3D BLog has return

Go  to Check    https://thereal3dblog.com/