How to close Camera app after opening it using CameraCaptureDialog

H

Heather B.

Hi,

I am using the following code from my VB.NET program to take a picture and
save it to the database. Everything works fine, except when I close my
program, the camera application is still open. Is there anyway to close
this app from inside of VB after I'm done taking pics?

Dim cameraDialog As New CameraCaptureDialog

With cameraDialog
.Owner = Me
.Mode = CameraCaptureMode.Still
.StillQuality = CameraCaptureStillQuality.Normal
.Title = "Take a Picture"
.DefaultFileName = strFileName
.InitialDirectory = strDirectory
End With

'code that saves the picture to the database
and displays it in a list

cameraDialog = Nothing

Thanks,
Heather
 
P

Paul G. Tobey [eMVP]

You could try sending the OK button to it as a key. OpenNETCF has a wrapper
for PostKeybdMessage that should do that.

Not sure that this is the best/right way to do it, but I think that it will
work.

Paul T.
 
G

Guest

I'd just like to know if a solution to this problem was ever identified. I
have run into the same issue in a C# app. If possible, I'd like a solution
that does not involve OpenNETCF, since my app does not otherwise require it.

Thank you,

Matthew Fleming
DermVision
 
G

Guest

Paul G. Tobey said:
You could try sending the OK button to it as a key. OpenNETCF has a wrapper
for PostKeybdMessage that should do that.

Not sure that this is the best/right way to do it, but I think that it will
work.

Paul T.

I wasn't able to follow this advice, because I couldn't figure out how to
press the "OK" button using PostKeybdMessage. There is a virtual key code for
a mouse click, but how can we know the pointer is positioned over the button?

Instead, here is what seems to work:

extern "C" __declspec(dllexport)
void closeCameraApp() {

HWND cameraHandle = FindWindow(L"WCE_IA_Camera_Main", NULL);
if (cameraHandle!=NULL)
SendMessage(cameraHandle, WM_CLOSE, NULL, NULL);
}

This is called via PInvoke from managed code, of course. The
"WCE_IA_Camera_Main" window class I got using Remote Spy. Hopefully it will
work for CameraCaptureDialog running on any device, but I have only one
device for testing, an HTC Apache.

Regards,

Matthew Fleming
DermVision, LLC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top