
  $filename  "t.exe"
  'uses RTL64
  uses WinUtil

  sys hchw[2] 'child windows


  function WndProc(sys hWnd, wMsg, wParam,lparam) as sys callback
  ===============================================================
  
  indexbase 0  
  static sys hdc
  static RECT r

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

      SetWindowText hwnd,"Right-Click"

      int style
      string stys
      style=WS_CHILD | WS_THICKFRAME | WS_VISIBLE
      stys="static"
      hchw[0]=CreateWindowEx(0,stys, null, style, 0,0,0,0, hwnd, 100, hinst, null)
      stys="button"
      'style=WS_CHILD | BS_TEXT | BS_PUSHBOX | WS_VISIBLE
      style=WS_CHILD | BS_OWNERDRAW | BS_NOTIFY | WS_VISIBLE
      hchw[1]=CreateWindowEx(0,stys, null, style, 0,0,0,0, hwnd, 101, hinst, null)
      stys="edit"
      style=WS_CHILD | WS_VISIBLE '| ES_READONLY
      hchw[2]=CreateWindowEx(0,stys, null, style, 0,0,0,0, hwnd, 102, hinst, null)
      SetWindowText hchw[1],"ok"
      SetWindowText hchw[2],"Message Here"
      static sys hsbr=CreateSolidBrush 0xf0ffff
      SendMessage hwnd,WM_SIZE,0,0
      ShowWindow hchw[0],0
      ShowWindow hchw[1],0
      ShowWindow hchw[2],0


    case WM_DESTROY
    ================
          
    PostQuitMessage 0
      
    case WM_MOUSEMOVE
    =================

    static short mx,my
    mx=loword lparam
    my=hiword lparam

    case WM_RBUTTONDOWN
    ===================

    static int ms
    if not ms
      ms=1
      ShowWindow hchw[0],1
      ShowWindow hchw[1],1
      ShowWindow hchw[2],1
    endif

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

    sys hdc=wparam
    sys hwn=lparam
    if hwn=hchw[0]
      return hsbr
    endif

    case WM_CTLCOLOREDIT
    ====================

    sys hdc=wparam
    sys hwn=lparam
    int fcolor=0x880000
    int bcolor=0xf0ffff
    RECT rec
    if hwn=hchw[2]
      GetClientRect  hwn,@rec
      'sys hbr=CreateSolidBrush bcolor
      'FillRect hdc,@rec,hbr
      'DeleteObject hbr
      '
      SetBkColor   hdc,bcolor
      'SetTextColor hdc,fcolor
      'DrawText hDC,"text text",-1,@rec,0x25
      return hsbr
    endif

    case WM_CTLCOLORBTN
    ===================

    sys hdc=wparam
    sys hwn=lparam
    int bcolor=0x0020e0
    int fcolor=0xeeeeee
    RECT rec
    if hwn=hchw[1]
      GetClientRect  hwn,@rec
      sys hbr=CreateSolidBrush bcolor
      FillRect hdc,@rec,hbr
    
      SetBkColor   hdc,bcolor
      SetTextColor hdc,fcolor
      DrawText hDC,"OK",-1,@rec,0x25
      DeleteObject hbr
      return 0
    endif


    case WM_COMMAND
    ===============

    if wparam=101 'popup ok button
      ShowWindow hchw[0],0
      ShowWindow hchw[1],0
      ShowWindow hchw[2],0
      ms=0
    endif


    case WM_KEYDOWN
    ===============

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


    case WM_SIZE 
    ============

    RECT rc
    GetClientRect(hwnd, rc)
    int px=rc.right \2 - 100
    int py=rc.bottom \2 -35
    'child window, position x,y  size x.y, show
    MoveWindow(hchw[0], px,py, 200, 70, TRUE)
    MoveWindow(hchw[1], px+165,py+35, 30, 30 TRUE)
    MoveWindow(hchw[2], px+5,py+5, 190, 30 TRUE)

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


  MainWindow 320,220,WS_OVERLAPPEDWINDOW

