The Open event has different arguments for different objects:
Object |
See |
---|---|
Application |
|
Window |
Occurs when the user starts the application.
Event ID |
Objects |
---|---|
None |
Application |
Argument |
Description |
---|---|
commandline |
String by value. Additional arguments are included on the command line after the name of the executable program. |
None (do not use a RETURN statement)
This event can establish database connection parameters and open the main window of the application.
There is no way to specify command line values when you are testing your application in the development environment.
Opening the application with command-line arguments at runtime You can specify command line arguments when you use the Run command from the Start menu or as part of the Target specification when you define a shortcut for your application.
In other events and functions, you can call the CommandParm function to get the command line arguments.
For an example of parsing the string in commandline, see CommandParm.
This example populates the SQLCA global variable from the application’s initialization file, connects to the database, and opens the main window:
/* Populate SQLCA from current myapp.ini settings */
SQLCA.DBMS = ProfileString("myapp.ini", "database", &
"dbms", "")
SQLCA.Database = ProfileString("myapp.ini", &
"database", "database", "")
SQLCA.Userid = ProfileString("myapp.ini", "database", &
"userid", "")
SQLCA.DBPass = ProfileString("myapp.ini", "database", &
"dbpass", "")
SQLCA.Logid = ProfileString("myapp.ini", "database", &
"logid", "")
SQLCA.Logpass = ProfileString("myapp.ini", &
"database", "LogPassWord", "")
SQLCA.Servername = ProfileString("myapp.ini", &
"database", "servername", "")
SQLCA.DBParm = ProfileString("myapp.ini", "database", &
"dbparm", "")
CONNECT;
IF SQLCA.Sqlcode <> 0 THEN
MessageBox("Cannot Connect to Database", &
SQLCA.SQLErrText)
RETURN
END IF
/* Open MDI frame window */
Open(w_genapp_frame)
Occurs when a window is opened by one of the Open functions. The event occurs after the window has been opened but before it is displayed.
Event ID |
Objects |
---|---|
pbm_open |
Window |
None
Long. Return code choices (specify in a RETURN statement):
0 Continue processing
These functions trigger the Open event:
Open
OpenWithParm
OpenSheet
OpenSheetWithParm
When the Open event occurs, the controls on the window already exist (their Constructor events have occurred). In the Open event script, you can refer to objects in the window and affect their appearance or content. For example, you can disable a button or retrieve data for a DataWindow.
Some actions are not appropriate in the Open event, even though all the controls exist. For example, calling the SetRedraw function for a control fails because the window is not yet visible.
Changing the WindowState property Do not change the WindowState property in the Open event of a window opened as a sheet. Doing so might result in duplicate controls on the title bar. You can change the property in other scripts once the window is open.
When a window is opened, other events occur, such as Constructor for each control in the window, Activate and Show for the window, and GetFocus for the first control in the window’s tab order.
When the window contains a DataWindow control, you can retrieve data for it in the Open event. In this example, values for the transaction object SQLCA have already been set up:
dw_1.SetTransObject(SQLCA)
dw_1.Retrieve( )