Jump to content

How can I Position and Adjust Objects At Runtime via an Ajax Event (eg. orientation)


andyhill

Recommended Posts

As can be seen via the attachment I am trying to pretty up the form (I want to make cpScreen hide white space, also size and align objects etc.). cpScreen.AlignmentControl:= uniAlignmentClient; messes everything up.

 

I have a TUnimContainerPanel (cpScreen) with child objects and when an iPhone or iPad etc. is rotated (even on startup) I want to re-size, re-position and re-align my objects.

 

Can someone please advise with a Delphi code example - thanks.

 

// AjaxEvent Fires On Rotation

procedure TLoginmForm.UnimLoginFormAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
var
  i, p, w, h: Integer;
  s, JSName: String;
  ss: TUniStrings;
begin
  if SameText(EventName, 'vpsize') then begin
    w:= 0;
    h:= 0;
    ss:= Params;
    for i:= 0 to ss.Count-1 do begin
      s:= ss.Strings;
      p:= Pos('w=', s);
      if p > 0 then begin
        w:= StrToInt(Copy(s, p+2, Length(s)-p-1));
      end;
      p:= Pos('h=', s);
      if p > 0 then begin
        h:= StrToInt(Copy(s, p+2, Length(s)-p-1));
      end;
    end; // for
    if ( (w > 0) and (h > 0) ) then begin
      JSName:= cpScreen.JSName+'_id';
      s:= QuotedStr('w='+IntToStr(w))+'; '+QuotedStr('h='+IntToStr(h))+';';
      //UniSession.AddJS(JSName+' Color = red;'); // this test fails (I need to set width and height)
      // edtEmail: TUnimEdit; // then I need to center child objects on portrait, left align on landscape etc.
    end;
  end; // vpsize
end;
 

post-5752-0-45021000-1508111404_thumb.jpg

Link to comment
Share on other sites

×
×
  • Create New...