Archive: Linker for listview subitems


Linker for listview subitems
  Hi,

I wrote a very basic plugin, based on the old linker.dll, that support also listview subitems. I couldn't get it to change the fonts and styles of the subitem (but again, I didn't really try so you are all welcome to fix it :))

Linker::lvlink /NOUNLOAD ${hwndLV_} ${iItem_} ${iSubItem_} ${url_}

The original linker:
http://nsis.sourceforge.net/Linker_plug-in

for some reason I can't upload the attachment... so here it is:

http://www.mediafire.com/?smb6nz5oarpfmk5


Good work. Please post on the Wiki so that it doesn't get lost. Just upload to http://nsis.sf.net/File:Linker.zip.

Stu


uploaded to http://nsis.sf.net/File:Linker.zip.


I only see black text, without underline, and normal cursor when hovering, except it will open browser when I click the text. But after read the source I find that it support underline etc. It is very strange that it displays like normal text on My Windows XP.


Originally posted by jiake
I only see black text, without underline, and normal cursor when hovering, except it will open browser when I click the text. But after read the source I find that it support underline etc. It is very strange that it displays like normal text on My Windows XP.
Hi jiake,

In the code there are two event listeners, one for labels (the original linker) and one for listviews (with _lv_ somewhere in its name). The original *IS* adding the style, cursor, etc. and I didn't change it at all. I removed the style changes for the listview methods as I couldn't get the handle for the text (and I don't think it has one, cause if it had everything would be a lot easier to begin with). Anyway, this is my first attempt to edit/create a plugin and my knowledge in WIN32 programming is below basic. So if any of you WIN32 sharks are willing to take a look at the code and make the desired changes so the text in the subitem will be underlined, blue and with correct cursor when being hovered you are most welcome.

Thanks,

J

Trying to change listview subitem color
  Hi,

I'm trying to change the color of the text of the subitems that are defined as links. But I'm having troubles: I have a handler which:

case WM_NOTIFY:
{ switch (((LPNMHDR)lParam)->code)
{ case NM_CUSTOMDRAW:
{ SetWindowLongPtr(hwnd, DWL_MSGRESULT,(LONG_PTR)ProcessCustomDraw(lParam));
return TRUE;
}
}
break;
}

...
...

return CallWindowProc(oldproc,hwnd,uMsg,wParam,lParam);


but when it calls the oldproc (original handler), after changing DWL_MSGRESULT to be CDRF_NOTIFYITEMDRAW (0x20) for example, I get an error saying that there is a read violation when trying to access 0x00000020 (which is the DWL_MSGRESULT) I suspect that there's a bug in the original handler who for some reason tries to read result as a pointer instead of a value, or maybe I'm calling it the wrong way - I think it is part of the nsDialogs, but I'm not sure. If I use instead the DefWindowProc I don't get the error but I also don't see any of the items... any ideas?:(

http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

Stu


Hi Stu,

Thanks for the reply. It seems now that I tried everything and nothing works. The problem I got earlier was due to returning the result with SetWindowLong which is relevant only for Dialog window.

I would really (really really) appreciate it if you could take a look in the code and help me out :).

http://www.mediafire.com/?pd6tf3p1r269d84

p.s.

the relevant code is around lines 304 and 279 of URLCtrl.c


Maybe this tutorial can help you: http://www.codeguru.com/cpp/controls...icle.php/c5803


Hi T.Slappy,

Thanks for your reply. My current problem is accessing the subitems in the list view - I'm not getting the event (CDDS_ITEMPREPAINT | CDDS_SUBITEM). as a matter of fact I suspect I'm getting the notifications only for the titles and not for the items themselves: If I have 4 colums and 10 rows I get only 5 NM_CUSTOMDRAW events - one is PREPAINT and the other four are ITEMPREPAINTs.

Anyway, once I'll get notifications for each subitem I would do something like what you sent. But I'm still not there.

Thanks,

J


Hi,

I've managed to solve all the problems and I now released a new version which better supports subitems in listviews. It now changes the color to blue and after a click it changes to purple (this is the default, but can be changed the same way it is with labels). It also changes the cursor to a hand when hovering on the subitem.

(it's already updated in http://nsis.sourceforge.net/File:Linker.zip)

J


Hi
For some time I am trying to subclass label #1006 on Install page and draw text by myself.
I looked into Linker sources and I found this issue in this plugin:

Your window procedure looks like this:

LRESULT CALLBACK UrlMainProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)

caseWM_PAINT:
{ PAINTSTRUCT ps;
HDC hdc=(HDC)wParam;
if(wParam==0) hdc=BeginPaint(hwnd,&ps);
if(hdc)
{ DrawUrl(hwnd,hdc,NULL); // HERE IS THE MAIN DRAWING - YOUR FUNCTION
if(wParam==0) EndPaint(hwnd,&ps);
}
return0;
}
caseWM_SETTEXT:
{
LRESULT result=CallWindowProc(oldproc,hwnd,uMsg,wParam,lParam); // HERE you call standard Win function to draw the text
>.....
}
The problem is that you draw text in WM_SETTEXT by CallWindowProc() and then next in WM_PAINT in your function.
Whole text is drawn twice which produces ugly effect (however it is not visible because you fill area with BTNFACE color)
This problem is visible when I use TRANSPARENT color for background in my plugin.

How can I reduce this twice writing?
Commenting out LRESULT result=CallWindowProc()... will not help, because text will not be refreshed properly and it will be written over itself (like in layers).

Hi,

The part that changes the text on labels was taken from http://www.catch22.net/tuts/urlctrl, so your answer might lie there.

For what it worth, I think that WM_SETTEXT is being sent when the text is changed and the handler changes the the url to be placed in the correct position. WM_PAINT does the actual draw of the url.