1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
...
uses Classes, Windows, Messages, SysUtils, Controls, Grids, StrUtils, Dialogs; // <========== ajout de Classes comme premier élément de la liste
...
CM_SETCELL: begin
Result := -1;
if P^.DestWnd <> 0 then begin
SG := Pointer(FindControl(P^.DestWnd));
if SG <> nil then begin
X := WParam;
Y := LParam;
if (X >= 0) and (X < SG.ColCount) and (Y >= 0) and (Y < SG.RowCount) then begin
Result := Length(P^.Text);
if Result > 0 then begin
CellBuff := StrPas(P^.Text);
showmessage('CM_SETCELL: ['+CellBuff+']'); // <== prouve que les données sont bien transmises !
// SG.Cells[X, Y] := '123456'; // <== ok
showmessage('CM_SETCELL - count='+inttostr(MySL.Count)); // <=========== ajout ici crash !!!
MySL.Delete(0); // <=========== ajout ici crash !!!
showmessage('CM_SETCELL - clear ok'); // <=========== ajout ici
MySL.Add(StrPas(P^.Text)); // <=========== ajout ici
showmessage('CM_SETCELL - MySL[Strings[0]='+MySL.Strings[0]); // <=========== ajout ici
SG.Cells[X, Y] := MySL.Strings[0]; // <=========== ajout ici
end;
end;
end;
end;
Exit;
end;
...
procedure InstallHook(MainWnd, DestWnd: HWND); stdcall;
begin
if P^.hkMsg = 0 then
P^.hkMsg := SetWindowsHookEx(WH_GETMESSAGE, @GetMsgProc, HInstance, 0);
P^.HostWnd := MainWnd;
P^.HostPID := GetCurrentProcessId;
P^.DestWnd := DestWnd;
MySL := TStringList.Create; // <=========== ajout ici
MySL.Add('bidon'); // <=========== ajout ici pour créer l'élément initial
showmessage('MySL créé'); // <=========== ajout ici
end;
procedure UninstallHook; stdcall;
begin
if P^.hkMsg <> 0 then begin
UnhookWindowsHookEx(P^.hkMsg);
P^.hkMsg := 0;
MySL.Free; // <=========== ajout ici
showmessage('MySL libéré'); // <=========== ajout ici
end;
end;
... |
Partager