Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для Johny777

Ветеран


Сообщения: 649
Благодарности: 444

Профиль | Отправить PM | Цитировать


1. Переделал "проценты установки" под CallbackAddr

теперь библиотека "InnoCallback.dll" не нужна (нужна только расширенная версия Inno)

было так:
читать дальше »
Код: Выделить весь код
[Setup]
AppName=MyApp
AppVerName=MyApp
DefaultDirName={pf}\MyApp

[Files]
Source: compiler:innocallback.dll; Flags: dontcopy
Source: {win}\Help\*; DestDir: {app}; Flags: external recursesubdirs

[code]
type
  TTimerProc = procedure(HandleW, Msg, idEvent, TimeSys: LongWord);
  

var
  PercentsTimer: LongWord;
  PercentsLabel: TLabel;
  

function WrapTimerProc(callback: TTimerProc; Paramcount: Integer): longword; external 'wrapcallback@files:innocallback.dll stdcall';
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): longword; external 'SetTimer@user32';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord; external 'KillTimer@user32 stdcall delayload';


function NumToStr(Float: Extended): String;
begin
  Result:= Format('%.1n', [Float]); StringChange(Result, ',', '.');
  while ((Result[Length(Result)] = '0') or (Result[Length(Result)] = '.')) and (Pos('.', Result) > 0) do
  SetLength(Result, Length(Result)-1);
end;


procedure PercentsProc(h, msg, idevent, dwTime: Longword);
begin
  with WizardForm.ProgressGauge do
  begin
    PercentsLabel.Caption := NumToStr((Position*100)/Max) + ' %';
    Application.Title := ' ' + NumToStr((Position*100)/Max) + ' %';
  end;
end;


procedure DeinitializeSetup();
begin
  KillTimer(0, PercentsTimer);
end;


procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssInstall then
  begin
  
    PercentsLabel:= TLabel.Create(nil);
    with PercentsLabel do
    begin
      SetBounds(WizardForm.ProgressGauge.Left + ScaleX(30), WizardForm.ProgressGauge.Top + WizardForm.ProgressGauge.Height + ScaleY(10), WizardForm.StatusLabel.Width, WizardForm.StatusLabel.Height);
      AutoSize:= True;
      Transparent := True;
      Parent:= WizardForm.InstallingPage;
    end;

    PercentsTimer:= SetTimer(0, 0, 100, WrapTimerProc(@PercentsProc, 4));
    
  end;
  
  if CurStep = ssPostInstall then
  begin
    KillTimer(0, PercentsTimer);
    Application.Title := ' Готово';
  end;
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  if CurPageID=wpInstalling then
  begin
    Confirm := False;
    case ExitSetupMsgBox of
      True :
      begin
        PercentsLabel.Free;
        Application.Title := ExpandConstant(' ' + SetupMessage(msgButtonCancel) + '...');
        Cancel := True;
      end;
      False : Cancel := False;
    end;
  end;
end;


стало так:
читать дальше »
Код: Выделить весь код
[Setup]
AppName=MyApp
AppVerName=MyApp
DefaultDirName={pf}\MyApp

[Files]
Source: {win}\Help\*; DestDir: {app}; Flags: external recursesubdirs

[code]
var
  PercentsTimer: LongWord;
  PercentsLabel: TLabel;
  
  
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): LongWord; external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord; external 'KillTimer@user32.dll stdcall';
  

function NumToStr(Float: Extended): String;
begin
  Result:= Format('%.1n', [Float]); StringChange(Result, ',', '.');
  while ((Result[Length(Result)] = '0') or (Result[Length(Result)] = '.')) and (Pos('.', Result) > 0) do
  SetLength(Result, Length(Result)-1);
end;


procedure PercentsProc;
begin
  with WizardForm.ProgressGauge do
  begin
    PercentsLabel.Caption := NumToStr((Position*100)/Max) + ' %';
    Application.Title := ' ' + NumToStr((Position*100)/Max) + ' %';  /// проценты на кнопке в панели задач
  end;
end;


procedure DeinitializeSetup();
begin
  KillTimer(WizardForm.Handle, PercentsTimer);
end;


procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssInstall then
  begin
  
    PercentsLabel:= TLabel.Create(nil);
    with PercentsLabel do
    begin
      SetBounds(WizardForm.ProgressGauge.Left + ScaleX(30), WizardForm.ProgressGauge.Top + WizardForm.ProgressGauge.Height + ScaleY(10), WizardForm.StatusLabel.Width, WizardForm.StatusLabel.Height);
      AutoSize:= True;
      Transparent := True;
      Parent:= WizardForm.InstallingPage;
    end;
    
    PercentsTimer:= SetTimer(WizardForm.Handle, 0, 100, CallbackAddr('PercentsProc'));
    
  end;
  
  if CurStep = ssPostInstall then
  begin
    KillTimer(WizardForm.Handle, PercentsTimer);
    Application.Title := ' Готово';
  end;
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  if CurPageID=wpInstalling then
  begin
    Confirm := False;
    case ExitSetupMsgBox of
      True :
      begin
        PercentsLabel.Free;
        Application.Title := ExpandConstant(' ' + SetupMessage(msgButtonCancel) + '...');
        Cancel := True;
      end;
      False : Cancel := False;
    end;
  end;
end;


Примечание:
кто не хочет отображения десятой доли процента после запятой удалите функцию
function NumToStr(Float: Extended): String;
begin
...
end;
и замените в процедуре
procedure PercentsProc;

NumToStr на IntToStr
===========================================================================================
2. может кто пожалуйста избавить это код от InnoCallBack.dll (при перетаскивании основного окно перетаскивается форма)
читать дальше »
Код: Выделить весь код
[Setup]
AppName=MyApp
AppVerName=MyApp
DefaultDirname={pf}\MyApp

[Files]
Source: compiler:innocallback.dll; DestDir: {tmp}; Flags: dontcopy

[code]
const
  WM_MOVE = $3;

  GWL_WNDPROC = -4;

type
  TCallbackProc = function(h:hWnd;Msg,wParam,lParam:Longint):Longint  ;

function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
function WndProcCallBack(P:TCallbackProc;ParamCount:integer  ):LongWord; external 'wrapcallback@files:innocallback.dll stdcall';
function CallWindowProc(lpPrevWndFunc: Longint; hWnd: HWND; Msg: UINT; wParam, lParam: Longint): Longint; external 'CallWindowProcA@user32.dll stdcall';
function SetWindowPos(hWnd: HWND; hWndInsertAfter: HWND; X, Y, cx, cy: Integer; uFlags: UINT): BOOL; external 'SetWindowPos@user32.dll stdcall';

var
Form1: TForm;
OldProc: Longint;

function MyProc(h: HWND; Msg, wParam, lParam: longint): Longint;
begin
  if Msg=WM_MOVE then SetWindowPos(Form1.Handle, 0, WizardForm.Left+WizardForm.Width+5, WizardForm.Top, 0, 0, $415);
  Result:= CallWindowProc(OldProc, h, Msg, wParam, lParam);
end;

procedure InitializeWizard();
begin
  Form1:= TForm.Create(MainForm);
  Form1.SetBounds(WizardForm.Left+WizardForm.Width+5  , WizardForm.Top, 100, 358);
  Form1.BorderStyle:= bsSingle;
  Form1.Show;

  OldProc:= SetWindowLong(WizardForm.Handle, GWL_WNDPROC, WndProcCallBack(@MyProc, 4));
end;

procedure DeinitializeSetup();
begin
  SetWindowlong(WizardForm.Handle, GWL_WNDPROC, OldProc);
end;

речь идёт о функции:
function WndProcCallBack(P:TCallbackProc;ParamCount:integer ):LongWord; external 'wrapcallback@files:innocallback.dll stdcall';
=================================================================================
3. и последнее:
Скажите пожалуйста (если можно попроще) когда нужно (лучше?) использовать указатель nil в Inno и на что он влияет?
(из интереса присвоил всем элементам (ричэдитам, панелям, чекбосам) этот указатель и теперь инсталл кушает на 400 кб оперативки меньше )

Последний раз редактировалось Johny777, 07-07-2012 в 13:50.

Это сообщение посчитали полезным следующие участники:

Отправлено: 15:27, 06-07-2012 | #386