LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Panel/Control Resize

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.

0 Kudos
Message 1 of 8
(6,027 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 8
(6,024 Views)

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?

 

 

0 Kudos
Message 3 of 8
(6,018 Views)

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:

Screenshot 2016-04-01 14.11.28.png

 

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 8
(6,009 Views)

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!

0 Kudos
Message 5 of 8
(6,005 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 6 of 8
(5,999 Views)

The panel is used as a popup:

 

InstallPopup (selectPanel->handle);

 

are popup panels resizable?

0 Kudos
Message 7 of 8
(5,997 Views)

I guess that is the problem!

 

🙂


Thanks!

0 Kudos
Message 8 of 8
(5,996 Views)