Steve's Digicams Forums

Steve's Digicams Forums (https://forums.steves-digicams.com/)
-   Remote Control (https://forums.steves-digicams.com/remote-control-46/)
-   -   The sample of Remote Control with Canon SDK(ViewFinder part) (https://forums.steves-digicams.com/remote-control-46/sample-remote-control-canon-sdk-viewfinder-part-96912/)

WWWSpider Aug 2, 2006 5:14 AM

1.call the SDK function of StartSDK.

var Err:cdErr;
Ver:cdVersionInfo;
.........

Ver.MajorVersion :=7;
Ver.MinorVersion :=1;
Ver.Size :=Sizeof(ver);
Result :=cdINVALID;
Err := CDStartSDK(Ver, 0);
if Err<>cdOK then
exit;
2.call CDEnumDeviceReset,CDGetDeviceCount,CDEnumDeviceNex t,CDEnumDeviceRelease function to select source.It is very easy.

3.you must call like this to enter remote control mode.

Err := CDLockUI(m_hSource);
If Err <> cdOK Then
exit;

Err := CDEnterReleaseControl(m_hSource,@Rel_CallBackFunc, 0 );
If Err <> cdOK Then
exit;

Err := CDUnlockUI(m_hSource);
If Err <> cdOK Then
exit;
4.Register a release callback function to reture the release event
function Rel_CallBackFunc(EventID:cdReleaseEventID;pData:po inter;DataSize:cdUInt32;Context:cdContext): cdUInt32 stdcall;
begin
.......
Result :=cdOK;
end;
5.ViewFinder part
define BmpData as TBitmap of a gobal variant

function ViewFinder_CallbackFunction(pBuf:pointer;Size:cdUI nt32;Format:cdUInt32;Context : cdContext) : cdUInt32 stdcall;
var BmpStream:TMemoryStream;
begin
BmpStream :=TMemoryStream.Create;
Try
BmpStream.WriteBuffer(pBuf^,Size);
BmpStream.Position :=0;
BmpData.LoadFromStream(BmpStream);
Result :=cdOK;
finally
BmpStream.Free;
end;
end;


Register the Viewfinder call back function


cdStartViewFinder(m_hSource,1,@ViewFinder_Callback Function,0);
ViewFinderTimer.Enabled :=True; //the timer of paint

Draw the image of viewfinder

procedure TfrmMain.ViewFinderTimerTimer(Sender: TObject);
begin
Image1.Canvas.CopyRect(Image1.Canvas.ClipRect,BmpD ata.Canvas,BmpData.Canvas.ClipRect);
end;
==================================================

the code is compiled with Delphi 7 without error and work OK.
Pls. do not ask me to send you the SDK,because the copyright is under the law.
best regards.




minwhei Mar 7, 2007 12:53 AM

Dear WWWSpider:

may i ask how to define the "CDEnterReleaseControl" function.

you have call the function:

Err := CDEnterReleaseControl(m_hSource,@Rel_CallBackFunc, 0 );
If Err <> cdOK Then
exit;

and I wanna to know how to define the "CDEnterReleaseControl" Function

if i define

function CDEnterReleaseControl(
hSource :cdHSource;
var pFunc :Rel_CallBackFunc
Context :CdContext
):cdUInt32 ; stdcall;external cdsdk;


and

function Rel_CallBackFunc(EventID: cdReleaseEventID;
pData: pointer; DataSize: cdUInt32; Context: cdContext): cdUInt32;
begin
//
Result :=cdOK;
end;

when i compiler , it display "Rel_CallBackFunc" is not a type identifier...
would you tell my why ??

thanks your help !



All times are GMT -5. The time now is 6:38 PM.