Recent

Author Topic: Lazarus and TProcess  (Read 11711 times)

apostleofchrist

  • New Member
  • *
  • Posts: 21
Lazarus and TProcess
« on: April 07, 2012, 06:59:43 pm »
Hello everyone!

I'd like to asky you all a little help about a certain issue...

Here's the scenario:

My application call another applicarion using TProcess. So far, so good the applications starts and everything looks fine, but...
My main application window loses focus. Of course, if I click on it it gets it again. Is there any way to do this inside the application itself, after the external application call? Remarks: I don't care about the external application messages, neither i need to wait for any process from it. I just want to set the main application as the active one.

Thanks in advance for any help, from anyone.

May the Lord bless you all.

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: Lazarus and TProcess
« Reply #1 on: April 07, 2012, 08:52:26 pm »
If it's a Windows Application, then the best solution is to open the process without activation in the first place.

eg.  TheProcess.ShowWindow := swoShowNoActivate;


apostleofchrist

  • New Member
  • *
  • Posts: 21
Re: Lazarus and TProcess
« Reply #2 on: April 09, 2012, 12:27:49 am »
Thanks for your reply! But, unfortunately it didn't worked.  It seems that the focus continue on the application called by tprocess.

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: Lazarus and TProcess
« Reply #3 on: April 09, 2012, 12:45:34 am »
Does swoHIDE work?

If it does, one idea might be to do it this way, and then manually set the process visibility using Postmessage, again this is not a cross platform solution, it's windows only.

joseme

  • Full Member
  • ***
  • Posts: 128
    • Logosoft sistemas
Re: Lazarus and TProcess
« Reply #4 on: April 09, 2012, 02:51:00 pm »
I have compiled a small program to try myself, and it seems not to be any problem, may be your app is modal, if I call calc.exe from a process and after that show a message from the calling app, everything ok. If I want to give the focus to calc, I have to add this line
Code: [Select]
AProcess.Options := AProcess.Options + [poWaitOnExit]; to he code.
un aporte a la comunidad:
http://pascalylazarus.blogspot.com/

apostleofchrist

  • New Member
  • *
  • Posts: 21
Re: Lazarus and TProcess
« Reply #5 on: April 10, 2012, 04:15:16 am »
Thanks again for your assistance on this matter! I really appreciate it!

Now, here is what I'm trying to do. The app i'm calling is the VLC player. It must play a certain video while my application do another stuff.
My app has only one Form, which is the Main form. It is not modal, but borderstyle is set to bsNone and windowstate is wsMaximized.
When my app is called, it hides everything, including Windows task bar, which is the desired effect for this application. Now, when I call the VLC player, the focus change to it and the task bar reappears. Here is an interesting thing: When I click on the main window of my app, the focus go back to it and the task bar is hidden again. Here it is the paramaters for the VLC call:

Code: [Select]
              VLCParametros := '-I dummy --dummy-quiet --no-embedded-video --no-video-deco --video-on-top  --no-video-title-show ' +
                     '--video-title="VLC" ' +
                     '--video-x=' + IntToStr(927) + ' ' +
                     '--video-y=' + IntToStr(Image2.Top) + ' ' +
                     '--width=' + IntToStr(Image2.Width) + ' ' +
                     '--height=' + IntToStr(Image2.Height) + ' ' +
                     '--volume=200 ' +
                     '"' + video + '"';

Oh, one more thing. Before you suggest I use the PasLibVlc let me tell you that I've tried that but, unfortunately, it seems that component needs a little more work. Why? Well, the application crashes after a few minutes playing the video. So, I had to search for a new approach for the problem.

Once again, thank you for your replies.

May the Lord bless you all. :)

apostleofchrist

  • New Member
  • *
  • Posts: 21
Re: Lazarus and TProcess
« Reply #6 on: April 18, 2012, 06:18:00 pm »
Hello everyone!

Does anyone has a solution for my problem? I really need it!

Thanks again!

God bless!  :D

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Lazarus and TProcess
« Reply #7 on: April 18, 2012, 07:21:38 pm »
You can use the VLC ActiveX object. More info here http://wiki.freepascal.org/LazActiveX.

Only available with lazarus and fpc from svn trunk!!!


apostleofchrist

  • New Member
  • *
  • Posts: 21
Re: Lazarus and TProcess
« Reply #8 on: April 20, 2012, 04:32:03 am »
Hey ludob!

Thanks for your reply. Unfortunately I'm having some throuble finding the ActiveX package. I tried to follow the instructions from the wiki page, but I can't find the LazActiveX 0.1 where it says it can be found. It's not on the list.

My lazarus is the most recent one for windows: 0.9.30.4

Thanks again!

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Lazarus and TProcess
« Reply #9 on: April 20, 2012, 08:32:52 am »
The package is very recent and only available in Lazarus and fpc from svn. More info here: http://wiki.freepascal.org/Getting_Lazarus.

apostleofchrist

  • New Member
  • *
  • Posts: 21
Re: Lazarus and TProcess
« Reply #10 on: April 20, 2012, 03:28:46 pm »
I've got the files from svn but when I try to install the component I've got the following messages:

Code: [Select]
C:\lazarus\components\activex\activexcontainer.pas(85,23) Error: No matching implementation for interface method "IOleInPlaceSite.CanInPlaceActivate:LongInt;" found
C:\lazarus\components\activex\activexcontainer.pas(85,23) Error: No matching implementation for interface method "IOleInPlaceSite.OnInPlaceActivate:LongInt;" found
C:\lazarus\components\activex\activexcontainer.pas(85,23) Error: No matching implementation for interface method "IOleInPlaceSite.OnUIActivate:LongInt;" found

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Lazarus and TProcess
« Reply #11 on: April 20, 2012, 04:37:07 pm »
Looks like you are still using an older compiler. Did you also install fpc from svn? Info can be found on the same wiki page.
Verify also your lazarus configuration (Tools/Options) and check that it is using the new compiler. Fpc.cfg could also point to older units.

apostleofchrist

  • New Member
  • *
  • Posts: 21
Re: Lazarus and TProcess
« Reply #12 on: April 22, 2012, 12:52:42 am »
My fpc version is 2.6.0. The wiki says that the ActiveX component requires 2.6.1. Now, how can I updare my fpc? I usually download lazarus installer package for win32 and it does all the job. I always get the most recent version from sourceforge. I don't know how to update only the fpc of my instalation. What can I do?

Thanks again!

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Lazarus and TProcess
« Reply #13 on: April 22, 2012, 08:57:46 am »
Probably the best solution is to use fpcup. Download from https://bitbucket.org/reiniero/fpcup/downloads, more info http://forum.lazarus.freepascal.org/index.php/topic,15919.0.html.
fpcup will install a complete lazarus and fpc environment from svn in a separate directory. So it doesn't touch your existing installation.
fpcup downloads per default fpc 2.6.1 but a patch that is important for VLC AcitveX hasn't been back-ported yet to 2.6.1. To use 2.7.1 start fpcup with the following command:
Code: [Select]
fpcup --fpcURL=http://svn.freepascal.org/svn/fpc/trunk

An alternative is installing CodeTyphon 2.6.0 released yesterday. http://www.pilotlogic.com/sitejoom/index.php/codetyphon. It contains fpc 2.7.1 and lazarus 1.1 from svn dated 20/4 and has LazActiveX pre-installed in the bigide. Install it on a separate machine if you want to keep your existing release version compiler.

 

TinyPortal © 2005-2018