#define INCL_PM

#include <OS2.h>
#include <StdLib.h>
#include <functional>
#include <typeinfo>

#define t_id(x) ( typeid (x).hash_code () )
#define t_name(x) ( typeid (x).name () )

#define Run int main

//
// ...  ᠭ ⨯  ... 
//

Run ()
{
  //    ﭨ ணࠬ.
  P_PROGRAM_STATE Program_state; Allocate (&Program_state, t_id (PROGRAM_STATE), VM_PROGRAM_STATE | VM_WRITE_ZEROS);

  // 稭 ࠡ   窥.
  HAB Shell_handle = WinInitialize (0);

  //  । ᮮ饭.
  HMQ Msg_queue = WinCreateMsgQueue (Shell_handle, 0);

  //
  // ...    ᮧ  ... 
  //

  // ⠥ ᮮ饭  ।  .
  QMSG Message = {0}; ULONG Rc = 1;

  while (Rc)
  {
    Rc = WinGetMsg (Shell_handle, &Message, 0, 0, 0);

    if (Rc)
    {
      Message.reserved = (ULONG) Program_state; WinDispatchMsg (Shell_handle, &Message);
    }
  }

  //
  //  ⠪:
  // ReadMessages (Shell_handle, [=] (PQMSG Message) {
  //                                                   ProcessMessage (Program_state, Message);
  //                                                 });
  //
  //

  //
  //  ⠪:
  // WinMessageBox (HWND_DESKTOP, NULLHANDLE, "Hello World!", "", 0, 0);
  //

  // 
  //   뫮   ⠪:
  // WinReadMsgQueue (Msg_queue, Program_state);
  // 

;

  //
  // ...    㤠 ᮧ  ... 
  //

  // 塞 ।.
  WinDestroyMsgQueue (Msg_queue);

  // 蠥 ࠡ   窥.
  WinTerminate (Shell_handle);

  // 塞   ﭨ ணࠬ.
  Free (&Program_state);

  return 0;
}