  '
  '
  $ filename "t.exe"
  includepath "$/inc/"
  '#include "RTL32.inc"
  '#include "RTL64.inc"
  include   "WinUtil.inc"

  MainWindow 320,100,WS_OVERLAPPEDWINDOW


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

  'MENU ITEMS
  '
  %IDM_FILE_NEW     40001
  %IDM_FILE_OPEN    40002
  %IDM_FILE_SAVE    40003
  %IDM_FILE_SAVE_AS 40004
  %IDM_APP_EXIT     40005
  %IDM_EDIT_UNDO    40006
  %IDM_EDIT_CUT     40007
  %IDM_EDIT_COPY    40008
  %IDM_EDIT_PASTE   40009
  %IDM_EDIT_CLEAR   40010
  %IDM_APP_HELP     40011
  %IDM_APP_ABOUT    40012
  '
  static sys hdc,hMenu,hMenuPopup
  static String txt
  static rect crect
  static PaintStruct Paintst
  sys id
  '
  select wMsg
  '==========
      
  case WM_CREATE

  hMenu = CreateMenu
  hMenuPopup = CreateMenu
  AppendMenu hMenuPopup, MF_STRING,    IDM_FILE_NEW,     "&New"
  AppendMenu hMenuPopup, MF_STRING,    IDM_FILE_OPEN,    "&Open..."
  AppendMenu hMenuPopup, MF_STRING,    IDM_FILE_SAVE,    "&Save"
  AppendMenu hMenuPopup, MF_STRING,    IDM_FILE_SAVE_AS, "Save &As..."
  AppendMenu hMenuPopup, MF_SEPARATOR, 0,                null
  AppendMenu hMenuPopup, MF_STRING,    IDM_APP_EXIT,     "E&xit"
  AppendMenu hMenu,      MF_POPUP,     hMenuPopup,       "&File"

  hMenuPopup = CreateMenu
  AppendMenu hMenuPopup, MF_STRING,    IDM_EDIT_UNDO,    "&Undo"
  AppendMenu hMenuPopup, MF_SEPARATOR, 0,                null
  AppendMenu hMenuPopup, MF_STRING,    IDM_EDIT_CUT,     "Cu&t"
  AppendMenu hMenuPopup, MF_STRING,    IDM_EDIT_COPY,    "&Copy"
  AppendMenu hMenuPopup, MF_STRING,    IDM_EDIT_PASTE,   "&Paste"
  AppendMenu hMenuPopup, MF_STRING,    IDM_EDIT_CLEAR,   "De&lete"
  AppendMenu hMenu,      MF_POPUP,     hMenuPopup,       "&Edit"

  hMenuPopup = CreateMenu
  AppendMenu hMenuPopup, MF_STRING,    IDM_APP_HELP,     "&Help"
  AppendMenu hMenuPopup, MF_STRING,    IDM_APP_ABOUT,    "&About MenuDemo..."
  AppendMenu hMenu,      MF_POPUP,     hMenuPopup,       "&Help"
  '
  SetMenu       hwnd, hMenu
  SetWindowText hwnd,"Menu Demo"
  '
  sys dis=MF_DISABLED or MF_GRAYED
  CheckMenuItem hMenu,IDM_FILE_NEW, MF_CHECKED
  EnableMenuItem hMenu,IDM_FILE_OPEN,dis
  hMenu = GetMenu(hwnd)
      
  case WM_COMMAND

  if wparam = %IDM_APP_EXIT then        
    'print "exit"
    SendMessage hwnd, WM_CLOSE, 0, 0
  end if
      
  case WM_DESTROY
  '
  PostQuitMessage 0

  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
