Odd issue with sfoSelectColumns not working as expected
I am seeing an odd issue and hoping someone may have some guidance. In our app, I added sfoSelectColumns to each grid's title menu attributes. When the menu option is selected, the columns dialog appears and I select (check) a column to add. However, the column is not added.
In troubleshooting, ExecuteSelectGridColumnsDialog shows the dialog, iterates the nodes, and finds the node that I checked. At this point, node.FieldName is an empty string for some reason. Walking backwards and looking at TwwCustomDBGrid.DoInitSelectColumnsDialog, I confirmed that node.FieldName is assigned the expected field name. I also confirmed the memory address of the node is the same address of the node at the point that FieldName is empty.
Further, I assigned a setter method to the TwwSelectColumnsTreeNode.FieldName property, to try and find a reason for the value to be an unexpected empty string. No luck. I have not been able to determine why the FieldName value is lost.
I have not been able to reproduce the issue in a simple test app. My plan is to get the test app closer to the configuration of the real application.
Our app is using ADO (dbGo) datasets and TwwDataSource. TwwDBGrid.UseTFields is False, although setting it to True does not resolve the issue.
Any thoughts? Thanks.
-
It took quite a while, but I discovered the cause. Our application has Application.ModalPopupMode := pmAuto. TwwGridSelectColumnsForm has PopupMode set to pmNone. This causes the TreeView window to be destroyed and recreated without persisting the TreeView's items (nodes). Remy provides an excellent explanation in the StackOverflow link below.
That link also includes a couple of solutions. Perhaps Roy could do some testing and implement one as a solution for InfoPower dialogs.
I found a slightly easier solution that works for my issue. I added
PopupMode := Application.ModalPopupMode;
to the bottom of TwwGridSelectColumnsForm.Create(AOwner: TComponent); This was part of Alexandre's solution. But this scenario does not appear to require overriding DoClose and broadcasting CM_DESTROYHANDLE.
https://stackoverflow.com/questions/32099167/pmauto-modalpopupmode-proper-use-or-bug-workaround
Please sign in to leave a comment.
Comments
1 comment