Recent

Author Topic: freepascalvideo only works in Lazarus IDE  (Read 3791 times)

Stygian

  • Jr. Member
  • **
  • Posts: 90
freepascalvideo only works in Lazarus IDE
« on: September 08, 2016, 10:28:44 am »
Hello,

I recently start to play with webcams and i made a simple app with freepascalvideo. If i compile it and run from the lazarus IDE it's works like a charm, but when i try to run the .exe a Video Source Selector pops up and I get black screen(notice: i only have one cam connected). I try to run the oringinal source(same problem), but the compiled "Video Test.exe" is working fine.

OS: Windows 7

Anyone have this issue?

Thanks,
Sty.

Stygian

  • Jr. Member
  • **
  • Posts: 90
Re: freepascalvideo only works in Lazarus IDE
« Reply #1 on: September 09, 2016, 08:16:02 am »
Update:

When I restart the PC it works at first start, but after that it's black screen again.

And the solution:

In your camera connect procedure you have to add the following lines:

Code: Pascal  [Select][+][-]
  1. procedure TFsettings.BstartClick(Sender: TObject);
  2. var
  3.   FDriverCaps: TCapDriverCaps;
  4. begin
  5.   if not(IsCameraConnected)then
  6.    begin
  7.     Camera := TFmainpg.Create(Self);
  8.     Camera.FHandle := @FHandle;
  9.     FHandle := capCreateCaptureWindowA(nil, WS_CHILDWINDOW or WS_VISIBLE or WS_CLIPCHILDREN or WS_CLIPSIBLINGS , Fmainpg.TCamera.Left+ 0, Fmainpg.TCamera.Top- 0, Fmainpg.TCamera.Width- 10, Fmainpg.TCamera.Height-10, Fmainpg.TCamera.Handle, 0);
  10.     Sleep(1000);
  11.     AVICapSM(Fhandle, WM_CAP_DRIVER_CONNECT,0,0);
  12.  
  13. //Other stuffs from here

When you stop the camera you have to add the following lines:
Code: Pascal  [Select][+][-]
  1.     AVICapSM(Fhandle, WM_CAP_STOP,0,0);
  2.     AVICapSM(Fhandle, WM_CAP_DRIVER_DISCONNECT,0,0);

The windows is still pop up but it's working after you press OK.

Some Edit:

After you stopped the camera and want to restart it the window stays black.
Just simply change:
Code: Pascal  [Select][+][-]
  1. WS_CHILDWINDOW or WS_VISIBLE or WS_CLIPCHILDREN or WS_CLIPSIBLINGS
to
Code: Pascal  [Select][+][-]
  1. WS_CHILD or WS_VISIBLE

I'll try to remove that too, and update this post.

Regards,
Sty
« Last Edit: September 09, 2016, 10:51:02 am by Stygian »

 

TinyPortal © 2005-2018