Announcement

Collapse
No announcement yet.

Control Add Imgbutton

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Control Add Imgbutton

    Please add your comments and suggestions as a Reply to this thread.





    PB/WIN - CONTROL ADD IMGBUTTON statement

    Purpose
    Add an image button to a dialog. Image buttons are often used to enhance the appearance of a dialog.
    Syntax
    CONTROL ADD IMGBUTTON, hDlg, id&, image$, x, y, xx, yy [, [style&] [, [exstyle&]]] [[,] CALL callback]
    hDlg
    Handle of the dialog in which the button will be created. The dialog will become the parent of the control.
    id&
    Unique identifier for the button in the range 1 to 65535, frequently specified with numeric equates for clarity of the code. For example, the equate %IconButton1 is more informative than a literal value such as 497. Best practice suggests identifiers should start at 100 to avoid conflict with any of the standard predefined identifiers.

    However, it is typical for a dialog to include an OK and/or a Cancel button, represented by the predefined equates %IDOK and %IDCANCEL respectively. A button with an ID of %IDOK is triggered (clicked) when the ENTER key is pressed by the user, and a button with the ID of %IDCANCEL is triggered when the ESCAPE key is pressed. These and other predefined "standard" equates can be found in the WIN32API.INC and DDT.INC files.
    image$
    Name of the bitmap or icon in the resource file. If the image resource uses an integral identifier, image$ should begin with a Number symbol (#) followed by the identifier in an ASCII format, e.g., "#998". Otherwise, use the text identifier name for the image.
    x, y
    Integral expressions, variables, or numeric literal values, specifying the location of the control inside the dialog client area. x is the horizontal position, and y is the vertical position. 0,0 refers to the upper left corner of the dialog box client area. Coordinates are specified in the same terms (pixels or dialog units) as the parent dialog.
    xx
    Integral expression, variable, or numeric literal value, specifying the width of the control. The width is given in the same terms (pixels or dialog units) as the parent dialog. The most common value used in the Microsoft Dialog Editor and Visual Studio is 40 dialog units.
    yy
    Integral expression, variable, or numeric literal value, specifying the height of the control. The height is given in the same terms (pixels or dialog units) as the parent dialog. The most common value used in the Microsoft Dialog Editor and Visual Studio is 14 dialog units.
    style&
    Primary style of the image button control. The default image button style is %WS_TABSTOP. The default style is used only if both the primary and extended parameters are omitted from the statement. For example:

    Code:
    CONTROL ADD IMGBUTTON, hDlg, id&, txt$, 100, 100, 150, 200, , , _
      CALL ImgButtonCallback() ' Use default styles
    Custom style values replace the default values. That is, they are not additional to the default style values - your code must specify all necessary primary and extended style parameters.

    The primary image button style value can be a combination of any values below, combined together with the OR operator to form a bitmask:
    %BS_DEFAULT
    Create the button with a heavy black border. The user can select this button by pressing the ENTER key. This style is useful for enabling the user to quickly select the most likely option. There may only be one Default button per dialog.
    %BS_FLAT
    Create a flat button (without the raised 3D look).
    %BS_NOTIFY
    Enable a button to send the %BN_KILLFOCUS and %BN_SETFOCUS notification messages to the button Callback Function.
    %WS_DISABLED
    Create a control that is initially disabled. A disabled control cannot receive input from the user. Use the CONTROL ENABLE statement to re-enable the button.
    %WS_GROUP
    Define the start of a group of controls. The first control in each group should also use %WS_TABSTOP style. The next %WS_GROUP control in the tab order defines the end of this group and the start of a new group. Groups configured this way permit the arrow keys to shift focus between the controls within the group, and focus can jump from group to group with the usual TAB and SHIFT+TAB keys. Both tab stops and groups are permitted to wrap from the end of the tab order back to the start.
    %WS_TABSTOP
    Allow button control to receive keyboard focus when the user presses the TAB and SHIFT+TAB keys. The TAB key shifts keyboard focus to the next control with the %WS_TABSTOP style, and SHIFT+TAB shifts focus to the previous control with %WS_TABSTOP. (default)
    exstyle&
    Extended style of the image button control. The default extended image button style comprises %WS_EX_LEFT. The default extended style is only used if both the primary and extended parameters are omitted from the CONTROL ADD IMGBUTTON statement, in the same manner as style& above.

    The extended image button style value can be a combination of any values below, combined together with the OR operator to form a bitmask:
    %WS_EX_LEFT
    The button has generic "left-aligned" properties. (default)
    %WS_EX_RIGHT
    The button has generic "right-aligned" properties. This style has an effect only if the shell language is Hebrew, Arabic, or another language that supports reading order alignment; otherwise, the style is ignored.
    %WS_EX_TRANSPARENT
    Controls/windows beneath the control are drawn before the control is drawn. The control is deemed transparent because elements behind the control have already been painted - the control itself is not drawn differently. True transparency is achieved by using Regions - see MSDN for more information.
    callback
    Optional name of a Callback Function that receives all %WM_COMMAND and %WM_NOTIFY messages for the control. See the #MESSAGES metastatement to choose which messages will be received. If a callback for the control is not designated, you must create a dialog Callback Function to process messages from your control.

    Generally speaking, if the Callback Function processes a message, it should return TRUE (non-zero) to prevent the message being passed unnecessarily to the dialog callback (if one exists). The dialog callback should also return TRUE if the notification message is processed by that Callback Function. Otherwise, the DDT engine processes unhandled messages.
    Remarks
    The bitmap or icon used in the button is not resized to fit the button. If your button is 64 dialog units wide and your icon or bitmap is only 32, half of the button will be blank. For best results, icons should be 32x32 pixels.

    An image button is drawn on the dialog using a 3-dimensional look, unless the %BS_FLAT style is specified. When the user clicks on the image button, a message is sent to the button's Callback Function. If there is no Callback Function designated, the message is sent to the callback for the dialog.

    Notification messages are sent to the Callback Function with CB.MSG = %WM_COMMAND, CB.CTL holding the ID (id&) of the control, and CB.CTLMSG holding the following values:
    %BN_CLICKED
    Sent when the user clicks a mouse button, or activates the button with the hot-key (unless the button has been disabled).
    %BN_DISABLE
    Sent when a button is disabled.
    %BN_KILLFOCUS
    Sent when a button loses the keyboard focus. The button must include the %BS_NOTIFY style.
    %BN_SETFOCUS
    Sent when a button receives the keyboard focus. The button must include the %BS_NOTIFY style.
    When a Callback Function receives a %WM_COMMAND message, it should explicitly test the value of CB.CTL and CB.CTLMSG to guarantee it is responding appropriately to the notification message.
    See AlsoReferences
    Last edited by Gary Beene; 28 Oct 2014, 07:01 PM.
Working...
X