Jump to content

Trapping Column resizing of a MCL in an Xcontrol


Recommended Posts

Using LV8.2. I'm working on an Xcontrol that contains a multi-column listbox (MCL). I wanted to do certain things from inside the Xcontrol based on if a column was resized by the end user. One snag is that there are no events for this on MCL. I tried putting the code inside the timeout event case in the xcontrol but this case only executes under certain conditions. In other words it's not always called. One solution I was thinking was to spawn a parallel process VI (from within the Xcontrol) to monitor this continuously. Any other suggestions?

Link to comment
Using LV8.2. I'm working on an Xcontrol that contains a multi-column listbox (MCL). I wanted to do certain things from inside the Xcontrol based on if a column was resized by the end user. One snag is that there are no events for this on MCL. I tried putting the code inside the timeout event case in the xcontrol but this case only executes under certain conditions. In other words it's not always called. One solution I was thinking was to spawn a parallel process VI (from within the Xcontrol) to monitor this continuously. Any other suggestions?

The user can only change the column size as a result of moving the mouse. So, you could monitor the Mouse.Move event and check to see if any of the column positions have changed. You would probably want to send this to a notifier, rather than queuing up the events (since there will be a lot of them) and you generally only care about the current (latest) state.

Link to comment
I don't have time to investigate but I can share.

How about a mouse down event then use a MCListbox >>> Invoke node >>> Point to Row Collumn

It returns "In bounds"

and

I wonder what the CellPosition is when you click on the line seperating cells.

Ben

- Events Mouse Down and Mouse Up give you information if something is dragged on the control

- MCListbox >>> Invoke node >>> Point to Row Collumn gets you information where on the control mouse down and mouse up occurred (row, column) but doesn't tell if anything was resized

- You can however see if something was resized from the fact that the control FP image changes, so by comparing the image of the control from Mouse Down Event and Mouse Up event you know that the control has visually changed.

- If both mouse down and mouse up occurred on row -1 and same column, you know that the visual change cannot be due to anything else but resizing (if user cannot change header row strings)

- From mouse down and mouse up event Coords you can then find out how much the column was resized

Complicated but should get you there... Perhaps you want to post the final solution to the code repository

Edit: I wrote you a functional example

Download File:post-4014-1166738035.vi

Link to comment
- Events Mouse Down and Mouse Up give you information if something is dragged on the control

- MCListbox >>> Invoke node >>> Point to Row Collumn gets you information where on the control mouse down and mouse up occurred (row, column) but doesn't tell if anything was resized

- You can however see if something was resized from the fact that the control FP image changes, so by comparing the image of the control from Mouse Down Event and Mouse Up event you know that the control has visually changed.

- If both mouse down and mouse up occurred on row -1 and same column, you know that the visual change cannot be due to anything else but resizing (if user cannot change header row strings)

- From mouse down and mouse up event Coords you can then find out how much the column was resized

Complicated but should get you there... Perhaps you want to post the final solution to the code repository

Edit: I wrote you a functional example

Download File:post-4014-1166738035.vi

Jimi,

This is a nice trick (I can't believe there is no easier way to do this!). However, the attached VI appears to be non functional when the mouse up event does not appen on the header (ie, when you finish resizing inside the MCListbox but not over the header).

Also, for performance sake, I would set the image depth of the get image method to 1 (Black and White).

PJM

Link to comment
This is a nice trick (I can't believe there is no easier way to do this!). However, the attached VI appears to be non functional when the mouse up event does not appen on the header (ie, when you finish resizing inside the MCListbox but not over the header).

Also, for performance sake, I would set the image depth of the get image method to 1 (Black and White).

Both suggestions taken into account and the VI modified respectively. The attatchment is for LV 8.0.

Download File:post-4014-1166742406.vi

This is easily fixed if you remove the checking in the mouse up case to see if it's in the column. Don't need this check anyway.

For safety I think you should check that you are in the same column but you could ignore the row check in Mouse Up event (as I did in the v1.1 of the example).

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.