Simplicty and flexibility!


HowTo::

How to Open Web Pages and send email from DataEase 7.2


Parameters


Returns/Result


Examples


Reference

How to Open Web Pages and send email from DataEase 7.2

ShellExecuteA performs an operation on a specified file. It uses the file associations within Windows, so you do not need to know the location of the application just the name of the file you wish to perform the action on. In order to use ShellExecuteA you must first register the following CDF in DataEase 7.2

 

How to Use the ShellExecute API function with DataEase 7.2

 

ShellExecuteA performs an operation on a specified file.
It uses the file associations within Windows, so you do not need to know the location
of the application just the name of the file you wish to perform the action on .

 

See the cAction parameter below for more detail.

 

In order to use ShellExecuteA you must first register the following CDF in DataEase 7

 

Function Name: ShellExecuteA

CDF Library Name: C:\windows\system\shell32.dll

Return Type: Int

Parameters Hndwin Int

CAction String
cFileName String
cParams String
cDir String
nShowWin Int

 

Note: the directory in library name should be your windows\system directory.

 

Description of the parameters

 

Hndwin: Handle to a parent window. This window receives any message boxes that an application produces, such as error reporting. default 0 .

 

cAction: A string, referred to as a verb, that specifies the action to be performed.

The set of available verbs depends on the particular file or folder.
Generally, the actions available from an object’s shortcut menu (the menu that you see when you right click on the object) are available verbs.

The open verb is a good example, as it is commonly supported. For .exe files, open simply launches the application.

However, it is more commonly used to launch an application that operates on a particular file.

For instance, .txt files can be opened by WordPad.

 

The following verbs are commonly used:

 

edit Launches an editor and opens the document for editing.
If cFileName is not a document file, the function will fail.
explore Explores the folder specified by cFileName.
find Initiates a search starting from the specified directory.
open Opens the file specified by the lpFile parameter.

The file can be an executable file, a document file, or a folder.
print Prints the document file specified by cFileName.
If cFileName is not a document file, the function will fail.
If you set this parameter to “” :
For systems prior to Windows 2000, the default verb is used if it is valid and available
in the registry. If not, the “open” verb is used.

For Windows 2000 and later systems, the default verb is used if available. If not, the
“open” verb is used. If neither verb is available, the system uses the first verb listed in
the registry.

 

cFileName: The string that specifies the file or object on which to execute the specified verb.

Note that not all verbs are supported on all objects.

For example, not all document types support the “print” verb.

 

cParams: If the cFileName parameter specifies an executable file, cParams is a string that specifies the parameters to be passed to the application.
The format of this string is determined by the verb that is to be invoked. If cFileName specifies a document file, cParams should be “”.

 

cDir: String that specifies the default directory.

 

nShowWin: Flags that specify how an application is to be displayed when it is opened.
If cFileName specifies a document file, the flag is simply passed to the associated application.

 

It is up to the application to decide how to handle it.

 

0 Hides the window and activates another window. 3 – Maximizes the specified
window.

6 Minimizes the specified window and activates the next top-level window in
the z-order.

9 Activates and displays the window. If the window is minimized or maximized,
Windows restores it to its original size and position. An application should
specify this flag when restoring a minimized window.

5 Activates the window and displays it in its current size and position.

3 Activates the window and displays it as a maximized window.

2 Activates the window and displays it as a minimized window.

7 Displays the window as a minimized window. The active window remains
active.

8 Displays the window in its current state. The active window remains active.

4 Displays a window in its most recent size and position. The active window
remains active. 1 – Activates and displays a window. If the window is
minimized or maximized, Windows restores it to its original size and position.

 

An application should specify this flag when displaying the window for the
first time.

 

Error Messages Returned

Greater than 32 is success

 

0 The operating system is out of memory or resources.
2 The specified file was not found.
3 The specified path was not found.
11 The .exe file is invalid (non-Win32® .exe or error in .exe image).
5 The operating system denied access to the specified file.
27 The file name association is incomplete or invalid.
30 The DDE transaction could not be completed because other DDE transactions
were being processed.
29 The DDE transaction failed.
28 The DDE transaction could not be completed because the request timed out.
32 The specified dynamic-link library was not found.
31 There is no application associated with the given file name extension. This
error will also be returned if you attempt to print a file that is not printable.
8 There was not enough memory to complete the operation.
26 A sharing violation occurred

 

Examples:

 

1- To create a field that will accept a web address and open the browser on that
web address

Create a field on your form called URL ( text 255)
On the LostFocus event for that field put the following script:

 

define “URL” text 255 .

define “retcode” number .
URL := URLFld.Value .
if firstc(URL,4) not= “www.” then
URL := concat (“www.”,URL) .
end
retcode := ShellExecuteA(0,”open”,URL,”",”",1).

As the user exits the field the browser will open and go to the web address entered

 

2- To send an email
Assuming that the email address required is in a field called MailFld (you could hard
code the mailto address if you what to create the equivalent of a mailto button on a
web page).

 

Create either a text object or a button and put the following script on the clicked
event. As the object is clicked the default mail program will open with all of the
details already entered and ready to send. Any of the details can be omitted (for
instance if you don’t want the body text automatically entered leave out mailbody)

 

define “mailstr” text 255 .
define “mailto” text 255 .
define “mailcc” text 255 .
define “mailsubject” text 255 .
define “mailbody” text 255 .
define “retcode” number .
mailto := MailFld.Value .
mailcc :=concat(“CC=”,”ccto@test.com”) .
mailsubject := concat(“Subject=”,”Mail Subject”) .
mailbody := concat(“Body=”,”Mail Body Text”) .
mailstr := concat(“mailto:”,mailto,”?”,mailcc,”&”,mailsubject,”&”,mailbody) .
retcode := ShellExecuteA(0,”open”,mailstr,”",”",1).

 

3- To print a document

 

define “retcode” number .
define “cFileName” Text .
cFileName = “c:\filename.doc” .
retcode := ShellExecuteA(0,”print”,cFileName,”",”",1)

 

Note: If cFileName is not a document file, the function will fail.

 

See Also


On the forum about How to Open Web Pages and send email from DataEase 7.2

[@EOF@]...

Product: . Written by alembagheri tahmas 07/12/13 at 13:37:32

Hi there,I am trying to use an external MySQL DB in dataease. I have successfully create the ODBC link and added the DB to dataease. I can also access the DB from dataease. Now, just for testing purposes, I am trying to create a simple report b...

Product: DataEase for Windows 7.x. Written by George Washington 11/04/14 at 08:26:17

no se pude exportar ahora archivos a pdf, ni a excel o otros cosa mala. en verdad creo que hace faltaen las versiones anteriores me funcionaba mas o menos bien. le hace falta a los aplicativos que se desarrollan en Dataeasegr...

Product: DataEase 8 Reporter. Written by eduardo paez 02/05/14 at 14:40:11

Thanks. Anyway I'm trying to use this fuction but it seems to me that it doesn't work on 8.2. I tried also in a DQL.There's something wrong?<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA9IAAAJ3CAYAAAB4NWk3AAAAAXNSR0IArs4...

Product: . Written by Marco Marchesi 15/02/16 at 14:50:46

[@EOF@]...

Product: Dataease [{8}]FIVE. Written by Chamil Rajindra 21/02/19 at 10:17:46

Thanks for the very good explanation!AS...

Product: . Written by afonso santos 28/10/19 at 00:50:14

I am pleased to see that the migration from Dos 4.53 is then sa 5.5 works. A really useful thing would be a compiler of SQL languages. Will you get there?Original Text:Mi compiaccio a vedere che la migrazione da Dos 4.53 รจ poi sa 5.5 funzio...

Product: . Written by Grossi Gioacchino 18/11/19 at 14:33:44

How can i delete a Style sheet?...

Product: Dataease [{8}]FIVE. Written by Rainer 22/03/21 at 11:13:10

I run W7 and since a few days&nbsp;Dataease 8.5 is not starting any more, do you have an idea? i installed it again but that did not help....

Product: Dataease [{8}]FIVE. Written by Rainer 08/06/21 at 14:12:40

[@EOF@]...

Product: . Written by Hiralal Rampul 01/12/21 at 17:47:10

On the blog about How to Open Web Pages and send email from DataEase 7.2


dg3_HelpView