Applies To:
  • CitectSCADA

Summary:
I want to disable user input to a Window, at a Microsoft Windows Level. In other words, I do not want the user to be able to click on a window at all. 

Solution:
The best way of doing this is by using a flag in the 'Disable When' section on the 'Access' tab of an object, as shown below, or by using Users, Areas and Privileges.
However, a Windows API call can also be utilised in order to disable user input to that window, as shown after the screenshot.

Method 1:

Method 2:
This was tested on WinXP in Citect v6.10 and v7.00.

Using the following Cicode, and calling it from a Citect Keyboard Command, will allow you to toggle input on and off by pressing F2.

iStatus, will hold the return value of the function, 1 meaning that the Window can accept user input, 0 meaning it cannot.


INT
FUNCTION ToggleInput()
    INT hGetActiveWindow = DLLOpen("user32", "GetActiveWindow", "J");
    INT hEnableWindow = DLLOpen("user32", "EnableWindow", "JJJ");
    INT hCheckWindow = DLLOpen("user32", "IsWindowEnabled", "JJ");
    INT iRetVal,iWndHnd,iEnabled,iEnable;
    iWndHnd =
DLLCallEx(hGetActiveWindow);
    TraceMsg("iWndHnd2 = " + IntToStr(iWndHnd));
    iEnabled =
DLLCallEx(hCheckWindow, iWndHnd);
    TraceMsg("iEnabled2 = " + IntToStr(iEnabled));
    IF iEnabled THEN
        iEnable=0
    ELSE
        iEnable=1
    END
    iRetVal = DLLCallEx(hEnableWindow, iWndHnd, iEnable);
    TraceMsg("iRetVal2 = " + IntToStr(iRetVal));
    iEnabled =
DLLCallEx(hCheckWindow, iWndHnd);
    TraceMsg("iEnabled2 = " + IntToStr(iEnabled));
    DLLClose(hGetActiveWindow);
    DLLClose(hEnableWindow);
    DLLClose(hCheckWindow);
    RETURN iEnabled;
END  

Keywords:
 

Attachments