TMSFNCToolBarPopup AutoSize

I have a popup with 3 buttons, but want to have the control resize according to the button visibility. Is this possible?

Hi,

This should all happen automatically. Can you post your code snippet you are using?

procedure TfrmMain.fncToolBarPopupActivate(Sender: TObject);
var
Parent: TTMSFNCTreeViewNode;

begin
fncToolBarPopup.Align := TAlignLayout.Vertical;
Parent := fncTreeView.GetParentNode(FInspectorNode);
case TBaseObject(Parent.DataObject).ObjectType of
otRadar: begin
fncToolBarPopup.Buttons[0].Visible := True;
fncToolBarPopup.Buttons[1].Visible := True;
fncToolBarPopup.Buttons[2].Visible := False;
end;
otQuarantine, otBackTest: begin
fncToolBarPopup.Buttons[0].Visible := False;
fncToolBarPopup.Buttons[1].Visible := False;
fncToolBarPopup.Buttons[2].Visible := True;
end;
end;

end;

You need to set the visibility of the buttons before activating the popup. Then the popup will automatically be resized. Also, The Alignment of the popup should not be set to make the auto-size work based on the number of visible buttons.

Thanks Pieter!

Hi Pieter,

For some reason I can’t get this to work correctly. Attached a document showing the code I use and the response I get.

Regards,

Rainier

(Attachment TMSFNCToolbarPopup.docx is missing)

Hi Pieter,

For some reason I can’t get this to work correctly. Attached a document showing the code I use and the response I get.

Regards,

Rainier

TMSFNCToolbarPopup.pdf (42.7 KB)

Can you send me the complete sample project that demonstrates this?

Hi Pieter,

Attached is a sample project that shows this behaviour.

If you first select Test1 and right click for the popup to activate only one button is shown, which is correct. Now if you do the same for Test2 again only one button is shown, but there should be three buttons.

Now do the reverse by selecting Test2 after starting the application. Now the popup shows the three buttons which is correct. If you select Test1 now only one button is shown, but the control has the size of 3 buttons.

Regards,

Rainier

PopupTest.zip (43.5 KB)

Hi,

We have investigated the sample and are able to reproduce this. However, we haven't yet found a workaround for this issue. Please, as a workaround, create popup menus for each "state" you need to avoid setting buttons visible property.

Thanks Pieter, will follow your suggestion!