PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WDM20] Resizing a Static control and Looper control row
[WDM20] Resizing a Static control and Looper control row
Iniciado por guest, 21,mar. 2016 16:36 - 14 respuestas
Publicado el 21,marzo 2016 - 16:36
Hi guys,

I have a Static control in a looper; is there a way to dynamically increase the size of the Static control based on the amount of text to be displayed in the Static control, then correspondingly increase the size of the Looper row to accommodate the new size of the Static control?

I can see ..Height might do the trick, but if this is the only way, does anyone have any example code that might handle things like the sizing of the control when things like proportional fonts are used?

Cheers...
Publicado el 22,marzo 2016 - 10:18
Hmmm, I presume it's a bit tricky then?
Publicado el 22,marzo 2016 - 13:09
Hello Darren

there is an example of how to resize a static based on its content in the info window (when you integrate the windows into your project/theme).

As to how to resize the looper control row, I'm not sure...

Personally, I have done something of that sort by NOT using a looper, but by cloning the controls of my original row instead, which gives me full control.

Best regards
Publicado el 22,marzo 2016 - 13:32
Thanks Fabrice; I see what you mean, although I like the functionality that looper controls give me as I need to allow for multiple selections etc...

I'm thinking out loud now, but I suppose I could for example, have 3 planes and put a looper on each plane. Each looper would have a specific row size adjusted to accommodate 1, 2 & 3 line Static controls. Then, the only issue is to come up with an algorithm that works out if the text I'm trying to put into the Static control would wrap onto line 2 or 3 of the Static control - if you see what I mean?
Publicado el 22,marzo 2016 - 14:01
Darren,

I have done this before and it does work, just with one looper.
The height-property of each individual row is your friend i.e. LOOP_Messages[nRow]..Height = 123

You can calculate the required height by using TextHeight(EDT_Text1,sText,,tMultiline)
Where (in my case) an edit-control was used in the looper to display RTF-text.

I even had an option to display a photo, or not, on each row. By having a 1 pixel height image control (invisible) and resize that one when a photo has to be displayed. Accordingly the height of the looper-row has to grow equally.

One thing I ran into was that resizing of looper-rows was too complex for the WD-framework in certain situations and caused some weird redraw effects. I managed to overcome this by first making a row BIG, like 1000 pixels. And then resize is as needed. So "shrinking" rows seems work better than increasing the height.

Last on: use DsiplayEnabled to avoid redraw flicker

LOOP_Mededelingen[nRow]..Height = 1000 EDT_Tekst..Height = 990 nHeight = TextHeight(EDT_Tekst,sTekst,tMultiline) + 10 nDiff = nHeight - EDT_Tekst..Height LOOP_Mededelingen[nRow].EDT_Tekst..Height = nHeight LOOP_Mededelingen[nRow].IMG_Foto..Y = LOOP_Mededelingen[nRow].EDT_Tekst..Y + LOOP_Mededelingen[nRow].EDT_Tekst..Height + 5 LOOP_Mededelingen[nRow]..Height = (nHeight + 10) IF LOOP_Mededelingen[nRow].ATT_Foto <> "" THEN LOOP_Mededelingen[nRow]..Height += 380 // LOOP_Mededelingen[nRow].IMG_Foto..Height += 380 // don't need this anymore - anchor of image control is set to width + height LOOP_Mededelingen[nRow].IMG_Foto..Visible = True END
Publicado el 22,marzo 2016 - 14:07
And it looks like this :xcool:
Publicado el 22,marzo 2016 - 15:49
Thanks Arie, I'm not at my PC - did you manage to do this in WDM (android)?
Publicado el 22,marzo 2016 - 16:42
Darren,

my bad. I did not notice you mentioned WM. I'm talking about WD.
I can't tell you if it works in WM.
Publicado el 22,marzo 2016 - 16:55
I'll be able to tell you later... ;)

...although I'm not holding my breath as the Help pages mention that the ..Height property is available in WM Android but only for Break Header & Footer rows in the Looper control :(
Publicado el 22,marzo 2016 - 17:47
Hi i have used the following code in WM21 with Android and it works fine :)

FOR nn = 1 TO 30
// Create a long text for each Looper line
sValor is string = Complete(sValor,nn*10,nn)
// Add the line
LooperAdd(ZR_Lista,sValor)
// Change the line height
ZR_Lista[nn]..Height = TextHeight(LIB_Alto,sValor,tMultiline) + 20//25*nn
//MeasureMultilineTextHeight("ZR_Lista[" + nn + "].LIB_Alto", sValor)
// Change the label height with the screing size
ZR_Lista[nn].LIB_Alto..Height = TextHeight(LIB_Alto,sValor,tMultiline)
// See the changed size
Trace(ZR_Lista[nn].LIB_Alto..Height)


END

It works fine for me.

Rubén
Publicado el 22,marzo 2016 - 17:57
Ruben... WM21 is a whole different ball game! ;) ...but I'll try it in WM20 and post it here... :spos:
Publicado el 22,marzo 2016 - 18:26
Hi. The same functions exist in WM20.

Rubén
Publicado el 29,marzo 2016 - 11:53
As always - thanks guys!

The main reason for me seeing strange happenings was (I think) due to me using a query to (pre)populate my Looper control. Once I changed this to use something similar to Ruben's suggestion; i.e. using LooperAddLine and converting the Looper control to be populated "by programming" has solved my issues :spos:
Publicado el 29,marzo 2016 - 12:05
Darren,

I found also that using attributes does not always work as expected, especially when using an image as one of the controls in the looper. Same thing for radio-controls.

I had to UNbind these controls from the attribute and do something like this in the "display row event" of the looper
IMG_Arie = ATT_PhotoArie
Publicado el 29,marzo 2016 - 12:27
Hi Arie,

Yeah, based on the "pain" of getting this far, nothing would surprise me! ;)

Also, I forgot to mention, I took note of the example in the Help pages for LooperAddLine and coded it like this:

http://doc.windev.com/en-US/…

// Add an empty row LooperAddLine(LOOP_Looper) // Position on the empty row Subscript = LooperCount(LOOP_Looper) // Then, initialize the attributes ATT_ID[Subscript] = QRY_Query.ID ATT_Static[Subscript] = QRY_Query.Text . . Some ..Height coding goes here... . .
Based on some repeated testing, it seems to be pretty reliable.

I can post the actual code if anyone expresses an interest.