Rapid-Q Documentation by William Yu (c)1999-2000 | Appendix A: QCOMBOBOX |
|
Field | Type | R/W | Default | Support |
|
|
|
|
|
Align | INTEGER | RW | alNone | W |
Align determines how the control aligns within its parent control. | ||||
Color | INTEGER | RW | W | |
CopyMode | INTEGER | RW | cmBlackness | W |
Cursor | INTEGER | RW | crDefault | W |
DropDownCount | INTEGER | RW | 8 | W |
DropDownCount is the maximum number of items displayed in the drop-down list. | ||||
Enabled | INTEGER | RW | True | WXG |
Font | QFONT | W | W | |
Handle | INTEGER, for windows API calls | R | W | |
Height | INTEGER | RW | WXG | |
Hint | STRING | RW | WXG | |
Item | ARRAY of STRING | RW | WXG | |
ItemCount | INTEGER | R | WXG | |
ItemHeight | INTEGER | RW | W | |
ItemIndex | INTEGER | RW | -1 | WXG |
ItemIndex indicates which item in the drop-down list is selected. If no item is selected, then ItemIndex is -1. | ||||
Left | INTEGER | RW | 0 | WXG |
MaxLength | INTEGER | RW | W | |
MaxLength is the maximum number of characters the user can type into the edit portion of the combobox. | ||||
Parent | QFORM/QPANEL/QTABCONTROL | W | WXG | |
PopupMenu | QPOPUPMENU | W | W | |
ShowHint | INTEGER | RW | False | WXG |
Sorted | INTEGER | RW | False | WG |
Style | INTEGER | RW | csDropDown | W |
Style determines the display
style of the combobox. 0 = csDropDown -- A drop-down list with an edit box for manually entered text. 1 = csSimple -- A drop-down list with an edit box and a fixed list (list box) underneath. 2 = csDropDownList -- A drop-down list with no edit box for manual entry. 3 = csOwnerDrawFixed -- Owner-draw drop-down list with an edit box. Each item in the list is the height specified by the ItemHeight property. 4 = csOwnerDrawVariable -- Owner-draw drop-down list with an edit box. Each item can have varying heights. | ||||
TabOrder | INTEGER | RW | W | |
Tag | INTEGER | RW | WXG | |
Text | STRING | RW | W | |
Top | INTEGER | RW | 0 | WXG |
Visible | INTEGER | RW | True | WXG |
Width | INTEGER | RW | WXG |
Method | Type | Description | Params | Support |
|
|
|
|
|
AddItems | SUBI | Add items to combobox | STRINGs, Infinite | WXG |
Circle | SUB (x1%, y1%, x2%, y2%, c%, fill%) | Draw & Fill Circle | 6 | W |
Clear | SUB | Clears entire Combobox | 0 | WXG |
CopyRect | SUB (D, Image, S) | D and S are QRECTs, Image can be a QImage, QCanvas, or QBitmap | 3 | W |
DelItems | SUBI | Delete items by their index | Index #s, Infinite | WXG |
Draw | SUB (x%, y%, BMP) | Draw Bitmap at (X,Y) | 3 | W |
FillRect | SUB (x1%, y1%, x2%, y2%, c%) | Draws & Fills a rectangle | 5 | W |
InsertItem | SUB (Index%, String$) | Insert item at Index% | 2 | WXG |
Line | SUB (x1%, y1%, x2%, y2%, c%) | Draws a line | 5 | W |
Paint | SUB (x%, y%, c%, borderc%) | Fill Region | 4 | W |
Pset | SUB (x%, y%, c%) | Pixel plot | 3 | W |
Rectangle | SUB (x1%, y1%, x2%, y2%, c%) | Draws a rectangle | 5 | W |
Repaint | SUB | Force repainting of combobox | 0 | W |
RoundRect | SUB (x1%, y1%, x2%, y2%, x3%, y3%, c%) | Draws & Fills a rounded rectangle | 7 | W |
StretchDraw | SUB (Rect AS QRECT, BMP) | Draw BMP and stretch to fit inside Rect | 2 | W |
TextHeight | FUNCTION (Text$) AS WORD | Returns the height, in pixels, of Text$ string | 1 | W |
TextWidth | FUNCTION (Text$) AS WORD | Returns the width, in pixels, of Text$ string | 1 | W |
TextRect | SUB (Rect AS QRECT, x%, y%, S$, fc%, bc%) | Write text, and clip within region Rect | 6 | W |
TextOut | SUB (x%, y%, S$, fc%, bc%) | Writes text to image | 5 | W |
Event | Type | Occurs when... | Params | Support |
|
|
|
|
|
OnChange | VOID | User selects a different item | 0 | WXG |
OnDrawItem | SUB (Index%, State%, R AS QRect) | Items are redrawn for ownerdraw comboboxes | 3 | W |
OnMeasureItem | SUB (Index%, Height%) | Calculate Height for ownerdraw variable comboboxes | 3 | W |
DIM Form AS QForm DIM ComboBox AS QComboBox SUB ItemChanged PRINT ComboBox.Item(ItemIndex) END SUB ComboBox.Parent = Form ComboBox.OnChange = ItemChanged ComboBox.AddItems "1. Apples", "2. Oranges", "3. Bananas" Form.ShowModal
DECLARE FUNCTION SetFocus LIB "user32" ALIAS "SetFocus"(hwnd AS LONG) AS LONG DECLARE SUB EditKeyDown(Key AS WORD , Shift AS INTEGER) DECLARE SUB EditChange DECLARE SUB ComboChange DIM B AS INTEGER : CONST FALSE = 0 : CONST TRUE = 1 CREATE Form AS QFORM Width = 200 Height = 150 Center CREATE Combo AS QCOMBOBOX Left = 10 Top = 10 Width = 170 OnChange = ComboChange AddItems "Action" , "active" , "Advance" , "Adventure" , "Affair" , "Affection" , "Alighted" , "aligned","allured","Allegation" END CREATE CREATE Edit AS QEDIT 'Must be created after combo, to set the right z-order Left = 13 'if it doesn't overlap the Combo's edit, you have to move the Edit's values by yourself Top = 13 Width = 148 Height = 16 BorderStyle = 0 'guess why ;-) OnKeyDown = EditKeyDown 'for count the keys "back" and "delete" OnChange = EditChange END CREATE END CREATE SetFocus Edit.Handle Form.ShowModal SUB EditKeyDown(Key AS WORD , Shift AS INTEGER) IF Key = 37 OR Key = 8 THEN IF Edit.Text <> "" THEN B = TRUE END IF END SUB SUB EditChange DEFINT X , P 'P is the cursor position IF B = TRUE OR Edit.Text = "" THEN B = FALSE ELSE FOR X = 0 TO Combo.ItemCount - 1 IF INSTR(1 , UCASE$(Combo.Item(X)) , UCASE$(Edit.Text)) <> 0 THEN P = Edit.SelStart Edit.Text = Combo.Item(X) Edit.SelStart = P Edit.SelLength = LEN(Edit.Text) - P EXIT FOR END IF NEXT X END IF END SUB SUB ComboChange Edit.Text = Combo.Item(Combo.ItemIndex) 'so it works as a Combo too SetFocus Edit.Handle 'Edit.SelLength = 0 'or if you like: Edit.SelStart = 0 : Edit.SelLength = LEN(Edit.Text) END SUB
Prev Component | Contents | Next Component |