Basic Univers
; Papier peint de Windows sur une fenêtre

Procedure.l myCallback(hWnd.l, uMsg.l, wParam.l, lParam.l)
   Select uMsg
      Case #WM_ERASEBKGND
         ProcedureReturn
      Case #WM_PAINT
         For i = 1 To 2
            x = GadgetX(i)
            y = GadgetY(i)
            SetRect_(Rect.RECT, x, y, x + GadgetWidth(i), y + GadgetHeight(i))
            ValidateRect_(hWnd, Rect)
            RedrawWindow_(GadgetID(i), 0, 0, $407)
         Next
         PaintDesktop_(BeginPaint_(hWnd, ps.PAINTSTRUCT))
         EndPaint_(hWnd, ps)
      Case #WM_SIZING, #WM_MOVING
         InvalidateRect_(hWnd, 0, 1)
   EndSelect
   ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

If OpenWindow(0, 100, 100, 320, 240, "", #PB_Window_SystemMenu|#PB_Window_SizeGadget)
   CreateGadgetList(WindowID(0))
   ButtonGadget(1, 5, 5, 100, 50, "Hello")
   EditorGadget(2, 5, 60, 100, 175)
   SetWindowCallback(@myCallback(), 0)
   InvalidateRect_(WindowID(0), 0, 1)
   Repeat: Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf