  $ filename "t.exe"
  'uses rtl32
  'uses rtl64
  uses MinWin



  #lookahead ' for procedures


  macro EventKeyDown()
  ====================
  select wParam
  case 27 : SendMessage hwnd, WM_CLOSE, 0, 0 'ESCAPE
  end Select
  end macro

  macro EventLbuttonDown()
  ========================
  print "left button"
  end macro

  macro EventRbuttonDown()
  ========================
  print "right button"
  end macro

  macro EventMouseMove()
  ======================
  end macro

  macro EventTimer()
  ==================
  end macro



  ==========
  'MAIN CODE
  ==========
  
  dim cmdline as asciiz ptr, inst as sys
  &cmdline=GetCommandLine
  inst=GetModuleHandle 0
  '
  'WINDOWS START
  '=============
  '
  WinMain inst,0,cmdline,SW_NORMAL
  end




  '--------------------------------------------------------------------
  Function WinMain(sys inst, prevInst, asciiz*cmdline, sys show) as sys
  '====================================================================


  WndClass wc
  MSG      wm

  sys hwnd, wwd, wht, wtx, wty, tax

  wc.style = CS_HREDRAW or CS_VREDRAW
  wc.lpfnWndProc = @WndProc 
  wc.cbClsExtra =0
  wc.cbWndExtra =0    
  wc.hInstance =inst
  wc.hIcon=LoadIcon 0, IDI_APPLICATION
  wc.hCursor=LoadCursor 0,IDC_ARROW
  wc.hbrBackground = GetStockObject WHITE_BRUSH 
  wc.lpszMenuName =null
  wc.lpszClassName = strptr "Demo"

  RegisterClass (@wc)
 
  Wwd = 320 : Wht = 200
  Tax = GetSystemMetrics SM_CXSCREEN
  Wtx = (Tax - Wwd) /2
  Tax = GetSystemMetrics SM_CYSCREEN
  Wty = (Tax - Wht) /2
 
  hwnd = CreateWindowEx 0,wc.lpszClassName,"OXYGEN BASIC",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0
  ShowWindow hwnd,SW_SHOW
  UpdateWindow hwnd
  '
  sys bRet
  '
  do while bRet := GetMessage (@wm, 0, 0, 0)
    if bRet = -1 then
      'show an error message
    else
      TranslateMessage @wm
      DispatchMessage @wm
    end if
  wend

  End Function 



  dim as rect crect 'for WndProc and TimerProc

  '------------------------------------------------------------------
  function WndProc ( sys hWnd, wMsg, wParam, lparam ) as sys callback
  '==================================================================

    static as sys hdc
    static as String txt
    static as PaintStruct Paintst
 
    '==========
    select wMsg
    '==========
        
      case WM_CREATE
      '=============

      GetClientRect  hWnd,&cRect

      case WM_DESTROY
      '===============
          
      PostQuitMessage 0
        
      case WM_PAINT
      '============


      'TEXT
      'http://msdn.microsoft.com/en-us/library/dd144821(v=VS.85).aspx

      'DRAWING AND PAINTING
      'http://msdn.microsoft.com/en-us/library/dd162760(v=VS.85).aspx

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

      SetBkColor   hdc,yellow
      SetTextColor hdc,red
      DrawText hDC,"Hello World!",-1,&cRect,0x25
      EndPaint hWnd,&Paintst
        
      case WM_KEYDOWN     : EventKeyDown()
      case WM_LBUTTONDOWN : EventLbuttonDown()
      case WM_RBUTTONDOWN : EventRbuttonDown()
      case WM_MOUSEMOVE   : EventMouseMove()
      case WM_TIMER       : EventTimer()

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

  end function ' WndProc

 