由于OnEnter
Inno Setup API中缺少事件,因此难以实现。
首先,您要设置TabStop
按钮的属性,False
以防止按钮通过按键获得焦点Tab。
Button.TabStop := False;
(在您的情况下,就是SoundCtrlButton
)。
如果您对焦点感到满意,请始终返回到“下一步”按钮,当单击鼠标时,这很容易。只需将焦点明确设置为按钮处理程序末尾的“下一步”按钮即可OnClick
:
procedure ButtonClick(Sender: TObject);
begin
{ Some actual code }
{ If the button is focused (it won't be, when access key was used to "click" it) ... }
if TButton(Sender).Focused then
{ ... focus the "Next" button }
WizardForm.ActiveControl := WizardForm.NextButton;
end;
(在您的情况下,OnClick
处理程序为SoundCtrlButtonClick
)。
但是,如果您想很好地实现此目的,则可以通过将焦点返回到之前实际具有焦点的控件来,这会更加困难。
我没有想到比安排一个频繁的计时器来监视集中控制更好的解决方案了。
[Code]
function SetTimer(hWnd: LongWord; nIDEvent, uElapse: LongWord;
lpTimerFunc: LongWord): LongWord; external '[email protected] stdcall';
var
LastFocusedControl: TWinControl;
procedure FocusMonitorProc(
H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord);
begin
{ Remember focused control, unless the currently focused control is already the one, }
{ we do not want to get focused }
if (WizardForm.ActiveControl = nil) or
WizardForm.ActiveControl.TabStop then
begin
LastFocusedControl := WizardForm.ActiveControl;
end;
end;
procedure ButtonClick(Sender: TObject);
begin
{ Some actual code }
{ If the button is focused (it won't be, when access key was used to "click" it) ... }
if TButton(Sender).Focused and (LastFocusedControl <> nil) then
{ ... focus the previously focused control }
WizardForm.ActiveControl := LastFocusedControl;
end;
procedure InitializeWizard();
begin
{ Set up 50ms timer to monitor the focus }
SetTimer(0, 0, 50, CreateCallback(@FocusMonitorProc));
{ Create the "unfocusable" button }
SomeButton := TNewButton.Create(WizardForm);
{ Initialize button }
SomeButton.TabStop := False;
end;
对于CreateCallback
功能,您需要Inno Setup6。如果您坚持使用Inno Setup 5,则可以使用InnoTools InnoCallback库中的WrapCallback
功能。
另一种解决方案是使用类似按钮的图片(TBitmapImage
控件),而不是实际的图片TButton
。该TBitmapImage
控制(并非TWinControl
)在所有不能接收焦点。
实际上,它可以使您获得漂亮的“静音”图像,而不是普通的“静音”标题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句