MUI: Basename should not contain ':','/', raise exception if application object fails to create.

git-svn-id: trunk@53970 -
This commit is contained in:
marcus 2017-01-18 19:18:58 +00:00
parent fec575ae2b
commit 85b6fc0bc3

View File

@ -166,7 +166,8 @@ begin
end; end;
var var
AppTitle, FinalVers, Vers, CopyR, Comment, prgName, Author: string; // MUI does not copy this values, so we keep them here
AppTitle, FinalVers, Vers, CopyR, Comment, PrgName, Author: string;
procedure TMUIWidgetSet.DebugOutEvent(Sender: TObject;s: string; var Handled: Boolean); procedure TMUIWidgetSet.DebugOutEvent(Sender: TObject;s: string; var Handled: Boolean);
begin begin
@ -195,16 +196,21 @@ var
end; end;
begin begin
// connect Debug log output
DebugLogger.OnDbgOut := @DebugOutEvent; DebugLogger.OnDbgOut := @DebugOutEvent;
DebugLogger.OnDebugLn := @DebugOutLNEvent; DebugLogger.OnDebugLn := @DebugOutLNEvent;
// Initial Application Values
Vers := ''; Vers := '';
CopyR := ''; CopyR := '';
Comment := ''; Comment := '';
Dollar := '$'; Dollar := '$';
prgName := Application.title; // Get the name from Application.Title, remove the Path Part
AppTitle := Application.title; PrgName := ExtractFilename(Application.Title);
AppTitle := PrgName;
// Miu can't handle empty AppTitle, use Exename
if AppTitle = '' then if AppTitle = '' then
AppTitle := ExtractFilename(ParamStr(0)); AppTitle := ExtractFilename(ParamStr(0));
// load Informations from resource
Info := TVersionInfo.Create; Info := TVersionInfo.Create;
try try
Info.Load(HINSTANCE); Info.Load(HINSTANCE);
@ -214,17 +220,14 @@ begin
for j := 0 to Info.StringFileInfo.Items[i].Count - 1 do for j := 0 to Info.StringFileInfo.Items[i].Count - 1 do
begin begin
if Info.StringFileInfo.Items[i].Keys[j] = 'LegalCopyright' then if Info.StringFileInfo.Items[i].Keys[j] = 'LegalCopyright' then
begin CopyR := Info.StringFileInfo.Items[i].Values[j]
CopyR := Info.StringFileInfo.Items[i].Values[j]; else
end else
if Info.StringFileInfo.Items[i].Keys[j] = 'Comments' then if Info.StringFileInfo.Items[i].Keys[j] = 'Comments' then
begin Comment := Info.StringFileInfo.Items[i].Values[j]
Comment := Info.StringFileInfo.Items[i].Values[j]; else
end else
if Info.StringFileInfo.Items[i].Keys[j] = 'CompanyName' then if Info.StringFileInfo.Items[i].Keys[j] = 'CompanyName' then
begin Author := Info.StringFileInfo.Items[i].Values[j]
Author := Info.StringFileInfo.Items[i].Values[j]; else
end else
if Info.StringFileInfo.Items[i].Keys[j] = 'ProductName' then if Info.StringFileInfo.Items[i].Keys[j] = 'ProductName' then
begin begin
if Length(Trim(Info.StringFileInfo.Items[i].Values[j])) > 0 then if Length(Trim(Info.StringFileInfo.Items[i].Values[j])) > 0 then
@ -234,11 +237,15 @@ begin
end; end;
except except
end; end;
// end resource loading
Info.Free; Info.Free;
// get the Icon (to use as Iconify Image), nil is no problem, MUI handle that and use the default
ThisAppDiskIcon := GetDiskObject(PChar(ParamStr(0))); ThisAppDiskIcon := GetDiskObject(PChar(ParamStr(0)));
// Version information as Standard AMIGA Version string
FinalVers := Dollar + 'VER: ' + PrgName + ' ' + Vers + '('+{$I %DATE%}+')'; FinalVers := Dollar + 'VER: ' + PrgName + ' ' + Vers + '('+{$I %DATE%}+')';
// Create the Application
TagList.AddTags([ TagList.AddTags([
LongInt(MUIA_Application_Base), NativeUInt(PChar(AppTitle)), NativeInt(MUIA_Application_Base), NativeUInt(PChar(AppTitle)),
MUIA_Application_DiskObject, NativeUInt(ThisAppDiskIcon), MUIA_Application_DiskObject, NativeUInt(ThisAppDiskIcon),
MUIA_Application_Title, NativeUInt(PChar(AppTitle)), MUIA_Application_Title, NativeUInt(PChar(AppTitle)),
MUIA_Application_Version, NativeUInt(PChar(FinalVers)), MUIA_Application_Version, NativeUInt(PChar(FinalVers)),
@ -247,6 +254,9 @@ begin
MUIA_Application_Author, NativeUInt(PChar(Author)) MUIA_Application_Author, NativeUInt(PChar(Author))
]); ]);
MUIApp := TMuiApplication.Create(TagList); MUIApp := TMuiApplication.Create(TagList);
if not Assigned(MUIApp) or not Assigned(MUIApp.Obj) then
raise EInvalidOperation.Create('Unable to Create Application object.');
// same basic Screen info, no idea where to get that
ScreenInfo.PixelsPerInchX := 72; ScreenInfo.PixelsPerInchX := 72;
ScreenInfo.PixelsPerInchY := 72; ScreenInfo.PixelsPerInchY := 72;
ScreenInfo.ColorDepth := 32; ScreenInfo.ColorDepth := 32;