First Focused Control

InstallationWay

Новичок
Hi Friends, here is my script. I have made NextButton invisible, so the only available button is CancelButton, so it should be focused on start. But I need to press TAB once to get it focused. It seems the wizard page is focusing on hidden NextButton on start. any fix here?
Код:
[Setup]
AppName="MyApp"
AppVersion= "1.5"
DefaultDirName=Nothing
DisableWelcomePage=no

[Code]
procedure InitializeWizard;
begin
  with WizardForm do begin
    NextButton.Width:=ScaleX(0);
    NextButton.Visible:=False;
    NextButton.TabStop:=False;
    NextButton.Enabled:=False;
    NextButton.Default:=False;
    WizardForm.ActiveControl:=CancelButton;
  end;
end;
 
Последнее редактирование модератором:

Nemko

Дилетант
Модератор
Eng: InstallationWay, no guarantees:
Rus: InstallationWay, без гарантий:
Код:
[Setup]
AppName=Test
AppVersion=0.1
CreateAppDir=no
[Code]
const
  WM_SETFOCUS = 7;

var
  FirstRun: Boolean;

procedure CurPageChanged(Page: Integer);
begin
  with WizardForm.CancelButton do begin
    if (Page = wpWelcome) and not FirstRun then FirstRun:=PostMessage(Handle, WM_SETFOCUS, 0, 0);
  end;
end;
 
Сверху