PB Practical Skills Eight

Source: Internet
Author: User
Tags zip

First, the implementation of the running Window Center

As we all know, PowerBuilder 7.0 provides a graphical preview tool in previous releases, and it is easy to center the window in the design phase. However, by 7.0 it seemed that the tool had been canceled and there was no property to set it, at least I didn't find it. Every time we need to center the window with only 1.1 points to adjust its x,y value, this 1:10 is a headache. Condemned, had to be realized by programming. We will automatically center the window by writing the code in the Open event of each window that needs to be centered.

To automatically center the window, we can use the function move () to implement it. However, since the applications we develop are often run in different settings, although we are generally configured for the user, we cannot guarantee that the user's display settings will not change. Fortunately, PB provides us with the environment object environment, the object is actually a system structure, which holds the PB application platform information, such as code set, CPU type, etc. Of course there will be the screen width and height we need. In order to get the structure we can use the function getenvironment (). The function is to get system information about the operating system, the processor, and the screen. The specific usage is as follows:

Environment My_system

Integer Li_screenwidth, Li_screenheight

Getenvironment (My_system)

Get the total width and length of the screen

Li_screenwidth = Pixelstounits (My_system. ScreenWidth, xpixelstounits!)

Li_screenheight = Pixelstounits (My_system. ScreenHeight, xpixelstounits!)

The function pixelstounits () is to convert the image number of the screen to the unit used by the PowerBuilder, since the image number is usually not used in squares, see the function manual for specific use.

You can then use Move () to center the window.

This.move (li_screenwidth-this. Width)/2, &

(Li_screenheight-this. Height)/2)

The combination of the fields in the Data window

Have you ever encountered such a situation, we entered the customer's detailed address information, including provinces, cities, addresses, postcode. When we want to send letters to customers, we need to print out their provinces, cities, addresses and zip codes together. However, this information is stored separately, that is, there are different fields. In this case, we can use the Powerbuiler provided in the Data window to add a computational field (Compute field) to achieve a combination of character fields display.

Now assume that the customer's provinces, cities, addresses, and postcode are stored in separate fields, which are province,city,address,pc. We want to get "Zip + Province + City + address" format, such as: "(214001) Jiangsu Province, Wuxi Renmin Road, No. 1th." ", specifically implemented as follows:

1. Add a compute field where you want to display (Compute field)

2, in its expression column write "' (' + PC + ') ' + Province + City + address"

3, click OK complete.

It's easy, isn't it. You need to be reminded that a calculated field can only be displayed and cannot be modified because it does not have the tab attribute and does not get the focus.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.