Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24:
| function WndProc(hWnd: HWND; dwMsg: DWORD; wParam: WPARAM; lParam: LPARAM): LRESULT; virtual; stdcall; ... function WndProc(hWnd: HWND; dwMsg: DWORD; wParam: WPARAM; lParam: LPARAM): LRESULT; var pWnd : PWindowBase; pCS : PCreateStruct; nUserData : Integer; begin if dwMsg = WM_NCCREATE then begin pCS := PCreateStruct(lParam); nUserData := Integer(pCS.lpCreateParams); SetWindowLongPtr(hWnd, GWL_USERDATA, nUserData ); end;
nUserData := GetWindowLongPtr(hWnd, GWL_USERDATA); pWnd := PWindowBase(@nNewData); if Assigned(pWnd) then Result := pWnd^.EventHandler(hWnd, dwMsg, wParam, lParam) else Result := DefWindowProc(hWnd, dwMsg, wParam, lParam); end; |
ich hab erstmal so ein C++ klasse gebaut, genauso wollte ich das in Delphi realisieren.
bei C++ hab ich pWnd = (PWindowBase*) GetWindowLongPtr(hWnd, GWL_USERDATA);
theoritisch muesste dass doch in delphi so funktionieren pWnd := PWindowBase(GetWindowLongPtr(hWnd, GWL_USERDATA)); so laesst es nicht mal komplieren, so pWnd := PWindowBase(nUserData) kompilierbar, aber fenster nicht angezeigt, erst mit pWnd := PWindowBase(@nUserData); funktioniert es wieder. warum is das so? ich bin ein bisschen verwirrt