mgy333
13 years agoContributor
Refreshing screen using Win32API
We have a piece of code which draws green circle for pass and red x for fail on the screen.
I had a routine to clear those drawings, which worked flawlessly for a very long time, since TestComplete 3.
But when we upgraded from TestComplete 7 to TestComplete 8.6, that no longer worked. It throws exception: An exception occurred: 0xC0000005; class: ; description: ''.
The code to clear the screen that no longer works:
var User32DLL = DLL.DefineDLL("USER32");
var User32Lib = DLL.Load("USER32");
var oRect;
var defRect = DLL.DefineType("RECT",
vt_i4, "left",
vt_i4, "top",
vt_i4, "right",
vt_i4, "bottom"
);
User32DLL.DefineProc("InvalidateRect", vt_i4, defRect, vt_i4, vt_bool);
oRect = DLL.New("RECT");
oRect.left = 0;
oRect.top = 0;
oRect.right = 0;
oRect.bottom = 0;
User32Lib.InvalidateRect(0, oRect, 0); // <---- TC8 throws exception
So I did some research and tried few different options. None of the following works. None of them cause any exceptions, but they don't seem to do anything either.
Win32API.UpdateWindow(Win32API.GetDesktopWindow());
Win32API.InvalidateRgn(0, Win32API.GetDesktopWindow(), true);
Win32API.InvalidateRgn(0, Win32API.NULLREGION, true);
So is there a way to refresh the screen? Why doesn't the above code no longer works with TC8?
Thanks,
Motoo
I had a routine to clear those drawings, which worked flawlessly for a very long time, since TestComplete 3.
But when we upgraded from TestComplete 7 to TestComplete 8.6, that no longer worked. It throws exception: An exception occurred: 0xC0000005; class: ; description: ''.
The code to clear the screen that no longer works:
var User32DLL = DLL.DefineDLL("USER32");
var User32Lib = DLL.Load("USER32");
var oRect;
var defRect = DLL.DefineType("RECT",
vt_i4, "left",
vt_i4, "top",
vt_i4, "right",
vt_i4, "bottom"
);
User32DLL.DefineProc("InvalidateRect", vt_i4, defRect, vt_i4, vt_bool);
oRect = DLL.New("RECT");
oRect.left = 0;
oRect.top = 0;
oRect.right = 0;
oRect.bottom = 0;
User32Lib.InvalidateRect(0, oRect, 0); // <---- TC8 throws exception
So I did some research and tried few different options. None of the following works. None of them cause any exceptions, but they don't seem to do anything either.
Win32API.UpdateWindow(Win32API.GetDesktopWindow());
Win32API.InvalidateRgn(0, Win32API.GetDesktopWindow(), true);
Win32API.InvalidateRgn(0, Win32API.NULLREGION, true);
So is there a way to refresh the screen? Why doesn't the above code no longer works with TC8?
Thanks,
Motoo