home | |||
links |
|
||
developer's mag main page article part 1 part 2 part 3 part 4 part 5 |
4 - And Now to Wrap It UpOnce you have the list box, it's a simple matter to attach it to a window. Here we create a popup, complete with a Cancel button.
MsgHandler() picks up the row selection message MSG_ROW_SELECT, which has the row number in the data variable. We store this in the static variable Choice so the result is available to the program after this form closes. The only other point to note is that the Cancel button sets an invalid index of -1, so we can easily determine if no row was selected. To call this dialog up, we can use GUI_EventLoop(), and pass it an array of string selections and a total - upon return, Choice is set: This creates a modal form (one that doesn't return until it is closed); of course, we could also add the list box to the main form with AddChild().The documentation goes into detail about what you can do with it there, but unless you are planning on doing intensive programming with an interactive list box, you might find many of them unnecessary, with the exception of SetTopRow() and SetCurrentRow() for display positioning. An important note about display is that the CList constructor flag LISTOPTION_ALWAYS_HIGHLIGHT (which keeps the entry inverted instead of flashing it) affects the result of GetCurrentRow(). Rather than using it, I prefer to store the pick in a variable in the message loop, as in the example code. Previous Section Next Section |
||
Copyright © 2001-2006 ebmDevMag.com - Legal Notice |