Thema: Delphi NM_RETURN - Problem

Einzelnen Beitrag anzeigen

Dirk - nonVCL

Registriert seit: 14. Mai 2007
Ort: Islamabad
2 Beiträge
 
Delphi 2005 Personal
 
#33

Re: NM_RETURN - Problem

  Alt 14. Mai 2007, 11:32
Hallo Dezipaitor,

Super Beitrag. Danke.

In Delphi habe ich das subclassing-Problem so gelöst:

Delphi-Quellcode:
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
Mit CallWindowProc muss man sich keine Gedanken um das richtige weiterleiten der Msg machen. Windows erledigt das. In meinen Programmen funktioniert das super.
Verbesserungen sind bestimmt noch möglich.

Viele Grüße

Dirk
Dirk
  Mit Zitat antworten Zitat