Вопрос Озучивание компонентов

justdj

Мимокрокодил
Shegorat, А воспроизведение не по нажатию на символ, а по нажатию на строку? Такое возможно?
 

justdj

Мимокрокодил
Замените второй параметр в функции sndPlaySound с 0 на 1.
Код:
sndPlaySound(iSound[f].SoundName, 1);
Огромное спасибо. А можете адаптировать скрипт под TvStyle? Пока не раскроешь предыдущие - звука нет.
 
Последнее редактирование:

Shegorat

Lord of Madness
Администратор
А можете адаптировать скрипт под TvStyle? Пока не раскроешь предыдущие - звука нет.
Во вложении, для Ansi и Unicode версий.
UPD: Добавил облегченный пример и поправил предыдущий.
 

Вложения

bacon

Мимокрокодил
Во вложении, для Ansi и Unicode версий.
UPD: Добавил облегченный пример и поправил предыдущий.
Hi Shegorat.... Thank you, I was able to use the TRIM version in my ANSI.
Could I get your help with this question?

This part of the code:

Код:
procedure InitializeWizard();
begin
  WizardForm.TypesCombo.Visible:=False;
  WizardForm.ComponentsList.Height := ScaleY(181) - WizardForm.TypesCombo.Top;
  WizardForm.ComponentsList.Top := WizardForm.TypesCombo.Top;
  WizardForm.ComponentsList.Width := ScaleX(417);
  sndCompOldProc:= WizardForm.ComponentsList.OnClick;
  WizardForm.ComponentsList.OnClick:= @PlaySound;

  ExtractTemporaryFile('piano2.wav');
  ExtractTemporaryFile('organfinale.wav');
  AddItemSound(15, '{tmp}\piano2.wav');
  AddItemSound(16, '{tmp}\organfinale.wav');
end;
Instead of having 15 & 16 to connect to the COMPONENTS menu item, how can the code be changed to recognize the "Components" "Description" Name?

For example the Description name that's here in my code for Picture Preview:

Код:
[Components]
Name: Tank_Icons\Advanced_Icons; Description: Advanced Contour Icons; Flags: exclusive disablenouninstallwarning
As an example the "pic" part of my code uses the Description name to connect the pic with the menu item, which is what I'm talking about.

Код:
'Advanced Contour Icons': UndefPic := 'adv_icon.bmp';
---

One other thing......
How can the code be changed so the sound plays on "Mouse Over" rather than "clicking" the menu item?

Thanks
 

Grizla

Мимокрокодил
Привет помоги исправить что б после выбора чекбокса с мелодией чекбокс без мелодии не проигрывал мелодию.

Код:
[Setup]
AppName=SoundResourceDemo
AppVerName=1.0
DefaultDirName={pf}\SoundResourceDemo
OutputDir=.
RawDataResource=SndA:bugreporter_succeeded.wav |SndB:WindowsLogoffSound.wav |SndE:Sound1.wav
[Components]
Name: "main"; Description: "Main Files";
Name: "main\a"; Description: "A Files";
Name: "main\b"; Description: "B Files";
Name: "main\c"; Description: "C Files";
Name: "main\d"; Description: "D Files";
Name: "main\e"; Description: "E Files";
[Code]
#define A = (Defined UNICODE) ? "W" : "A"
type
    HINST = THandle;
    HMODULE = HINST;
    Pointer = Longint;
    HRSRC = THandle;
    HGLOBAL = THandle;
const
    SND_ASYNC           = $0001;
    SND_NODEFAULT       = $0002;
    SND_MEMORY          = $0004;
    RT_RCDATA           = 10;

function sndPlaySound(lpszSoundName: Pointer; uFlags: UINT): BOOL; external 'sndPlaySound{#A}@Winmm.dll stdcall';
function LoadResource(hModule: HINST; hResInfo: HRSRC): HGLOBAL; external 'LoadResource@kernel32.dll stdcall';
function FindResource(hModule: HMODULE; lpName: String; lpType: Longint): HRSRC; external 'FindResource{#A}@kernel32.dll stdcall';
function LockResource(hResData: HGLOBAL): Pointer; external 'LockResource@kernel32.dll stdcall';
var
pSoundMemory_A, pSoundMemory_B, pSoundMemory_E: Pointer;
  
function GetResourceSoundAddr(const ResourceName: String): Pointer;
var
    hResourceSound: HRSRC;
begin
    hResourceSound := FindResource(HInstance, ResourceName, RT_RCDATA);
    Result := LockResource(LoadResource(HInstance, hResourceSound));
end;
procedure ComponentsOnClickCheck(Sender: TObject);
begin
    if IsComponentSelected('main\a') then
    begin
    sndPlaySound(pSoundMemory_B, SND_MEMORY or SND_NODEFAULT or SND_ASYNC);
    end;
    if IsComponentSelected('main\b') then
    begin
    sndPlaySound(pSoundMemory_A, SND_MEMORY or SND_NODEFAULT or SND_ASYNC);
    end;
    if IsComponentSelected('main\e') then
    begin
    sndPlaySound(pSoundMemory_E, SND_MEMORY or SND_NODEFAULT or SND_ASYNC);
    end;
end;
procedure InitializeWizard();
begin
    pSoundMemory_A := GetResourceSoundAddr('_IS_SNDA');
    pSoundMemory_B := GetResourceSoundAddr('_IS_SNDB');
    pSoundMemory_E := GetResourceSoundAddr('_IS_SNDB');
  
    WizardForm.ComponentsList.OnClickCheck := @ComponentsOnClickCheck;
end;
 

Shegorat

Lord of Madness
Администратор
bacon
In attachment. But "GetComponentIndex" works only if there are unique Description names of components.

Grizla
У вас абсолютно неправильный по логике код. Если будут выбраны все компоненты, то будут проиграны все звуковые дорожки. Да и не учитывается, какой компонент был выбран при клике.
Чем вам не угодил мой пример?
 

Вложения

Grizla

Мимокрокодил
Привет в этом коде вы уже добавили выбор чекбокса по названию и за это огромное спасибо но все ровно пропадает выбор типов установки.
Если можете напиши код как отдельный скрипт со своей библиотекой.

Код:
[Setup]
AppName=My Program
AppVerName=My Program 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
ComponentsListTVStyle=true

[Files]
Source: sounds\*; flags: dontcopy;

[Languages]
Name: russian; MessagesFile: compiler:Languages\Russian.isl

[Types]
Name: custom; Description: Пользовательськая установка; Flags: iscustom
Name: full; Description: Вибор;
Name: component; Description: Снять вибраное;

[Components]
Name: dummy1; Description: dummy1; Flags: collapsed
Name: dummy1\dummy2; Description: dummy2; Types: full;
Name: dummy1\dummy3; Description: dummy3;
Name: dummy1\dummy4; Description: dummy4;
Name: dummy1\dummy5; Description: dummy5;
Name: dummy1\dummy5\dummy1; Description: dummy6;
Name: dummy1\dummy5\dummy2; Description: dummy7;
Name: dummy1\dummy6; Description: dummy8;
Name: dummy2; Description: dummy9;
Name: dummy2\dummy2; Description: dummy10;
Name: dummy2\dummy3; Description: dummy11;
Name: dummy2\dummy4; Description: dummy12;
Name: dummy2\dummy5; Description: dummy13;
Name: sound; Description: Sound of a shot;
Name: sound\snd1; Description: Quiet; Types: full; Flags: exclusive;
Name: sound\snd2; Description: Loud; Flags: exclusive;

[Code]
const
  LB_ITEMFROMPOINT  = $01A9;
#ifdef UNICODE
  #define A "W"
  #define Phrase "#$266B#$266B"
#else
  #define A "A"
  #define Phrase "'(пример)'";
#endif

type
  TComponentSound = record
    SoundName: String;
    Index: Integer;
  end;

var
  iSound: array of TComponentSound;
  sndCompOldItemMouseMoveProc: TItemMouseMoveEvent;
  sndCompOldMouseLeaveProc: TNotifyEvent;
  LastIndex: Integer;
 
function GetCursorPos(var lpPoint: TPoint): BOOL; external 'GetCursorPos@user32.dll stdcall';
function MapWindowPoints(hWndFrom, hWndTo: HWND; var lpPoints: TPoint; cPoints: UINT): Integer; external 'MapWindowPoints@user32.dll stdcall';
function sndPlaySound(lpszSoundName: String; fuSound: UINT): BOOL; external 'sndPlaySound{#A}@winmm.dll stdcall';

procedure PlaySound(Sender: TObject; X, Y: Integer; Index: Integer; Area: TItemArea);
var
  i, f: Integer;
  s: String;
begin
  if (Index = LastIndex) then
    Exit;

  LastIndex:= Index;
   
  f:= -1;
  for i:= 0 to GetArrayLength(iSound)-1 do begin
    if (Index = iSound[i].Index) then begin
      f:= i;
      Break;
    end;
  end;

  if (f < 0) or (Index < 0) or (Index >= TNewCheckListBox(Sender).ItemCount) then begin
    sndPlaySound('', 0);
    Exit;
  end;
 
  s:= TNewCheckListBox(Sender).ItemCaption[Index];
  if (Pos({#Phrase}, s) <= 0) then Exit;

  if FileExists(iSound[f].SoundName) then
    sndPlaySound(iSound[f].SoundName, 1);
 
  if (sndCompOldItemMouseMoveProc <> nil) then
    sndCompOldItemMouseMoveProc(Sender, x, y, Index, Area);
end;

procedure LeaveEvent(Sender: TObject);
begin
  LastIndex:= -1;
  sndPlaySound('', 0);
 
  if (sndCompOldMouseLeaveProc <> nil) then
    sndCompOldMouseLeaveProc(Sender);
end;

function GetComponentIndex(Name: String): Integer;
var
  i: Integer;
begin
  Result:= -1;
  for i:= 0 to WizardForm.ComponentsList.ItemCount-1 do begin
    if (WizardForm.ComponentsList.ItemCaption[i] = Name) then begin
      Result:= i + 1;
      Break;
    end;
  end;
end;

procedure AddItemSound(AIndex: Integer; AFilename: String);
var
  i: Integer;
begin
  if (AIndex <= 0) then   //invalid index
    Exit;

  i:= GetArrayLength(iSound);
  SetArrayLength(iSound, i+1);
  iSound[i].Index:= AIndex-1;
  iSound[i].SoundName:= ExpandConstant(AFilename);
  WizardForm.ComponentsList.ItemCaption[AIndex-1]:= WizardForm.ComponentsList.ItemCaption[AIndex-1] + ' '+{#Phrase};
end;

procedure InitializeWizard();
begin
  lastIndex:= -1;
 
  WizardForm.TypesCombo.Visible:=False;
  WizardForm.ComponentsList.Height := ScaleY(181) - WizardForm.TypesCombo.Top;
  WizardForm.ComponentsList.Top := WizardForm.TypesCombo.Top;
  WizardForm.ComponentsList.Width := ScaleX(417);
  sndCompOldItemMouseMoveProc:= WizardForm.ComponentsList.OnItemMouseMove;
  WizardForm.ComponentsList.OnItemMouseMove:= @PlaySound;
  sndCompOldMouseLeaveProc:= WizardForm.ComponentsList.OnMouseLeave;
  WizardForm.ComponentsList.OnMouseLeave:= @LeaveEvent;
 
  ExtractTemporaryFile('sound3.wav');
  ExtractTemporaryFile('sound4.wav');
  AddItemSound(GetComponentIndex('Quiet'), '{tmp}\sound3.wav');
  AddItemSound(GetComponentIndex('Loud'), '{tmp}\sound4.wav');
end;
 

Shegorat

Lord of Madness
Администратор
все ровно пропадает выбор типов установки.
Ну так уберите строки
Код:
WizardForm.TypesCombo.Visible:=False;
WizardForm.ComponentsList.Height := ScaleY(181) - WizardForm.TypesCombo.Top;
WizardForm.ComponentsList.Top := WizardForm.TypesCombo.Top;
WizardForm.ComponentsList.Width := ScaleX(417);
 

Chip

Мимокрокодил
Добрый день,пробовал прикрутить себе озвучку из последнего ответа,но видимо скрипт предпросмотра перекрывает озвучку.Если не затруднит посмотрите как объединить эти два скрипта
 

Вложения

Le9ent

Новичок
Во вложении, для Ansi и Unicode версий.
UPD: Добавил облегченный пример и поправил предыдущий.
Доброго времени суток, возможно ли адаптировать облегченный пример под стандартную версию компилятора Inno (не китайскую), в которой нет параметра "ItemCount".
 

Kotyarko_O

Новичок
Le9ent, убрать это условие. Т.к. в стандартной версии Inno Setup нет TVStyle у компонентЛиста.
 
Сверху