It would be handy if I could DetailPrint 4 lines of text for current status, and then if something fails, then I want to be able to remove just those 4 lines, but not the rest of the text from the log window, and print the status once again (4 lines).
Is this possible?
-Stu
Can System do this?
6 posts
Hi,
You can use this two functions to accomplish this task;
Ofcourse this functions only have effect while inside sections.
Hope this help,good luck
Ramon
You can use this two functions to accomplish this task;
Ofcourse this functions only have effect while inside sections.
######################################
!define LVM_GETITEMCOUNT 0x1004
!define LVM_DELETEITEM 0x1008
######################################
; This function delete one element from the details view
; Push the index of the elemnet to delete before call
Function DeleteDetailViewItem
exch $0
push $1
FindWindow $1 "#32770" "" $HWNDPARENT
GetDlgItem $1 $1 0x3F8 ; This is the Control ID of the details view
SendMessage $1 ${LVM_DELETEITEM} $0 0
pop $1
pop $0
FunctionEnd
; This function get the count of entries from the details view
; You must Pop the result value after call
Function GetDetailViewItemCount
push $1
FindWindow $1 "#32770" "" $HWNDPARENT
GetDlgItem $1 $1 0x3F8 ; This is the Control ID of the details view
SendMessage $1 ${LVM_GETITEMCOUNT} 0 0 $1
exch $1
FunctionEnd Usage example:Section Dummy
DetailPrint "Copying file A..."
StrCpy $0 "success!"
MessageBox MB_YESNO "Generate copy errors?" IDNO +2
StrCpy $0 "failure!"
push $0 ; save
call GetDetailViewItemCount
pop $0
intop $0 $0 - 1 ; decrement to delete last entry
push $0
call DeleteDetailViewItem
pop $0 ; restore
DetailPrint "Copying file A...$0"
SectionEnd As you can see, you can use this functions to delete any entry(ies) you want 🙂Hope this help,good luck
Ramon
If this is not already on the archive, may I add it?
-Stu
-Stu
This is what I want to do
Will this work?
Section Dummy
DetailPrint "This line stays!"
DetailPrint "line 1"
DetailPrint "line 2"
DetailPrint "line 3"
DetailPrint "line 4"
Call GetDetailViewItemCount
Pop $0
Push $0
Call DeleteDetailViewItem
IntOp $0 $0 - 1
Push $0
Call DeleteDetailViewItem
IntOp $0 $0 - 1
Push $0
Call DeleteDetailViewItem
IntOp $0 $0 - 1
Push $0
Call DeleteDetailViewItem
SectionEnd
Will this work?
Section Dummy
DetailPrint "This line stays!"
DetailPrint "line 1"
DetailPrint "line 2"
DetailPrint "line 3"
DetailPrint "line 4"
Call GetDetailViewItemCount
Pop $0
Push $0
Call DeleteDetailViewItem
IntOp $0 $0 - 1
Push $0
Call DeleteDetailViewItem
IntOp $0 $0 - 1
Push $0
Call DeleteDetailViewItem
IntOp $0 $0 - 1
Push $0
Call DeleteDetailViewItem
SectionEnd
No it won't work, because you don't decrement the value returned by GetDetailViewItemCount, ie:
Suppose you have 3 items on details view:
"Line 1" -> Index is 0
"Line 2" -> Index is 1
"Line 3" -> Index is 2
But GetDetailViewItemCount returns 3, if you want to delete last entry you must decrement the returned value to get 2, witch is the correct index to "Line 3", you see?
I can change the function "DeleteDetailViewItem" so the input param is not ZERO based, if you want?
btw, use this macros to accomplish what you need:
good luck,
Ramon
Suppose you have 3 items on details view:
"Line 1" -> Index is 0
"Line 2" -> Index is 1
"Line 3" -> Index is 2
But GetDetailViewItemCount returns 3, if you want to delete last entry you must decrement the returned value to get 2, witch is the correct index to "Line 3", you see?
I can change the function "DeleteDetailViewItem" so the input param is not ZERO based, if you want?
btw, use this macros to accomplish what you need:
then in your dummy section:
!macro DELETE_LAST_ENTRY
push $0
Call GetDetailViewItemCount
Pop $0
IntOp $0 $0 - 1 ; decrement to get the right index of last entry
Push $0
Call DeleteDetailViewItem
pop $0
!macroend
PS: if you want to add it to the archive, feel free to add it, sorry I have no time now
DetailPrint "This line stays!"
DetailPrint "line 1"
DetailPrint "line 2"
DetailPrint "line 3"
DetailPrint "line 4"
!insertmacro DELETE_LAST_ENTRY ;delete "line 4"
!insertmacro DELETE_LAST_ENTRY ;delete "line 3"
!insertmacro DELETE_LAST_ENTRY ;delete "line 2"
!insertmacro DELETE_LAST_ENTRY ;delete "line 1"
good luck,
Ramon
I put up this page with 2 new functions on it.
One deletes lines from the end of the log window, and the other deletes lines from the top.
Works great too!
-Stu
One deletes lines from the end of the log window, and the other deletes lines from the top.
Works great too!
-Stu