Preventing your OpenInsight process from triggering the Windows 'Not Responding' message
Window ghosting is a Windows Manager feature that lets the user minimize, move, or close the main window of an application while it is busy. A side effect is that it raises an error if an application does not yield control every few seconds. Because OpenInsight does not always yield control our users see spurious error messages. The Windows API includes a function named DisableProcessWindowsGhosting. This API will prevent your OpenInsight windows from receiving the "Not Responding" message. A side effect is that your OpenInsight window cannot be moved while it is busy. For additional information please see the Sprezzatura blog post on this topic.
Below is a program that can be compiled in SYSPROG or your application. It can be called once from the create event of the main window. This setting remains in effect until OpenInsight is closed and affects the entire OpenInsight session, not just the current program.
Function rti_DisableProcessWindowsGhosting(void)
/*
** Prevent 'This program is not responding' messages
** http://msdn.microsoft.com/en-us/library/ms648415%28VS.85%29.aspx
** rjc 07-11-14 Created
*/
declare function GetVersionEx, blank_Struct, struct_to_var
Status = 1
Gosub install
OsVersionInfo = BLANK_STRUCT('RTI_OSVERSIONINFOEX')
PutBinaryValue(OsVersionInfo, 1, ulong, GetByteSize(OsVersionInfo))
if GetVersionEx(OsVersionInfo) else
Status = 0
End
If Status then
work = struct_to_var(OsVersionInfo,'RTI_OSVERSIONINFOEX' )
majorVersion = work<2>
minorversion = work<3>
Status = ( MajorVersion ge 6 ) ; * vista or better, the function will exist
end
If status then
End
If Status Then
Call rti_winapi_DisableProcessWindowsGhosting()
End
Return status
Install:
/*
** Add WinApi prototypes
*/
dll = 'USER32'
id = 'DLL_':dll
prototypes =
* INT STDCALL GetWindowLongA(HANDLE, INT) as GetWindowLong
prototypes←1> = "VOID STDCALL DisableProcessWindowsGhosting(LPVOID) as rti_winapi_DisableProcessWindowsGhosting"
rec = Xlate('SYSPROCS', id, , 'X')
orig = rec
if rec =
then
rec = dll:@fm
end
col =
loop
remove prototype from prototypes at col setting mark
if prototype #
then
func = field(prototype, ' ', 3)
func = func[1,'(']
func = ' ' : func : '('
if indexc(rec, func, 1) else
rec←1> = prototype
end
end
while mark
repeat
if rec # orig Then
Open 'SYSPROCS' To f_sysprocs Then
Lock f_sysprocs, id then
Write rec On f_sysprocs, id Then
call Declare_Fcns(id)
end
UnLock f_sysprocs, id Else null
Call Set_Status(0)
End
end
end
* Is the structure there?
struct_name = 'RTI_OSVERSIONINFOEX'
struct = "156;11;5,5,5,5,5,9,3,3,3,1,1;4,4,4,4,4,128,2,2,2,1,1"
Open 'SYSOBJ' To f_sysobj Then
Read test From f_sysobj, 'STRUCT_':struct_name else
Lock f_sysobj, 'STRUCT_':struct_name Then
Convert ';,' To @fm:@vm In struct
Write struct On f_sysobj, 'STRUCT_':struct_name Else
Status = 0
end
Unlock f_sysobj, 'STRUCT_':struct_name Else null
end
end
End Else
Status = 0
end
return