Ru-Board.club
← Вернуться в раздел «Программы»

» Помогите оптимизировать пожалуйста

Автор: SergeyLS
Дата сообщения: 18.06.2008 18:30
Нужно, чтобы в зависимости от языка менялись названия кнопок и сообщений.
Вот сделал, но получилось коряво, может кто-нибудь оптимизирует?

[more]

[Setup]
AppName=Test
AppVerName=Test 1.0.1
CreateAppDir=false
Uninstallable=false
OutputBaseFilename=testsetup
ShowUndisplayableLanguages=true
WindowVisible=true
WizardImageFile=pics\wizard.bmp
WizardSmallImageFile=pics\wizard-small.bmp
SetupIconFile=pics\Icon.ico
WindowResizable=true

[Languages]
Name: en; MessagesFile: compiler:Default.isl
Name: de; MessagesFile: compiler:\Languages\German.isl
Name: ru; MessagesFile: compiler:\Languages\Russian.isl

[CustomMessages]

en.AboutButtonCaption=Test
de.AboutButtonCaption=Test
ru.AboutButtonCaption=Тест

[Files]
Source: pics\WizModernBigImage.bmp; Flags: dontcopy
Source: pics\WizModernSmallImage.bmp; Flags: dontcopy
Source: pics\wizard.bmp; Flags: dontcopy
Source: pics\wizard-small.bmp; Flags: dontcopy
Source: support\bass.dll; Flags: dontcopy
Source: support\isxbb.dll; Flags: dontcopy
Source: support\music.ogg; Flags: dontcopy


Код:
const
BASS_SAMPLE_LOOP = 4;

type
HSTREAM = DWORD;
function BASS_Init(device: Integer; freq, flags: DWORD; win: hwnd; CLSID: Integer): Boolean;
external 'BASS_Init@files:BASS.dll stdcall delayload';

function BASS_StreamCreateFile(mem: BOOL; f: PChar; offset: DWORD; length: DWORD; flags: DWORD): HSTREAM;
external 'BASS_StreamCreateFile@files:BASS.dll stdcall delayload';

function BASS_Start(): Boolean;
external 'BASS_Start@files:BASS.dll stdcall delayload';

function BASS_ChannelPlay(handle: DWORD; restart: BOOL): Boolean;
external 'BASS_ChannelPlay@files:BASS.dll stdcall delayload';

function BASS_Stop(): Boolean;
external 'BASS_Stop@files:BASS.dll stdcall delayload';

function BASS_Free(): Boolean;
external 'BASS_Free@files:BASS.dll stdcall delayload';

procedure CreateTheWizardPages;
var
Page: TWizardPage;
BitmapImage: TBitmapImage;
BitmapFileName: String;
begin
if ExpandConstant('{language}') = 'en' then
begin
Page := CreateCustomPage(wpWelcome, 'test', 'continue test');
BitmapFileName := ExpandConstant('{tmp}\WizModernSmallImage.bmp');
ExtractTemporaryFile(ExtractFileName(BitmapFileName));
BitmapImage := TBitmapImage.Create(Page);
BitmapImage.AutoSize := True;
BitmapImage.Bitmap.LoadFromFile(BitmapFileName);
BitmapImage.Parent := Page.Surface;
end
else
if ExpandConstant('{language}') = 'de' then
begin
Page := CreateCustomPage(wpWelcome, 'Testiren ...', 'testiren');
BitmapFileName := ExpandConstant('{tmp}\WizModernSmallImage.bmp');
ExtractTemporaryFile(ExtractFileName(BitmapFileName));
BitmapImage := TBitmapImage.Create(Page);
BitmapImage.AutoSize := True;
BitmapImage.Bitmap.LoadFromFile(BitmapFileName);
BitmapImage.Parent := Page.Surface;
end
else
if ExpandConstant('{language}') = 'ru' then
begin
Page := CreateCustomPage(wpWelcome, 'Тест', 'Продолжить тест');
BitmapFileName := ExpandConstant('{tmp}\WizModernSmallImage.bmp');
ExtractTemporaryFile(ExtractFileName(BitmapFileName));
BitmapImage := TBitmapImage.Create(Page);
BitmapImage.AutoSize := True;
BitmapImage.Bitmap.LoadFromFile(BitmapFileName);
BitmapImage.Parent := Page.Surface;
end
end;

procedure AboutButtonOnClick(Sender: TObject);
begin
if ExpandConstant('{language}') = 'en' then
begin
MsgBox('Test...', mbInformation, mb_Ok);
end
else
if ExpandConstant('{language}') = 'de' then
begin
MsgBox('Testen...', mbInformation, mb_Ok)
end
else
if ExpandConstant('{language}') = 'ru' then
begin
MsgBox('Тест...', mbInformation, mb_Ok)
end
end;

procedure URLLabelOnClick(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExec('open', 'http://www.test.ru/', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

procedure InitializeWizard();
var
NmPlay: string;
i: Integer;
s:string;
AboutButton, CancelButton: TButton;
URLLabel: TNewStaticText;
BackgroundBitmapImage: TBitmapImage;
begin
ExtractTemporaryFile('BASS.dll');
ExtractTemporaryFile('vistaharp.ogg');
if BASS_Init(-1, 44100, 0, 0, 0) then
begin
BASS_Start();
NmPlay:=ExpandConstant('{tmp}\music.ogg');
i:=BASS_StreamCreateFile(FALSE, PChar(NmPlay), 0, 0, 4);
if i <> 0 then
begin
begin
BASS_ChannelPlay(i, True);
begin
ExtractTemporaryFile('WizModernBigImage.bmp');
CreateTheWizardPages;
CancelButton := WizardForm.CancelButton;

AboutButton := TButton.Create(WizardForm);
AboutButton.Left := WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width;
AboutButton.Top := CancelButton.Top;
AboutButton.Width := CancelButton.Width;
AboutButton.Height := CancelButton.Height;
AboutButton.Caption :=ExpandConstant('{cm:AboutButtonCaption}');
AboutButton.OnClick := @AboutButtonOnClick;
AboutButton.Parent := WizardForm;

URLLabel := TNewStaticText.Create(WizardForm);
URLLabel.Caption := 'www.odin.worldofgothic.ru';
URLLabel.Cursor := crHand;
URLLabel.OnClick := @URLLabelOnClick;
URLLabel.Parent := WizardForm;
URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
URLLabel.Font.Color := clBlack;
URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(12);

s:=ExpandConstant('{tmp}')+'\WizModernBigImage.bmp';
BackgroundBitmapImage := TBitmapImage.Create(MainForm);
BackgroundBitmapImage.Bitmap.LoadFromFile(s);
BackgroundBitmapImage.Align := alClient;
BackgroundBitmapImage.Parent := MainForm;
BackgroundBitmapImage.AutoSize := True;
BackgroundBitmapImage.Stretch:=True;
MainForm.Visible:=True;
WizardForm.CancelButton.BringToFront;
end
end
end
end
end;

procedure DeInitializeSetup();
begin
BASS_Stop();
BASS_Free();
end;

Страницы: 1

Предыдущая тема: "Техэксперт" или "NormaCS"


Форум Ru-Board.club — поднят 15-09-2016 числа. Цель - сохранить наследие старого Ru-Board, истории становления российского интернета. Сделано для людей.