- 华软网


  • 授权方式: 免费源码
  • 支付金币: 0个
  • 金币充值: 点击查看
  • 下载方法: 点击查看
  • 源码大小: 18528 KB
  • 评分等级: ★★★
  • 源码类别: 国内视频
  • 运行环境: WinXP/NT/Vista/Win7
  • 整理录入: 昕晨
  • 更新时间: 2009/12/2 8:29:00




The following PowerBuilder®  9 sample demonstrates a PBNI nonvisual extension that wraps CPing, a freeware MFC class to encapsulate the PING protocol.
• PBNI – Nonvisual Extension
Setting up Your Environment
• PowerBuilder® 9 GA
• Visual C++ 6.0 (only if the extension workspace needs to be opened)
Detailed Steps
• Unzip into a folder, for example c:\pbni_ping.
• Open the workspace pb_ping.pbw in the \debug directory with PowerBuilder 9 and add the nonvisual extension pbni_mfc_ping.pbd  to the library path.
• Run the application using the running man.
• You can type in the dropdown ListBox a Hostname or IP address of your choice or you can simply choose from the the dropdown ListBox a network ip address or ftp server and press the Button Ping1. You should then get the reply from the host, including the time needed if successful, or a failure message and code otherwise.
• Open the Visual C++ 6.0 workspace pbni_ping_mfc.dsw and look at the pbni_ping.cpp starting in section CPING_USE_WINSOCK2 to see how the extension calls the MFC class Cping. The main code for the Cping class is in ping.cpp.
For more information
The best source for information will be the PowerBuilder® Native Interface
Programmer’s Guide and Reference.
Also look for other PBNI extension samples, eg. Visual extension called Oscilloscope and Flags.

For information about the freeware MFC Cping class please look at


This PowerBuilder® 10.5 sample demonstrates a PBNI visual extension that displays an LED control.

The Control is MFC based and wraps the freeware Cled class from . The CLed class is a static control for a simple LED control and is derived from the CStatic class. Using a single bitmap of an LED array, the BitBlt function is used to index through the bitmap for the appropriate LED.
• PBNI – Visual extension
Setting up Your Environment
• PowerBuilder 10.5 GA
• Visual C++ 6.0 (if you want to open the visual extension workspace)
Detailed Steps
• Unzip into a folder, for example c:\led.
• Open the workspace pbni_led.pbw in the \debug directory with PowerBuilder 9 and add pbni_led.pbd to the library path of the pbni_led target.
• Run the application using the running man.
• If you run the debug version of the DLL, you get “debug assertion failed” error messages from Visual C++.  You can ignore these messages (use the ignore option on the dialog box).
• After the window opens, select different colors and modes using the radio buttons to invoke the visual class's SetLed function.
• Clicking the Ping button invokes the visual class's Ping function.
• Selecting Help>About demonstrates a small Led animation.

• Open the Visual C++ 6.0 workspace pbni_led.dsw. Look at led.cpp to see how the base class for the LED is implemented. Look at the source and header files for pbni_led_Ctrl to see how the LED control is implemented as a visual extension. The pbni_led source and header files provide initialization routines.

For more information
The best source for information is the PowerBuilder Native Interface
Programmer’s Guide and Reference.
Also look for other simple visual extension samples called Flags and Oscilloscope.


PowerBuilder 9 introduces new versions of the GetFileOpenName and GetFileSaveName functions that allow for multipe file selection and the passing of 'flags' that control the operation of the dialog.

This PBNI example demostrates how such PowerScript functions can be overloaded by PBNI functions to extend the native capability.  In this particular case, an additional argument is provided that is used (when the hook flag is passed) to replace the text on the default command button on the dialog.

This PBNI extension demonstrates the following techniques:

1.  Handling callbacks (used to customize the text on the dialog)

2.  Returning an array that was passed by reference.  Note that - unlike calling an external DLL - it is not necessary with PBNI to prepopulate string arguments passed by reference (including a string array passed by reference here).

A few items are worth noting:

1.  PowerScript does not allow for the overwriting of global functions.  As a result - since the PBNI functions are global functions in this case - it is not possible to overload both of the overloaded methods in the original PowerScript functions.

2.  The value for the 'flags' that the native GetFileOpenName and GetFileSaveName use are *not* the same values used by the underlying GetOpenFileName and GetSaveFileName functions in the Windows API.  Notice the constants defined as instance variables in the window, where there are two sets, one for the PowerScript methods and another for the PBNI methods.  It would certainly be possible to decode the PB flag values into the Windows API flag values within the PBNI extension, but to date I have not done so.

3.  The GetOpenFileName/GetSaveFileName functions change the working directory.  If the .PBX file containing the PBNI functions is in the working directory (i.e. not in the path), subsequent calls to the function will fail if the working directory is changed.  In this sample, the inital working directory is saved and reset prior to each PBNI call to ensure that it continues to work properly.

4.  Windows 2000 and later introduce the 'places' bar on the 'explorer'version of the GetOpenFileName/GetSaveFileName dialogs.  That bar do not appear when using the PowerScript methods.  During testing it appeared when using the 'explorer' version of the PBNI methods, but only if the hook was not enabled.



  • PBNI_Demo


  • 为防止盗链,本站资源部分有解压密码,解压密码点击查看
  • 如果您发现该资源不能下载,请通知管理员;
  • 为了保证您快速的下载,推荐使用迅雷或网际快车等专业工具下载;
  • 为确保所下资源能正常使用,请使用WinRAR v3.80或以上版本解压本站资源;
  • 本站所收集的下载资源均来源于网络,如果有侵犯您的版权,请来信告知,我们会马上处理;
  • 本站所提供的资源仅供学习和研究,请勿用于商业用途,请在下载后24小时内删除;
  • 本站不承担用户因使用这些下载资源对自己和他人造成任何形式的损失或伤害!