Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

COLSTYLE message (Checkbox column style)

I have code that uses the COLSTYLE message to change the style of the first column of an OI edit-table to a checkbox for each cell:

EditTable = @Window:".EDT_PRINT_FAX"
ColStyle1 = Send_Message(EditTable, "COLSTYLE", 1)
ColStyle1 = bitor(ColStyle1, 0x10000)
ColStyle1 = Send_Message(EditTable, "COLSTYLE", 1, ColStyle1)

If the cell has not before been ticked, I need two single mouse-clicks to tick the box:
one click to highlight the cell;
a second click to produce a tick in the cell's checkbox.
Subsequently the same cell can be unticked and ticked with one mouse-click.

Has anyone found a workaround to avoid two initial single-clicks to produce a tick?

Comments

  • I can't recall experiencing this before. I don't work with the OI edit table control a lot, but I just happened to help a client get an OI edit table with a checkbox configured last week. Do you see this behavior even if you carefully click in the checkbox itself?

    P.S. I highly recommend you add the RTI_Style_Equates insert into your code so you can use DTCS_CHECKBOX$ instead of 0x100000 when working with styles. It will make your code much easier to read.
  • Yes, the mouse cursor points at the middle of the unchecked box, unmoved between first and second clicks: same behavior.

    Thanks for the insert advice. I will add it to this old code.
  • Confirm something for me. Let's say you've already clicked in a cell (twice) and you are now able to toggle the tick in the checkbox. Do you need to click twice to toggle the tick in a different cell?
  • Yes, for every cell I tried: click twice initially in the cell to toggle the tick first time.

    There is code to tick every cell in the column as the default when starting the window, courtesy of a "select all" checkbox outside the table. With every cell initially ticked, one click suffices to toggle the tick. But by unticking this "select all" checkbox to untick every cell in the column, I am back to needing two clicks to initially produce a tick in a cell.

    When I was at first trying to fix this, I added code in a CLICK event subroutine for this edit-table (CLICK.EDT_PRINT_EMAIL) to toggle the tick. But, using the debugger, the tick toggled in the window before the CLICK event code was reached. I cannot find the code that does this, and a colleague thinks that it is tied up with the COLSTYLE message that I posted earlier.

    (By the way, ".EDT_PRINT_FAX" in my first post should have read ".EDT_PRINT_EMAIL".)
  • I'm inclined to believe that you have some event handler that is running upon the clicking into the cell that is preventing the checkbox tick from taking effect immediately. It could be GOTFOCUS or POSCHANGED event. I would have suggested CLICK, but it appears you did not already have a CLICK event until recently.
  • I believe the CLICK event handler has been in the code for quite some time. For the window in question we have handlers for the CHANGED, CLICK, CREATE, DBLCLK, GOTFOCUS, ONCLICK and POSCHANGED events (and other events for individual controls). I have worked out that the tick toggles after GOTFOCUS or POSCHANGED. More accurately, after the handlers for these two finish, PROMOTED_EVENTS is called, and it is when PROMOTED_EVENTS returns that the tick toggles, before the handler for the CLICK event is reached.

    If I place debugs everywhere I can think of (excluding the WINMSG and MOUSEOVER events), the tick still toggles on returning from PROMOTED_EVENTS, but now stopping at the beginning of the ..._EVENTS stored procedure for this window, again before the the runtime program reaches the CLICK event handler.

    This next question may reveal my unfamiliarity with the windowing world, but is it at all possible that the COLSTYLE message code in my first post could be solely responsible, both for the tick toggling before the CLICK event handler and for the initial single click on an unticked box failing to fill the box? Or will it always have to be some event that is triggered, for which I have not found the code?
  • This next question may reveal my unfamiliarity with the windowing world, but is it at all possible that the COLSTYLE message code in my first post could be solely responsible, both for the tick toggling before the CLICK event handler and for the initial single click on an unticked box failing to fill the box? Or will it always have to be some event that is triggered, for which I have not found the code?


    What event handler is calling Send_Message to set COLSTYLE?
  • The window CREATE event handler calls Send_Message. (Unfortunately Send_Message itself is a closed book.) So I suppose that COLSTYLE is finished with once the window has been created.

    I have tried removing the COLSTYLE code. The column then populates with ones and zeros rather than ticks and no ticks. In that case I don't need to click twice to toggle a cell.
  • Okay, good. I really wanted to make sure this wasn't being called during a reoccurring event and thus itself was creating the problem. I continue to see both novice and veteran developers call code in every event handler, even though it should only exist in the CREATE event hander.

    This next question may reveal my unfamiliarity with the windowing world, but is it at all possible that the COLSTYLE message code in my first post could be solely responsible, both for the tick toggling before the CLICK event handler and for the initial single click on an unticked box failing to fill the box? Or will it always have to be some event that is triggered, for which I have not found the code?


    I think I understand your question but I'm not 100% sure how to answer it. I do not think the checkbox has its own event handler, if that helps. I'm still inclined to believe you have related event handlers that are interfering with normal behavior. The only way to know for certain is to remove all event handlers. That may prove to be difficult. At the very least, open up another application (like EXAMPLES) where there are no promoted events, and create a simple form with an edit table control and create a column with checkboxes. See if you can tick the checkbox in one click or two clicks.
  • I will do that. Unfortunately it won't be straightaway as I've been roped into another task.
  • Well, I found the cause of the problem -- a zero in the code instead of an empty string to uncheck all checkboxes in the column. When the user unticked the "select or deselect all" checkbox, a zero was written to all checkboxes in the column; similarly a one was written to all checkboxes if the user ticked the "select or deselect all" checkbox. I have not found OpenInsight documentation to indicate what values the tickboxes takes for a "CheckBox" COLSTYLE, but I suppose for the original programmer a zero made sense. However I found through the debugger that after a zero has been written to the checkbox in the code, which definitely clears it, trying to toggle the empty checkbox by clicking it writes an empty string to it, and it remains cleared. So it appears that although programmatically writing either a zero or an empty string clears the checkbox, clicking an unticked checkbox that has been "zeroed" instead of "emptied" effectively resets it to a default empty string behind the scenes, and it remains unticked. Replacing 0 with "" fixed the problem.
  • Nice pickup
Sign In or Register to comment.