
  $ filename "t.exe"
  uses corewin


  % ID_Timer   3000
  % Interval   100


  
  dim cmdline as asciiz ptr,inst as sys
  &cmdline=GetCommandLine
  inst=GetModuleHandle 0
  '
  '
  function WndProc (sys hWnd,wMsg,wParam,lparam) as sys callback
  ==============================================================

    static as sys hdc, htimer
    static as sys hDCs
    static as String txt
    static as RECT crect
    static as RECT rs
    static as PAINTSTRUCT Paintst
    static as POINT p
    static as int pix
 
    '==========
    select wMsg
    '==========
        
      case WM_CREATE

      hTimer = SetTimer (hWnd, ID_Timer, 100, 0)
      GetClientRect hWnd,@crect

typedef struct tagMONITORINFO {
  DWORD cbSize;
  RECT  rcMonitor;
  RECT  rcWork;
  DWORD dwFlags;
} MONITORINFO, *LPMONITORINFO;

'HMONITOR MonitorFromPoint(
'  POINT pt,
'  DWORD dwFlags
');

#define MONITOR_DEFAULTTONULL       0x00000000
#define MONITOR_DEFAULTTOPRIMARY    0x00000001
#define MONITOR_DEFAULTTONEAREST    0x00000002

sys hm
'POINT pt
'pt.x=100
'pt.y=100
hm=MonitorFromWindow(hWnd,MONITOR_DEFAULTTOPRIMARY)
MONITORINFO mi
mi.cbSize=sizeof mi
GetMonitorInfo hm,@mi
'mbox str mi.rcMonitor.right
'mbox str mi.rcWork.right
  
hDCs=GetDC 0


'GetClientRect  hWnd,&cRect

       case WM_TIMER

      GetCursorPos @p
      pix=GetPixel(hDCs,p.x, p.y)
      InvalidateRect hwnd,&crect, 1

      case WM_DESTROY
          
      ReleaseDC hDCs
      KillTimer(hWnd,ID_TIMER)
      PostQuitMessage 0
        
      case WM_PAINT

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

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

       'SetBkColor   hdc,pix
       SetTextColor hdc,0
       txt="x y color " str(p.x) " , " str(p.y) " , " hex(pix,6)
       DrawText hDC,strptr txt,-1,&cRect,0x25
       EndPaint hWnd,&Paintst
       ValidateRect hwnd,&crect 
        
      case WM_KEYDOWN

        Select wParam

	Case 27 : SendMessage hwnd, WM_CLOSE, 0, 0      'ESCAPE

        End Select
       '
       InvalidateRect hwnd, &cRect, 1 'FULL SCREEN REFRESH

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

  end function ' WndProc


  Function WinMain(sys inst,prevInst,zstring*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 =0
  wc.lpszClassName = strptr "Demo"

  RegisterClass (&wc)
 
  Wwd = 400 : 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=0
      exit while
    end if
    if bRet = -1
      'show an error message
      exit while
    else
      TranslateMessage @wm
      DispatchMessage @wm
    end if
  end while
  End Function 

  WinMain inst,0,cmdline,SW_NORMAL
  
 