03-09-2015 04:05 PM
Is there a way to forbid active resizing of a panel below minimums? I've read this post and looked up example projects, but they mostly deal with the EVENT_PANEL_SIZE event (after the resize is done).
I'd like to utilize the EVENT_PANEL_SIZING event which is while the resizing is happening. The idea is this:
As you click and drag the size of a panel, I would like the panel to stop resizing with your mouse cursor once the minimum height and width dimensions are reached. This seams like it should be easy. But I can't quite crack it.
Solved! Go to Solution.
03-09-2015 04:26 PM
Yes, there's a trick to EVENT_PANEL_SIZING to constrain sizes (I think it's in the list of examples, otherwise search for it).
But personally I find it easier to use EVENT_PANEL_SIZE and GetPanelAttribute(...ATTR_WIDTH) and "if (Width<Limit) Width=Limit" before doing the disposition of my controls. This way you avoid errors (negative size or position controls) while still allowing the user to give the panel a tiny size to get it 'out of the way'. There's no real drawback to this. I think.
03-09-2015 04:32 PM
Thanks,
Yeah, I have that method working now. It's funcational, but I don't love it. The reason is that I feel it gives a "jumpy" effect to the user. When they attempt a size that is below the minimums, then the callback will force it back to the minimums, which is kind of jolting to my eye.
03-09-2015 04:36 PM - edited 03-09-2015 04:47 PM
Eureka! Good suggestion on the search. The CVI example projects app didn't find much for this, so I did a search in MS Explorer for "EVENT_PANEL_SIZING". There's a really great project in there called 'events.cws'.
There's an option to restrict panel sizing dynamically. A very nice implementation.
The "magic" you mentioned looks to be usage of GetPanelEventRect & SetPanelEventRect. Not very intuitive a solution, but magical.