Migration Guide : E. Features Introduced in OpenROAD 6.2 : New Features : Frames Without a Titlebar Can Be Dragged
 
Share this page          
Frames Without a Titlebar Can Be Dragged
OpenROAD frames without a titlebar can now be moved in "show contents while dragging" mode by dragging a field instead. Here's how to accomplish this.
The drag field can be any ActiveField visible in the frame. If you are using this field to simulate a titlebar, use a SubForm within the top MainBar, and give the SubForm a SizeToFit setting of STF_FRAMEHORIZONTAL so that its width always matches the frame width. This means you can incorporate your title text using a left-aligned FreeTrim field, and incorporate your iconize, maximize, and close icons as ButtonFields in a right-aligned StackField.
To enable dragging:
The drag field must contain a BgBitmap, although the bitmap need not be displayed. This bitmap must be a compound BitmapObject that contains one or more sprites (use the BitmapObject ComposeBitmap method in the Language Reference Guide to create the bitmap).
The field must have a BgDisplayPolicy of BDP_CORNERED.
The field must also be activated for "show contents while dragging": populate a SpriteDescriptor object with the appropriate settings, and use the SpriteDescriptor ApplySpriteMap method to activate the field with it.
The frame itself must have no titlebar, otherwise the field will move, not the frame.
The following code illustrates how you could provide this facility. It assumes a frame with no titlebar, and a field called "titlebar." After the code has run, dragging the "titlebar" field will drag the frame.
initialize=
declare
    SD          = SpriteDescriptor;
    SDS         = array of SpriteDescriptor;
    …
enddeclare
{
    /*
    ** Prepare the field
    */
    field(titlebar).SetAttribute(
        Bgcolor=CC_SYS_ACTIVECAPTION,
        BgPattern=FP_SOLID,
        BgDisplayPolicy=BDP_CORNERED,
        BgBitmap=mySpriteContainingBitmap);
 
    /*
    ** Make the field draggable in “show contents while dragging” mode
    */
    SDS.InsertRow(rowobject=SD);
    SD.SetAttribute(spritesourceindex=0, response=RSP_DRAG, x=0, y=0);
    SD.ApplySpriteMap(targetfield=field(titlebar), descriptors=SDS);
}