ASPit - Totally ASP JSit - Totally JavaScript
Search PHPit

Use this textbox to search for articles on PHPit. Seperate keywords with a space.

Advertisements

An Introduction to the Winbinder Library, Part 1

(Page 2 out of 3)

"Hello World"

There's no better way to demonstrate something new than using the classic "Hello World" example, so…

// Include Winbinder library
include ("D:\WinBinder\phpcode\include/winbinder.php");

// Create main window
$mainwin = wb_create_window(NULL, PopupWindow, "Hello world!", 100, 100);

// Create label control inside the window
wb_create_control($mainwin, Label, "Hello World!",
  0, 25, 100, 100, 0, WBC_CENTER);

// Enter message loop
wb_main_loop();                                                 

?>

The above example will create the following window when run:

Hello World Screenshot

To run the above example yourself, save the code as 'helloworld.phpw', and double-click this file. You'll be most likely asked by Windows to select a program to run it with. You should run it with 'php-win.exe', located in C:\WinBinder\binaries\php4\ (this depends on where you installed WinBinder). See the installation instructions for more information.

Let's go through the example. In the first line the Winbinder library is included. In the second line the main window of the application is created using the wb_create_window() function. This function is used to create new windows, and takes several arguments (see the manual). This is probably one of the most important functions of Winbinder, and almost every PHP WinBinder application uses it.

On the next line the wb_create_control() function is used to create a 'Label' control. This is also a very vital function, because it allows you to create different types of controls, and build up the interface of your application. Winbinder supports dozens of different types of controls, including a text box, listview, HTML control, label, button, and more. A complete list can be viewed by clicking here. As you can see, in the above example we create a label control with the caption set to 'Hello World!'.

Finally the wb_main_loop() function is called. This will start the event handler for the program. Although we don't use it in the above example, the event handler allows you to handle certain events in your application. Let's have a closer look at the event handler.

« Previous: Introduction
Next: The Event Handler »



3 Responses to “An Introduction to the Winbinder Library, Part 1”

  1. giverhard.com » Windbinder - Creating windows apps with PHP Says:

    […] Tutorial Source: PhpIt.net - Download […]

  2. Michal Kuklis Says:

    looks really need. I would like to see some examples involving sql; plus is there any way to integrate it with web applications?? It would be great for example to have a website with pictures and then create something in Winbinder to upload pictures on it. Something like Flickr does.

  3. Harry D Says:

    This is really impressive.
    I think it could be also good for user authentification. Though it is necessary to encrypt traffic at client side and decrypt on server side, as well as updating the client software with different algorithms to avoid a security leak through cracking the code by reverse engineering.

Leave a Reply

About the author
Dennis Pallett is the main contributor to PHPit. He owns several websites, including ASPit and Chill2Music. He is currently still studying.
Article Index
  1. Introduction
  2. Hello World
  3. The Event Handler
Bookmark Article
Download Article
PDF
Download this article as a PDF file