I am implementing a listbox with sizable columns and have ran into the following issue:
The listbox sizes without consideration for the dialogs extents:
Default (before sizing):
When decreasing size:
When increasing size:
This occurs with or without the extended attribute to allow last column to resize
extendedIntAttributes {{{EXTINTATTR_ITEMATTRS, LISTATTRX_USERRESIZELASTCOL}}};
Anyone know how to fix this?
What are you resizing: the ListBox, the DialogBox, or both?
Are any hook functions involved here?
Regards, Jon Summers LA Solutions
Hi Jon,
1) Just resizing the list columns by header. Dialog is non-sizable.
3) Just the standard hook function processing the following messages:
case DITEM_MESSAGE_CREATE: case DITEM_MESSAGE_DESTROY: case DITEM_MESSAGE_BUTTON: case DITEM_MESSAGE_STATECHANGED:
P.S. Here's the resource spec:
DItem_ListBoxRsc DITEM_QAFlagList = { NOHELP, NOHELP, HOOKID_QAFlagList, NOARG, LISTATTR_NOSELECTION|LISTATTR_DYNAMICSCROLL|LISTATTR_RESIZABLECOLUMNS, 17,0,"",{ {1*XC, 2, 0, "*"}, {6*XC, 16, 0, "Category"}, {6*XC, 128, 0, "Name"}, {16*XC, 128, 0, "Description"}, {8*XC, 256, 0, "Block"}, } } extendedIntAttributes {{{EXTINTATTR_ITEMATTRS, LISTATTRX_USERRESIZELASTCOL}} };
To clarify "Just resizing the list columns by header" I mean sizing the column interactively with the mouse not programmatically.
Loren said:I mean sizing the column interactively with the mouse not programmatically
The innards of MDL dialog items are a mystery. What behavioural difference is there when you omit LISTATTRX_USERRESIZELASTCOL?
LISTATTRX_USERRESIZELASTCOL
It's not advertised, but the MicroStationAPI introduced hook classes for dialogs and dialog items. They are useful because you can do way with those unwieldy switch statements: instead, you just implement a virtual function.
Better yet, you can create a hierarachy of your own hook function classes. For example, I wrote a class that handles the code to deallocate the ListModel assigned to a ListBox or ComboBox. When your hook class inherits from that class, your ListModel will always be deallocated, so you can't forget.
Jon Summers said:What behavioural difference is there when you omit LISTATTRX_USERRESIZELASTCOL?
Same behavior. Going to look into hooking the DITEM_MESSAGE_DRAW message and try to limit the sizing there.
Update: I have opened a SELECT Service request on this issue. When 1st level support could not figure out how to reproduce this I supplied the following:
To reproduce all you have to do is add the "| LISTATTR_RESIZABLECOLUMNS" attribute to the LISTBOXID_SelectionList resource of Bentley's API listbox example (C:\Program Files\Bentley\MicroStationCONNECTSDK\examples\DialogBoxes\listbox\listmult.r):
DItem_ListBoxRsc LISTBOXID_SelectionList = { NOHELP, MHELP, NOHOOK, NOARG, LISTATTR_DYNAMICSCROLL | LISTATTR_NEVERSELECTION | LISTATTR_RESIZABLECOLUMNS, 10, 2, TXT_CurrentSelection, { {1*XC, 1, 0, ""}, /* { */ {4*XC, 8, ALIGN_RIGHT, TXT_Row}, {4*XC, 8, ALIGN_RIGHT, TXT_Col}, {2*XC, 1, 0, ""}, /* } */ {14*XC, 60, 0, ""}, {8*XC, 60, 0, ""}, } };
Compile the sample MA and then resize the columns:
Some time ago, but I had the same problem and the solution is quite simple. This happens when the width of the listbox is set to 0 in the dialog box definition, which means that the width is determined by the column widths, like so:
{{X1, Y6, 0, 0}, ListBox, LISTBOXID_CMT_One, ON, TEXT_MASK_LABELABOVE | LABEL_FONT_BOLD, "One mapping found:", ""},
The listbox should be set to a fixed width like so:
{{X1, Y6, W2, 0}, ListBox, LISTBOXID_CMT_One, ON, TEXT_MASK_LABELABOVE | LABEL_FONT_BOLD, "One mapping found:", ""},
Now the listbox keeps a fixed size while the columns are scaled, which is the desired behaviour.