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?
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?
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!
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"
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
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 (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 (http://stackoverflow.com/questions/4975077/how-do-i-right-align-the-shortcut-keys-in-menu)
To the right. See image
I can send the project if you want.
John
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.
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
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!
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
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.
What am I missing? The short cuts look right aligned to me.
John
Czerny mean right justifyed.
Like this.
John
That is exactly what that app does.
Note the "&Copy\tC"
AppendMenu(hSubMenu, MF_STRING, MENU_EDIT_CUT, TEXT("Cu&t\tCtrl+X"));
AppendMenu(hSubMenu, MF_STRING, MENU_EDIT_COPY, TEXT("&Copy\tC"));
John
Quote from: JohnF on August 19, 2014, 12:20:33 PM
That is exactly what that app does.
I have not compiled your SmallEd2 example and we have different looks. Doesn't that mean that it is OS dependent?
I am working here with XP SP3.
Quote from: czerny on August 19, 2014, 12:41:32 PM
Quote from: JohnF on August 19, 2014, 12:20:33 PM
That is exactly what that app does.
I have not compiled your SmallEd2 example and we have different looks. Doesn't that mean that it is OS dependent?
I am working here with XP SP3.
Yes, I just tried it on an old XP - it is not working the same. Don't know what to suggest.
John
So the question arises: How can you left-align your shurtcuts?
Here (XP SP3) Pelles C ide shurtcuts are right-aligned and per example notepad is left-aligned. So there should be a difference. Do you have any differences?
Could anybody else try the SmallEd2 example and look at the edit menu?
sprintf(MenuItem, "%s%cCtrl-X", "Example", 8); // works!
Though '\a' == 7
a value of 8 is working.
'\b' is working too!
Ascii 7 doesn't work on XP SP3 (inserts a black dot),
8 means right-aligned,
9 means left-aligned.
Now the question is how it works on Win 7 + 8...
On Win7 \t and \b work the same, right aligned.
John