// InitRsrcDlg -- set up the dialog contents for the
// dialog box represented by hWnd.
void InitRsrcDlg(HWND hWnd)
{
TCHAR szTemplate[256];
TCHAR szDate[32];
TCHAR szTime[32];
PVOID pvBuffer;
PVOID pvArgs[] = {szTime, szDate};
TCHAR szCurrency[MAX_CURRENCY_LEN];
TCHAR szNumber[MAX_NUMERIC_LEN];
// First, initialize the startup time string.
// GetDateFormat is the NLS routine that formats a time in a
// locale-sensitive fashion. In this case, the current date is
// being displayed in the long date format
if (0 == GetDateFormat(g_dwCurLcid, DATE_LONGDATE, NULL, NULL,
szDate, 32)) {
return;
}
// GetTimeFormat is the NLS routine that formats a time in a
// locale-sensitive fashion. In this case, the current time is
// being displayed in the default format
if (0 == GetTimeFormat(g_dwCurLcid, 0, NULL, NULL, szTime, 32)) {
return;
}
// Load the formatting string for the date and time entry from the
// satellite DLL, not the main program. This resource is in
// whatever language is represented in the resource DLL; it is not
// directly sensitive to the operational language.
if (0 == LoadString(g_hRsrc, IDS_THETIMEIS, szTemplate, 256)) {
return;
}
// Use FormatMessage to create a single string which contains these
// items in the correct order. FormatMessage will allocate the
// output buffer containing the formatted message itself, but
// we will be responsible for freeing it when we're done.
FormatMessage(FORMAT_MESSAGE_FROM_STRING |
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_ARGUMENT_ARRAY,
szTemplate,
0, // Ignored
0, // Ignored
(LPTSTR) &pvBuffer,
256,
(va_list *) pvArgs);
// Display the string in the dialog box.
SetDlgItemText(hWnd, IDC_DATETIME, (LPCTSTR) pvBuffer);
// Release the buffer.
LocalFree(pvBuffer);
// Now, display the currency amount and the number using NLS.
// GetCurrencyFormat is the NLS routine that formats a currency
// amount in a locale-sensitive fashion.
if (0 != GetCurrencyFormat(g_dwCurLcid, 0, k_szCurrencyAmount, NULL,
szCurrency, MAX_CURRENCY_LEN)) {
SetDlgItemText(hWnd, IDC_CURRENCY, szCurrency);
}
// GetNumberFormat is the NLS routine which formats a number in a
// locale-sensitive fashion.
if (0 != GetNumberFormat(g_dwCurLcid, 0, k_szNumericAmount, NULL,
szNumber, MAX_NUMERIC_LEN)) {
SetDlgItemText(hWnd, IDC_NUMBER, szNumber);
}
}
lpBuffer [out]
A pointer to a buffer that receives the null-terminated string that specifies the formatted message. If dwFlags includes FORMAT_MESSAGE_ALLOCATE_BU
This buffer cannot be larger than 64K bytes.