Formslib use

Discussion in 'Questions (Windows Mobile)' started by kshetarpal, Nov 27, 2007.

  1. kshetarpal

    kshetarpal Member Licensed User

    I have several forms in my application. If the user has a device with larger or smaller screen or changes orientation the forms should redraw accordingly. How do I code that?

    Sub App_Start
    Form1.show
    flb.New1("Form1",B4PObject(1))

    The example above shows the coding for 1 form. Do I need to do that for every form?

    For example

    Sub App_Start
    Main.show
    flb.New1("Main",B4PObject(1))


    I have other forms that show up later in the application. Do I add this line each time I have Form.Show line like;
    Rform.Show
    flb.New1("Rform",BB4PObject(1))

    or Is it written differently?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Each form require a FormLib object to handle screen orientations.
    However you should only create the objects once :
    Code:
    Sub App_Start
        flb1.New1(
    "form1",B4PObject(1))
        flb2.New1(
    "form2",B4PObject(1))
        Form1.Show
    End Sub

    Sub Button1_Click
        form2.Show
    End Sub
     
  3. kshetarpal

    kshetarpal Member Licensed User

    Form resizing

    Thanks, Do I need to add any additional code for resizing or reorientation will that happen automatically?
    Amit
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You could use the Resize event to change the controls layout:
    Code:
    Sub flb1_Resize
     
    if Form1.Height > Form1.Width the
      ...
     
    else 
      ...
     
    end if
    end sub
     
  5. yildi

    yildi Member Licensed User

    Strange...
    I have two form in my application and I have attached a formlib object only to one of them. Or it seems that the resize event fires even if the other form is visible in the screen (my application nicely resizes following the code used in the event that resizes both forms even if only one of them has a formlib object).

    I am not complaining of course, since this allowed me to write only one resize event Sub :) Any idea?

    Murat
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Yes, it is enough to use one resize event as all forms raise this event (even when the forms are not visible).
    Still, one FormLib object is required for each form unless you are using a Panel or some other control that covers the form.
     
  7. yildi

    yildi Member Licensed User

    Yes, I have panels on both forums. This is maybe the reason...
     
Loading...