MM们
自己写一个格式化MessageBox嘛:#include <windows.h>#include <tchar.h>#include <stdio.h>int CDECL MessageBoxPrintf(TCHAR * szCaption, TCHAR * szFormat, ...){va_list pArgList;va_start(pArgList, szFormat);TCHAR szBuffer[1024];_vsntprintf_s(szBuffer, sizeof szBuffer / sizeof TCHAR, szFormat, pArgList);va_end(pArgList);return MessageBox(NULL, szBuffer, szCaption, MB_OK);}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iShowCmd){int year = 2007;const TCHAR* greeting = "Hello!";MessageBoxPrintf(TEXT("Message"), TEXT("%s This is year %d"), greeting, year);}或者使用wsprintf:#include <windows.h>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){TCHAR buffer[1024];int year = 2007;const TCHAR* month = TEXT("Apr.");int day = 11;wsprintf(buffer, TEXT("Today is: %d %s %d"), day, month, year);MessageBox(NULL, buffer, TEXT("Data Report"), MB_OK | MB_ICONASTERISK);}