产生bug的情况:
1, 使用Tab键切换焦点在Button上,按空格键执行按钮事件时
2, 焦点在RadioButton上,按任意字母时
bug错误现像:地址错误
环境: VCLSkin 4.9.1, Win 2003 Ent Sp2, Delphi 7.0
WinSkinForm.pas中代码段:
//fixed by Brian Lowe
procedure TWinSkinForm.CMDialogChar(var Message: TMessage); //TCMDialogChar
var
Button: TMenubtn;
ShiftState: TShiftState;
KeyState: TKeyboardState;
begin
OldWndProc(message);
if message.result<>0 then exit;
GetKeyboardState(KeyState);
ShiftState := KeyboardStateToShiftState(KeyState);
Button := FindButtonFromAccel(TWMKey(Message).CharCode);
if (Button <> nil) and (ShiftState = [ssAlt]) then begin
clickbutton(button);
Message.Result := 1;
done2:=true;
end else begin
//mdiform mainmenu shortcut
if (formstyle=sfsmdichild) then begin
if skinmanager.MDIForm.Perform(CM_DIALOGCHAR,
TWMKey(Message).CharCode,TWMKey(Message).KeyData)<>0 then exit;
end else if (fform<>application.MainForm) and (not (fsModal in fform.FormState)) then begin //has problem
application.MainForm.Perform(CM_DIALOGCHAR,TWMKey(Message).CharCode,TWMKey(Message).KeyData); [注1]
end;
message.Result:=0;
// OldWndProc(message);
end;
end;
本想写个示例程序,但新建的示例程序怎么也不出现错误.
比如幸运的时, 作者在写这部分代码时,有一行注释:mdiform mainmenu shortcut, 现在没时间去追根问底, 对于这一行注释, 猜测这是针对MDI窗口的代码, 所以,有一种情况是:一直在执行[注1]处代码, 为了避免这种隐患, 加一行代码或许更好些(下面代码粗体部分).
//fixed by Brian Lowe
procedure TWinSkinForm.CMDialogChar(var Message: TMessage); //TCMDialogChar
var
Button: TMenubtn;
ShiftState: TShiftState;
KeyState: TKeyboardState;
begin
OldWndProc(message);
if message.result<>0 then exit;
GetKeyboardState(KeyState);
ShiftState := KeyboardStateToShiftState(KeyState);
Button := FindButtonFromAccel(TWMKey(Message).CharCode);
if (Button <> nil) and (ShiftState = [ssAlt]) then begin
clickbutton(button);
Message.Result := 1;
done2:=true;
end else if (Application.MainForm <> nil) and (Application.MainForm.FormStyle = fsMDIForm) then begin
//mdiform mainmenu shortcut
if (formstyle=sfsmdichild) then begin
if skinmanager.MDIForm.Perform(CM_DIALOGCHAR,
TWMKey(Message).CharCode,TWMKey(Message).KeyData)<>0 then exit;
end else if (fform<>application.MainForm) and (not (fsModal in fform.FormState)) then begin //has problem
application.MainForm.Perform(CM_DIALOGCHAR,TWMKey(Message).CharCode,TWMKey(Message).KeyData);
message.Result:=0;
end;
// OldWndProc(message);
e
1, 使用Tab键切换焦点在Button上,按空格键执行按钮事件时
2, 焦点在RadioButton上,按任意字母时
bug错误现像:地址错误
环境: VCLSkin 4.9.1, Win 2003 Ent Sp2, Delphi 7.0
WinSkinForm.pas中代码段:
//fixed by Brian Lowe
procedure TWinSkinForm.CMDialogChar(var Message: TMessage); //TCMDialogChar
var
Button: TMenubtn;
ShiftState: TShiftState;
KeyState: TKeyboardState;
begin
OldWndProc(message);
if message.result<>0 then exit;
GetKeyboardState(KeyState);
ShiftState := KeyboardStateToShiftState(KeyState);
Button := FindButtonFromAccel(TWMKey(Message).CharCode);
if (Button <> nil) and (ShiftState = [ssAlt]) then begin
clickbutton(button);
Message.Result := 1;
done2:=true;
end else begin
//mdiform mainmenu shortcut
if (formstyle=sfsmdichild) then begin
if skinmanager.MDIForm.Perform(CM_DIALOGCHAR,
TWMKey(Message).CharCode,TWMKey(Message).KeyData)<>0 then exit;
end else if (fform<>application.MainForm) and (not (fsModal in fform.FormState)) then begin //has problem
application.MainForm.Perform(CM_DIALOGCHAR,TWMKey(Message).CharCode,TWMKey(Message).KeyData); [注1]
end;
message.Result:=0;
// OldWndProc(message);
end;
end;
本想写个示例程序,但新建的示例程序怎么也不出现错误.
比如幸运的时, 作者在写这部分代码时,有一行注释:mdiform mainmenu shortcut, 现在没时间去追根问底, 对于这一行注释, 猜测这是针对MDI窗口的代码, 所以,有一种情况是:一直在执行[注1]处代码, 为了避免这种隐患, 加一行代码或许更好些(下面代码粗体部分).
//fixed by Brian Lowe
procedure TWinSkinForm.CMDialogChar(var Message: TMessage); //TCMDialogChar
var
Button: TMenubtn;
ShiftState: TShiftState;
KeyState: TKeyboardState;
begin
OldWndProc(message);
if message.result<>0 then exit;
GetKeyboardState(KeyState);
ShiftState := KeyboardStateToShiftState(KeyState);
Button := FindButtonFromAccel(TWMKey(Message).CharCode);
if (Button <> nil) and (ShiftState = [ssAlt]) then begin
clickbutton(button);
Message.Result := 1;
done2:=true;
end else if (Application.MainForm <> nil) and (Application.MainForm.FormStyle = fsMDIForm) then begin
//mdiform mainmenu shortcut
if (formstyle=sfsmdichild) then begin
if skinmanager.MDIForm.Perform(CM_DIALOGCHAR,
TWMKey(Message).CharCode,TWMKey(Message).KeyData)<>0 then exit;
end else if (fform<>application.MainForm) and (not (fsModal in fform.FormState)) then begin //has problem
application.MainForm.Perform(CM_DIALOGCHAR,TWMKey(Message).CharCode,TWMKey(Message).KeyData);
message.Result:=0;
end;
// OldWndProc(message);
e