Jump to content

Recommended Posts

Posted

Hi, Farshad!

 

Is there any way to get maximum used height for TUniHTMLFrame (something like TComponent.HorzScrollbar.Size) ?

 

Let me explain this. I have TuniHTMLFrame with Height 36 and property AutoScroll=True. Text in component has different length and I would to know, what is minimum Height for component to show all text without scrollbar. Is this possible ?

 

Regards

 

Bogdan

  • Administrators
Posted

Hi, Farshad!

 

Is there any way to get maximum used height for TUniHTMLFrame (something like TComponent.HorzScrollbar.Size) ?

 

Let me explain this. I have TuniHTMLFrame with Height 36 and property AutoScroll=True. Text in component has different length and I would to know, what is minimum Height for component to show all text without scrollbar. Is this possible ?

 

Regards

 

Bogdan

 

Hi,

 

You can only get design time height of TUniHTMLFrame. Its variable HTML height can not retrieved.

Posted

Hi,

 

You can only get design time height of TUniHTMLFrame. Its variable HTML height can not retrieved.

 

No, this is not what I need :). I saw that vertscrollbox indicator is different depending on length of text. This is what I need. I would like to increase height of UniHTMLFrame until the entire text is visible.

Posted

No, this is not what I need :). I saw that vertscrollbox indicator is different depending on length of text. This is what I need. I would like to increase height of UniHTMLFrame until the entire text is visible.

Text height is come from various result, i.e. font name/family, fony size, etc.

You can use JavaScript to calculate a height of text.

 

<script language="javascript" type="text/javascript">
function TextHeight(text, points, family){
 test = document.getElementById("Test");
 test.style.fontFamily = family;
 test.style.fontSize = points;
 test.innerHTML = text;
 return test.clientHeight + ' px height';
}

alert("Arial: " + TextHeight("Product", "41pt", "Arial"));
alert("Verdana: " + TextHeight("Product", "41pt", "Verdana"));
</script>

or

<script language="javascript" type="text/javascript">
function getDivHeight(){
 alert("Client Height:  " + document.getElementById("div1").clientHeight);       
 alert("Offset Height:  " + document.getElementById("div1").offsetHeight);
}
</script>

<body>
 <center>
   <div id="div1">
       Get Div Height using Javscript function. Javascript DOM document can access the
       height of HTML Div element dynamically.
   </div>
   <br />   
   <input type="button" value="Get Div Height" onclick="getDivHeight()" />
 </center>
</body>

 

But again, how can we get value from JavaScript? maybe Farshad has an answer :)

  • 6 years later...
Posted

hi, for future answers seekers! Has similar question, found solution with help of great Delphi Developer

 

this will just alert with heightInfo

js:='alert('+HTMLFrame.JSName+'.body.el.dom.scrollHeight);';
  UniSession.JSCode(js);

you can send it like this from client

 js := ' function getTextHeight()' + //
    '{' + //
    
    'return HTMLFrame.JSName+'.body.el.dom.scrollHeight' + //
    '}' + //
    'ajaxRequest(' + HTMLFrame.JSName + ', ''HTMLFrameHeightAdjust'', [ ''param0=''+getTextHeight(), ''param1=B'' ]);';
  UniSession.JSCode(js);

on Server accept like this

procedure TPaymentsPageContent.HTMLFrameAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings);
begin
  if SameText(EventName, 'HTMLFrameHeightAdjust') then  
    begin
    ShowMessage('Here ' + Params.Values['param0']);
    // do smth
    HTMLFrame.Height:=Params.Values['param0'].toInteger;
    end;
end;

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...