user180574
user180574

Reputation: 6094

MFC: how to make menu item auto-adjust to fit long string?

When the caption of a menu item is long, part of it is cut off. Is there way to make it auto-adjust to fit the whole string?

POPUP "&File"
    BEGIN
        MENUITEM "This is a pretty long me&nu item...\tCtrl+N", ID_FILE_LONG_ONE

Below is the screen shot (with some text concealed). What is seen in design doesn't match runtime; it doesn't display "Ctrl+N".

enter image description here

Upvotes: 0

Views: 351

Answers (1)

Jeaninez - MSFT
Jeaninez - MSFT

Reputation: 4040

As far as I'm concerned, the menu items are adaptive and can automatically adjust the width based on the length of the string.

Regarding the problem of not displaying shortcut keys, In my opinion, you may not add shortcut key resources to the control.

For example:

1,Add a menu item with the ID "ID_FILE_Long". When you only modify the "Caption" in the properties. The results are shown in the following figure:

enter image description here

enter image description here

2,I suggest you should try to add shortcut key resources to the menu item.Open the Accelerator resource in the Resource view. And then add a shortcut for the menu item with the ID "ID_FILE_Long", as shown in the figure below:

enter image description here

3,The results are shown in the following figure:

enter image description here

Upvotes: 1

Related Questions