the_20extended_20combobox
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| the_20extended_20combobox [2018/03/31 13:19] – external edit 127.0.0.1 | the_20extended_20combobox [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| ===== Initialisation ===== | ===== Initialisation ===== | ||
| \\ To start off with we need to include this initialisation code:\\ \\ | \\ To start off with we need to include this initialisation code:\\ \\ | ||
| + | <code bb4w> | ||
| DIM icex{dwSize%, | DIM icex{dwSize%, | ||
| ICC_USEREX_CLASSES = &200 | ICC_USEREX_CLASSES = &200 | ||
| Line 9: | Line 10: | ||
| icex.dwICC% = ICC_USEREX_CLASSES | icex.dwICC% = ICC_USEREX_CLASSES | ||
| SYS " | SYS " | ||
| + | </ | ||
| \\ | \\ | ||
| ===== Image lists ===== | ===== Image lists ===== | ||
| \\ The set of images to be used in the extended combobox must be supplied as an //image list//. The first step is to create an empty image list as follows:\\ \\ | \\ The set of images to be used in the extended combobox must be supplied as an //image list//. The first step is to create an empty image list as follows:\\ \\ | ||
| + | <code bb4w> | ||
| dx% = 16 | dx% = 16 | ||
| dy% = 16 | dy% = 16 | ||
| Line 17: | Line 20: | ||
| SYS " | SYS " | ||
| IF himglist% = 0 ERROR 100, " | IF himglist% = 0 ERROR 100, " | ||
| + | </ | ||
| Here **dx%** and **dy%** are the width and height, respectively, | Here **dx%** and **dy%** are the width and height, respectively, | ||
| + | <code bb4w> | ||
| nimages% = 5 | nimages% = 5 | ||
| bmpfile$ = @lib$+" | bmpfile$ = @lib$+" | ||
| Line 23: | Line 28: | ||
| SYS " | SYS " | ||
| IF hbitmap% = 0 ERROR 100, " | IF hbitmap% = 0 ERROR 100, " | ||
| + | </ | ||
| Now it is straightforward to populate the first five images in the image list from the bitmap:\\ \\ | Now it is straightforward to populate the first five images in the image list from the bitmap:\\ \\ | ||
| + | <code bb4w> | ||
| SYS " | SYS " | ||
| SYS " | SYS " | ||
| + | </ | ||
| More images (or strips) can be added, up to the limit specified when the image list was created, using further calls to **ImageList_Add**.\\ \\ Now the image list is ready we can concentrate on creating the extended combobox itself. The process depends on whether you want to display the combobox in a dialogue box or directly on your program' | More images (or strips) can be added, up to the limit specified when the image list was created, using further calls to **ImageList_Add**.\\ \\ Now the image list is ready we can concentrate on creating the extended combobox itself. The process depends on whether you want to display the combobox in a dialogue box or directly on your program' | ||
| ===== Dialogue box ===== | ===== Dialogue box ===== | ||
| \\ As usual, we must install the appropriate library for working with dialogue boxes:\\ \\ | \\ As usual, we must install the appropriate library for working with dialogue boxes:\\ \\ | ||
| + | <code bb4w> | ||
| INSTALL @lib$+" | INSTALL @lib$+" | ||
| + | </ | ||
| (alternatively install **WINLIB2A** or **WINLIB2B** if you need the facilities they provide).\\ \\ Now we will create a simple dialogue box containing just a cancel button and the extended combobox:\\ \\ | (alternatively install **WINLIB2A** or **WINLIB2B** if you need the facilities they provide).\\ \\ Now we will create a simple dialogue box containing just a cancel button and the extended combobox:\\ \\ | ||
| + | <code bb4w> | ||
| dlg% = FN_newdialog(" | dlg% = FN_newdialog(" | ||
| PROC_pushbutton(dlg%, | PROC_pushbutton(dlg%, | ||
| Line 43: | Line 54: | ||
| \ WS_VSCROLL OR CBS_AUTOHSCROLL OR CBS_DROPDOWN, | \ WS_VSCROLL OR CBS_AUTOHSCROLL OR CBS_DROPDOWN, | ||
| \ " | \ " | ||
| + | </ | ||
| Note that the combobox has been allocated the ID number **101**. Refer to the documentation for [[http:// | Note that the combobox has been allocated the ID number **101**. Refer to the documentation for [[http:// | ||
| + | <code bb4w> | ||
| PROC_showdialog(dlg%) | PROC_showdialog(dlg%) | ||
| + | </ | ||
| We've now created the dialogue box and the extended combobox, but the combobox is still empty. The next step is to tell the combobox which image list to use:\\ \\ | We've now created the dialogue box and the extended combobox, but the combobox is still empty. The next step is to tell the combobox which image list to use:\\ \\ | ||
| + | <code bb4w> | ||
| CBEM_SETIMAGELIST = &402 | CBEM_SETIMAGELIST = &402 | ||
| SYS " | SYS " | ||
| + | </ | ||
| Note the use of the combobox' | Note the use of the combobox' | ||
| + | <code bb4w> | ||
| CBEIF_TEXT = 1 | CBEIF_TEXT = 1 | ||
| CBEIF_IMAGE = 2 | CBEIF_IMAGE = 2 | ||
| Line 55: | Line 72: | ||
| DIM cbxi{mask%, iItem%, pszText%, cchTextMax%, | DIM cbxi{mask%, iItem%, pszText%, cchTextMax%, | ||
| \ iOverlay%, iIndent%, lParam} | \ iOverlay%, iIndent%, lParam} | ||
| + | </ | ||
| Now we can define each item as follows:\\ \\ | Now we can define each item as follows:\\ \\ | ||
| + | <code bb4w> | ||
| text$ = " | text$ = " | ||
| cbxi.mask% = CBEIF_TEXT OR CBEIF_IMAGE OR CBEIF_SELECTEDIMAGE | cbxi.mask% = CBEIF_TEXT OR CBEIF_IMAGE OR CBEIF_SELECTEDIMAGE | ||
| Line 63: | Line 82: | ||
| cbxi.iSelectedImage% = imageno% | cbxi.iSelectedImage% = imageno% | ||
| SYS " | SYS " | ||
| + | </ | ||
| Here **itemno%** is the item to define (starting at zero for the first item), **imageno%** is the image to display alongside the text (zero for the first image in the image list) and **text$** is the text for this item. Note particularly the **CHR$0** termination for the text string. You can set **itemno%** to the special value **-1**, which adds it at the end of the list.\\ \\ Note that is possible to use a different image for the currently selected item from that shown against the item in the drop-down list. If it's not convenient to define the text and image(s) at the same time, you can set the value of **cbxi.mask%** according to which you want to set.\\ \\ To test which item in the extended combobox is selected you can use exactly the same code as for a regular combobox:\\ \\ | Here **itemno%** is the item to define (starting at zero for the first item), **imageno%** is the image to display alongside the text (zero for the first image in the image list) and **text$** is the text for this item. Note particularly the **CHR$0** termination for the text string. You can set **itemno%** to the special value **-1**, which adds it at the end of the list.\\ \\ Note that is possible to use a different image for the currently selected item from that shown against the item in the drop-down list. If it's not convenient to define the text and image(s) at the same time, you can set the value of **cbxi.mask%** according to which you want to set.\\ \\ To test which item in the extended combobox is selected you can use exactly the same code as for a regular combobox:\\ \\ | ||
| + | <code bb4w> | ||
| CB_GETCURSEL = &147 | CB_GETCURSEL = &147 | ||
| SYS " | SYS " | ||
| + | </ | ||
| \\ | \\ | ||
| ===== Main output window ===== | ===== Main output window ===== | ||
| \\ The process for creating an extended combobox on the main output window is very similar to that for creating one in a dialogue box. As usual, we must install the appropriate library for working with boxes and buttons:\\ \\ | \\ The process for creating an extended combobox on the main output window is very similar to that for creating one in a dialogue box. As usual, we must install the appropriate library for working with boxes and buttons:\\ \\ | ||
| + | <code bb4w> | ||
| INSTALL @lib$+" | INSTALL @lib$+" | ||
| + | </ | ||
| (alternatively install **WINLIB5A**, | (alternatively install **WINLIB5A**, | ||
| + | <code bb4w> | ||
| WS_VSCROLL = &200000 | WS_VSCROLL = &200000 | ||
| CBS_AUTOHSCROLL = &40 | CBS_AUTOHSCROLL = &40 | ||
| Line 76: | Line 101: | ||
| hcbex% = FN_createwindow(" | hcbex% = FN_createwindow(" | ||
| \ WS_VSCROLL OR CBS_AUTOHSCROLL OR CBS_DROPDOWN, | \ WS_VSCROLL OR CBS_AUTOHSCROLL OR CBS_DROPDOWN, | ||
| + | </ | ||
| Refer to the documentation for [[http:// | Refer to the documentation for [[http:// | ||
| + | <code bb4w> | ||
| CBEM_SETIMAGELIST = &402 | CBEM_SETIMAGELIST = &402 | ||
| SYS " | SYS " | ||
| + | </ | ||
| Note the use of the combobox' | Note the use of the combobox' | ||
| + | <code bb4w> | ||
| CBEIF_TEXT = 1 | CBEIF_TEXT = 1 | ||
| CBEIF_IMAGE = 2 | CBEIF_IMAGE = 2 | ||
| Line 86: | Line 115: | ||
| DIM cbxi{mask%, iItem%, pszText%, cchTextMax%, | DIM cbxi{mask%, iItem%, pszText%, cchTextMax%, | ||
| \ iOverlay%, iIndent%, lParam} | \ iOverlay%, iIndent%, lParam} | ||
| + | </ | ||
| Now we can define each item as follows:\\ \\ | Now we can define each item as follows:\\ \\ | ||
| + | <code bb4w> | ||
| text$ = " | text$ = " | ||
| cbxi.mask% = CBEIF_TEXT OR CBEIF_IMAGE OR CBEIF_SELECTEDIMAGE | cbxi.mask% = CBEIF_TEXT OR CBEIF_IMAGE OR CBEIF_SELECTEDIMAGE | ||
| Line 94: | Line 125: | ||
| cbxi.iSelectedImage% = imageno% | cbxi.iSelectedImage% = imageno% | ||
| SYS " | SYS " | ||
| + | </ | ||
| Here **itemno%** is the item to define (starting at zero for the first item), **imageno%** is the image to display alongside the text (zero for the first image in the image list) and **text$** is the text for this item. Note particularly the **CHR$0** termination for the text string. You can set **itemno%** to the special value **-1**, which adds it at the end of the list.\\ \\ Note that is possible to use a different image for the currently selected item from that shown against the item in the drop-down list. If it's not convenient to define the text and image(s) at the same time, you can set the value of **cbxi.mask%** according to which you want to set.\\ \\ To test which item in the extended combobox is selected you can use exactly the same code as for a regular combobox:\\ \\ | Here **itemno%** is the item to define (starting at zero for the first item), **imageno%** is the image to display alongside the text (zero for the first image in the image list) and **text$** is the text for this item. Note particularly the **CHR$0** termination for the text string. You can set **itemno%** to the special value **-1**, which adds it at the end of the list.\\ \\ Note that is possible to use a different image for the currently selected item from that shown against the item in the drop-down list. If it's not convenient to define the text and image(s) at the same time, you can set the value of **cbxi.mask%** according to which you want to set.\\ \\ To test which item in the extended combobox is selected you can use exactly the same code as for a regular combobox:\\ \\ | ||
| + | <code bb4w> | ||
| CB_GETCURSEL = &147 | CB_GETCURSEL = &147 | ||
| SYS " | SYS " | ||
| + | </ | ||
the_20extended_20combobox.1522502386.txt.gz · Last modified: 2024/01/05 00:16 (external edit)