Old 5th June 2015, 03:12   #1
Squirre1
Member
 
Join Date: Aug 2001
Posts: 55
Send a message via ICQ to Squirre1
Custompage - Scrolling Textbox

Using the nsdialog controls I can create a multiline textbox, but I would like to append text to it and have it scroll just like the classic log display that uses detailprint. The only thing I can see being able to do is to REPLACE the text in the textbox via the SetText.

Anyone have any ideas?

Thanks,

Squirre1
Squirre1 is offline   Reply With Quote
Old 5th June 2015, 06:03   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
http://nsis.sourceforge.net/Header_file_for_Listview

Use LVM_ENSUREVISIBLE (with SendMessage) to scroll to the newly inserted item.

Stu
Afrow UK is offline   Reply With Quote
Old 5th June 2015, 12:22   #3
Squirre1
Member
 
Join Date: Aug 2001
Posts: 55
Send a message via ICQ to Squirre1
Sweet Control... Thanks for pointing it out to me... Ill give it a shot, but it looks like that will get the job done..
Squirre1 is offline   Reply With Quote
Old 5th June 2015, 16:26   #4
Squirre1
Member
 
Join Date: Aug 2001
Posts: 55
Send a message via ICQ to Squirre1
Not quite getting it to work like I want to...

What I am looking for is a multiline textbox, lets say it displays 4 lines.

Line 1
Line 2
Line 3
Line 4

It will allow you to append lines to it, and when it does, it scrolls up showing the last line appended. (w/ a Vertical Scroll)

Line 2
Line 3
Line 4
Line 5

Using the ensure Visible w/ the listbox appends the lines to the top.. displaying the "log" backwards basically.

Line 5
Line 4
Line 3
Line 2

Thoughts.?
Squirre1 is offline   Reply With Quote
Old 5th June 2015, 17:15   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
You can add listview items to the bottom, set the LVITEM iItem member to 0x7fffffff and it will be appended to the end...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 5th June 2015, 17:49   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
This duplicates the InstFiles page log:

Quote:
!include nsDialogs.nsh
!include WinMessages.nsh
!ifndef LVM_ENSUREVISIBLE
!define /math LVM_ENSUREVISIBLE ${LVM_FIRST} + 19
!endif
!ifndef LVS_EX_LABELTIP
!define LVS_EX_LABELTIP 0x4000
!endif
!ifndef LVIF_TEXT
!define LVIF_TEXT 0x0001
!endif
!ifndef LVCF_WIDTH
!define LVCF_WIDTH 2
!endif
!ifndef SYSSTRUCT_LVITEM_V1
!define SYSSTRUCT_LVITEM_V1 (i,i,i,i,i,t,i,i,i)
!endif
!ifndef SYSSTRUCT_LVCOLUMN_V1
!define SYSSTRUCT_LVCOLUMN_V1 (i,i,i,t,i,i)
!endif
Page Custom myCreate
Page InstFiles

Function myCreate
nsDialogs::Create 1018
Pop $0

nsDialogs::CreateControl "SysListView32" "${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP}|${LVS_SINGLESEL}|${LVS_REPORT}|${LVS_NOCOLUMNHEADER}" "${WS_EX_CLIENTEDGE}" 0 0 100% 80% ""
Pop $0
SendMessage $0 ${LVM_SETEXTENDEDLISTVIEWSTYLE} ${LVS_EX_LABELTIP} ${LVS_EX_LABELTIP}
System::Call "*${SYSSTRUCT_LVITEM_V1}i.r1" ; Buffer for LVITEM, LVCOLUMN and RECT
System::Call 'USER32::GetSystemMetrics(i2)i.r3'
System::Call 'USER32::GetClientRect(ir0,ir1)'
System::Call "*$1(i,i,i.r2,i)"
IntOp $3 $2 - $3
System::Call "*$1${SYSSTRUCT_LVCOLUMN_V1}(${LVCF_WIDTH},0,$3,,,0)"
SendMessage $0 ${LVM_INSERTCOLUMN} 0 $1
StrCpy $2 0
loop:
IntOp $2 $2 + 1
System::Call '*$1${SYSSTRUCT_LVITEM_V1}(${LVIF_TEXT},0x7fffffff,0,,,"Item $2")'
SendMessage $0 ${LVM_INSERTITEM} 0 $1 $3
SendMessage $0 ${LVM_ENSUREVISIBLE} $3 0
StrCmp $2 55 "" loop
System::Free $1

nsDialogs::Show
FunctionEnd

Section
SectionEnd
Works in NSIS v3, you probably need to add a few more missing defines in 2.46...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 5th June 2015, 19:07   #7
Squirre1
Member
 
Join Date: Aug 2001
Posts: 55
Send a message via ICQ to Squirre1
Here is the code I have and this is working... Obviously, there are some pieces missing, like including the aforementioned control that afrow pointed out. This automatically scrolls like it should... I got the sendmessage for the LVM_SCROLL from here which is the detailprint source..:
http://nsis.sourceforge.net/DetailPr...nside_.NET_DLL


Quote:
Var hCtl_JavaUninstaller_lstStatusLog

Function JavaUninstaller_SubCreate
${NSD_CreateListView} 4.61u 11.69u 291.59u 57u "Listview"
Pop $hCtl_JavaUninstaller_lstStatusLog
${NSD_AddStyle} $hCtl_JavaUninstaller_lstStatusLog ${LVS_NOCOLUMNHEADER}
${NSD_LV_InsertColumn} $hCtl_JavaUninstaller_lstStatusLog 0 400 ""
SendMessage $hCtl_JavaUninstaller_lstStatusLog ${LVM_ENSUREVISIBLE} 0 0

${NSD_CreateLabel} 4.61u -0.62u 55.29u 16.62u "Status Log:"
Pop $hCtl_JavaUninstaller_Label2
SendMessage $hCtl_JavaUninstaller_Label2 ${WM_SETFONT} $hCtl_JavaUninstaller_Font1 0
FunctionEnd ; End JavaUninstaller_SubCreate

Function JavaUninstaller_OnLoad
${NSD_KillTimer} JavaUninstaller_OnLoad
!insertmacro logme ${APPLOG} " Application Loaded " l
IntOp $R1 0 + 0
${DoUntil} ${Errors}
# MessageBox MB_OKCANCEL "This is a test, Cancel to end" IDOK _ok IDCANCEL _cancel
_ok:
${NSD_LV_InsertItem} $hCtl_JavaUninstaller_lstStatusLog 0x7fffffff "$R1 supercalafragelistic expialidocious abcdefghijklmnopqrstuvwxyz"
SendMessage $hCtl_JavaUninstaller_lstStatusLog ${LVM_SCROLL} 0 12
IntOp $R1 $R1 + 1
${LoopUntil} $R1 == 100
_cancel:
FunctionEnd ; End JavaUninstaller_OnLoad
Lastly, I am not sure how to shim in a redraw after the insertitem. it is not a big deal if you popped out a log entry here or there, but in the loop, if I looped like 100000 for example, the listbox appears frozen..

But Anyway, I think i have the worst done..

Thanks for the help guys...
Squirre1 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump