在选择画面中创建按钮(push button)详解编程语言

选择画面上创建按钮,并且在按钮上通过ICON_CREATE()添加图标。

代码:

REPORT ZTEST_PUSHBUTTON. 
TYPE-POOLS: icon. 
TABLES sscrfields. 
*--------------------------------------------------------------* 
*Selection-Screen 
*--------------------------------------------------------------* 
SELECTION-SCREEN: 
      PUSHBUTTON /2(40) button1 USER-COMMAND but1, "40是按钮长度 
      PUSHBUTTON /2(40) button2 USER-COMMAND but2. 
*--------------------------------------------------------------* 
*At Selection-Screen 
*--------------------------------------------------------------* 
AT SELECTION-SCREEN. 
* 相应按钮事件 
  CASE sscrfields. 
    WHEN 'BUT1'. 
      MESSAGE 'Button 1 was clicked' TYPE 'I'. 
    WHEN 'BUT2'. 
      MESSAGE 'Button 2 was clicked' TYPE 'I'. 
  ENDCASE. 
*--------------------------------------------------------------* 
*Initialization 
*--------------------------------------------------------------* 
INITIALIZATION. 
  button1 = 'Button 1'. 
  button2 = 'Button 2'. 
* 按钮上添加图标 
  CALL FUNCTION 'ICON_CREATE' 
    EXPORTING 
      name   = icon_okay 
      text   = 'Continue' 
      info   = 'Click to Continue' 
    IMPORTING 
      RESULT = button1 
    EXCEPTIONS 
      OTHERS = 0. 
 
  CALL FUNCTION 'ICON_CREATE' 
    EXPORTING 
      name   = icon_cancel 
      text   = 'Exit' 
      info   = 'Click to Exit' 
    IMPORTING 
      RESULT = button2 
    EXCEPTIONS 
      OTHERS = 0.

运行效果:

2017-02-16_9-39-36

以上。

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/19212.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论