Re: [Lazarus] Dynamic Form Components - SynEdit Help Please...

2016-10-03 Thread Martin Collins via Lazarus
I understand now you've explained it and again slap my face in stupidity. Thank you very much indeed. Much appreciated. 
Martin
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Dynamic Form Components - SynEdit Help Please...

2016-10-03 Thread Martin Collins via Lazarus
Thanks very much. I was googling about dynamically created components and that led me down the path of RTTI, to the point I became confused. Why I didn't see your answer makes me slap my face in stupidity. Thank you very much for your help. Much appreciated.
Martin
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Dynamic Form Components - SynEdit Help Please...

2016-10-03 Thread Martin Frb via Lazarus

See mail from Mattias.

On 03/10/2016 22:17, Martin Collins via Lazarus wrote:


  If IsPublishedProp(Comp, 'Lines') then
  begin
PropInfo := GetPropInfo(Comp, 'Lines', [tkClass]);

SynEdit.Lines is TStrings, not TStringList.


HTMLFile := TStringList(GetObjectProp(Comp, PropInfo, TStrings));
If anything, you get a reference to the SynEdit.LInes object, but you do 
NOT create a new object here




HTMLFile.Free;

So this then is the same as
  SynEdit.Lines.Free;
And that you should not do.

--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Dynamic Form Components - SynEdit Help Please...

2016-10-03 Thread Martin Collins via Lazarus

I apologise for emailing but need a little bit of help please.

Creating form components dynamically is a new area of pascal programming 
for me and I have become stuck. My application is supposed to be an 
editor that can open multiple files for editing. I have a page control 
and when opening a new file I add a page and place a synedit on the page 
on it's own, into which the file is loaded. The loading works fine - I 
create a stringlist, loadfromfile, then SetObjectProp(Component, 
PropInfo['Lines'], StringList). StringList.Free works without error.


However, when I try to save the file the following code works, insomuch 
the file is saved to disk, but the application crashes when trying to 
free the stringlist (HTMLFile.Free) with the error 'Project raised 
exception class 'External: SIGSEGV' At address 4201C3'. If I don't free 
the stringlist, the application does not crash but I'm left with a 
memory leak as indicated in my heap.trc file.


I have a feeling that HTMLFile is not actually a stringlist, I'm just 
forcing it to be one here - HTMLFile := TStringList(GetObjectProp(Comp, 
PropInfo, TStrings)); If that's the case, how can I get and/or save the 
text from the dynamically created synedit. This has been puzzling me for 
days now


Many thanks for your help.

Martin Collins

Using Lazarus 1.6, FPC 3.0.0, Linux x86_64 gtk2



procedure TMainForm.SaveSynEdit(ThisPage: Integer);
var
  HTMLFile: TStringList;
  Filename: String;
  Comp : TComponent;
  PropInfo: PPropInfo;
begin
  FileSaveDialog.Title:= 'Save File...';
  FileSaveDialog.DefaultExt := 'html'; //default extension
  FileSaveDialog.Filter := 'HTML source file|*.html';
  Filename:= FileList[ThisPage];
  FileSaveDialog.FileName:= Filename + '.html';
  If FileSaveDialog.Execute then
  begin
HTMLFile:= TStringList.Create;
Comp := PageControlEditor.ActivePage.Controls[0];
If Comp is TWinControl then
begin
  If IsPublishedProp(Comp, 'Lines') then
  begin
PropInfo := GetPropInfo(Comp, 'Lines', [tkClass]);
HTMLFile := TStringList(GetObjectProp(Comp, PropInfo, TStrings));
Filename:= FileSaveDialog.FileName;
HTMLFile.SaveToFile(Filename);
HTMLFile.Free;
FileList[ThisPage]:= Filename;
PageControlEditor.ActivePage.Caption:= ExtractFileName(Filename);
PageControlEditor.ActivePage.Font.Style:= [];
PageControlEditor.ActivePage.Font.Color:= clDefault;
  end;
end;
  end;
end;

--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] TPageControl OnChange calling issue

2016-10-03 Thread Bart via Lazarus
On 10/3/16, Michael W. Vogel via Lazarus  wrote:

OT reply: I can't see you on contributors list?

Bart
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] TPageControl OnChange calling issue

2016-10-03 Thread Bart via Lazarus
On 10/3/16, Michael W. Vogel via Lazarus  wrote:

> If I understand Bart right, he had a fix for that bug report,

Not yet ;-)

Bart
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] TPageControl OnChange calling issue

2016-10-03 Thread Michael W. Vogel via Lazarus

Am 03.10.2016 um 19:34 schrieb Ondrej Pokorny via Lazarus:

Isn't TTabSheet.OnShow enough for you?

Ondrej


Interesting approach!

I've just tested it in one of my apps and yes, it seems to work too. So 
this could be a obviously better solution for me.


Thank you for that hint!

Kind regards

Michl

--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] TPageControl OnChange calling issue

2016-10-03 Thread Ondrej Pokorny via Lazarus

On 03.10.2016 19:01, Michael W. Vogel via Lazarus wrote:

Hi,

we want to discuss a bug report 
http://bugs.freepascal.org/view.php?id=25554 here, not in Mantis 
(hope, I understand Bart right).


Today, the TPageControl.OnChange event behave different in Lazarus 
than in Delphi. In Delphi it is only called (so the bug report), if 
the user change the page. In Lazarus it is also called, when the page 
is changed by code.


Isn't TTabSheet.OnShow enough for you?

Ondrej
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] TPageControl OnChange calling issue

2016-10-03 Thread Michael W. Vogel via Lazarus

Hi,

we want to discuss a bug report 
http://bugs.freepascal.org/view.php?id=25554 here, not in Mantis (hope, 
I understand Bart right).


Today, the TPageControl.OnChange event behave different in Lazarus than 
in Delphi. In Delphi it is only called (so the bug report), if the user 
change the page. In Lazarus it is also called, when the page is changed 
by code.


I like (need) the behaviour in Lazarus, cause I mostly use blank 
TPageControls, with dynamic added pages and filled with dynamic created 
TFrames (created on demand). So for me it isn't important, if the user 
select a page or it is selected by code, I need the OnChange event to 
create or initialize the TFrame.


If I understand Bart right, he had a fix for that bug report, but than 
the behaviour now is gone.


I would prefer a option like nboCallPageChangeByCodeSelection to keep 
the current behaviour (so it doesn't break Lazarus code). A other 
possibility would be a new event like OnChangePage (as a replacement for 
the current Lazarus TPageControl.OnChange).

I wouldn't throw the current (in my eyes: better) behaviour away.

What is your opinion?

Kind regards

Michl
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Plivo API

2016-10-03 Thread Mattias Gaertner via Lazarus
On Mon, 3 Oct 2016 08:36:03 +0200
duilio foschi via Lazarus  wrote:

> Hi Mattias,
> 
> your code shows what Plivo probably does :)

Sorry. I misunderstood.
I don't know if TFPHttpServer already supports HTTPS.

Mattias
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Plivo API

2016-10-03 Thread duilio foschi via Lazarus
Hi Mattias,

your code shows what Plivo probably does :)

After recording a call, Plivo will call my remote application X (I
will write the URI of X in a configuration file) with Https/Post.

At the time of the request Plivo passes the URI of a MP3 file to application X.

This information is written in a XML file, but lets say a text file
just to hide details.

I need to write application X.

This application X wont make calls, but will be called from 3th party
software (Plivo).

How do I read the parameters passed when a Https/Post request is done
to my code ?

Thank you

Peppe

2016-10-02 21:36 GMT+02:00 Mattias Gaertner via Lazarus
:
> On Sun, 2 Oct 2016 20:45:08 +0200
> duilio foschi via Lazarus  wrote:
>
>> I am wetting my feet in Plivo API (www.plivo.com).
>>
>> "
>> Plivo communicates with remote applications built by businesses
>> through a series of API calls. These back and forth calls between
>> Plivo and other applications are communicated through XML (Extensible
>> Markup Language).
>> "
>>
>> Say that at a given time Plivo calls application X with HTTPS/Post and
>> passes it a XML file.
>>
>> I need to write a minimal application X in Lazarus that will write the
>> XML file to disk
>>
>> Could you point me to some sample code possibly using Synapse ?
>
> You don't need Synapse if you only need to download a file. FPC
> provides a HTTP client:
>
> function DownloadText(const URL: string): TStrings;
> var
>   client: TFPHTTPClient;
>   doc: TStringList;
> begin
>   Result:=nil;
>   doc:=TStringList.Create;
>   client:=TFPHTTPClient.Create(nil);
>   try
> client.Get(URL,doc);
> Result:=doc;
> doc:=nil;
>   finally
> doc.Free;
> client.Free;
>   end;
> end;
>
>
> Mattias
> --
> ___
> Lazarus mailing list
> Lazarus@lists.lazarus-ide.org
> http://lists.lazarus-ide.org/listinfo/lazarus
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus