next up previous contents
Next: 5. Release Information Up: 4. Implementing COM objects Previous: 4.7 Full Example   Contents

4.8 Building a Lua OLE control

Most of what is needed to build an OLE control was already covered in the last section. Controls are like ordinary LuaCOM objects, but they are created by the NewControl API function, instead of NewObject. The registration info table must also have verb+Control+ field set to true. The table that implements the control must also implement a few additional methods, part of the control protocol. These are:
InitialSize
The control may use this method to return its initial size, in pixels.
CreateWindow
Called when the control has to create its window. The parameters to this function are the handle of the parent window (an userdata), the initial position and initial size of the window. The control must return an userdata with its window handle.
SetExtent
Called whenever the host wants to change the size of the control. The parameters are the new size. Must return true if the control accepts the size change, and false otherwise.
GetClass
Must return the class id of the control.
DestroyWindow
Called when the host is finished with the control, and it has to destroy its window and release its resources.
The demo/control directory of the LuaCOM distribution has an example of a control.
next up previous contents
Next: 5. Release Information Up: 4. Implementing COM objects Previous: 4.7 Full Example   Contents
Fabio Mascarenhas de Queiroz 2005-06-06