Bulat_Ziganshin
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору [Setup] AppName=Test AppVerName=Test DefaultDirName={pf}\Test OutputDir=userdocs:Test. [Languages] Name: "rus"; MessagesFile: "compiler:Languages\Russian.isl"; [CustomMessages] NEEDSIZE=Space required rus.NEEDSIZE=Требуется места на диске FREESIZE=Space available rus.FREESIZE=Доступно места на диске [Files] Source: button.bmp; DestDir: {tmp}; Flags: dontcopy [Code] const ButtonWidth = 80; ButtonHeight = 23; bidBack = 0; bidNext = 1; bidCancel = 2; bidDirBrowse = 3; bidGroupBrowse = 4; var NeedSize: Integer; FreeMB, TotalMB: Cardinal; NeedSpaceLabel,FreeSpaceLabel: TLabel; ButtonPanel: array [0..4] of TPanel; ButtonImage: array [0..4] of TBitmapImage; ButtonLabel: array [0..4] of TLabel; procedure GetFreeSpaceCaption(Sender: TObject); var Path: String; begin Path := ExtractFileDrive(WizardForm.DirEdit.Text); GetSpaceOnDisk(Path, True, FreeMB, TotalMB); if FreeMB > 1024 then FreeSpaceLabel.Caption := ExpandConstant('{cm:FREESIZE}') + ': ' + FloatToStr(round(FreeMB/1024*100)/100) + ' GB' else FreeSpaceLabel.Caption := ExpandConstant('{cm:FREESIZE}') + ': ' + IntToStr(FreeMB) + ' MB'; if FreeMB < NeedSize then begin WizardForm.NextButton.Enabled := False; end else begin WizardForm.NextButton.Enabled := True; ButtonLabel[bidNext].Enabled := True; ButtonPanel[bidNext].Enabled := True; end; end; procedure GetNeedSpaceCaption; begin if NeedSize > 1024 then NeedSpaceLabel.Caption := ExpandConstant('{cm:NEEDSIZE}') + ': ' + FloatToStr(round(NeedSize/1024*100)/100) + ' GB' else NeedSpaceLabel.Caption := ExpandConstant('{cm:NEEDSIZE}') + ': ' + IntToStr(NeedSize)+ ' MB'; end; procedure ButtonLabelClick(Sender: TObject); var Button: TButton; begin ButtonImage[TLabel(Sender).Tag].Left:=0 case TLabel(Sender).Tag of bidBack: Button:=WizardForm.BackButton bidNext: Button:=WizardForm.NextButton bidCancel: Button:=WizardForm.CancelButton bidDirBrowse: Button:=WizardForm.DirBrowseButton bidGroupBrowse: Button:=WizardForm.GroupBrowseButton else Exit end Button.OnClick(Button) end; procedure ButtonLabelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if ButtonLabel[TLabel(Sender).Tag].Enabled then ButtonImage[TLabel(Sender).Tag].Left:=-ButtonWidth end; procedure ButtonLabelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ButtonImage[TLabel(Sender).Tag].Left:=0 end; procedure LoadButtonImage(AButton: TButton; AButtonIndex: integer); var Image: TBitmapImage; Panel: TPanel; Labl: TLabel; begin Panel:=TPanel.Create(WizardForm) Panel.Left:=AButton.Left Panel.Top:=AButton.Top Panel.Width:=AButton.Width Panel.Height:=AButton.Height Panel.Tag:=AButtonIndex Panel.Parent:=AButton.Parent ButtonPanel[AButtonIndex]:=Panel Image:=TBitmapImage.Create(WizardForm) Image.Width:=160 Image.Height:=23 Image.Enabled:=False Image.Bitmap.LoadFromFile(ExpandConstant('{tmp}\button.bmp')) Image.Parent:=Panel ButtonImage[AButtonIndex]:=Image with TLabel.Create(WizardForm) do begin Tag:=AButtonIndex Parent:=Panel Width:=Panel.Width Height:=Panel.Height Transparent:=True OnClick:=@ButtonLabelClick OnDblClick:=@ButtonLabelClick OnMouseDown:=@ButtonLabelMouseDown OnMouseUp:=@ButtonLabelMouseUp end Labl:=TLabel.Create(WizardForm) Labl.Left:=23 Labl.Top:=5 Labl.Autosize:=True Labl.Alignment:=taCenter Labl.Tag:=AButtonIndex Labl.Transparent:=True Labl.Font.Color:=clWhite Labl.Caption:=AButton.Caption Labl.OnClick:=@ButtonLabelClick Labl.OnDblClick:=@ButtonLabelClick Labl.OnMouseDown:=@ButtonLabelMouseDown Labl.OnMouseUp:=@ButtonLabelMouseUp Labl.Parent:=Panel ButtonLabel[AButtonIndex]:=Labl end; procedure UpdateButton(AButton: TButton;AButtonIndex: integer); begin ButtonLabel[AButtonIndex].Caption:=AButton.Caption ButtonPanel[AButtonIndex].Visible:=AButton.Visible ButtonLabel[AButtonIndex].Enabled:=Abutton.Enabled end; procedure LicenceAcceptedRadioOnClick(Sender: TObject); begin ButtonLabel[bidNext].Enabled:=True end; procedure LicenceNotAcceptedRadioOnClick(Sender: TObject); begin ButtonLabel[bidNext].Enabled:=False end; procedure InitializeWizard(); begin NeedSize := 307200; WizardForm.DiskSpaceLabel.Hide; NeedSpaceLabel := TLabel.Create(WizardForm); NeedSpaceLabel.Left := ScaleX(0); NeedSpaceLabel.Top := ScaleY(202); NeedSpaceLabel.Width := ScaleX(209); NeedSpaceLabel.Height := ScaleY(13); NeedSpaceLabel.Parent := WizardForm.SelectDirPage; FreeSpaceLabel := TLabel.Create(WizardForm); FreeSpaceLabel.Left := ScaleX(0); FreeSpaceLabel.Top := ScaleY(220); FreeSpaceLabel.Width := ScaleX(209); FreeSpaceLabel.Height := ScaleY(13); FreeSpaceLabel.Parent := WizardForm.SelectDirPage; WizardForm.BackButton.Width:=ButtonWidth WizardForm.BackButton.Height:=ButtonHeight WizardForm.NextButton.Width:=ButtonWidth WizardForm.NextButton.Height:=ButtonHeight WizardForm.CancelButton.Width:=ButtonWidth WizardForm.CancelButton.Height:=ButtonHeight WizardForm.DirBrowseButton.Left:=337 WizardForm.DirBrowseButton.Width:=ButtonWidth WizardForm.DirBrowseButton.Height:=ButtonHeight WizardForm.GroupBrowseButton.Left:=337 WizardForm.GroupBrowseButton.Width:=ButtonWidth WizardForm.GroupBrowseButton.Height:=ButtonHeight WizardForm.LicenseAcceptedRadio.OnClick:=@LicenceAcceptedRadioOnClick WizardForm.LicenseNotAcceptedRadio.OnClick:=@LicenceNotAcceptedRadioOnClick ExtractTemporaryFile('button.bmp') LoadButtonImage(WizardForm.BackButton,bidBack) LoadButtonImage(WizardForm.NextButton,bidNext) LoadButtonImage(WizardForm.CancelButton,bidCancel) LoadButtonImage(WizardForm.DirBrowseButton,bidDirBrowse) LoadButtonImage(WizardForm.GroupBrowseButton,bidGroupBrowse) end; procedure CurPageChanged(CurPageID: Integer); begin UpdateButton(WizardForm.BackButton,bidBack) UpdateButton(WizardForm.NextButton,bidNext) UpdateButton(WizardForm.CancelButton,bidCancel) if CurPageID = wpSelectDir then begin GetNeedSpaceCaption; WizardForm.DirEdit.OnChange := @GetFreeSpaceCaption; WizardForm.DirEdit.Text := WizardForm.DirEdit.Text + #0; if FreeMB < NeedSize then begin WizardForm.NextButton.Enabled := False; ButtonLabel[bidNext].Enabled := False; ButtonPanel[bidNext].Enabled := False; end; end; end; //зы: файл Button.bmp (размеры 160х23) в нем изображения двух кнопок, видимо одно изображение // для активного состояния кнопки при наведении или клике, другое неактивное. сам не проверял (paul_smART) |