Michael Aivaliotis Posted December 21, 2006 Report Share Posted December 21, 2006 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? Quote Link to comment
Jim Kring Posted December 21, 2006 Report Share Posted December 21, 2006 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. Quote Link to comment
Grampa_of_Oliva_n_Eden Posted December 21, 2006 Report Share Posted December 21, 2006 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 Quote Link to comment
LAVA 1.0 Content Posted December 21, 2006 Report Share Posted December 21, 2006 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 Quote Link to comment
Michael Aivaliotis Posted December 21, 2006 Author Report Share Posted December 21, 2006 Wow jimi, thanks! The VI you posted works great! The trick is the mouse down+up combination. Quote Link to comment
PJM_labview Posted December 21, 2006 Report Share Posted December 21, 2006 - 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 Quote Link to comment
Michael Aivaliotis Posted December 21, 2006 Author Report Share Posted December 21, 2006 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).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. Quote Link to comment
LAVA 1.0 Content Posted December 21, 2006 Report Share Posted December 21, 2006 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). Quote Link to comment
Michael Aivaliotis Posted December 21, 2006 Author Report Share Posted December 21, 2006 Well, there's another way to detect a change. You can detect the column width size before and after and compare the two. Quote Link to comment
crelf Posted December 22, 2006 Report Share Posted December 22, 2006 Perhaps you want to post the final solution to the code repository :thumbup: Great idea! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.