04-01-2016 05:01 AM
Hello,
I am working with some legacy code, and I am using LabWindows CVI 2010 (might be updated to 2015). Part of the code builds a panel with controls at runtime, with code like:
// Main panel.
selectPanel->handle = NewPanel(0, tempBuf,centerY-127+BORDER_WIDTH, centerX-198+BORDER_WIDTH,300,400);
...
//Button
selectPanel->deleteCtrlBtn = NewCtrl (selectPanel->handle,CTRL_SQUARE_COMMAND_BUTTON,"DELETE",258,114);
SetCtrlAttribute (selectPanel->handle, selectPanel->deleteCtrlBtn, ATTR_WIDTH, 76);
SetCtrlAttribute (selectPanel->handle, selectPanel->deleteCtrlBtn, ATTR_HEIGHT, 26);
SetCtrlAttribute (selectPanel->handle, selectPanel->deleteCtrlBtn,ATTR_CALLBACK_FUNCTION_POINTER, deleteCtrlBlkBtnCB);
SetCtrlAttribute (selectPanel->handle, selectPanel->deleteCtrlBtn, ATTR_LABEL_BOLD, 0);
...More controls etc...
So most attributes, like size and position is set at runtime. If I want to make this panel (with controls) user resizable (with minimize and maximize) can I build an UIR file
for that panel instead of the runtime code to solve my problem?
Best regards,
ChristianG.
P.S. I am very new to the LabWindows development environment. D.S.
04-01-2016 05:23 AM
If the problem is only the min/max facility, some SetPanelAttribute with ATTR_CAN_MAXIMIZE and ATTR_CAN_MINIMIZE attributes is all you need to add.
If on the other hand you want the user to be able to size the panel and adapt its aspect to the new size, you'll need to play with ATTR_SCALE_CONTENTS_ON_RESIZE and ATTR_RESOLUTION_ADJUSTMENT attributes. Be warned that the latter cannot be set for a panel already in memory: you must call SetSystemAttribute with this attribute before creating the panel. To add those functionalities you do not need to rewrite the panel from scratch as only a feww calls are needed. With scale contents on resize, all controls on the panel are rescaled when resizing the panel.
Another option you have is to use splitters, which can be tailored so that some controls are rescaled and some moved when operating splitters (and some others may be simply ignored in the process). In this case the move to the UIR editor is almost mandatory, as using AddCtrlToSplitter and understanding how it works can be a little confising at the beginning.
04-01-2016 06:09 AM
Thank you for the quick answer!
I need user resizability (minimize and maximzie would be nice to but not needed). It sounds like using SetSystemAttribute with ATTR_SCALE_CONTENTS_ON_RESIZE and ATTR_RESOLUTION_ADJUSTMENT is the easiest way, if I understood you correctly. I will look into that function some more.
I am not sure I understand the second section. If I design a panel with controls, using UIR editor (that would be my first time), will that panel (and controls?) have user resizability as a default attribute or do I have to use what you called splitters in the design?
04-01-2016 07:12 AM - edited 04-01-2016 07:12 AM
Of course resizability can be setup in the UIR editor too: the corresponding parameters are grouped in the panel you see pressing Other attributes... button in panel settings:
What I was intending in my second sentence is that there is an alternative to the rescale and is the use of splitters. Splitters do not rescale controls: they can move or resize them instead, in some you can find it more convenient than rescaling. I personally don't like the simple rescale and extensively use splitters especially if I need to expand an application to full screen, possibly with an aspect ratio different from the one I used in desiginig the panel.
04-01-2016 07:35 AM
I tried adding the following code to my panel:
SetPanelAttribute(selectPanel->handle,ATTR_SIZABLE,1);
SetPanelAttribute(selectPanel->handle,ATTR_SCALE_CONTENTS_ON_RESIZE,1);
But the panel is still not resizable. Meaning I can not grab the frame and resize it. I guess I am missing something!
04-01-2016 08:02 AM - edited 04-01-2016 08:03 AM
Is the panel modal (i.e. displayed with InstallPopup)? If so, you won't be able to resize it. The situation is described in this very old thread, as fas as I know it has not changed over time.
04-01-2016 08:05 AM
The panel is used as a popup:
InstallPopup (selectPanel->handle);
are popup panels resizable?
04-01-2016 08:06 AM
I guess that is the problem!
🙂
Thanks!