A Simple Button
This simple button, when clicked will show a message box indicating that the button was clicked. For button controls there is a default configuration dialog that is used for controls that do not themselves define a OnConfigureControl(OnEditControl) event handler. The default dialog, depending on its current design is able to set all relavent properties common to buttons, such as colors, font, button style, perhaps a page change indicator.
OnCreateMenuButton( “basic/Hello World” )( PMENU_BUTTON button )
{
return 1; // result OK to create.
}
OnKeyPressEvent( “basic/Hello World” )( PTRSZVAL psvUnused )
{
SimpleMessageBox( NULL // the parent frame, NULL is okay
, “Hello World!” // the message within the message box
, “Button Clicked” ); // the title of the message box.
// SimpleMessageBox displays a simple frame with a message
// and a title, and an OK button. The function waits
// until the OK button is clicked before returning.
}
A Simple Listbox
OnCreateListbox( “basic/List Test” )( PSI_CONTROL pc_list ) { return pc_list; // result non-zero OK to create. // this result can also be used in subsequent events // by typecasting it back to the original PSI_CONTROL // type that it is. }
// several implementations of listboxes change their content
based on the state of other controls around them, and/or
database content. The OnShowControl is a convenient place
to re-populate the listbox with new data.
There is no requirement to do this in this way.
Some listboxes may populate their content during OnCreate.
OnShowControl( “basic/List Test” )( PTRSZVAL psvList ) { PSI_CONTROL pc_list = (PSI_CONTROL)psvList; ResetList( pc_list ); AddListItem( pc_list, “One List Item” ); AddListItem( pc_list, “Another List Item” ); } A Simple Control There is no such thing as a ‘simple’ control. OnCreateControl( “basic/Other Control” )( PSI_CONTROL frame, S_32 x, S_32 y, _32 w, _32 h ) { // this code results with a create PSI control. // the PSI control must have been previously registered // or defined in some way. // the result of creating an invalid control, // or of creating a control that fails creation // for one reason or another is NULL, which will in turn // fails creation of the MILK control. return (PTRSZVAL)MakeNamedControl( frame , “Some PSI Control type-name” , x, y // control position passed to event
, w, h // control size passed to event , -1 ); // control ID; typically unused.
}
// For MILK to be able to hide the control when pages change,
// show the control when pages change, move the control to
// a new position, or to resize the control, this method MUST
// be defined for MILK widgets created through OnCreateControl.
OnQueryGetControl( PTRSZVAL psv )
{
// since we know that we returned a PSI_CONTROL from the
// creation event, this can simply be typecast and returned.
return (PSI_CONTROL)psv;
}
Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at
support@toolsfactory.com.