Lister: what happened to cursor after Search?

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

Moderators: white, Hacker, petermad, Stefan2

Post Reply
little-brother
Junior Member
Junior Member
Posts: 43
Joined: 2021-09-27, 10:27 UTC

Lister: what happened to cursor after Search?

Post by *little-brother »

When I hit the F3 (or Ctrl + F and then OK button) the cursor change a state from arrow (IDC_ARROW) to a text caret (IDC_IBEAM).

Below the minimal example of the issue

Code: Select all

#define UNICODE
#define _UNICODE

#include <windows.h>
#include <tchar.h>
#include <stdio.h>

BOOL APIENTRY DllMain (HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
	return TRUE;
}

void __stdcall ListGetDetectString(char* DetectString, int maxlen) {
	snprintf(DetectString, maxlen, "MULTIMEDIA & ext=\"TEST\"");
}

HWND APIENTRY ListLoadW (HWND hListerWnd, TCHAR* fileToLoad, int showFlags) {
	HWND hMainWnd = CreateWindowEx(0, TEXT("BUTTON"), TEXT("test-wlx"), WS_CHILD | SS_SUNKEN | WS_VISIBLE,
		0, 0, 100, 100, hListerWnd, (HMENU)1000, GetModuleHandle(0), NULL);

	return hMainWnd;
}

void __stdcall ListCloseWindow(HWND hWnd) {
	DestroyWindow(hWnd);
	return;
}
The source and x64-binary are here

P.S. I use TC 10.00 (2021-06-10)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Lister: what happened to cursor after Search?

Post by *ghisler(Author) »

In a lister plugin, you are responsible for the mouse cursor shown to the user, e.g. in WM_MOUSEMOVE of your window.
Author of Total Commander
https://www.ghisler.com
little-brother
Junior Member
Junior Member
Posts: 43
Joined: 2021-09-27, 10:27 UTC

Re: Lister: what happened to cursor after Search?

Post by *little-brother »

I didn't change cursor in the example. By default it's an arrow. After search it changed to caret.

If I set cursor to arrow forcibly by

Code: Select all

SetClassLongPtr(hWnd, GCLP_HCURSOR, (LONG_PTR)LoadCursor(0, IDC_ARROW));
it doesn't work.

If I send WM_LBUTTONDOWN to Lister window in ListSearchTextW then the cursor will change to arrow.
little-brother
Junior Member
Junior Member
Posts: 43
Joined: 2021-09-27, 10:27 UTC

Re: Lister: what happened to cursor after Search?

Post by *little-brother »

It looks like I solved the issue by interception WM_SETFOCUS. But it still not clear yet why the cursor is changed after search.

Code: Select all

#define UNICODE
#define _UNICODE

#include <windows.h>
#include <tchar.h>
#include <stdio.h>

BOOL APIENTRY DllMain (HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
	return TRUE;
}

void __stdcall ListGetDetectString(char* DetectString, int maxlen) {
	snprintf(DetectString, maxlen, "ext=\"TEST\"");
}

LRESULT CALLBACK cbNewMain(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch (msg) {		
		case WM_SETCURSOR: {
			SetCursor(LoadCursor(0, IDC_ARROW));
			return TRUE;
		}
		break;
	}
	
	return CallWindowProc((WNDPROC)GetProp(hWnd, TEXT("WNDPROC")), hWnd, msg, wParam, lParam);
}	
		
HWND APIENTRY ListLoadW (HWND hListerWnd, TCHAR* fileToLoad, int showFlags) {
	HWND hMainWnd = CreateWindowEx(0, TEXT("BUTTON"), TEXT("test-wlx"), WS_CHILD | SS_SUNKEN | WS_VISIBLE,
		0, 0, 100, 100, hListerWnd, (HMENU)1000, GetModuleHandle(0), NULL);
	SetProp(hMainWnd, TEXT("WNDPROC"), (HANDLE)SetWindowLongPtr(hMainWnd, GWLP_WNDPROC, (LONG_PTR)&cbNewMain));
	
	return hMainWnd;
}

void __stdcall ListCloseWindow(HWND hWnd) {
	DestroyWindow(hWnd);
}
Post Reply