win32, wince: remove unused ancient accelerator code

git-svn-id: trunk@26775 -
This commit is contained in:
paul 2010-07-22 08:46:31 +00:00
parent 085918972f
commit ec0670136a
6 changed files with 10 additions and 224 deletions

View File

@ -336,7 +336,6 @@ end;
procedure TWin32WidgetSet.AppProcessMessages;
var
AMessage: TMsg;
AccelTable: HACCEL;
retVal, index: dword;
pHandles: Windows.LPHANDLE;
@ -378,19 +377,17 @@ begin
PostQuitMessage(AMessage.wParam);
break;
end;
AccelTable := GetWin32WindowInfo(AMessage.HWnd)^.Accel;
if (AccelTable = HACCEL(nil)) or (TranslateAccelerator(AMessage.HWnd, AccelTable, @AMessage) = 0) then
begin
TranslateMessage(@AMessage);
// todo: maybe check the keyboard messages here before their applying to window
// to prevent system keys mix with LCL shortcuts?
TranslateMessage(@AMessage);
{$IFDEF WindowsUnicodeSupport}
if UnicodeEnabledOS then
DispatchMessageW(@AMessage)
else
DispatchMessage(@AMessage);
{$ELSE}
if UnicodeEnabledOS then
DispatchMessageW(@AMessage)
else
DispatchMessage(@AMessage);
{$ELSE}
DispatchMessage(@AMessage);
{$ENDIF}
end;
end;
end else
if retVal = WAIT_TIMEOUT then

View File

@ -43,8 +43,6 @@ Type
PWin32WindowInfo = ^TWin32WindowInfo;
TWin32WindowInfo = record
AccelGroup: HACCEL;
Accel: HACCEL;
Overlay: HWND; // overlay, transparent window on top, used by designer
UpDown: HWND;
PopupMenu: TPopupMenu;
@ -88,11 +86,6 @@ procedure CallEvent(Const Target: TObject; Event: TNotifyEvent;
function ObjectToHWND(Const AObject: TObject): HWND;
function LCLControlSizeNeedsUpdate(Sender: TWinControl;
SendSizeMsgOnDiff: boolean): boolean;
procedure SetAccelGroup(Const Control: HWND; Const AnAccelGroup: HACCEL);
function GetAccelGroup(Const Control: HWND): HACCEL;
procedure SetAccelKey(Window: HWND; Const CommandId: Word; Const AKey: word;
Const AModifier: TShiftState);
function GetAccelKey(Const Control: HWND): LPACCEL;
function GetLCLClientBoundsOffset(Sender: TObject; var ORect: TRect): boolean;
function GetLCLClientBoundsOffset(Handle: HWnd; var Rect: TRect): boolean;
procedure LCLBoundsToWin32Bounds(Sender: TObject;
@ -776,99 +769,6 @@ begin
end;
end;
// ----------------------------------------------------------------------
// The Accelgroup and AccelKey is needed by menus
// ----------------------------------------------------------------------
procedure SetAccelGroup(Const Control: HWND; Const AnAccelGroup: HACCEL);
var
WindowInfo: PWin32WindowInfo;
begin
Assert(False, 'Trace:TODO: Code SetAccelGroup');
WindowInfo := GetWin32WindowInfo(Control);
if WindowInfo <> @DefaultWindowInfo then
begin
WindowInfo^.AccelGroup := AnAccelGroup;
end else begin
DebugLn('Win32 - SetAccelGroup: no window info to store accelgroup in!');
end;
end;
function GetAccelGroup(Const Control: HWND): HACCEL;
begin
Assert(False, 'Trace:TODO: Code GetAccelGroup');
Result := GetWin32WindowInfo(Control)^.AccelGroup;
end;
procedure SetAccelKey(Window: HWND; Const CommandId: Word; Const AKey: word; Const AModifier: TShiftState);
var AccelCount: integer; {number of accelerators in table}
NewCount: integer; {total sum of accelerators in the table}
ControlIndex: integer; {index of new (modified) accelerator in table}
OldAccel: HACCEL; {old accelerator table}
NewAccel: LPACCEL; {new accelerator table}
NullAccel: LPACCEL; {nil pointer}
function ControlInTable: integer;
var i: integer;
begin
Result:=AccelCount;
i:=0;
while i < AccelCount do
begin
if NewAccel[i].cmd = CommandId then
begin
Result:=i;
exit;
end;
inc(i);
end;
end;
function GetVirtFromState(const AState: TShiftState): Byte;
begin
Result := FVIRTKEY;
if ssAlt in AState then Result := Result or FALT;
if ssCtrl in AState then Result := Result or FCONTROL;
if ssShift in AState then Result := Result or FSHIFT;
end;
var
WindowInfo: PWin32WindowInfo;
begin
WindowInfo := GetWin32WindowInfo(Window);
OldAccel := WindowInfo^.Accel;
NullAccel := nil;
AccelCount := CopyAcceleratorTable(OldAccel, NullAccel, 0);
Assert(False,Format('Trace: AccelCount=%d',[AccelCount]));
NewAccel := LPACCEL(LocalAlloc(LPTR, AccelCount * sizeof(ACCEL)));
CopyAcceleratorTable(OldAccel, NewAccel, AccelCount);
ControlIndex := ControlInTable;
if ControlIndex = AccelCount then {realocating the accelerator array, adding new accelerator}
begin
LocalFree(HLOCAL(NewAccel));
NewAccel := LPACCEL(LocalAlloc(LPTR, (AccelCount+1) * sizeof(ACCEL)));
CopyAcceleratorTable(OldAccel, NewAccel, AccelCount);
NewCount := AccelCount+1;
end
else NewCount := AccelCount;
NewAccel[ControlIndex].cmd := CommandId;
NewAccel[ControlIndex].fVirt := GetVirtFromState(AModifier);
NewAccel[ControlIndex].key := AKey;
DestroyAcceleratorTable(OldAccel);
if WindowInfo <> @DefaultWindowInfo then
begin
WindowInfo^.Accel := CreateAcceleratorTable(NewAccel, NewCount);
end else begin
DebugLn('Win32 - SetAccelKey: no windowinfo to put accelerator table in!');
end;
end;
function GetAccelKey(Const Control: HWND): LPACCEL;
begin
Assert(False, 'Trace:TODO: Code GetAccelKey');
//Result := GeWin32tWindowInfo(Control)^.AccelKey;
Result := nil;
end;
{-------------------------------------------------------------------------------
function GetLCLClientOriginOffset(Sender: TObject;
var LeftOffset, TopOffset: integer): boolean;

View File

@ -597,12 +597,8 @@ end;
class procedure TWin32WSWinControl.DestroyHandle(const AWinControl: TWinControl);
var
Handle: HWND;
AccelTable: HACCEL;
begin
Handle := AWinControl.Handle;
AccelTable := GetWin32WindowInfo(Handle)^.Accel;
if AccelTable <> 0 then
DestroyAcceleratorTable(AccelTable);
DestroyWindow(Handle);
end;

View File

@ -284,7 +284,6 @@ end;
procedure TWinCEWidgetSet.AppProcessMessages;
var
AMessage: TMsg;
AccelTable: HACCEL;
retVal, index: dword;
pHandles: Windows.LPHANDLE;
begin
@ -315,13 +314,8 @@ begin
begin
while PeekMessage(AMessage, HWnd(nil), 0, 0, PM_REMOVE) do
begin
AccelTable := GetWindowInfo(AMessage.HWnd)^.Accel;
if (AccelTable = HACCEL(nil))
or (TranslateAccelerator(AMessage.HWnd, AccelTable, @AMessage) = 0) then
begin
TranslateMessage(@AMessage);
DispatchMessage(@AMessage);
end;
TranslateMessage(@AMessage);
DispatchMessage(@AMessage);
end;
if FWaitHandleCount = 0 then
break;

View File

@ -22,8 +22,6 @@ type
PWindowInfo = ^TWindowInfo;
TWindowInfo = record
AccelGroup: HACCEL;
Accel: HACCEL;
Overlay: HWND; // overlay, transparent window on top, used by designer
PopupMenu: TPopupMenu;
DefWndProc: WNDPROC;
@ -836,101 +834,6 @@ begin
end;
end;
//roozbeh : not yet ready!
(*
// ----------------------------------------------------------------------
// The Accelgroup and AccelKey is needed by menus
// ----------------------------------------------------------------------
procedure SetAccelGroup(Const Control: HWND; Const AnAccelGroup: HACCEL);
var
WindowInfo: PWindowInfo;
Begin
Assert(False, 'Trace:TODO: Code SetAccelGroup');
WindowInfo := GetWindowInfo(Control);
if WindowInfo <> @DefaultWindowInfo then
begin
WindowInfo^.AccelGroup := AnAccelGroup;
end else begin
DebugLn('Win32 - SetAccelGroup: no window info to store accelgroup in!');
end;
End;
function GetAccelGroup(Const Control: HWND): HACCEL;
Begin
Assert(False, 'Trace:TODO: Code GetAccelGroup');
Result := GetWindowInfo(Control)^.AccelGroup;
End;
procedure SetAccelKey(Window: HWND; Const CommandId: Word; Const AKey: word; Const AModifier: TShiftState);
var AccelCount: integer; {number of accelerators in table}
NewCount: integer; {total sum of accelerators in the table}
ControlIndex: integer; {index of new (modified) accelerator in table}
OldAccel: HACCEL; {old accelerator table}
NewAccel: LPACCEL; {new accelerator table}
NullAccel: LPACCEL; {nil pointer}
function ControlInTable: integer;
var i: integer;
begin
Result:=AccelCount;
i:=0;
while i < AccelCount do
begin
if NewAccel[i].cmd = CommandId then
begin
Result:=i;
exit;
end;
inc(i);
end;
end;
function GetVirtFromState(const AState: TShiftState): Byte;
begin
Result := FVIRTKEY;
if ssAlt in AState then Result := Result or FALT;
if ssCtrl in AState then Result := Result or FCONTROL;
if ssShift in AState then Result := Result or FSHIFT;
end;
var
WindowInfo: PWindowInfo;
Begin
WindowInfo := GetWindowInfo(Window);
OldAccel := WindowInfo^.Accel;
NullAccel := nil;
AccelCount := CopyAcceleratorTable(OldAccel, NullAccel, 0);
Assert(False,Format('Trace: AccelCount=%d',[AccelCount]));
NewAccel := LPACCEL(LocalAlloc(LPTR, AccelCount * sizeof(ACCEL)));
CopyAcceleratorTable(OldAccel, NewAccel, AccelCount);
ControlIndex := ControlInTable;
if ControlIndex = AccelCount then {realocating the accelerator array, adding new accelerator}
begin
LocalFree(HLOCAL(NewAccel));
NewAccel := LPACCEL(LocalAlloc(LPTR, (AccelCount+1) * sizeof(ACCEL)));
CopyAcceleratorTable(OldAccel, NewAccel, AccelCount);
NewCount := AccelCount+1;
end
else NewCount := AccelCount;
NewAccel[ControlIndex].cmd := CommandId;
NewAccel[ControlIndex].fVirt := GetVirtFromState(AModifier);
NewAccel[ControlIndex].key := AKey;
DestroyAcceleratorTable(OldAccel);
if WindowInfo <> @DefaultWindowInfo then
begin
WindowInfo^.Accel := CreateAcceleratorTable(NewAccel, NewCount);
end else begin
DebugLn('Win32 - SetAccelKey: no windowinfo to put accelerator table in!');
end;
End;
function GetAccelKey(Const Control: HWND): LPACCEL;
Begin
Assert(False, 'Trace:TODO: Code GetAccelKey');
//Result := GetWindowInfo(Control)^.AccelKey;
Result := nil;
End;
*)
{-------------------------------------------------------------------------------
function GetLCLClientOriginOffset(Sender: TObject;
var LeftOffset, TopOffset: integer): boolean;

View File

@ -439,12 +439,8 @@ end;
class procedure TWinCEWSWinControl.DestroyHandle(const AWinControl: TWinControl);
var
Handle: HWND;
AccelTable: HACCEL;
begin
Handle := AWinControl.Handle;
// AccelTable := GetWindowInfo(Handle)^.Accel;
// if AccelTable <> 0 then
// DestroyAcceleratorTable(AccelTable);
DestroyWindow(Handle);
end;