5 Replies Latest reply: Mar 14, 2013 12:35 PM by frank1018 RSS

    How to get Applet size in my form ?

    frank1018
      I'm running Oracle forms 11g, I want to center my window use the code below :
        v_app_width := TO_NUMBER(GET_WINDOW_PROPERTY(FORMS_MDI_WINDOW,WIDTH));
        v_app_height := TO_NUMBER(GET_WINDOW_PROPERTY(FORMS_MDI_WINDOW,HEIGHT));
        v_win_width := TO_NUMBER(GET_WINDOW_PROPERTY(p_window_name,WIDTH));
        v_win_height := TO_NUMBER(GET_WINDOW_PROPERTY(p_window_name,HEIGHT));
       -- message("width" ||v_app_width);
        SET_WINDOW_PROPERTY(p_window_name,POSITION,(v_app_width- v_win_width) / 2,(v_app_height - v_offset - v_win_height) / 2);
      This works for 6i but not working for 11g. As
       GET_WINDOW_PROPERTY(FORMS_MDI_WINDOW,WIDTH)
      returns 0.
      But once that message line is uncommented, the next form calling this center window procedure works fine.

      My problem is similar with this one : http://www.orafaq.com/forum/t/149809/2/ But it has no solution.

      I also found this : http://docs.oracle.com/cd/B14099_19/winitan.1012/relnotes.1012/relnotes/forms.htm
       5.1.4.1 GET_WINDOW_PROPERTY Returns 0 on Microsoft Windows
      
      GET_WINDOW_PROPERTY(FORMS_MDI_WINDOW,WINDOW_HANDLE) returns zero even with separateframe=true. Oracle Forms Online Help states that this should work on windows platform. This is incorrect as this Built-in does not support MDI. 
      [Edited on 3/12 4:50pm] Today I found this code does work for my first form (login form) when the application launches. After login, the rest forms can be centered very well. Don't know what's the reason.

      So if this doesn't work, how could I get the applet size and center my window ?

      Edited by: frank1018 on Mar 12, 2013 4:53 PM
        • 1. Re: How to get Applet size in my form ?
          frank1018
          Any helps ? please !
          • 2. Re: How to get Applet size in my form ?
            ck
            If you want to center your window when MDI is maximized..

            first create timer.. under when-new-forms-intance..
            Declare
                 timer_id   Timer ;
            Begin     
              timer_id := Create_Timer( 'laf_timer', 50, NO_REPEAT ) ;
            end ;
            use this in when time expired.. because it will not run this procedure in when-new-forms-instance or pre-form triggers..
            declare
                 mh number;     rh number;     mw number;     rw number;
            begin     
                              If lower(Get_Application_Property( TIMER_NAME )) = 'laf_timer' Then

                                     mh     :=     get_window_property(forms_mdi_window,height);
                                mw     :=     get_window_property(forms_mdi_window,width);
                                rh     :=     get_window_property('yourwindowname',height);
                                rw     :=     get_window_property('yourwindowname',width);     
                                set_window_property('yourwindowname',position,(mw/2)-(rw/2),0);  /* i make 0 for the value of Y.. for i liked it on the top but you can change it too */
                             
                      end if;
             
            end ;
            Edited by: ck on Mar 14, 2013 2:44 AM
            • 3. Re: How to get Applet size in my form ?
              frank1018
              Dear CK :

              You are right, I try to call the center_window procedure in the When-Timer-Expired trigger, then it works.

              But why
               it will not run this procedure in when-new-forms-instance or pre-form triggers..
              • 4. Re: How to get Applet size in my form ?
                HamidHelal
                frank1018 wrote:
                Dear CK :

                You are right, I try to call the center_window procedure in the When-Timer-Expired trigger, then it works.

                But why
                 it will not run this procedure in when-new-forms-instance or pre-form triggers..
                No need of timer. Write you code at
                WHEN-WINDOW-ACTIVATED
                hope this works
                • 5. Re: How to get Applet size in my form ?
                  frank1018
                  Yes, It also works, but why doesn't work in PRE-FORM AND WHEN-NEW-FORM-INSTANCE trigger ?