[WDM20] Resizing a Static control and Looper control row [Solved]

Startbeitrag von DarrenF am 21.03.2016 15: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...

Antworten:

Re: [WDM20] Resizing a Static control and Looper control row

Hmmm, I presume it's a bit tricky then?

von DarrenF - am 22.03.2016 09:18

Re: [WDM20] Resizing a Static control and Looper control row

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

von Fabrice Harari - am 22.03.2016 12:09

Re: [WDM20] Resizing a Static control and Looper control row

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?

von DarrenF - am 22.03.2016 12:32

Re: [WDM20] Resizing a Static control and Looper control row

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


von Arie - am 22.03.2016 13:01

Re: [WDM20] Resizing a Static control and Looper control row

And it looks like this :xcool:




von Arie - am 22.03.2016 13:07

Re: [WDM20] Resizing a Static control and Looper control row

Thanks Arie, I'm not at my PC - did you manage to do this in WDM (android)?

von DarrenF - am 22.03.2016 14:49

Re: [WDM20] Resizing a Static control and Looper control row

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.

von Arie - am 22.03.2016 15:42

Re: [WDM20] Resizing a Static control and Looper control row

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 :(

von DarrenF - am 22.03.2016 15:55

Re: [WDM20] Resizing a Static control and Looper control row

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

von Ruben Sanchez Peña - am 22.03.2016 16:47

Re: [WDM20] Resizing a Static control and Looper control row

Ruben... WM21 is a whole different ball game! ;) ...but I'll try it in WM20 and post it here... :spos:

von DarrenF - am 22.03.2016 16:57

Re: [WDM20] Resizing a Static control and Looper control row

Hi. The same functions exist in WM20.

Rubén

von Ruben Sanchez Peña - am 22.03.2016 17:26

Re: [WDM20] Resizing a Static control and Looper control row

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:

von DarrenF - am 29.03.2016 09:53

Re: [WDM20] Resizing a Static control and Looper control row

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

von Arie - am 29.03.2016 10:05
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/?3083004


// 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.

von DarrenF - am 29.03.2016 10:27
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.