ListNotificationReceived broken?

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
Holyhead
Junior Member
Junior Member
Posts: 13
Joined: 2006-03-03, 20:06 UTC

ListNotificationReceived broken?

Post by *Holyhead »

Hi everybody,

I just made my first steps into developing an own lister-plugin. I have started with the listplug-sample code. The sample helped me a lot, but I did not get ListNotificationReceived() to work. It seems to be never called. I have played around with different EM_SETEVENTMASK-s for the RichEdit plugin, but I never observed a call of ListNotificationReceived() and hence the percentage-display is not updated when the RichEdit window is scrolled.

Is this a bug in totalcommander? Or in the listplug example?
Or is there another way to update the percentage dispaly on scrolling the RichEdit window?

Thanks for your help,
Holyhead
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50421
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Something is definitely wrong, but I cannot say what without a longer debug session. I will try to find out as soon as possible.
Author of Total Commander
https://www.ghisler.com
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

I cannot conform this. I have a running sample where ListNotificationReceived is definetely called.
Tested with TC 6.54a.

Here is the sample code:

Code: Select all

#include <tchar.h>
#include <windows.h>
#include "listplug.h"

void drawItem (LPDRAWITEMSTRUCT drawItemInfo);
void measureItem (LPMEASUREITEMSTRUCT measureItemInfo);
void addItems (HWND childHandle, UINT itemsToAddCount);

BOOL APIENTRY DllMain( HANDLE hinstDLL, DWORD fdwReason, LPVOID )
{
    return TRUE;
}

HWND __stdcall ListLoad(HWND ParentWin,char* FileToLoad,int ShowFlags)
{	
	HWND windowHandle = CreateWindow(
		TEXT("LISTBOX"), NULL,
		WS_CHILDWINDOW | WS_VISIBLE | WS_HSCROLL | WS_TABSTOP |
		LBS_OWNERDRAWFIXED | LBS_DISABLENOSCROLL | LBS_MULTICOLUMN,
		0, 0, 0, 0, ParentWin, NULL, GetModuleHandle(NULL), NULL);	
	
	SendMessage (windowHandle, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);

	addItems (windowHandle, 5000);
	return windowHandle;
}

int __stdcall ListNotificationReceived(HWND ListWin,int Message, WPARAM wParam, LPARAM lParam)
{		
	switch (Message)
	{
	case WM_MEASUREITEM:	
		// handler for measure item.
		measureItem ((LPMEASUREITEMSTRUCT)lParam);
		break;
	case WM_DRAWITEM:	
		// handler for drawing item.				
		drawItem ((LPDRAWITEMSTRUCT)lParam);
		break;
	default:		
		break;
	}
	return 0;
}

void addItems (HWND childHandle, UINT itemsToAddCount)
{
	for (UINT currentItemIndex = 0; currentItemIndex < itemsToAddCount; currentItemIndex++)
	{
		SendMessage (childHandle, LB_ADDSTRING, NULL, NULL);
	}
}

void drawItem (LPDRAWITEMSTRUCT drawItemInfo)
{
	TCHAR s [20] = {0};		
	_itot (drawItemInfo->itemID, s, 10);
	if (drawItemInfo->itemState & ODS_SELECTED)
	{
		FillRect (drawItemInfo->hDC, &drawItemInfo->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
		RoundRect (drawItemInfo->hDC, drawItemInfo->rcItem.left + 4, drawItemInfo->rcItem.top + 4, 
			drawItemInfo->rcItem.right -4, drawItemInfo->rcItem.bottom -24, 2, 2);
		SetBkMode (drawItemInfo->hDC, TRANSPARENT);
		SetTextColor (drawItemInfo->hDC, RGB(255, 255, 255));
		TextOut (drawItemInfo->hDC, drawItemInfo->rcItem.left, drawItemInfo->rcItem.bottom - 20, s, (int)strlen(s));
	}		
	else
	{	
		FillRect (drawItemInfo->hDC, &drawItemInfo->rcItem, GetSysColorBrush(COLOR_3DFACE));
		RoundRect (drawItemInfo->hDC, drawItemInfo->rcItem.left + 4, drawItemInfo->rcItem.top + 4, 
			drawItemInfo->rcItem.right -4, drawItemInfo->rcItem.bottom -24, 2, 2);
		SetBkColor (drawItemInfo->hDC, RGB(255, 255, 255));
		SetBkMode (drawItemInfo->hDC, TRANSPARENT);
		SetTextColor (drawItemInfo->hDC, RGB(0, 0, 0));
		TextOut (drawItemInfo->hDC, drawItemInfo->rcItem.left, drawItemInfo->rcItem.bottom - 20, s, (int)strlen(s));
	}
}

void measureItem (LPMEASUREITEMSTRUCT measureItemInfo)
{	
	measureItemInfo->itemWidth = 128;
	measureItemInfo->itemHeight = 96;
}
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50421
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I have checked it now - ListNotificationReceived is indeed only called for WM_NOTIFY, WM_DRAWITEM and WM_MEASUREITEM, but not for WM_COMMAND. I will correct this in TC 7.
Author of Total Commander
https://www.ghisler.com
Holyhead
Junior Member
Junior Member
Posts: 13
Joined: 2006-03-03, 20:06 UTC

Post by *Holyhead »

Thanks for your quick reply. RichEdit sends a WM_COMMAND on scrolling and hence I did not observe a call to ListNotificationReceived (I have not tried the WM_DRAWITEM and WM_MEASUREITEM command on my plugin as I could not make RichEdit to issue one of these messages...)
I'm looking forward to TC7 :-) Keep up the good work!
Post Reply