03 July, 2012

Center Canvas and Window in Oracle Forms

Today I will present two dynamic procedure for centering canvas or windows in middle center of the screen.

We always want to show canvas at middle center in another canvas and also for window in oracle forms.

So I will produce today two generic procedures for centering canvas/window at middle center of others.

Centering Canvas
To implement displaying canvas at middle center of another canvas (Container canvas) I will create procedure has two parameters ( canvas [C1] and container canvas[C2] ) and procedure will change x,y coordination of canvas[C1] at middle center of canvas[C2]

 PROCEDURE CENTER_VIEW (IN_VIEW_NAME VARCHAR2, IN_CONTAINER_VIEW VARCHAR2)  
 IS  
 BEGIN  
   SET_VIEW_PROPERTY (IN_VIEW_NAME,  
            VIEWPORT_X_POS,  
             (GET_VIEW_PROPERTY (IN_CONTAINER_VIEW, WIDTH) / 2  
             )  
            - (GET_VIEW_PROPERTY (IN_VIEW_NAME, WIDTH) / 2)  
            );  
   SET_VIEW_PROPERTY (IN_VIEW_NAME,  
            VIEWPORT_Y_POS,  
             (GET_VIEW_PROPERTY (IN_CONTAINER_VIEW, HEIGHT) / 2  
             )  
            - (GET_VIEW_PROPERTY (IN_VIEW_NAME, HEIGHT) / 2)  
            );  
 END;  



Centering Window
To implement displaying window at middle center of another window (Container window  ) I will create procedure has two parameters ( window[W1] and container window[W2] ) and procedure will change x,y coordination of window [W1] at middle center of window [W2]

 PROCEDURE CENTER_WINDOW (IN_WIN_NAME VARCHAR2, IN_CONTAINER_WIN VARCHAR2)  
 IS  
 BEGIN  
   SET_WINDOW_PROPERTY (IN_WIN_NAME,  
             X_POS,  
              (GET_WINDOW_PROPERTY (IN_CONTAINER_WIN, WIDTH) / 2  
              )  
             - (GET_WINDOW_PROPERTY (IN_WIN_NAME, WIDTH) / 2)  
             );  
   SET_WINDOW_PROPERTY (IN_WIN_NAME,  
             Y_POS,  
              (GET_WINDOW_PROPERTY (IN_CONTAINER_WIN, HEIGHT) / 2  
              )  
             - (GET_WINDOW_PROPERTY (IN_WIN_NAME, HEIGHT) / 2)  
             );  
 END;  

Sample
I create sample form that implement example for this post.
You can download it from here.

Thanks

1 comment:

  1. How can i align window center in Oracle Forms 11g

    ReplyDelete

ADF : Scope Variables

Oracle ADF uses many variables and each variable has a scope. There are five scopes in ADF (Application, Request, Session, View and PageFl...