right aligned shortcut key in menu item

Started by czerny, August 18, 2014, 12:55:47 PM

Previous topic - Next topic

czerny

Hallo,

with a menu item string "Example\tCtrl-x" I get left aligned shurtcuts. But I want them right aligned.

After a bit of googling I found "Example\aCtrl-x". But it is not working, neither in resources nor with AppendMenu. Pelle doubles the backshlash. Is there an other methode?

jj2007

#1
If the escapes don't work properly, use an array of chars?

  char x[] = {'E', 'x', 'a', 'm', 'p', 'l', 'e', 7, 'C', 't', 'r', 'l', '-', 'x', 0};
  printf("The string: [%s]\n", x);

(assuming \a means Ascii 7...)

P.S.: In assembler, one would use chr$("Example", 7, "Ctrl-X", 0)
Is there a C equivalent to that syntax?

czerny

Quote from: jj2007 on August 18, 2014, 03:08:40 PM
P.S.: In assembler, one would use chr$("Example", 7, "Ctrl-X", 0)
Is there a C equivalent to that syntax?

"Example\07Ctrl-X" // doesn't work!

sprintf(MenuItem, "%s%cCtrl-X", "Example", 7); // doesn't work!

frankie

#3
Quote from: jj2007 on August 18, 2014, 03:08:40 PM
In assembler, one would use chr$("Example", 7, "Ctrl-X", 0)
Is there a C equivalent to that syntax?

char string[] = "Example\x07Ctrl-X"
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

JohnF

Found this, it works ok here using \t.


hMenu = CreateMenu();

hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, TEXT("&File"));
AppendMenu(hSubMenu, MF_STRING, MENU_FILE_NEW, TEXT("&New\tCtrl+N"));



John

czerny

#5
Quote from: JohnF on August 18, 2014, 04:16:02 PM
Found this, it works ok here using \t.


hMenu = CreateMenu();

hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, TEXT("&File"));
AppendMenu(hSubMenu, MF_STRING, MENU_FILE_NEW, TEXT("&New\tCtrl+N"));



John

John! If you do this

hMenu = CreateMenu();

hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, TEXT("&File"));
AppendMenu(hSubMenu, MF_STRING, MENU_FILE_NEW, TEXT("&New\tCtrl+N"));
AppendMenu(hSubMenu, MF_STRING, MENU_FILE_BLA, TEXT("&Bla\tAlt+Ctrl+B"));



is than 'Ctrl+N' and 'Alt+Ctrl+B' left aligned or right aligned?

See http://msdn.microsoft.com/en-us/library/windows/desktop/aa381024(v=vs.85).aspx
and http://stackoverflow.com/questions/4975077/how-do-i-right-align-the-shortcut-keys-in-menu

JohnF

To the right. See image

I can send the project if you want.

John

TimoVJL

I think czerny has found bug in porc.exe. It doesn't handle that escape \a correctly.
That left-hand aligning is WinForms feature and needs OwnerDraw for WinAPI32.
May the source be with you

JohnF

Quote from: TimoVJL on August 19, 2014, 05:00:01 AM
I think czerny has found bug in porc.exe. It doesn't handle that escape \a correctly.
That left-hand aligning is WinForms feature and needs OwnerDraw for WinAPI32.

Welcome back!

John

czerny

I am a little bit confused.

Quote from: TimoVJL on August 19, 2014, 05:00:01 AM
I think czerny has found bug in porc.exe. It doesn't handle that escape \a correctly.
That left-hand aligning is WinForms feature and needs OwnerDraw for WinAPI32.

Do you really mean that the left-hand aligning is WinForms feature?

John: If this is a Pelles C project, then please post the project!

JohnF

Quote from: czerny on August 19, 2014, 08:37:15 AM
I am a little bit confused.

Quote from: TimoVJL on August 19, 2014, 05:00:01 AM
I think czerny has found bug in porc.exe. It doesn't handle that escape \a correctly.
That left-hand aligning is WinForms feature and needs OwnerDraw for WinAPI32.

Do you really mean that the left-hand aligning is WinForms feature?

John: If this is a Pelles C project, then please post the project!

Here it is.

John

czerny

#11
Quote from: JohnF on August 19, 2014, 09:15:30 AM
Here it is.
And it is not right-aligned!

See the Pelles C IDE edit menu as an example.

JohnF

What am I missing? The short cuts look right aligned to me.

John

frankie

"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide