PB 5中PFC的使用

PB 5中PFC的使用

(加入日期:2002-7-18)

保存文章至硬盘】【打印文章】【字体:

分享到: 0
中原石油勘探局计算中心系统集成部 刘少青

---- PFC是PowerBuilder高级开发工具集中的一个基本类库,提供了进行一般应用开发时会经常用到的对象和函数代码。PowerBuilder 5.0的基本类库中的内容十分丰富,比以前版本中所提供的功能要增加了许多,而且对象之间的继承和引用关系也比以前更为清晰合理。因此编写一个完全建构在PFC类库之上的应用可大大提高软件质量,而且利用基类的已有代码也会使得许多复杂的功能实现起来要轻松得多。

---- 本文将根据笔者使用PFC的经验,介绍如何创建PFC的应用。

---- 1、首先在C盘新建一个目录Test,启动PowerBuilder5.0,创建一个新的应用,并将应用对象保存在Test.pbl中,将应用取名为test,保存时不使用PB提供的快速模板。

---- 2、进入应用的“Properties”(属性)中,选中“Libraries”标签,单击“Browes…”按钮,选中C:\Pwrs\Pb5i32\Adk\pfc目录下的全部8个pbl文件:pfcapsrv.plb、pfcdwarv.pbl、pfcmain.pbl、pfcwnsrv.pbl、pfeapsrv.pbl、pfedwarv.pbl、pfemain.pbl、pfewnsrv.pbl,单击“打开”按钮,再单击“Apply”按钮。然后选中“Variable Types”标签,将“SQLCA:”中的“transaction”改为“n_tr”,单击“OK”按钮保存对属性的修改。

---- 3、新建一个“User Object”(用户对象),单击“Inherit…”(继承)按钮,在“Application Libraries”中选中“PFEAPSRV.PBL”,在“User Objects”中选中“n_cst_appmanager”,单击“OK”按钮,在其“pfc_open”事件中写入以下登录数据库的程序(以SQL Server为例):

//pfc_open for n_cst_test inherited
n_cst_appmananger returns (none)
SQLCA.DBMS=ProfileString
("PB.INI","Database","DBMS", " ")
SQLCA.Database=ProfileString
("PB.INI","Database","DataBase"," ")
SQLCA.LogID=ProfileString
("PB.INI","Database","LogID", " ")
SQLCA.LogPass=ProfileString
("PB.INI","Database","LogPassword"," ")
SQLCA.ServerName=ProfileString
("PB.INI","Database","ServerName"," ")
SQLCA.UserID=ProfileString
("PB.INI","Database","UserID"," ")
SQLCA.DBPass=ProfileString
("PB.INI","Database","DatabasePassword", " ")
SQLCA.Lock=ProfileString
("PB.INI","Database","Lock"," ")
SQLCA.DbParm=ProfileString
("PB.INI","Database","DbParm"," ")
Connect Using SQLCA;
If SQLCA.sqlcode < > 0 Then
MessageBox("Cannot Connect to Database",
SQLCA.sqlerrtext,StopSign!)
Halt Close
Return
End If
Open(w_frame_test) //打开应用的主窗口(假设为w_frame_test)

---- 将该用户对象保存为n_cst_test。

---- 4、进入应用的“Script”中,选择“Declare/Global Variables…”菜单,定义全局变量:

n_cst_appmanager gnv_app //该全局变量的名称必须为gnv_app

并在该应用的open事件和close事件中分别写入以下程序:

//open for test returns (none)
gnv_app = Create n_cst_test
gnv_app.Event pfc_open(commandline)

//close for test returns (none)
gnv_app.Event pfc_close()
Destroy n_cst_appmanager

---- 经过上述步骤后,我们所要的PFC应用的总体械架就形成了,剩下的就是具体的编程工作了,本人在此不再赘述。
运行效果 http://hi.csdn.net/attachment/201012/9/0_1291865794j998.gif ************************************************************************* PowerBuilder Foundation Class Library Version 9.0 R E L E A S E N O T E S Copyright ?1996-2003 Sybase, Inc. and its subsidiaries. All rights reserved. ************************************************************************* Last Updated: January 17, 2003 ************************************************************************* Please take a few minutes to review this file for fixes that were made in PowerBuilder 8.0.2 and 9.0. ************************************************************************* BUG FIXES IN PFC 9.0 ************************************************************************* CR300376 Object: pfc_n_cst_fileSrv, pfc_n_cst_fileSrvwin32 Method: OfGetDiskSpace Fix: Method returned a negative number when the calculated amount of free disk space exceeded 2 gigabytes. Added new method of_GetDiskSpaceEx that takes decimals as arguments instead of longs. of_GetDiskSpace will be obsolete in a future release. ************************************************************************* BUG FIXES IN PFC 8.0.2 ************************************************************************* PFC.PBR CR256529 Fix: The PFC.PBR file can be used to copy bitmaps and dynamically referenced DataWindow objects into the executable file for deployment. The following bitmap files that were removed from PFC have now been removed from the PFC.PBR file: details.bmp, helptop.bmp, largeico.bmp, listv.bmp, and smallico.bmp. ======================================================== PFC DataStore CR261992 Object: pfc_u_ds Method: pfc_print/pfc_printdlg Fix: Changed the return code test to check for 1 on success, otherwise there is an error or the user cancelled. Fix: Set the
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值