[ABAP] Selektionsbild mit HTML-Elementen, Dateneingabe, SALV-Grid, CSS, Eventhandling

**********************************************************************
*
* Datentypen, Variablen, Konstanten
*
**********************************************************************
TYPES: ty_it_events TYPE STANDARD TABLE OF cntl_simple_event WITH DEFAULT KEY.
TYPES: ty_it_html TYPE STANDARD TABLE OF char1024 WITH DEFAULT KEY.

CONSTANTS: co_carrid TYPE string VALUE 'carrid'.
CONSTANTS: co_airpto TYPE string VALUE 'airpto'.

DATA: o_splitter_main TYPE REF TO cl_gui_splitter_container.
DATA: o_container_l   TYPE REF TO cl_gui_container.
DATA: o_container_r   TYPE REF TO cl_gui_container.
DATA: o_html TYPE REF TO cl_gui_html_viewer.
DATA: o_salv TYPE REF TO cl_salv_table.

DATA: it_spfli TYPE STANDARD TABLE OF spfli.
DATA: it_salv_spfli TYPE STANDARD TABLE OF spfli.
DATA: it_sairport TYPE STANDARD TABLE OF sairport.

DATA: it_html TYPE ty_it_html.
**********************************************************************
*
* Eventhandler
*
**********************************************************************
CLASS lcl_html_events DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      on_sapevent FOR EVENT sapevent OF cl_gui_html_viewer
        IMPORTING
            action
            frame
            getdata
            postdata
            query_table
            sender.
ENDCLASS.

CLASS lcl_html_events IMPLEMENTATION.
* Link- oder Button-Klick
  METHOD on_sapevent.
    IF o_salv IS BOUND.
      TRY.
* Element in der Nodes-Tabelle lesen
          ASSIGN query_table[ name = co_carrid ] TO FIELD-SYMBOL(<fs_carrid>).
          ASSIGN query_table[ name = co_airpto ] TO FIELD-SYMBOL(<fs_airpto>).

* iTab für SALV-Table neu aufbauen, abhängig von der Eingabe in den Formularfeldern
          it_salv_spfli = VALUE #( FOR l IN it_spfli WHERE ( ( carrid = <fs_carrid>-value ) OR ( airpto = <fs_airpto>-value ) )
                                   ( mandt = l-mandt
                                     carrid = l-carrid
                                     connid = l-connid
                                     countryfr = l-countryfr
                                     cityfrom = l-cityfrom
                                     airpfrom = l-airpfrom
                                     countryto = l-countryto
                                     cityto = l-cityto
                                     airpto = l-airpto
                                     fltime = l-fltime
                                     deptime = l-deptime
                                     arrtime = l-arrtime
                                     distance = l-distance
                                     distid = l-distid
                                     fltype = l-fltype
                                     period = l-period ) ).

* SALV-Table neu anzeigen
          o_salv->refresh( ).
        CATCH cx_root INTO DATA(e_txt).
          MESSAGE e_txt->get_text( ) TYPE 'S'.
      ENDTRY.
    ENDIF.
  ENDMETHOD.
ENDCLASS.
**********************************************************************
*
* SELECTION-SCREEN
*
**********************************************************************
* leeres Selektionsbild als Dummy für die Container-Objekte (o_splitter_main ...)
SELECTION-SCREEN BEGIN OF SCREEN 2000.
SELECTION-SCREEN END OF SCREEN 2000.
**********************************************************************
*
* INITIALIZATION
*
**********************************************************************
INITIALIZATION.
* Daten holen
  SELECT * INTO TABLE it_spfli FROM spfli.
  SELECT * INTO TABLE it_sairport FROM sairport.

* HTML-Code mit Buttons und Forms
  APPEND |<html>| TO it_html.
  APPEND |  <head>| TO it_html.
  APPEND |    <meta http-equiv="content-type" content="text/html; charset=utf-8">| TO it_html.
  APPEND |    <script type="text/javascript">| TO it_html.
  APPEND |      function onKeyDown(f)| TO it_html.
  APPEND |      \{ if(event.keyCode == 13)| TO it_html.
  APPEND |         \{ document[f.name].submit();| TO it_html.
  APPEND |         \}| TO it_html.
  APPEND |      \}| TO it_html.
  APPEND |    </script>| TO it_html.
  APPEND |    <style type="text/css">| TO it_html.
  APPEND |       body \{| TO it_html.
  APPEND |         font-family: Courier New;| TO it_html.
  APPEND |         font-size: 13px;| TO it_html.
  APPEND |         font-style: normal;| TO it_html.
  APPEND |         font-variant: normal;| TO it_html.
  APPEND |         font-weight: 400;| TO it_html.
  APPEND |         line-height: 13px;| TO it_html.
  APPEND |       \}| TO it_html.
  APPEND |       form \{| TO it_html.
  APPEND |         background: lightblue;| TO it_html.
  APPEND |       \}| TO it_html.
  APPEND |       label \{| TO it_html.
  APPEND |         text-align: right;| TO it_html.
  APPEND |         line-height: 1.5;| TO it_html.
  APPEND |         float: left;| TO it_html.
  APPEND |         width: 40%;| TO it_html.
  APPEND |       \}| TO it_html.
  APPEND |       input \{| TO it_html.
  APPEND |         margin: 0 0 1em .2em;| TO it_html.
  APPEND |         padding: .2em .5em;| TO it_html.
  APPEND |         background-color: #fffbf0;| TO it_html.
  APPEND |         border: 1px solid #e7c157;| TO it_html.
  APPEND |         float: left;| TO it_html.
  APPEND |         width: 40%;| TO it_html.
  APPEND |         font-family: Courier New;| TO it_html.
  APPEND |         font-size: 13px;| TO it_html.
  APPEND |         font-style: normal;| TO it_html.
  APPEND |         font-variant: normal;| TO it_html.
  APPEND |         font-weight: 400;| TO it_html.
  APPEND |         line-height: 13px;| TO it_html.
  APPEND |       \}| TO it_html.
  APPEND |       select \{| TO it_html.
  APPEND |         margin: 0 0 1em .2em;| TO it_html.
  APPEND |         padding: .2em .5em;| TO it_html.
  APPEND |         background-color: #fffbf0;| TO it_html.
  APPEND |         border: 1px solid #e7c157;| TO it_html.
  APPEND |         float: left;| TO it_html.
  APPEND |         width: 40%;| TO it_html.
  APPEND |         font-family: Courier New;| TO it_html.
  APPEND |         font-size: 13px;| TO it_html.
  APPEND |         font-style: normal;| TO it_html.
  APPEND |         font-variant: normal;| TO it_html.
  APPEND |         font-weight: 400;| TO it_html.
  APPEND |         line-height: 13px;| TO it_html.
  APPEND |       \}| TO it_html.
  APPEND |       button \{| TO it_html.
  APPEND |         margin-top: 1.5em;| TO it_html.
  APPEND |         float: right;| TO it_html.
  APPEND |       \}| TO it_html.
  APPEND |      </style>| TO it_html.
  APPEND |  </head>| TO it_html.
  APPEND |  <body>| TO it_html.
  APPEND |    <form name="INPUT" accept-charset="utf-8" method="post" action="SAPEVENT:INPUT_FIELDS">| TO it_html.
  APPEND |      <br>| TO it_html.
  APPEND |      <label for="{ co_carrid }">Fluggesellschaft:</label>| TO it_html.
  APPEND |      <input type="text" name="{ co_carrid }" value="LH" onKeyDown="onKeyDown(this.form);">| TO it_html.
  APPEND |      <br>| TO it_html.
  APPEND |      <label for="{ co_airpto }">Zielflughafen:</label>| TO it_html.
  APPEND |      <select name="{ co_airpto }">| TO it_html.

  LOOP AT it_sairport ASSIGNING FIELD-SYMBOL(<fs_airport>).
    APPEND |        <option>{ <fs_airport>-id }</option>| TO it_html.
  ENDLOOP.

  APPEND |      </select>| TO it_html.
  APPEND |      <br>| TO it_html.
  APPEND |      <button type="submit" title="Anzeigen">Anzeigen</button>| TO it_html.
  APPEND |      <br>| TO it_html.
  APPEND |      <br>| TO it_html.
  APPEND |      <br>| TO it_html.
  APPEND |      <br>| TO it_html.
  APPEND |    </form>| TO it_html.
  APPEND |  </body>| TO it_html.
  APPEND |</html>| TO it_html.

**********************************************************************
*
* AT SELECTION-SCREEN OUTPUT
*
**********************************************************************
AT SELECTION-SCREEN OUTPUT.
* Doppelte Objekterzeugung unterbinden
  IF NOT o_splitter_main IS BOUND.
* Splitter auf default_screen (SELECTION-SCREEN 2000) erzeugen
    o_splitter_main = NEW #( parent  = cl_gui_container=>default_screen
                             rows    = 1
                             columns = 2 ).

* Breite in % (linke Spalte für den Tree)
    o_splitter_main->set_column_width( id = 1 width = 20 ).

* linken und rechten Splitcontainer holen
    o_container_l = o_splitter_main->get_container( row = 1 column = 1 ).
    o_container_r = o_splitter_main->get_container( row = 1 column = 2 ).

* HTML-Viewer
    o_html = NEW cl_gui_html_viewer( parent = o_container_l ).

* Eventtypten müssen gesondert registriert werden
    DATA(it_events) = VALUE ty_it_events( ( eventid = cl_gui_html_viewer=>m_id_sapevent
                                            appl_event = abap_true ) ).

    o_html->set_registered_events( events = it_events ).

* Eventhandler registrieren
    SET HANDLER lcl_html_events=>on_sapevent FOR o_html.

* URL zu HTML holen
    DATA: lv_url TYPE char1024.

    o_html->load_data( IMPORTING
                         assigned_url = lv_url
                       CHANGING
                         data_table   = it_html ).

* HTML anzeigen
    o_html->show_url( url = lv_url ).

    it_salv_spfli = it_spfli.

* SALV-Table für Anzeige der Daten
    cl_salv_table=>factory( EXPORTING
                              r_container    = o_container_r
                            IMPORTING
                              r_salv_table   = o_salv
                            CHANGING
                              t_table        = it_salv_spfli ).

    o_salv->get_display_settings( )->set_striped_pattern( abap_true ).
    o_salv->get_columns( )->set_optimize( abap_true ).
    o_salv->get_functions( )->set_all( ).
    o_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).
    o_salv->display( ).
  ENDIF.
**********************************************************************
*
* AT SELECTION-SCREEN
*
**********************************************************************
AT SELECTION-SCREEN.
* wenn "Ausführen" (F8) geklickt wurde
  IF sy-ucomm = 'CRET'.
* Selektionbild 2000 wieder anzeigen
    CALL SELECTION-SCREEN 2000.
  ENDIF.
**********************************************************************
*
* START-OF-SELECTION
*
**********************************************************************
START-OF-SELECTION.
* leeres Selektionbild 2000 anzeigen
  CALL SELECTION-SCREEN 2000.

[C#] Window maximized event abfangen

Variante 1:

private void Form1_SizeChanged(object sender, EventArgs e)
{
	if (this.WindowState == FormWindowState.Maximized)
	{
		...
	}
}

Variante 2:

protected override void WndProc(ref Message m)
{
	if ((UInt32)m.Msg == Constant.WM_SYSCOMMAND)
	{
		switch ((UInt32)m.WParam)
		{
			case Constant.SC_MAXIMIZE:
                break;
			case Constant.SC_RESTORE:
                break;
			default:
				break;
		}
	}
	base.WndProc(ref m);
}