type
{Since Delphi does not distinguish between capital and non-capital
letters, TWPARAM & TLPARAM should be declared.}
TWPARAM = WPARAM;
TLPARAM = LPARAM;
var
WndProcLV : Integer;
hListView : HWND;
//*************** LVWndProc ***************
function LVWndProc(
handle : HWND; Msg : Cardinal; wParam1 : TWPARAM;
lParam1 : TLPARAM) : Integer;
stdcall;
begin // LVWndProc
// if "Return" was pressed, then process it in the list view
if (Msg = WM_GETDLGCODE)
and (wParam1 = VK_RETURN)
then
Result:= DLGC_WANTALLKEYS
or DLGC_WANTMESSAGE
// otherwise give the control back to the calling procedure
else
Result:= CallWindowProc(Pointer(WndProcLV),
handle, Msg, wParam1, lParam1);
end;
// LVWndProc
//*************** LVWndProc ***************
//begin main dialog function
//...
hListView := GetDlgItem(hwndDlg, FolderList);
// handle to the ListView
hHeader := SendMessage(hListView, LVM_GETHEADER, 0, 0);
// LV header
{Create a subclass for the list view,
to catch the VK_RETURN for the list view}
WndProcLV:= GetWindowLong(hListView, GWL_WNDPROC);
SetWindowLong(hListView, GWL_USERDATA, WndProcLV);
SetWindowLong(hListView, GWL_WNDPROC, Integer(@LVWndProc));
//...
// end main dialog function