

  'http://msdn.microsoft.com/en-us/library/ms632598(VS.85).aspx

  $ filename "t.exe"
  'uses RTL32
  'uses RTL64
  $ EscapeKeyEnd
  uses WinUtil
  MainWindow 900,480,WS_OVERLAPPEDWINDOW


  % ID_FIRSTCHILD  100 


  sys hinstance
  sys hWndMain


  'STANDARD CHILD WINDOWS STYLES
  '=============================
  '
  'Button	The class for a button.
  'ComboBox	The class for a combo box.
  'Edit	        The class for an edit control.
  'ListBox	The class for a list box.
  'MDIClient	The class for an MDI client window.
  'ScrollBar	The class for a scroll bar.
  'Static	The class for a static control.




  dim cRect   as rect
  dim Paintst as paintstruct

  dim hDC     as sys


  function WndProc(sys hwnd, uMsg, wParam, lParam) as long callback
  '================================================================
  indexbase 0
  RECT rcClient; 
  sys i,w,px,py,lx,ly,nx,ny,id,idmenu,style
  static sys hchw[0x200] 
  string s,stys
 
  select umsg 
 
  case WM_CREATE

    idmenu=0
    '
    SetWindowText hwnd,"Controls"
    style=WS_CHILD | WS_BORDER | WS_VISIBLE
    py=10 : lx=180 : ly=400 : stys="edit"
    ;
    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)
      ShowWindow(hchw[i], SW_SHOW)
    next
    '
    i=0x100
    lx=40
    ly=40
    nx=0
    ny=0
    stys="button"
    style=WS_CHILD | BS_TEXT | BS_PUSHBOX | WS_VISIBLE
    do
      i++
      px=410+nx*lx
      py=10+ny*ly
      id=i
      s=str id
      hchw[i]=CreateWindowEx(0,strptr stys, s, style, px,py,lx,ly, hwnd, id, inst, null)
      nx++
      if nx>=10 then
        ny++
        if ny>=5 then exit do 'complete x and y
        nx=0
      end if
    end do

    case WM_COMMAND

      id=wparam and 0xffff
      int co=wparam >>16
      if id>0x100 and id<0x200 then
        s="PushButton: " str id
        SetWindowText hWnd, s
        SetWindowText hchw[id], hex(id)+"h"
        SetFocus hwnd
      end if

    case WM_SIZE:   // main window changed size 
 
      'GetClientRect(hwnd, &rcClient); 
      'MoveWindow(hwndChild, w, 0, v, rcParent.bottom, TRUE); 
      'ShowWindow(hwndChild, SW_SHOW); 

    case WM_DESTROY: 
 
      PostQuitMessage 0 

    case else

      return DefWindowProc(hwnd, uMsg, wParam, lParam)
    end select
    '
  end function

 
