很多兄弟问我如何在SAP里面实现对本地OCX的调用,希望能有个例子,不才写了一个在GUI里面调用Flash播放器的例子,希望能抛砖引玉,如果有好的想法,请不吝留言,让大家分享一下,谢谢!
REPORT z_barry_flash NO STANDARD PAGE HEADING.
DATA: cont TYPE REF TO cl_gui_custom_container .
CLASS cl_flash DEFINITION DEFERRED .
DATA: o_flash TYPE REF TO cl_flash .
*---------------------------------------------------------------------*
* CLASS cl_flash DEFINITION
*---------------------------------------------------------------------*
CLASS cl_flash DEFINITION INHERITING FROM cl_gui_control .
PUBLIC SECTION .
METHODS:
constructor
IMPORTING
value(shellstyle) TYPE i OPTIONAL
value(disp_mode) TYPE i OPTIONAL
value(life_time) TYPE i OPTIONAL
value(name) TYPE string OPTIONAL
EXCEPTIONS
cntl_error
cntl_install_error .
ENDCLASS . "cl_flash DEFINITION
*----------------------------------------------------------------------*
* CLASS cl_flash IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS cl_flash IMPLEMENTATION .
METHOD constructor.
DATA: ctrl_name(80) TYPE c ,
wf_clsid(100) TYPE c .
IF NOT cl_gui_object=>activex IS INITIAL .
wf_clsid = '{D27CDB6E-AE6D-11cf-96B8-444553540000}' .
ELSE .
RAISE cntl_error .
ENDIF .
CALL METHOD super->constructor
EXPORTING
clsid = wf_clsid
parent = cont
shellstyle = shellstyle
lifetime = life_time
name = name
EXCEPTIONS
cntl_system_error = 1
OTHERS = 2.
CASE sy-subrc .
WHEN 1 .
RAISE cntl_install_error .
WHEN 2 .
RAISE cntl_error .
ENDCASE .
CALL METHOD set_property
EXPORTING
property = 'Movie'
value = 'c:\test.swf'
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3.
CALL METHOD cl_gui_cfw=>subscribe
EXPORTING
ref = me
shellid = me->h_control-shellid
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0 .
RAISE cntl_error .
ENDIF .
ENDMETHOD . "constructor
ENDCLASS . "cl_flash IMPLEMENTATION
START-OF-SELECTION.
CALL SCREEN 100 .
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
IF cont IS INITIAL.
CREATE OBJECT cont
EXPORTING
container_name = 'CON1'.
CREATE OBJECT o_flash .
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
阅读(8346) | 评论(13) | 转发(0) |