Windows uses handles of type HWND to refer to most GUI objects. Since handles are 32-bit pointers that are unique to each window, it would be tempting to use them as PHP variables to refer to controls. However, this approach is not ideal for the following reasons:
Therefore a WinBinder Object (WBOBJ) structure is defined. All WinBinder windows and controls are of type WBOBJ. The structure contains the window handle (HWND) and other data. Below is a copy of the WBOBJ definition in WB.H:
|
|
The WinBinder functions wb_create_control() and wb_create_window() effectively return a pointer to the window's WBOBJ structure as a long integer. This pointer is also stored (with Window API function SetWindowLong() and GWL_USERDATA) in every window. Therefore it always possible to obtain the HWND from a WBOBJ and vice-versa, for any given window or control.
The first LPARAM type field, lparam, carries the value of the param argument that is passed in functions wb_create_control() and wb_create_window(). The array of LONGs, lparams, is reserved for internal use and can be used to carry additional user information or 32-bit pointers. These additional pointers are accessible only via the wb_peek() function.
A control handle is a unique integer value that is returned the control created with wb_create_control(). It is actually a pointer to the WBOBJ structure that defines the control as seen above. A control identifier is an integer number that is assigned by you when the control is created (the id parameter). It is used to easily differentiate between controls. You should assign a unique identifier to each control so a single switch statement in the callback function is enough to process all messages.
Containers are windows or controls that act as parents for other controls. The only valid containers in WinBinder are windows and tab controls. Therefore the following rule must be observed:
|
|
For tab controls, messages and events are sent automatically to and from the main window (i.e. the tab control parent) so there is no need to create an additional callback function for the tab control. All processing of controls contained inside a tab control is handled automatically and transparently by the main window callback function.
|
|
wb_create_control
wb_create_window
Callback functions and window handlers
Window
classes
Window messages
and events