Skip to content

Windows Framework Improvements in DataFlex 18.0

pbShield

If true, the Windows elevated rights shield will appear as the button's image. This is only supported with Windows Vista/Windows 2008 and above. If set with an earlier version of Windows, nothing happens.

psImage

This assigns the image and can be used in place of Set Bitmap, which is deprecated. By default, the image size is 16 x 16, which can be changed with piImageSize. peImageAlign determines the image alignment. The piImageMarginTop, piImageMarginBottom, piImageMarginRight, and piImageMarginLeft properties determine the image margins.

If the label is non-blank, both the text and image are displayed. If the label is blank, only the image is displayed. This can be changed after the button is displayed.

Instead of using psImage, you can create custom images for different button states by creating your own custom image list. See phoExternalImageList.

peImageAlign

peImageAlign determines the alignment of an image. It supports the following values:

Button_ImageList_Align_Left
Button_ImageList_Align_Right
Button_ImageList_Align_Top
Button_ImageList_Align_Bottom
Button_ImageList_Align_Center

piImageMarginTop, piImageMarginBottom, piImageMarginRight, and piImageMarginLeft

These set a margin for an image. By default, these values are all 0 except piImageMarginLeft, which is 3.

phoExternalButtonImageList

If you wish to assign a button a custom image list, you may do this by creating an image list using cImageList32 and assigning it to phoExternalImageList. If you do this, psImage and piImageSize are ignored.

Buttons support six image states: normal, hot, pressed, disabled, defaulted, and stylus-hot. Your custom image list should contain one or six images. If the image list has one image, this image is used for all states. If six images are defined, each is assigned to the appropriate state.

Object oImageList is a cImageList32
    Set piMaxImages to 6
    Set piImageHeight to 32
    Set piImageWidth to 32

    Procedure OnCreate
        Integer iIndex
        // these are normal, hot, pressed, disabled, defaulted, stylus-hot
        Get AddImage "ClosFold.bmp" to iIndex
        Get AddImage "OpenFold.bmp" to iIndex
        Get AddImage "OpenFold.bmp" to iIndex
        Get AddImage "ClosFold.bmp" to iIndex
        Get AddImage "OpenFold.bmp" to iIndex
        Get AddImage "ClosFold.bmp" to iIndex
    End_Procedure
End_Object

Object oButton5 is a Button
    Set Location to 155 140
    Set phoExternalButtonImageList to oImageList
    Set Label to "Folder"
End_Object

phoButtonPopup

This assigns a popup menu to the button. Normally, this should be a cCJContextMenu. If you send the event OnDropDown, it will popup this menu directly under the button. See OnDropDown for more.

Procedure OnDropDown

This pops up a context menu directly under the button. The phoButtonPopup property determines the context menu. Typically, a cCJContextMenu is used for this.

This example shows how to create a button, which when clicked, will invoke a menu under it.

Object oButton6 is a Button
    Set Location to 155 214
    Set Label to "Select"
    Set psImage to "down16.bmp"
    Set peImageAlign to BUTTON_IMAGELIST_ALIGN_RIGHT

    // fires when the button is clicked
    Procedure OnClick
        Send OnDropDown
    End_Procedure

    Object oButtonMenu is a cCJContextMenu
        Object oMenuItem1 is a cCJMenuItem
            Set psCaption to "Save"
            Procedure OnExecute Variant vCommandBarControl
            End_Procedure
        End_Object

        Object oMenuItem2 is a cCJMenuItem
            Set psCaption to "Clear"
            Procedure OnExecute Variant vCommandBarControl
            End_Procedure
        End_Object

        Object oMenuItem3 is a cCJMenuItem
            Set psCaption to "Delete"
            Procedure OnExecute Variant vCommandBarControl
            End_Procedure
        End_Object
    End_Object

    Set phoButtonPopup to oButtonMenu
End_Object

The cSplitButton class can also be used with OnDropDown and phoButtonPopup. When the split button is clicked, OnDropDown is sent automatically.

Typically, a cCJContextMenu is used for the popup. If you create your own, the popup object must understand Popup, PopupLocation, and be able to close itself when appropriate.

cSplitButton

This class displays a split button where the left part of the button displays the image and text, and the right side of the button displays a drop-down image. If you click on the left, OnClick is called. If you click on the right, OnDropDown is called.

By default, OnDropDown will invoke a menu under the button determined by phoButtonPopup.

Windows only supports this style of button with Vista/Windows Server 2008 and above. You would not want to use this with earlier versions. If used with a non-supported version, the right side split will not appear, and you will not be able to invoke the OnDropDown event.

Object oButton1 is a cSplitButton
    Set Location to 69 77
    Set Label to 'Save'
    Set psImage to "ActionSaveRecord.ico"

    // fires when the button is clicked
    Procedure OnClick
        Showln (Label(Self))
    End_Procedure

    Object oButtonMenu is a cCJContextMenu
        Object oMenuItem1 is a cCJMenuItem
            Set psCaption to "Set to Save"
            Procedure OnExecute Variant vCommandBarControl
                Delegate Set Label to "Save"
                Delegate Set psImage to "ActionSaveRecord.ico"
            End_Procedure
        End_Object

        Object oMenuItem2 is a cCJMenuItem
            Set psCaption to "Set to Clear"
            Procedure OnExecute Variant vCommandBarControl
                Delegate Set Label to "Clear"
                Delegate Set psImage to "ActionClear.ico"
            End_Procedure
        End_Object

        Object oMenuItem3 is a cCJMenuItem
            Set psCaption to "Set to Delete"
            Procedure OnExecute Variant vCommandBarControl
                Delegate Set Label to "Delete"
                Delegate Set psImage to "ActionDeleteRecord.ico"
            End_Procedure
        End_Object

        Object oMenuItem4 is a cCJMenuItem
            Set psCaption to "Set to Select"
            Procedure OnExecute Variant vCommandBarControl
                Delegate Set Label to "Select"
                Delegate Set psImage to ""
            End_Procedure
        End_Object
    End_Object

    Set phoButtonPopup to oButtonMenu
End_Object

cCommandLinkButton

This creates a command link button, which consists of an image on the left (by default the Windows green arrow pointing to the right), followed by the button label text in large text with optional notes text underneath it in smaller text. Typically, these buttons are stacked horizontally.

The Label property sets the label text. The psNote property sets the notes text. The image is the Windows arrow but can be changed using pbShield or psImage.

Windows only supports this style of button with Vista/Windows Server 2008 and above. You would not want to use this with earlier versions. If used with a non-supported version, this will appear as a big button, and the notes will not be displayed.

Object oButton1 is a cCommandLinkButton
    Set Location to 55 77
    Set Size to 30 100
    Set Label to 'Command Link Text'
    Set psNote to "Test Notes can go here"

    // fires when the button is clicked
    Procedure OnClick
    End_Procedure
End_Object

Object oButton2 is a cCommandLinkButton
    Set Location to 89 77
    Set Size to 30 100
    Set Label to 'Command Link Elevated'
    Set pbShield to True

    // fires when the button is clicked
    Procedure OnClick
    End_Procedure
End_Object

Object oButton3 is a cCommandLinkButton
    Set Location to 120 77
    Set Size to 32 186
    Set Label to 'Command Link Custom Image'
    Set psNote to "Test Notes can go here and have all kinds of stuff"
    Set psImage to "vdf32.bmp"
    Set piImageSize to 48

    // fires when the button is clicked
    Procedure OnClick
    End_Procedure
End_Object

psNote

This determines the notes that will appear in the command link button. Notes text will line wrap as needed.

SetPopupLocation

Procedure SetPopupLocation Integer iY Integer iX

Normally, a context menu popup locates itself based on the mouse cursor position, and it does this automatically. SetPopupLocation can be called immediately before you send Popup to the menu. You pass it an absolute row (iY) and column (iX) position which will be used to locate this popup. This is a one-time positioning. The next time Popup is called, the menu will be located automatically, unless you precede the call with another SetPopupLocation.

This is used to locate menus that are not invoked as right-mouse context menus. Buttons can and do use this to locate a menu. See Button.OnDropDown.

pbExplorerStyle

Setting this property to true will make your tree view look like a Windows Explorer tree view, which uses special chevrons instead of the normal tree view "+" and "-" expanders. This type of tree view does not contain tree lines, and therefore the TreeLinesState value is ignored.

Windows only supports this style of tree view with Vista/Windows Server 2008 and above. If used with a non-supported version, this property is ignored.

The Popup_Modal message now allows you to invoke a normally modeless view or dbView as a modal view. When modal, the view will act as a ModalDialog, meaning that it will float outside of the application panel and all windows under it will be disabled. This means global menus and toolbars are disabled.

For example, a customer view could be displayed as a modal dialog from within the order view as follows:

Procedure Prompt
    Send Popup_Modal to oCustomerView
    // because this is a modal dialog, the code here will not be executed until after the
    // view is closed. You can do post-popup processing here.
End_Procedure

The framework has no recommended way of working with modal views. The use of a view for two purposes, MDI view and modal dialog, is not supported as a high-level application technique. We are not recommending that this become a commonly used technique, but it has been requested and in the right conditions could be useful. Note that this technique does have limitations as the global menu and toolbars cannot be accessed by the modal view. In addition, using the same dialog for modal and modeless purposes can lead to confusion. An application should avoid the use of modal dialogs whenever possible.

A view or dbView can only be displayed once as a normal modeless view or a modal dialog. Therefore, if the view is already displayed as an MDI view, sending Popup_Modal will do nothing. You could test for this and handle this condition yourself.

Procedure Prompt
    Boolean bActive
    Get Active_State of oCustomerView to bActive
    If (bActive) Begin
        Send Close_Panel of oCustomerView
    End
    Send Popup_Modal of oCustomerView
End_Procedure

If you are invoking a view as a modal dialog, that view must first be created. Therefore, this technique may not work if your views are deferred as they may not be created yet. There is a technique which can be used to make sure that a view is created. Views that are created using the Active_View or Deferred_View syntax (which is the normal syntax used to create views) always create a method that is used to activate the view and to create it if needed. This usually takes the format of:

Send Activate_ + view name   (e.g., Send Activate_oCustomerView)

In addition, an additional method is created that creates the view, if needed, but does not activate it. This takes the format of:

Send Activate_ + view name + _Handle   (e.g., Send Activate_oCustomerView_Handle).

This could be used to make sure that the view is created and to create it as needed.

Procedure Prompt
    Handle hoView
    // make sure view is created if deferred.
    Get Activate_oCustomerView_Handle to hoView
    Send Popup_Modal of oCustomerView
End_Procedure

This Popup_Modal technique will work with standard views. Do not use this in conjunction with the Modal_State property (don't set this and don't augment it). Modal_State should never be set in a Windows application.

See Also

What's New in DataFlex 2014 - 18.0