Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
3
Erster Beitrag:
vor 1 Jahr, 3 Monaten
Letzter Beitrag:
vor 1 Jahr, 3 Monaten
Beteiligte Autoren:
Curtis, Arie

[WD20] Best Practice to Allow User to Scroll a Window

Startbeitrag von Curtis am 28.09.2016 20:37

I have a list of messages I want to display. This list could be long, so it needs to be scrollable. I'm using controlcreate/controlclone to create the static controls for each message. I would use a looper but I want each control to be sized to fit the message. I am currently using an internal window. I pass a data source var from the main window to a procedure in the internal window. I loop through the data source and create a control for each message. The problem is that the internal window is not scrollable unless the height of the internal window is set to more than the height of the internal window control in the editor. If I try to increase the height of the internal window each time I add a message the scrollbar does not show. Below is the code of the procedure.


nYPos is int = STC_Temp..Y
nIndex is int = 1

FOR EACH dsMessages
IW_Messages..Height += 100 // name of my internal window
ControlClone(STC_Temp,"STC_Message" + nIndex,STC_Temp..X,nYPos)
{"STC_Message"+nIndex,indControl} = dsMessages.Message
nIndex++
nYPos += 112
END

STC_Temp..Visible = False

Antworten:

Hi Curtis,

I use a looper for a similar situation. The looper has a few controls (stcatic, RFT-edit and an image.
For every row I calculate the height using the TextHeight() function

Then I set the height of that particular looper-row with LOOP_Messages[nRow]..Height

One thing I discovered is that decreasing the looper-row seems to work better than increasing, which caused some weird redraw issues. So now I set LOOP_Messages[nRow]..Height to 10000 first and set it to the desired height.
Also use DieplayEnabled = false/true to improve all.

von Arie - am 29.09.2016 08:06
Thanks! I'll give it a try. I did not think you could individually resize looper cells. That's good to know.

EDIT: Works great. Thanks so much! However, for some reason I have to add a Wait() command or the var nHeight is incorrect (too small).


FOR EACH dsResult
LooperAdd(LOOP_Messages)
LooperSelectPlus(LOOP_Messages,nIndex)
LOOP_Messages[nIndex].STC_Message = dsResult.TicketMEssage
// Wait(5)
nHeight is int = TextHeight(STC_Message,STC_Message,tMultiline)
nHeight += 24
LOOP_Messages[nIndex].STC_Message..Height = nHeight
LOOP_Messages[nIndex]..Height = LOOP_Messages[nIndex].STC_Message..Height
nIndex++
END


von Curtis - am 29.09.2016 13:55
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.