PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → Calling APIs in WinDev Mobile 18 (involves an api structure)
Calling APIs in WinDev Mobile 18 (involves an api structure)
Débuté par rob, 21 mai 2014 16:33 - 6 réponses
Membre enregistré
105 messages
Posté le 21 mai 2014 - 16:33
I'm currently writing a program in WDM18 for a Windows CE 6.0 device.
I ran into some problems using the built in WDM camera control, so I have to use the API's provided on the device to take pictures.

I can successfully call the necessary API's using the API Description variable type without any problems.

However I'm a little confused on how to access one of the provided APIs to set the path for the image it saves.

Here is the API as described in the device documentation:

SetStillCaptureState:
Purpose: Sets how to take pictures.
Syntax: DWORD SetStillCaptureState (PICSTATE *picInfo);
Parameters: picInfo
[in] Pointer to structure PICSTATE where the settings are stored.
Return Value: If successful, it returns 0. Otherwise it returns a non-zero value to indicate a specific error:

The PICSTATE structure is described as follows:
typedef struct
{
INT AutoExposure;
INT AutoWhiteBalance;
INT ImageFormat;
WCHAR lpPathName[500];
INT PathSize;
WCHAR lpFileName[500];
INT FileSize;
} PICSTATE, *PPICSTATE;


I'm unsure how to access this in WinDev Mobile. Any suggestions would be greatly appreciated.


As a reference, here is one of the other functions I am able to call successfully.

StartStillCapture:
Purpose: Starts taking pictures.
Syntax: DWORD StartStillCapture (INT playSound);
Parameters: playSound
[in] Integer variable
0 = No sound
1 = Sound to notice of a picture taken.
Return Value: If successful, it returns 0. Otherwise, it returns a non-zero value to indicate a specific error.

And the code I use to call StartStillCapture:
CapturePic is API Description
CapturePic..DLLName = "SystemCE"
CapturePic..FunctionName = "StartStillCapture"
CapturePic..ReturnType = apiSystemInt
CapturePic..Parameter[1]..Type = apiSystemInt
ResCapturePic is int
PlaySound is bool

PlaySound = True
CapturePic(PlaySound)


I can also provide the PDF documentation for the unit if it would help.

Many thanks for any assistance.
Posté le 21 mai 2014 - 20:37
Hi Rob

you need to declare a structure in wlanguage, with the EQUIVALENT format
as the one described in the documentation (for the equivalence, look at
the pages regarding API in the help, there is a full page about it)

Once this is done, you need to call your function and pass to it
&NameOfStructure

Best regards


--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXShowroom.com is available: Show your projects!
More information on http://www.fabriceharari.com


On 5/21/2014 8:33 AM, rob wrote:
I'm currently writing a program in WDM18 for a Windows CE 6.0 device.
I ran into some problems using the built in WDM camera control, so I
have to use the API's provided on the device to take pictures.

I can successfully call the necessary API's using the API Description
variable type without any problems.

However I'm a little confused on how to access one of the provided APIs
to set the path for the image it saves.

Here is the API as described in the device documentation:

SetStillCaptureState:
Purpose: Sets how to take pictures.
Syntax: DWORD SetStillCaptureState (PICSTATE *picInfo);
Parameters: picInfo
[in] Pointer to structure PICSTATE where the
settings are stored.
Return Value: If successful, it returns 0. Otherwise it returns a
non-zero value to indicate a specific error:

The PICSTATE structure is described as follows:
typedef struct
{
INT AutoExposure;
INT AutoWhiteBalance;
INT ImageFormat;
WCHAR lpPathName[500];
INT PathSize;
WCHAR lpFileName[500];
INT FileSize;
} PICSTATE, *PPICSTATE;


I'm unsure how to access this in WinDev Mobile. Any suggestions would be
greatly appreciated.


As a reference, here is one of the other functions I am able to call
successfully.

StartStillCapture:
Purpose: Starts taking pictures.
Syntax: DWORD StartStillCapture (INT playSound);
Parameters: playSound
[in] Integer variable
0 = No sound
1 = Sound to notice of a picture taken.
Return Value: If successful, it returns 0. Otherwise, it returns a
non-zero value to indicate a specific error.

And the code I use to call StartStillCapture:
CapturePic is API Description
CapturePic..DLLName = "SystemCE"
CapturePic..FunctionName = "StartStillCapture"
CapturePic..ReturnType = apiSystemInt
CapturePic..Parameter[1]..Type = apiSystemInt
ResCapturePic is int
PlaySound is bool

PlaySound = True
CapturePic(PlaySound)


I can also provide the PDF documentation for the unit if it would help.

Many thanks for any assistance.
Membre enregistré
105 messages
Posté le 21 mai 2014 - 22:39
Ok, so I need to use the API() function instead of the API Description variable type?

Thanks I'll give it a shot.
Posté le 22 mai 2014 - 13:42
Hi Rob



On 5/21/2014 2:39 PM, rob wrote:
Ok, so I need to use the API() function instead of the API Description
variable type?


no, you do not... My point was about delacring the proer structure to
pass in your call via EITHER of those methods

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXShowroom.com is available: Show your projects!
More information on http://www.fabriceharari.com



Thanks I'll give it a shot.
Membre enregistré
105 messages
Posté le 23 mai 2014 - 16:37
Thank you for your help Fabrice.

I'm getting close to getting it to work correctly using the API() function.

Out of curiosity, if I wanted to use the API Description Variable type, what would you set the Parameter[x]..Type to in order to pass it a structure?
From what I can see, the documentation only lists the following variable types.
apiBoolean
apiBuffer
apiCharacter
apiAnsiCharacter
apiUnicodeCharacter
apiString
apiAnsiString
apiUnicodeString
apiInt_4
apiInt_8
apiSystemInt
apiReal_4
apiReal_8
Posté le 23 mai 2014 - 17:31
Hi Rob

as you always pass a structure by its address, I would think that a
system int would be appropriate

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXShowroom.com is available: Show your projects!
More information on http://www.fabriceharari.com


On 5/23/2014 8:37 AM, rob wrote:
Thank you for your help Fabrice.

I'm getting close to getting it to work correctly using the API() function.

Out of curiosity, if I wanted to use the API Description Variable type,
what would you set the Parameter[x]..Type to in order to pass it a
structure?
From what I can see, the documentation only lists the following
variable types.
apiBoolean
apiBuffer
apiCharacter
apiAnsiCharacter
apiUnicodeCharacter
apiString
apiAnsiString
apiUnicodeString
apiInt_4
apiInt_8
apiSystemInt
apiReal_4
apiReal_8
Membre enregistré
105 messages
Posté le 23 mai 2014 - 20:20
Got ya. I should have known that...
You've been a huge help. Thank you.

Now I just have to figure out why it's accepting the lpPathName value of that structure, but not the lpFileName value.,