align.jpg

Using the Simplified Windows API library.

The Windows API is the very low-level basic of all you see on your screen when using Windows. Forms, buttons, comboboxes, etc... are all windows really just painted differently. To move windows around, resize them, change their caption or text, the Windows API is versatile but very complex to use for beginners. The best reference site is the venerable MSDN (Microsoft Developer Network) which can be reached at www.msdn.com

PPL is meant to be an easy-to-use language. The SWAPI (Simplified Windows API) is a library that we have created to simplify interaction with windows controls and forms. There are many sets of functions that are grouped in categories each function name following a naming convention.

Example:

For listbox controls, we have ListBox_Add to add an item to the list and for comboboxes we have ComboBox_Add to add an item to the list as well.

We have already learned how to design a form using the PIDE we will now learn how to interact with the controls on our form using the SWAPI library.

If you use the Visual Form Builder in the PIDE or the VFB on the PocketPC the SWAPI library is automatically included in your code file but if you are designing the form with code only, you will need to include the SWAPI.PPL library file in your code, here is how to do it:

#include "swapi"

We think the best way to learn how to use the SWAPI is to give you situations followed by an answer.

How I hide or show my forms?

Form_Show (FormHandle$)
Form_Hide (FormHandle$)

How do I move my form around?

Form_Move (FormHandle$, x$, y$)

How do I resize my form?

Form_Resize (FormHandle$, Width$, Height$)

How do I close a form?

Form_Close (FormHandle$)

How do I change the caption of a form?

Form_Set (FormHandle$, Caption$)

How do I move a control around?

Control_Move (ControlHandle$, x$, y$)

How do I resize a control?

Control_Resize (ControHandle$, Width$, Height$)

How do I hide or show a control?

Control_Show (ControlHandle$)
Control_Hide (ControlHandle$)

How do I set the text from an edit control?

Edit_Set (EditHandle$, NewText$)

How do I get all list items from a listbox?

ListBox_SaveToList (ListHandle$, List$)

How do I save all the list items from a listbox?

ListBox_SaveToFile (ListHandle$, Filename$)

How do I load list items from a file?

ListBox_LoadFromFile (ListHandle$, Filename$)

How do I change the font of a control?

Control_SetFont (ControlHandle$, FormHandle$, FontName$,
FontSize$, Bold$, Italic$, Underline$)

By now you should get the idea. Review the SWAPI.PPL file from the Lib\ folder to get the full list of functions.