import '../lib/polyfill.js' import * as gui from 'gui' import { useState } from 'react' import { render, ListBox } from '../lib/react-qw/index.js' let itemCounter = 10 function App() { const [items, setItems] = useState(() => { const a: string[] = [] for (let i = 0; i < 10; i++) a.push(`Item ${i}`) return a }) const [selectedText, setSelectedText] = useState('none') const [selIndex, setSelIndex] = useState(0) return ( { if (e.msg === gui.WmMsg.LBUTTONDOWN) { setItems(prev => [...prev, `Item ${itemCounter++}`]) } }} /> { setSelIndex(i) setSelectedText(items[i]!) }} style={{ flexGrow: 1, alignSelf: 'stretch' }} /> ) } gui.RegisterClass('ListBoxDemo', (hwnd, msg, wParam, lParam) => { if (!hwnd) return gui.DefWindowProc(hwnd, msg, wParam, lParam) if (msg === gui.WmMsg.CREATE) { render(, hwnd) return 0 } // WM_COMMAND 现在由 ListBox wrapper 通过 onEvent 处理 return gui.DefWindowProc(hwnd, msg, wParam, lParam) }) const hwnd = gui.CreateWindow('ListBoxDemo', 'ListBox Demo', gui.WindowStyle.OVERLAPPEDWINDOW, 200, 100, 400, 500, null, null) if (hwnd) gui.ShowWindow(hwnd)