  #case capital
  def NULL null
  uses corewin
  uses imgwin
  #lookahead ' for procedures


  sub GDIP_GetImages(sys hWnd, hDC, int mode=1)
  '============================================
  '
  static int      hstatus
  static sys      pGraphics,pImage
  static wstring  strFileName
  static int      nwidth,nheight
  '
  if mode=0
    if pImage
      GdipDisposeImage(pImage)
    endif
    if pGraphics
      GdipDeleteGraphics(pGraphics)
    endif
    pGraphics=0
    exit sub
  end if
  '
  if pGraphics=0
    hStatus GdipCreateFromHDC hdc, pGraphics
    strFileName = "../images/Dawn1815.jpg"
    hStatus = GdipLoadImageFromFile strFileName, pImage
    if hStatus
      pImage=0 : exit sub
    endif
    'hStatus = GdipGetImageWidth pImage, nWidth
    'hStatus = GdipGetImageHeight pImage, nHeight
  endif
  '
  if pImage
    RECT r
    GetClientRect hwnd,r
    nwidth=r.right
    nheight=r.bottom
    GdipDrawImageRectI pGraphics, pImage, 0, 0, nWidth, nHeight
  endif
  '
  end sub


  '==================
  'GLOBAL DEFINITIONS
  '==================

  sys inst,hdc


  '=========
  'MAIN CODE
  '=========
  
  dim cmdline as asciiz ptr
  &cmdline=GetCommandLine
  inst=GetModuleHandle 0
  

  '--------------------------------------------------------------------------------------------------------------
  Function WinMain(byval inst as long,byval prevInst as long,byval cmdline as asciiz, byval show as long) as long
  '==============================================================================================================


  sys hr,hdlg,token
  GdiplusStartupInput StartupInput

  StartupInput.GdiplusVersion = 1
  hr=GdiplusStartup token, StartupInput, byval 0
  '
  if hr
    print "Error initializing GDIplus: " hex hr
    exit function
  end if


  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 =@"Demo"

  RegisterClass (&wc)
 
  Wwd = 800 : Wht = 600
  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
  '
  int bRet
  '
  do while bRet := GetMessage (&wm, 0, 0, 0)
    if bRet = -1
      'show an error message
      exit while
    else
      TranslateMessage &wm
      DispatchMessage &wm
    end if
  wend

  GdiplusShutdown token

  End Function 



  RECT crect 'for WndProc and TimerProc


    Long count=0, refreshes=0, hdc

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

 
    indexbase 0
    % ID_FIRSTCHILD  100 
    static as PAINTSTRUCT Paintst
    static sys i,w,px,py,lx,ly,nx,ny,id,idmenu,style
    static sys hchw[0x200] 
    static string s,stys
  
    '==========
    select wMsg
    '==========
        
    case WM_CREATE
    '=============

      SetWindowText hwnd,"Static controls over backgrount image"
      'style=WS_CHILD | WS_BORDER | WS_VISIBLE
      style=WS_CHILD | WS_VISIBLE
      py=10 : lx=180 : ly=50 : stys="static"

      for i = 0 to 1
        id=ID_FIRSTCHILD+i
        px=10+i*200
        hchw[i]=CreateWindowEx(0,stys, null, style, px,py,lx,ly, hwnd, id, inst, null)
        SetWindowText hchw[i], "Control " i
        ShowWindow(hchw[i], SW_SHOW)
      next

     case   WM_CTLCOLORSTATIC
     ========================

       SetTextColor(wPARAM, 0xffffff)
       'set background to transparent
       SetBkMode(wPARAM, 1)
       return GetStockObject(NULL_BRUSH)
               
    case WM_DESTROY
    ===============

     hDC=GetDC hWnd    
     GDIP_GetImages hWnd,hDC,0
     PostQuitMessage 0
        
    case WM_ERASEBKGND
    ==================

      hDC=GetDC hWnd
      GDIP_GetImages hWnd,hDC
      refreshes+=1
      return 1
        
    case WM_KEYDOWN
    '==============

      '============            
      Select wParam
      '============

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

       End Select
       '

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

  end function ' WndProc

  WinMain(inst,0,cmdline,SW_NORMAL)

  'print refreshes
 