damos
-
Content Count
15 -
Joined
-
Last visited
Posts posted by damos
-
-
procedure OpenImageWithPaint3D(const FilePath: string);
var
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
AppName: string;CreateOK: Boolean;
begin
// ShellExecute(0, 'open', 'ms-paint:', PChar(FilePath +' /ForceBootstrapPaint3D'), nil, SW_SHOWNORMAL);
// ShellExecute(0, 'open', 'mspaint', PChar(FilePath), nil, SW_SHOWNORMAL);
AppName := 'mspaint';
ZeroMemory(@StartupInfo, SizeOf(TStartupInfo));
StartupInfo.cb := SizeOf(TStartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := SW_SHOWNORMAL;CreateOK := CreateProcess(nil, PChar(AppName + ' ' + FilePath), nil, nil, False, 0, nil, nil, StartupInfo, ProcessInfo);
if CreateOK then
begin
// Successfully created the process
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
end
else
begin
// Failed to create the process
MsgInformation('Failed to open the file with Paint 3D.');
end;end;
This function is working for mspaint
Paint 3D is a modern app, which doesn't use executables like older classic applications. With var AppName what i use ????
-
I am running ShellExecute(0, 'open', 'ms-paint:', PChar(FilePath), nil, SW_SHOWNORMAL) ,
Paint 3D is open but the file is missing ??? , with mspaint is working or other painting program
What is the correct command ???
Thank you Vagelis Bekyros
-
3 minutes ago, softtouch said:@damos: Just create the .ini in the homepath, not inside the mac app bundle. I believe there is no write access, only read access.
Hi thank for answer the only way working is read and write options are two different approaches , each time you have to free your TInifle var when you switch between read and write when using MacOS platform
-
Just now, David Heffernan said:Not with the code most recently by the asker.
That singleton code is enormously complex, obfuscates, and is certainly not helpful here.
Ok Thank you
-
1 hour ago, dummzeuch said:OK, so where do you create and assign Settings in that code? That must be done before using it.
here is my in Splah Unit
unit Splash;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,Common,rCommon,
FMX.Objects, FMX.Edit, FMX.Controls.Presentation, FMX.StdCtrls,Inifiles,System.IOUtils;type
TSplashform = class(TForm)
SplashImage: TImage;
Label1: TLabel;
Label2: TLabel;
lprogram2: TLabel;
lprogram: TLabel;
passwordedit: TEdit;
usernameedit: TEdit;
Backrect: TRectangle;
procedure usernameeditKeyDown(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
procedure passwordeditKeyDown(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
server,Schema,port,database, conectstr,apath:string;
Settings: TIniFile;public
{ Public declarations }
end;var
Splashform: TSplashform;
implementation{$R *.fmx} uses mdata,fMain,System.DateUtils;
procedure TSplashform.FormCreate(Sender: TObject);
begin
//PgTools:=Tstringlist.Create;
apath:= TPath.Combine(TPath.GetDirectoryName(ParamStr(0)), 'Pgtools.ini');
{$IF Defined(MACOS) }
apath:= StringReplace( apath,'MacOS','Resources/Startup',[rfReplaceAll, rfIgnoreCase]);
{$ENDIF}Settings:= TIniFile.Create(apath);
end;
procedure TSplashform.FormDestroy(Sender: TObject);
begin
if Settings<> nil then Settings.Free;end;
procedure TSplashform.FormShow(Sender: TObject);
begin
lprogram.text:=rCommon.sLogoprogram+' current version '+common.OraCurrentVersion;
usernameedit.Text:=Settings.ReadString('Server','Username','');end;
procedure TSplashform.passwordeditKeyDown(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
// var
// s1,s2:string;
begin
if key=vkReturn then
Begin
server:= Settings.ReadString('Server','Server','localhost');
Schema:= Settings.ReadString('Server','Schema','lis');
port:= Settings.ReadString('Server','port','5432');
database:=Settings.ReadString('Server','database','postgres');
conectstr:=format(common.Connectstr,[server,database,Schema]) ;
with dataform do
Begin
LisConnection.Port:=port.ToInteger;
LisConnection.ConnectString:=conectstr;
try
LisConnection.Open;
Mainform.ServerLb.Text:=format(rCommon.sUserConnection,[usernameedit.Text]);
Mainform.ServerLb.FontColor:= TAlphaColorRec.Green;
Common.CurrentUser:=usernameedit.Text;
if Settings<> nil then Settings.Free;
Settings:= TIniFile.Create(apath);
try
Settings.WriteString('Server','Username',Common.CurrentUser);
Settings.WriteString('Server','Connection',DateToISO8601(NOW));
finally
Settings.Free;
end;
Except
On E:EXception do
Mainform.ServerLb.Text:=E.Message;
end;
close;
End;
End;
end;procedure TSplashform.usernameeditKeyDown(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
begin
if Key = vkReturn then
begin
passwordedit.SetFocus
end;
end;end.
-
5 minutes ago, dummzeuch said:It is not be necessary to free Settings before creating it. That change cannot have solved your problem, it's something else that you also changed.
here is the code without free
server:= Settings.ReadString('Server','Server','localhost');
Schema:= Settings.ReadString('Server','Schema','lis');
port:= Settings.ReadString('Server','port','5432');
database:=Settings.ReadString('Server','database','postgres');
conectstr:=format(common.Connectstr,[server,database,Schema]) ;
with dataform do
Begin
LisConnection.Port:=port.ToInteger;
LisConnection.ConnectString:=conectstr;
try
LisConnection.Open;
Mainform.ServerLb.Text:=format(rCommon.sUserConnection,[usernameedit.Text]);
Mainform.ServerLb.FontColor:= TAlphaColorRec.Green;
Common.CurrentUser:=usernameedit.Text;
// if Settings<> nil then Settings.Free;
// Settings:= TIniFile.Create(apath);
// try
Settings.WriteString('Server','Username',Common.CurrentUser);
Settings.WriteString('Server','Connection',DateToISO8601(NOW));
// finally
// Settings.Free;
// end;
Except
On E:EXception do
Mainform.ServerLb.Text:=E.Message;
end;
close;
End;and the results from ini file without freeing and with freeing Connection= CurrentDatetime
-
Can Anyone share information about how to use a report Generator (Fast report or R Builder) inside a Context .
Mars library is grate with many many samples inside , but for reporting (a very important issue on web applications) has no any example
(The Author of Mars Mr Andrea Magni can help us how to start reporting with FastReport or RBuilder).
Thank You Vagelis Bekyros
-
3 minutes ago, David Heffernan said:Use a debugger, and look at what is in apath.
Knowing how to use a debugger is a bit skill.
Thank you David the problem was not the path i free the Settings: TIniFile before a write to the sections
if Settings<> nil then Settings.Free;
Settings:= TIniFile.Create(apath);
try
Settings.WriteString('Server','Username',Common.CurrentUser);
Settings.WriteString('Server','Connection',DateToISO8601(NOW));
finally
Settings.Free;
end;
Now is working as you see
-
17 minutes ago, Hans J. Ellingsgaard said:Have you checked if the user has write rights on the folder where the inifile is placed?
How to check is on Delphi Delphi deployment or on MacBook Pro
Why this is workig TFile.WriteAllText(TPath.GetHomePath() + TPath.DirectorySeparatorChar + 'Sample.txt', 'Hi over there for current user ');
on the same directory i see new file 'Sample.txt'
-
Hi David
This is simple FMX Splash form (login form) before user start working with connected database (Postgres using Devart PgDac Components for Connection)
All the init connections strings are stored in Pgtools.ini file on directory programs is running , but when deploy on MacOS i change the path as you see my project
here is my code attached files , running on windows write settings is working.
On MacBook Pro the software is running OK , logging is successfully after reading Pgtools.ini file settings (Cannot write)
-
I am trying to write on ini file with Delphi Alexandria 11.3 on MacBook Pro ,everything is working except I can't write to ini, the read option is working fine
my ini file
[Server]
Server=192.168.1.103
Database=postgres
Schema=lis
Port=5432
IdleTime=90
Username=nikos
Baseurl=
DicomID=1
Upload=PgTools
Connection=
server:= Settings.ReadString('Server','Server','localhost');
Schema:= Settings.ReadString('Server','Schema','lis');
port:= Settings.ReadString('Server','port','5432');
database:=Settings.ReadString('Server','database','postgres');
all variables are reading Server section
but when i try
Settings.WriteString('Server','Username',Common.CurrentUser);
Settings.WriteString('Server','Connection',DateTimetostr(NOW));
Nothing is happeni have give permissions read/write to the Pgtools,ini file
For example, this code is working TFile.WriteAllText(TPath.GetHomePath() + TPath.DirectorySeparatorChar + 'Sample.txt', 'Hi over there for current user ');
Any Idea -
How to handle a context like (FireDac ,Unidac) with Fastreport Engine loading reports from local file or blob fields
Thank you Vagelis Bekyros
-
Hi am new Onomnithread library , and i examine the TwoFish example i understand how Working Schedule works ,
My question is how can i restart the FWorker.Schedule if database is not connected (for example unstable network) after a few seconds until database be connected ???
In the main thread a create an instance of TComclass
procedure TMainform.Button1Click(Sender: TObject);
begin
acom:= TComclass.Create(nil);acom.OpenConnection(format(common.PostgresConnection,['wwwwwwwww','wwwwwwwwww','wwww']),
procedure (Sender: TObject; FatalException: Exception)
begin
if assigned(FatalException) then
Begin
if FatalException is EDAerror then
Begin
if (FatalException as EDAerror).ErrorCode=0 then
Errormessage.Caption:=FatalException.message
else
Errormessage.Caption:=FatalException.message+inttostr((FatalException as EDAerror).ErrorCode);
End
else
Errormessage.Caption:=FatalException.message;
// ShowMessage('Failed to connect to the database! ' + FatalException.Message)end
else
Begin
Errormessage.Caption:='ComServer database connected' ;
End;
end);end;
Declaration of Tcomlass
procedure TComclass.OpenConnection(const databaseName: string;
onConnectionOpen: TNotify);
begin
FWorker.Schedule(
FWorker.CreateWorkItem(databaseName),
FWorker.Config.OnExecute(ConnectToDatabase).OnRequestDone(
procedure (const Sender: IOmniBackgroundWorker; const workItem: IOmniWorkItem)
begin
if assigned(onConnectionOpen) then
Begin
onConnectionOpen(Self, workItem.FatalException);
if workItem.IsExceptional
then
Begin
fdataModule.lisconnection.ConnectString := workItem.Data.AsString;
fdataModule.lisconnection.Connected := true;
end;
end;
end
));
end;procedure TComclass.ConnectToDatabase(const workItem: IOmniWorkItem);
var
dataModule: TdmComdb;
begin
dataModule := (workItem.TaskState.AsObject as TdmComdb);
dmComdblock.Acquire; //probably only necessary when using InterBase driverdataModule.lisconnection.ConnectString := workItem.Data.AsString;
dataModule.lisconnection.Connected := true;
try
finally
dmComdblock.Release;
end;end;
-
Any one knows a good DICOM (Digital Imaging and Communications in Medicine) library doe Delphi.There are a few Chinese libraries but they totally missing documentation and support
Windows Paint 3D open file using ShellExecute
in VCL
Posted
Thanks that is working