| Home | Previous Lesson: Getting Your Bearings Next Lesson: Signing-in using PFC |
No class library satisfies the customer needs exactly. It has to be customized here and there. Our application is not an exception to that fact.
Don�t ever do changes to any of the object that is residing in PFC libraries (Library name starts with PFC). Any customization has to be done in the extension layer libraries (Library name starts with PFE).
Invoke n_cst_AppManager object from the PFEAPSRV.PBL library. All the event names that are declared as part of PFC start with "PFC". If you need to declare any user-defined event, start it with "ue_". We need to initialize some attributes of n_cst_AppManager object, either directly changing them or by calling methods. These attributes are used throughout the application. Write the following code to the Constructor event:
// Name of the application
iapp_object.DisplayName="Product Management System"
// Turning on the Microhelp functionality
of_SetMicroHelp (true)
// The file name of the application INI file
of_SetAppIniFile ("product.ini")
// PFC allows you using different files for the
// application and the user. We are using the same
// file for both purposes.
of_SetUserIniFile ("product.ini")
// PFC uses the registry if the registry is available.
// Application registry key
of_SetAppKey ("HKEY_LOCAL_MACHINE\Software\ASI\PMS")
// User registry key
of_SetUserKey ("HKEY_CURRENT_USER\Software\ASI\PMS")
// The file name of the application's online help file
//of_SetHelpFile ("pbpfc050.hlp")
// We don�t have any help file yet.
// The application version
of_SetVersion ("Version 1.0")
// The application logo (bitmap file name)
of_SetLogo ("asi.bmp")
// Application copyright message
of_SetCopyright ("Copyright @ 1996-99 Applied Software Inc")
// Wrapper property for application display name
is_title = iapp_object.DisplayName
The above code is self-explanatory. If you run the application now, you will see a different login screen. However, you may not be able to login successfully. If you are using Windows �95/NT 4.0, you need to create the following registry entry:
HKEY_LOCAL_MACHINE\SOFTWARE\ASI\PMS
Click on the operating system Start button and select Run option. Type RegEdit and click OK. Operating system invokes the registry editor. On the left hand side, expand HKEY_LOCAL_MACHINE and then Software. Create an entry ASI (Applied Software Inc). Why did we use our company name here? Because, every software company whose products are installed on your machine, have an entry under Software. Under the company key, they have one entry per software. Similarly, you need to create an entry to the "Product Management System", i.e., PMS.
Similarly create HKEY_CURRENT_USER\SOFTWARE\ASI\PMS entry. Under this, create one more registry key logon. Under that, create a string value userid and set it to DBA.
Add the following entries to the product.ini file.
[Database]
DBMS=ODBC
Database=product
DBParm=ConnectString='DSN=product'
Write the following code to the PFC_Open event of the n_cst_AppManager object.
Integer li_rc
if of_IsRegistryAvailable() then
sqlca.of_Init (of_GetUserKey() + "\PMS")
elseif sqlca.of_Init (is_userinifile, "Database") = -1 then
MessageBox (is_title, "Initialization failed " + &
"from file " + is_userinifile)
halt
end if
Idle( 300)
In the above code, we are asking PFC to read the key values specified in the of_SetUserKey() function in the Constructor event of n_cst_AppManager. of_Init() function reads the values specified in the registry and sets the values in the transaction object. Now, we need to display the logon window to the user and accept his user id/password and log on to the database. PFC has a function of_LogonDlg() which does all that for you. Append the following code to the PFC_Open event of n_cst_AppManager object.
li_rc = gnv_app.of_LogonDlg()
IF li_rc <> 1 THEN
MessageBox("Logon", "Logon failed")
Halt Close
End If
open(w_mdi_frame)
You can call this function before you open the w_mdi_frame or you can open it in the Open event of the w_mdi_frame. Let�s choose the later method. We choose the former method.
Now, run the application and you should be able to login. You will see the same MDI window and menu we were using so far. Now, we need to create new windows and menus using the PFC objects. The next step would be to create a MDI window and a menu using PFC classes.
Create a window by inheriting from w_frame (in the PFEMAIN.PBL). Change the window title to "Product Management System" and save the window as w_mdi_frame.
| Home | Previous Lesson: Getting Your Bearings Next Lesson: Signing-in using PFC |