05-07-2014 06:07 PM
I have a pop-up dialog GUI VI with an event structure.
I am programatically positioning certain elements on the GUI based on the window size. I do this positioning inside a "Panel Resize" event if the "Act" of the event was either "Maximize" or "Resized".
I would like to programatically trigger this event to run once when the VI first launches, to ensure that all my elements are properly positioned (in case something shifted during developement), however, the only way i have found to do that is to manually resize the window.
Of course a possible workaround is to put the positioning code in a sub-vi, but for various reasons I would rather not do that in this case, though I'll probably have to do it..
(I tried changing the panel size by -1 but this does not seem to genereate an event.)
So, is there a way to programatically create a "Panel Resize" event similar to a "Value (signaling)" property?
Thanks!
Solved! Go to Solution.
05-07-2014 07:41 PM - edited 05-07-2014 07:42 PM
05-08-2014 09:04 AM
I did as you suggested, not sure what to use for the "data type" input, so I used the "Act" enum from the original Panel Resize event, but when registering for that event "type" there are no "OldBnds" and "NewBnds" available anymore so you have to remove them from your event frame "cluster" before you can run.
Based on this, I'm either doing this wrong, or there is no way to create or trigger a "true" resize event that provides all the "frame outputs" assoicated with a real resize event?
Not sure if it helps clarify anything, but the following composite screen shot shows the frame outputs for a panel resize event, and in the red box, the limited subset of frame outputs available if I also include the "user event".
Is there a secret place to grab a "panel size" event data type that I can use to create the user event, and if so, where do I find it? (I'm guessing its in the same mythical place where you grab references to "group" items so you can easily move a group of objects with one property "position" command...)
05-08-2014 09:16 AM
@QFang wrote:
I did as you suggested, not sure what to use for the "data type" input, so I used the "Act" enum from the original Panel Resize event, but when registering for that event "type" there are no "OldBnds" and "NewBnds" available anymore so you have to remove them from your event frame "cluster" before you can run.
Based on this, I'm either doing this wrong, or there is no way to create or trigger a "true" resize event that provides all the "frame outputs" assoicated with a real resize event?
Not sure if it helps clarify anything, but the following composite screen shot shows the frame outputs for a panel resize event, and in the red box, the limited subset of frame outputs available if I also include the "user event".
Is there a secret place to grab a "panel size" event data type that I can use to create the user event, and if so, where do I find it? (I'm guessing its in the same mythical place where you grab references to "group" items so you can easily move a group of objects with one property "position" command...)
I would not treat the user event in the same event case as the Panel Resize event. The user event can be of any type, if I understand correctly you just want to trigger an event. You can use the front panel window bounds property to get the dimensions of the front panel. You can use this cluster as data type.
Ben64
05-08-2014 09:27 AM
As you can only resize and reposition FP objects by using property nodes, I don't see the advantage in keeping the functionality OUT of a SubVI. I have been doing this for years with a generic user interface which positions most oc the Objects relative to the FP bounds which is set relative to the workspace size on the primary desktop. You don't even need to pass in references as you can generate them using the VI call chain or other and getting an array of control references from the Panel. Provided that you define the position of each control by name, this actually works out quite nicely.
- My UI adds width to a large text box and auto spaces colunms based on a ratio within a 2D auto scaling Multicolumn listbox (add and remove rows based on number of pixels available to play with) As I never know what resolution someone is going to use for their monitor all I have to do is specify a minimum size and a maximum size that I have tested!
Think about it - you'll see it makes sense (also you can defer FPUpdates until all controls are respostioned to where they are expected thus speeding up the process).
James
05-08-2014 10:06 AM
You don't need trigger the event.
User producer-consumer design.
Don't handle the panel size inside the event structure. Handle it in a case in the consumer loop.
When initial, enqueue the same case right after initial the queue.
05-08-2014 12:40 PM
yes, normally thats what I would do, however, for a quick pop-up dialog window, it is rather overkill to do a full blown producer consumer design.
I'll go with the previously suggested user event and sub-vi encapsulation (I felt inspired and started my own set of re-use VI's that take a generic control reference in, and positions it anywhere on its active panel/pane or in one of 9 pre-defined relative positions with optional offsets.. you can do a lot with vi server!)