Pergunta

I'm using the following code to set the format of the Time Picker control (with the Win32 class name SysDateTimePick32) to display time in US English format only:

LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
TCHAR buffFmt[200] = {0};
GetLocaleInfo(lcid, LOCALE_STIMEFORMAT, buffFmt, SIZEOF(buffFmt));

TRACE(buffFmt);    //"h:mm:ss tt"

::SendMessage(m_hWnd, DTM_SETFORMAT, 0, (LPARAM)buffFmt);

When I run it on my Windows 7 set up for US English user account the control looks good like this:

enter image description here

But if I run it on a Windows 7 with the user account set up for a German format:

enter image description here

the control looks as such (AM/PM part is missing):

enter image description here

Note that in both cases the format string is "h:mm:ss tt", which according to this page means that tt should stand for AM/PM part.

Any idea how to fix this?

Foi útil?

Solução

From the Region and Language control panel dialog, click the "Additional settings" button and then the Time tab. What is set for AM symbol and PM symbol?

On my Windows 7 machine, with the Format set to German, these are both empty strings. The datetime control gets the strings to display from the user's current locale, so even if you force it to display AM/PM in the format string it will not actually have anything to display for this part.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top