Applies To:
  • CitectSCADA  7.0

Summary:

The XP Style login form does not appear in the centre of the users monitor as expected.

The XP Style login form is generated by calling the CSV_Form_Login Cicode function.

INT
FUNCTION
CSV_Form_Login ()

    STRING sName;
    
STRING sPassword;
    
INT bDone;
    
INT nStatus;
    
INT iX , iY;
    
INT iMonitor;

    iMonitor = CSV_MM_GetMonitor () ;

    iY = ( WndInfo ( 1 )- 112 )/ 2 ;
    
iX = CSV_MM_GetOffset ( iMonitor ) + ( CSV_MM_GetScreenWidth () - 208 )/ 2 ;

    bDone = FALSE;
    
WHILE bDone = FALSE DO

        FormNew ( "@(Login Form)" , 30 , 5 , 5 ) ;
        
FormPosition ( iX , iY , 0 )
        
FormInput ( 1 , 0 , "@(Name)" + " " , sName , 16 ) ;
        
FormPassword ( 1 , 2 , "@(Password)" + " " , sPassword , 16 ) ;
        
FormButton ( 1 , 4 , " " + "@(OK)" + " " , 0 , 1 ) ;
        
FormButton ( 17 , 4 , "@(Cancel)" , 0 , 2 ) ;

        IF FormRead ( 0 ) = 0 THEN

            IF Login ( sName , sPassword ) = 0 THEN

                bDone = TRUE;
                
nStatus = 0 ;
            
END  
                 ELSE

            bDone = TRUE;
            
nStatus = 298 ;
        
END  
         END

    RETURN nStatus;

END

Essentially the CSV_Form_Login() Cicode function is attempting to calculate the x,y coordinates for the centre of the monitor and then load a login form at that location. It is also designed to read the users inputs and attempt to login using the supplied credentials.

Due to the nature of the underlying code, the set of x,y coordinates calculated are not always correct (especially when multimonitor mode is used or the monitor is not set to be 1024 pixels wide).  


Solution:

Try setting the Monitors and ScreenWidth parameters within the [MultiMonitors] section of the Citect.ini file.

If a single monitor is used then setting the screen width to be 1024 may resolve the issue.

Lastly the CSV_Form_Login cicode can be taken and modifed to produce a new Cicode function that will accept two new paraemters, the X and Y coordinates at which the login form is to appear, which can be used to manually specify the starting location of the login form:

INT
FUNCTION
CSV_Form_Login_XY ( INT iX , INT iY )

    STRING sName;
    
STRING sPassword;
    
INT bDone;
    
INT nStatus;
    
//INT iX, iY;  
         INT iMonitor;

    iMonitor = CSV_MM_GetMonitor () ;

    //iY = (WndInfo(1)-112)/2;  
         //iX = CSV_MM_GetOffset(iMonitor) + (CSV_MM_GetScreenWidth() - 208)/2;

    bDone = FALSE;
    
WHILE bDone = FALSE DO

        FormNew ( "@(Login Form)" , 30 , 5 , 5 ) ;
        
FormPosition ( iX , iY , 0 )
        
FormInput ( 1 , 0 , "@(Name)" + " " , sName , 16 ) ;
        
FormPassword ( 1 , 2 , "@(Password)" + " " , sPassword , 16 ) ;
        
FormButton ( 1 , 4 , " " + "@(OK)" + " " , 0 , 1 ) ;
        
FormButton ( 17 , 4 , "@(Cancel)" , 0 , 2 ) ;

        IF FormRead ( 0 ) = 0 THEN

            IF Login ( sName , sPassword ) = 0 THEN  
                                 bDone = TRUE;
                
nStatus = 0 ;
           
 END  
                 ELSE

            bDone = TRUE;
            
nStatus = 298 ;
        
END  
         END

    RETURN nStatus;

END

 

Keywords:
 

Attachments