
  includepath "$/inc/"
  $ filename "t.exe"
  'include   "RTL32.inc"
  'include   "RTL64.inc"
  include   "WinUtil.inc"

  MainWindow 320,100,WS_OVERLAPPEDWINDOW


  function WndProc(sys hWnd, wMsg, wParam,lparam) as sys callback
  ===============================================================
    
  % ID_Timer   3000
  % Interval   100

  static sys hdc, htimer, keycode, charcode
  static String txt
  static PaintStruct Paintst
  static RECT crect

  '==========
  select wMsg
  '==========
        
    case WM_CREATE
    '=============

    hTimer = SetTimer hWnd, ID_Timer, interval, 0
    GetClientRect  hWnd,@cRect
    SetWindowText hwnd,"Key Codes and Ascii Codes"

    case WM_TIMER
    '=============

    InvalidateRect hwnd,@crect,1

    case WM_DESTROY
    '===============
          
    KillTimer(hWnd,ID_TIMER)
    PostQuitMessage 0
        
    case WM_PAINT
    '============

    hDC=BeginPaint hWnd,@Paintst
    GetClientRect  hWnd,@cRect
    'style
    '0x20 DT_SINGLELINE
    '0x04 DT_VCENTER
    '0x01 DT_CENTER
    '0x25

    SetBkColor   hdc,white
    SetTextColor hdc,blue
    '
    txt="Key Code 0x" hex(keycode,2) "     Char Code 0x" hex(charcode,2)
    '
    DrawText hDC,txt,-1,@cRect,0x25
    EndPaint hWnd,@Paintst
    ValidateRect hwnd,@crect 
      
    case WM_CHAR
    '===========

    charcode=wparam

    case WM_KEYDOWN
    '==============

    keycode=wParam : charcode=0
    if wParam=27 then SendMessage hwnd, WM_CLOSE, 0, 0      'ESCAPE

    case else
    '========
          
    function=DefWindowProc hWnd,wMsg,wParam,lParam
        
    end select
    '
  end function ' WndProc
