Official eMule-Board: Fix Copying Of Comments In Commentlist - Official eMule-Board

Jump to content


Page 1 of 1

Fix Copying Of Comments In Commentlist

#1 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 04 October 2006 - 08:19 AM

hi all
i've noticed that copying of comments in the commentlist
is not working correctly, don't know why but if it has copied
something, it might not be the correct column (of the comment)

this is my fix, though since i don't have VS.net installed,
someone will have to check it (but it's suppose to be ok)

Quote

...
BOOL CCommentListCtrl::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch (wParam)
{
// Avi3k: fix code
case MP_COPYSELECTED:
{
const SComment* pComment = (SComment*)GetItemData(iSel);
if (pComment)
theApp.CopyTextToClipboard(pComment->m_strComment);

return TRUE;
}
// end Avi3k: fix code
}
}
...


and if someone wants to add support for copying multiple comments:
(fixed thanx to Wiz)

Quote

...
BOOL CCommentListCtrl::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch (wParam)
{
// Avi3k: fix & improve code
case MP_COPYSELECTED:
{
CString strCmts = _T("");
POSITION pos = GetFirstSelectedItemPosition();
while (pos)
{
iSel = GetNextSelectedItem(pos);
const SComment* pComment = (iSel != -1) ? (SComment*)GetItemData(iSel) : NULL;
if (pComment)
strCmts += pComment->m_strComment + _T("\n");
}
theApp.CopyTextToClipboard(strCmts);

return TRUE;
}
// end Avi3k: fix & improve code
}
}
...


Regards,
Avi3k

This post has been edited by Avi-3k: 04 October 2006 - 03:40 PM

retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

#2 User is offline   PacoBell 

  • Professional Lurker ¬_¬ (so kyoot!)
  • PipPipPipPipPipPipPip
  • Group: Moderator
  • Posts: 7,296
  • Joined: 04-February 03

Posted 04 October 2006 - 08:33 AM

View PostAvi-3k, on Oct 4 2006, 01:19 AM, said:

Quote

...
BOOL CCommentListCtrl::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch (wParam)
{
// Avi3k: fix & improve code
case MP_COPYSELECTED:
{
POSITION pos = GetFirstSelectedItemPosition();
while (pos)
{
iSel = GetNextSelectedItem(pos);
const SComment* pComment = (iSel != -1) ? (SComment*)GetItemData(iSel) : NULL;
if (pComment)
theApp.CopyTextToClipboard(pComment->m_strComment);
}

return TRUE;
}
// end Avi3k: fix & improve code
}
}
...
And does that clobber the previous clipboard entry or does it actually append?
Sed quis custodiet ipsos custodes
Math is delicious!
MmMm! Mauna Loa Milk Chocolate Toffee Macadamias are little drops of Heaven ^_^
Si vis pacem, para bellum DIE SPAMMERS DIE!

#3 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5,630
  • Joined: 28-December 02

Posted 04 October 2006 - 09:05 AM

That deletes the previous one... proper code would be like that:
case MP_COPYSELECTED:
{
	CString buffer = _T("");
	POSITION pos = GetFirstSelectedItemPosition();
	while (pos)
	{
		iSel = GetNextSelectedItem(pos);
		const SComment* pComment = (iSel != -		1) ? (SComment*)GetItemData(iSel) : NULL;
		if (pComment)
		{
			if(!buffer.IsEmpty()) buffer.Append(_T("\n"));
			buffer.Append(pComment->m_strComment);
		}
	}
	theApp.CopyTextToClipboard(buffer);
	return TRUE;
}


Addon: to answer your question Avi3k, it was already posted around here... the 3 here:
theApp.CopyTextToClipboard(GetItemText(iSel, 3));
is wrong because 3 means "colUserName" (ECols enum) so you could also just replace it by 1 (better: colComment) to fix it :flowers:
0

#4 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 04 October 2006 - 03:37 PM

yeah, as i logged in a i remembered i forgot
the appending thingie in my code, lol :lol.
Wiz's code should fix that (i'll update the first post, thanx Wiz)

btw, i know about colComment but from what i saw
i though it wasn't going to work well since the copying
is not done correctly (i think it copies the column 3 after
the reordering done by the CMuleListCtrl code)

Regards,
Avi3k
retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

#5 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5,630
  • Joined: 28-December 02

Posted 04 October 2006 - 04:15 PM

Hmmm I don't think so but it *might* of course be, maybe you can verify that... (if so, then it'd apply in a lot of occassions, also in searchlistctrl and all SetItemText calls)
0

#6 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 04 October 2006 - 09:39 PM

@Wiz
the copy in the search, download & shared lists
is using the file's pointer (passed as Lparam)
to create the link so there shouldn't be any errors or
wrong parts being copied. it's working fine afaik...

the comments part is different, but i can't verify this until
i install VS.Net and debug the code.

Regards,
Avi3k

This post has been edited by Avi-3k: 04 October 2006 - 09:42 PM

retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

#7 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5,630
  • Joined: 28-December 02

Posted 05 October 2006 - 08:45 AM

^^ I meant the "SetItemText"-part which is used there and which would be screwed up so I think it will copy corectly :D
0

#8 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 05 October 2006 - 09:00 AM

@Wiz
ohh, ok, though i'm not sure why SetItemText() is the problem,
eMule uses GetItemText() in the copy part
so i think that part should be checked (gonna check msdn later)

i also checked the code and it looks okay as far as using SetItemText()
(when adding a new comment)

Regards,
Avi3k

This post has been edited by Avi-3k: 05 October 2006 - 09:01 AM

retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

#9 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5,630
  • Joined: 28-December 02

Posted 05 October 2006 - 10:18 AM

View PostAvi-3k, on Oct 5 2006, 11:00 AM, said:

ohh, ok, though i'm not sure why SetItemText() is the problem,
eMule uses GetItemText() in the copy part

Ok maybe I wasn't clear enough...
My guess is/was that if the GetItemText will screw up on a different column order then SetItemText will do the same as both just use the initial index of the column and not an actual item. And as SetItemText works ok then GetItemText should do the same :flowers:
GreetZ,
WiZ
0

#10 User is offline   Xman1 

  • Xtreme Modder
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,955
  • Joined: 21-June 03

Posted 05 October 2006 - 10:44 AM

the column numbers don´t change during runtime. Have a look at the SortProcs... we use fixed numbers also there.
0

#11 User is offline   PacoBell 

  • Professional Lurker ¬_¬ (so kyoot!)
  • PipPipPipPipPipPipPip
  • Group: Moderator
  • Posts: 7,296
  • Joined: 04-February 03

Posted 05 October 2006 - 11:55 AM

Didn't we already go over this somewhat in this thread?
Sed quis custodiet ipsos custodes
Math is delicious!
MmMm! Mauna Loa Milk Chocolate Toffee Macadamias are little drops of Heaven ^_^
Si vis pacem, para bellum DIE SPAMMERS DIE!

#12 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 05 October 2006 - 03:59 PM

@Wiz
ok, i get what you're saying.
i don't remember how CMuleListCtrl works,
that's why i wasn't sure...
i've just finished installing VS, i'll debug it later and we'll see :)

@Xman
thanx for the info

@PacoBell
i didn't see this post, too bad it wasn't moved here.
the problem's that the fix suggested in that post would not work
since this bug is also copying data from other columns.

@all
i suggest maybe using CListCtrl::GetSelectionMark(),
it's suppose to be the same as the code used in eMule but simpler...

Regards,
Avi3k

This post has been edited by Avi-3k: 05 October 2006 - 04:02 PM

retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

#13 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 08 October 2006 - 02:59 PM

i've tried to reproduce this and without luck,
everytime i copy it copies the nickname (3rd column)
so i don't know why it copied other columns before.
even though, i'm still gonna use this fix.

btw, for some reason you should use _T("\r\n")
to make the new line work correctly...

Regards,
Avi3k
retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

  • Member Options

Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users