| Customizing the
Application Manager No class library
satisfies the customer exact needs. It has to be
customized here and there. Our application
isnt an exception to this fact.
ever do any
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 the n_cst_AppManager object from the
PFEAPSRV.PBL library. All the event names,
declared as part of PFC, start with
"PFC". If you need to declare any
user-defined event, name the event starting with
"ue_". We need to initialize some
attributes of the n_cst_AppManager object either
by 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 dont 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
All the above code is self-explanatory.
If you run the application now, you will see a
different login screen than the one we were
using. 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. In the left hand side, expand
HKEY_LOCAL_MACHINE and then Software. Create an
entry ASI (Applied Software Inc). Why we used our
company name here? Because, every software
company whose products are installed on your
machine, has an entry under "Software".
Under the company key, they have one entry for
each of their 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 the PFC to
read the key values that we 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 in the
"open" event of the w_mdi_frame.
Lets 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 that we are using till so far. Now, we
need to create new windows and menus using the
PFC objects. The next step would be creating 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". Save the
window as "w_mdi_frame".
|