Re: [fpc-pascal] Can't close and reopen ptcgraph

2017-06-28 Thread James Richters
>add  ptcwrapper to uses list.
Thank you,  that worked!

James

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can't close and reopen ptcgraph

2017-06-28 Thread Stefan V. Pantazi

add  ptcwrapper to uses list.



I get reopengraph.pas(32,23) Error: Identifier not found "TPTCWrapperThread"


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can't close and reopen ptcgraph

2017-06-28 Thread James Richters
I thought I would try to get my demo program to work.  When I try to compile it 
with

//manually create the ptcwrapper thread
PTCWrapperObject := TPTCWrapperThread.Create;

I get reopengraph.pas(32,23) Error: Identifier not found "TPTCWrapperThread"

Demo program below... Any ideas?

James

{$mode objfpc}{$H+}
program ReOpenGraph.pas;
uses
  ptcgraph,ptccrt;
var
  gd,gm : smallint;

begin
  gd:=d8Bit;
  gm:=m800x600;
  Writeln('Opening Graphics Window');
  Initgraph(gd,gm,'');
  Writeln('Graphics Window Open');
  setcolor($4A);
  settextstyle(Defaultfont,HORIZDIR,2);
  outtextxy(30,30,'Graphics Window Open');
  readkey;
  //close graph window
  Closegraph;
  //manually terminate the ptcwrapper thread and free object
  PTCWrapperObject.Terminate;
  PTCWrapperObject.WaitFor;
  PTCWrapperObject.Free;
  Writeln('Closing Graphics Window');
  readln;
  Writeln('Create ptcwrapper thread');
  //manually create the ptcwrapper thread
  PTCWrapperObject := TPTCWrapperThread.Create; //compiler error 
  Writeln('Re-Opening Graphics Window');
  //init graph windows as usual
  Initgraph(gd,gm,''); // window opens then closes immediately with ptcgraph
  Writeln('Graphics Window Open Again'); // this never happens with ptcgraph
  setcolor($4A);
  settextstyle(Defaultfont,HORIZDIR,2);
  outtextxy(30,30,'Graphics Window Open Again');
  Readln;
  Closegraph;
end.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can't close and reopen ptcgraph

2017-06-23 Thread James Richters
>As a workaround, you can manually take care of the ptcwrapper object like 
>this, in between closegraph and initgraph calls, but first ask yourself, do 
>you really need this?

Thanks for figuring out what is going on.  I don't really need to close it and 
reopen it. I can work around by just hiding the window with 
ShowWindow(graphwindow,SW_hide);

To get back to my console window, then when needed I can clear it and show it 
again with.
ShowWindow(graphwindow,SW_show);

James


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can't close and reopen ptcgraph

2017-06-23 Thread Stefan V. Pantazi
I think I figured it out. It hink ptcgraph was not designed with that 
functionality in mind. If you take a look at the ptcgraph unit, it has 
initialization and finalization sections where the ptc wrapper object is 
created and freed. That happens only at application start and finish not 
during run, as you require.


As a workaround, you can manually take care of the ptcwrapper object 
like this, in between closegraph and initgraph calls, but first ask 
yourself, do you really need this?


[...]
//close graph window
ptcgraph.Closegraph;

//manually terminate the ptcwrapper thread and free object
PTCWrapperObject.Terminate;
PTCWrapperObject.WaitFor;
PTCWrapperObject.Free;

//manually create the ptcwrapper thread
PTCWrapperObject := TPTCWrapperThread.Create;

//init graph windows as usual
ptcgraph.Initgraph(gd,gm,'');
[...]

Stefan

On 06/23/2017 11:20 AM, James Richters wrote:

I ran into an unexpected issue with ptcgraph.  If I use closegraph, I
cannot re-open a new ptcgraph window with Initgraph.  It looks like it
opens the second graph window but then closes it immediately after.. my
program is then appears to be locked up after this happens.. no errors,
just locked up.   test program is below.  If I comment out ptcgraph and
ptccrt and uncomment graph and wincrt, it works as expected.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can't close and reopen ptcgraph

2017-06-23 Thread Stefan V. Pantazi
On Linux 64bit, reopening of a second window works fine, as expected. On 
Windows it does not, and behaves as you reported. This is most likely 
related to the use of a separate thread (TPTCWrapperThread) in ptcgraph. 
As far as I know graph and wincrt do not use threads. I suspect that on 
windows, the ptc thread is not properly terminating for some reason.


Stefan

On 06/23/2017 11:20 AM, James Richters wrote:

I ran into an unexpected issue with ptcgraph.  If I use closegraph, I
cannot re-open a new ptcgraph window with Initgraph.  It looks like it
opens the second graph window but then closes it immediately after.. my
program is then appears to be locked up after this happens.. no errors,
just locked up.   test program is below.  If I comment out ptcgraph and
ptccrt and uncomment graph and wincrt, it works as expected.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Can't close and reopen ptcgraph

2017-06-23 Thread James Richters
I ran into an unexpected issue with ptcgraph.  If I use closegraph, I cannot
re-open a new ptcgraph window with Initgraph.  It looks like it opens the
second graph window but then closes it immediately after.. my program is
then appears to be locked up after this happens.. no errors, just locked up.
test program is below.  If I comment out ptcgraph and ptccrt and uncomment
graph and wincrt, it works as expected.

 

James

 

 

program ReOpenGraph.pas;

 

{$mode objfpc}{$H+}

 

uses

  ptcgraph,ptccrt;

//  graph,wincrt;

 

var

  gd,gm : smallint;

 

begin

  gd:=d8Bit;

  gm:=m800x600;

  Writeln('Opening Graphics Window');

  Initgraph(gd,gm,'');

  Writeln('Graphics Window Open');

  setcolor($4A);

  settextstyle(Defaultfont,HORIZDIR,2);

  outtextxy(30,30,'Graphics Window Open');

  readkey;

  Closegraph;

  Writeln('Closing Graphics Window');

  readln;

  Writeln('Re-Opening Graphics Window');

  Initgraph(gd,gm,''); // window opens then closes immediately with ptcgraph

  Writeln('Graphics Window Open Again'); // this never happens with ptcgraph

  setcolor($4A);

  settextstyle(Defaultfont,HORIZDIR,2);

  outtextxy(30,30,'Graphics Window Open Again');

  Readln;

  Closegraph;

end.

 

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal