View Single Post
  #1  
Old 10-11-2014, 12:06
by_pbh by_pbh is offline
Registered User
 
Join Date: Dec 2008
Location: Romania
Posts: 4
Thanks: 4
Thanked 13 Times in 3 Posts
by_pbh is on a distinguished road
Post Example DirEdit and GroupEdit to text

diredit.jpg

Code:
code
#ifdef UNICODE
    #define A "W"
#else
    #define A "A"
#endif

const
  MAX_PATH = 260;
  MAX_PATH_LEN = 55;

var
  PathLabel: TLabel;

function PathCompactPathEx(pszOut: String; pszSrc: String; cchMax: UINT; dwFlags: DWORD): BOOL; external 'PathCompactPathEx{#A}@shlwapi.dll stdcall';

function ShortPath(Input: String; Length: Integer): String;
begin
  Result := StringOfChar(#32, MAX_PATH);
  PathCompactPathEx(Result, Input, Length, 0);
end;

procedure DirEditOnChange(Sender: TObject);
begin
  PathLabel.Caption := ShortPath('Install Path:' + #32 + TEdit(Sender).Text, MAX_PATH_LEN);
end;

procedure InitializeWizard();
begin
  with WizardForm do
  begin
    PathLabel := TLabel.Create(WizardForm)
    with PathLabel do
    begin
      Parent := DirEdit.Parent;
      Caption := ShortPath('Install Path:' + #32 + DirEdit.Text, MAX_PATH_LEN);
      Transparent := True;
      Font.Size := 10;
      Left := DirEdit.Left;
      Top := DirEdit.Top + Round((DirEdit.Height - Height) div 2);
    end;
    DirEdit.OnChange := @DirEditOnChange;
    DirEdit.Hide;
  end;
end;
groupedit.jpg

Code:
code
#ifdef UNICODE
    #define A "W"
#else
    #define A "A"
#endif

const
  MAX_PATH = 260;
  MAX_PATH_LEN = 55;

var
  PathLabel: TLabel;

function PathCompactPathEx(pszOut: String; pszSrc: String; cchMax: UINT; dwFlags: DWORD): BOOL; external 'PathCompactPathEx{#A}@shlwapi.dll stdcall';

function ShortPath(Input: String; Length: Integer): String;
begin
  Result := StringOfChar(#32, 260);
  PathCompactPathEx(Result, Input, Length, 0);
end;

procedure GroupEditOnChange(Sender: TObject);
begin
  PathLabel.Caption := ShortPath(#32 + TEdit(Sender).Text, 55);
end;

procedure InitializeWizard();
begin
  PathLabel := TLabel.Create(nil);
  with PathLabel do
  begin
    Parent:= WizardForm.SelectProgramGroupPage;
    Caption := ShortPath(#32 + WizardForm.GroupEdit.Text, 55);
    Transparent := True;
    Font.Size := 9;
    Left := WizardForm.GroupEdit.Left;
    Top := WizardForm.GroupEdit.Top + Round((WizardForm.GroupEdit.Height - Height) div 2);
  end;
  WizardForm.GroupEdit.OnChange := @GroupEditOnChange;
  WizardForm.GroupEdit.Hide;
end;
Reply With Quote
The Following 9 Users Say Thank You to by_pbh For This Useful Post:
ADMIRAL (21-02-2020), arkantos7 (11-11-2014), buttignol (08-06-2016), mausschieber (11-11-2014), oltjon (16-11-2016), Razor12911 (10-11-2014), sbalykov (04-03-2016), yasserdivar (04-10-2021), _EZEKiEL_ (19-11-2014)
Sponsored Links