PROFESSIONAL NEWSGROUPS
WINDEV
,
WEBDEV
and
WINDEV Mobile
Home
|
Recent messages
|
Connect
|
Sign out
|
English
Home
→
WINDEV 2024
→
Help with Making STATIC Element Responsive
Help with Making STATIC Element Responsive
Started by priv!qr5n441yynq14FM5v56rzn5vp10t+p1z, Oct., 03 2024 1:27 AM - No answer
Connect yourself…
priv!qr5n441yynq14FM5v56rzn5vp10t+p1z
#1
Posted on October, 03 2024 - 1:27 AM
Hello everyone at PC Soft,
At work, we're currently updating an old proprietary software, and one of the key features we're working on is a chatbox linked to an AI. The AI connection via fetch requests is working successfully, but we're struggling to adapt a `STATIC` element to make it responsive on the screen.
The goal is to dynamically adjust the `STATIC` element’s width and height based on the window size and the content inside it (such as text length). Currently, it seems that the width stays fixed at its initial size, regardless of the window adjustments.
### What we’re trying to achieve:
- **Make the static element's width** adjust based on the window size.
- **Make the static element's height** increase or decrease based on the length of the text content (line wrapping when the width reduces).
### Here’s part of the code we’re using:
Procedure
MakeTextResponsive
(
)
// Get the number of elements in the Multiline Zone
n
ElementCount
is int
=
MZ_ChatTest
..
Occurrence
// Get the text width based on current window size
INT_
TextWidth
is int
=
GetTextWidth
(
)
// Loop through all rows in the Multiline Zone
FOR IndexRow
=
1
TO
n
ElementCount
Trace
(
"Row #"
+
IndexRow
)
// We set Text to the static of the index row, if user static is empty then we set it to AI msg
Text
is string
=
MZ_ChatTest
[
IndexRow
]
.
STC_User_MSG
IF
Text
=
""
THEN
Text
=
MZ_ChatTest
[
IndexRow
]
.
STC_AI_MSG
// Calculate word count and required lines
TotalWordCount
is int
=
StringCount
(
Text
,
" "
) +
1
LineCount
is int
=
TotalWordCount
/
6
+
1
n
LineHeightNum
is int
// Set the height based on line count
SWITCH
LineCount
CASE
1
:
n
LineHeightNum
=
36
OTHER
CASE
:
n
LineHeightNum
=
24
END
LineHeight
is int
=
n
LineHeightNum
INT_
TextHeight
is int
=
LineCount
*
LineHeight
// Adjust the height and width for both user and assistant messages
IF
MZ_ChatTest
[
IndexRow
]
.
STC_User_MSG
<
>
""
THEN
MZ_ChatTest
[
IndexRow
]
.
STC_User_MSG
..
Height
=
INT_
TextHeight
MZ_ChatTest
[
IndexRow
]
.
STC_User_MSG
..
Width
=
INT_
TextWidth
ELSE
MZ_ChatTest
[
IndexRow
]
.
STC_AI_MSG
..
Height
=
INT_
TextHeight
MZ_ChatTest
[
IndexRow
]
.
STC_AI_MSG
..
Width
=
INT_
TextWidth
END
// Adjust the overall height of the looper row
MZ_ChatTest
[
IndexRow
]
..
Height
=
INT_
TextHeight
+
24
END
Procedure
MakeTextResponsive
(
)
// Set the width to a fixed size (you can calculate it based on character length if needed)
INT_
TextWidth
is int
=
Min
(
400
,
WIN_Test_MultiLineTEXT
..
Width
-
50
)
We’ve tried adjusting both the width and height based on the window size and content length, but the `STATIC` elements seem to remain at their initially created width. We would greatly appreciate any insights or suggestions on how to properly handle dynamic resizing for `STATIC` elements.
Thanks in advance for your help!
Report
0
0
→ Go back to WINDEV 2024
WINDEV 2024
WINDEV 2024
WEBDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV Mobile 2024
WINDEV (earlier versions)
WINDEV (earlier versions)
WINDEV 26
WINDEV 2025
WINDEV 2024
WINDEV 25
WEBDEV 2025
WEBDEV 2024
WINDEV Mobile 2025
WINDEV (earlier versions)
WEBDEV (earlier versions)
WINDEV Mobile (earlier versions)
Reports & Queries
Off-topic
Tools
Français
English
Español
Portuguesa
Close this window
Search type
Only topics
All the messages
Search period
Any time
Past hour
Past 24 hours
Past week
Past month
Past year
Cancel
Preview of your message
Adding an image
Import an image from a URL
Send an image from a file of your disk
Drop a file or click "Browse..."
or
Cancel
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Text