Advanced PowerBuilder

HomePrevious Lesson: External Function Arguments
Next Lesson: Calling an External Subroutine

Calling an External Function

In this example, let's find out screen dimensions in pixels. We need to call GetSystemMetrics() windows function.

Open w_system_info window. Select Declare > Local External Functions from the menu. Declare the following function. Here, we are calling functions that reside in User32.dll. If you are using Windows, replace "User32.dll" with "user.dll".
Function int GetSystemMetrics (int index) Library "USER32.DLL"

Write the following code in the Window open event:
// Argument zero returns screen width in pixels
sle_screen_width.Text = &
      String( GetSystemMetrics(0), "#,###" )
// Argument 1 returns screen height in pixels
sle_screen_height.Text = &
      String( GetSystemMetrics(1), "#,###" )

Open the "w_about" window. Write the following code to the clicked event for the "cb_system_info" CommandButton:
Open( w_system_info )

In the w_about window, we have code for the timer event, to close the window in ten seconds. Let's get rid of that code. So, comment the code in the open event for the "w_about" window.

Run the application and test the code.
HomePrevious Lesson: External Function Arguments
Next Lesson: Calling an External Subroutine