\ File: Combobox.f \ Author: Jeff Kelm \ Created: 07-Dec-1998 \ Updated: 31-Dec-1998 \ Generic Combo box class Comment: Revision History (most recent first) 19981231 - Incorporated the new ChildWindow class. 19981208 - corrected index value in InsertString: (was rel>abs 0 LB_INSERTSTRING) 19981207 - Created Comment; NEEDS BasicWin.f CR .( Loading Combobox class...) :Class Combobox R NULL appInst CreateNewID R> CW_USEDEFAULT CW_USEDEFAULT CW_USEDEFAULT CW_USEDEFAULT DefStyle: [ self ] WS_CHILD OR \ style NULL \ initial string to display Z" COMBOBOX" rel>abs NULL Call CreateWindowEx DUP TO hWnd ?WinError ;M comment; :M AddString: ( lpszString) \ add a new string to the combobox list rel>abs 0 CB_ADDSTRING SendMessage: self CB_ERR OVER = SWAP CB_ERRSPACE = OR ABORT" Error adding string to combo box" ;M :M InsertString: ( lpszString posn) \ insert string in specified position (0 based) >R rel>abs >R CB_INSERTSTRING SendMessage: self CB_ERR OVER = SWAP CB_ERRSPACE = OR ABORT" Error adding string to combo box" ;M :M DeleteString: ( index) \ delete string in specified position (0 based) 0 SWAP CB_DELETESTRING SendMessage: self DROP ;M :M Clear: ( -- ) \ clears all strings from combo box 0 0 CB_RESETCONTENT SendMessage: self DROP ;M :M Find: ( lpszString -- index) \ search the list for an item beginning \ with the string (case-insensitive) rel>abs -1 CB_FINDSTRING SendMessage: self ;M :M FindExact: ( lpszString -- index) \ find the first item that matches \ the string exactly (case-insensitive) rel>abs -1 CB_FINDSTRINGEXACT SendMessage: self ;M :M GetCount: ( -- n) \ return count of items in list 0 0 CB_GETCOUNT SendMessage: self ;M \ use GetText: to retrieve contents of edit control \ use SetText: to specify the contents of edit control (not on DropdownCombo) :M GetString: ( index -- a n) \ return string of specified item \ 0 OVER CB_GETLBTEXTLEN SendMessage: self HERE rel>abs SWAP CB_GETLBTEXT SendMessage: self HERE SWAP ;M :M GetCurrent: ( -- index) \ return current selection item 0 0 CB_GETCURSEL SendMessage: self ;M :M SetCurrent: ( index) \ set selection to item 0 SWAP CB_SETCURSEL SendMessage: self DROP ;M :M SelectString: ( lpszString -- index) \ select item beginning with string rel>abs -1 CB_SELECTSTRING SendMessage: self ;M ;Class :Class SimpleCombo