Old 8th July 2003, 17:47   #1
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Can System do this?

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
Afrow UK is offline   Reply With Quote
Old 8th July 2003, 22:42   #2
ramon18
NSIS Dev
 
ramon18's Avatar
 
Join Date: Apr 2003
Location: Portugal
Posts: 110
Hi,

You can use this two functions to accomplish this task;
Ofcourse this functions only have effect while inside sections.

PHP Code:
######################################
!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 
$"#32770" "" $HWNDPARENT
  GetDlgItem 
$$1 0x3F8 This is the Control ID of the details view
  SendMessage 
$${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 
$"#32770" "" $HWNDPARENT
  GetDlgItem 
$$1 0x3F8 This is the Control ID of the details view
  SendMessage 
$${LVM_GETITEMCOUNT0 0 $1
  exch 
$1
FunctionEnd 
Usage example:

PHP Code:
Section Dummy

  DetailPrint 
"Copying file A..."
  
StrCpy $"success!"
  
MessageBox MB_YESNO "Generate copy errors?" IDNO +2
  StrCpy 
$"failure!"
  
push $save
    call GetDetailViewItemCount
    pop 
$0
    intop 
$$decrement to delete last entry
    push 
$0
    call DeleteDetailViewItem
  pop 
$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
ramon18 is offline   Reply With Quote
Old 9th July 2003, 17:59   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
If this is not already on the archive, may I add it?

-Stu
Afrow UK is offline   Reply With Quote
Old 9th July 2003, 18:02   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 10th July 2003, 08:57   #5
ramon18
NSIS Dev
 
ramon18's Avatar
 
Join Date: Apr 2003
Location: Portugal
Posts: 110
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:

code:

!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



then in your dummy section:
code:

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"



PS: if you want to add it to the archive, feel free to add it, sorry I have no time now

good luck,
Ramon
ramon18 is offline   Reply With Quote
Old 10th July 2003, 19:23   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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.

http://nsis.sourceforge.net/archive/...50&instances=0

Works great too!

-Stu
Afrow UK 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