Applies To:
  • CitectSCADA 5.xx, 6.xx
  • CitectHMI 5.xx, 6.xx

Summary:
How can I make a pop-up page Modal, or otherwise prevent a user from clicking buttons located on pages otherthan the current popup?  

Solution:
One solution is to use the following Cicode to prevent the mouse from moving outside a pre-defined area. (i.e the limits of the Popup)

The following CiCode can be used to do this:

On the Popup page, put the following cicode as a 'On Page Shown Event'
While() DO Sleepms(10); TrapMouse(410,369);END;

Where in this case, the Width of the Popup is 410, and the height 369.

Then, in a Cicode file, define the following functions:
 

//Global Variables
INT
Xold,Yold;

//TRAPMOUSE - Prevent mouse from leaving a speciifed area.
//Implement from 'While Page Shown' event, i.e:TrapMouse(410,369)
//or to get the function to run faster, use the following in the 'OnPage Shown' event:
//WHILE(1) DO SleepMS(10);TrapMouse(410,369); END;

FUNCTION
TrapMouse(
INT Xlimit, INT Ylimit)

    INT
Xnew,Ynew;
    DspGetMouse
( Xnew, Ynew);
    IF
Xnew > 0 AND Xnew < Xlimit AND Ynew > 0 AND Ynew < Ylimit THEN
        Xold=Xnew;
        Yold=Ynew;

    ELSE

        SetMousePos(Xold,Yold);

    END
END

//Use DLL calls to move the mouse

FUNCTION
SetMousePos(
INT X, INT Y)

    INT
hSetMousePos;
    X = X +
StrToInt( PageInfo( 14)) + StrToInt( WndInfo( 32));
    IF
(StrToInt( PageInfo( 11)) BITAND 16) <> 16 THEN         //If title bar IS on
        Y = Y +
StrToInt( PageInfo( 15)) + StrToInt( WndInfo( 4))+ StrToInt( WndInfo( 6)) + StrToInt( WndInfo( 8));
    ELSE
        //No Title bar
        Y = Y +
StrToInt( PageInfo(15));
    END

    hSetMousePos =
DLLOpen("User32", "SetCursorPos", "JJJ");
   
//Ideally put above line in your startup function - only needs to be called once
   
DLLCall( hSetMousePos, X:##### + "," + Y:#####);
END

 

Keywords:
Trapping Trap mouse move movement movements window popup  

Attachments