Win32: add proper Unicode support to message boxes.
Before this commit, for every non-ASCII character, a replacement character was also printed.
This commit is contained in:
parent
fbd89a7e30
commit
c43a1988ae
@ -58,6 +58,7 @@ SiHdl SpaceNavigator = SI_NO_HANDLE;
|
|||||||
|
|
||||||
HWND MessageWnd, OkButton;
|
HWND MessageWnd, OkButton;
|
||||||
bool MessageDone;
|
bool MessageDone;
|
||||||
|
int MessageWidth, MessageHeight;
|
||||||
const char *MessageString;
|
const char *MessageString;
|
||||||
|
|
||||||
static LRESULT CALLBACK MessageProc(HWND hwnd, UINT msg, WPARAM wParam,
|
static LRESULT CALLBACK MessageProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||||
@ -78,21 +79,13 @@ static LRESULT CALLBACK MessageProc(HWND hwnd, UINT msg, WPARAM wParam,
|
|||||||
case WM_PAINT: {
|
case WM_PAINT: {
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
HDC hdc = BeginPaint(hwnd, &ps);
|
HDC hdc = BeginPaint(hwnd, &ps);
|
||||||
int row = 0, col = 0, i;
|
|
||||||
SelectObject(hdc, FixedFont);
|
SelectObject(hdc, FixedFont);
|
||||||
SetTextColor(hdc, 0x000000);
|
SetTextColor(hdc, 0x000000);
|
||||||
SetBkMode(hdc, TRANSPARENT);
|
SetBkMode(hdc, TRANSPARENT);
|
||||||
for(i = 0; MessageString[i]; i++) {
|
RECT rc;
|
||||||
if(MessageString[i] == '\n') {
|
SetRect(&rc, 10, 10, MessageWidth, MessageHeight);
|
||||||
col = 0;
|
std::wstring text = Widen(MessageString);
|
||||||
row++;
|
DrawText(hdc, text.c_str(), text.length(), &rc, DT_LEFT | DT_WORDBREAK);
|
||||||
} else {
|
|
||||||
TextOutW(hdc, col*SS.TW.CHAR_WIDTH + 10,
|
|
||||||
row*SS.TW.LINE_HEIGHT + 10,
|
|
||||||
Widen(&(MessageString[i])).c_str(), 1);
|
|
||||||
col++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -149,6 +142,8 @@ void SolveSpace::DoMessageBox(const char *str, int rows, int cols, bool error)
|
|||||||
const char *title = error ? "SolveSpace - Error" : "SolveSpace - Message";
|
const char *title = error ? "SolveSpace - Error" : "SolveSpace - Message";
|
||||||
int width = cols*SS.TW.CHAR_WIDTH + 20,
|
int width = cols*SS.TW.CHAR_WIDTH + 20,
|
||||||
height = rows*SS.TW.LINE_HEIGHT + 60;
|
height = rows*SS.TW.LINE_HEIGHT + 60;
|
||||||
|
MessageWidth = width;
|
||||||
|
MessageHeight = height;
|
||||||
MessageWnd = CreateWindowClient(0, L"MessageWnd", Widen(title).c_str(),
|
MessageWnd = CreateWindowClient(0, L"MessageWnd", Widen(title).c_str(),
|
||||||
WS_OVERLAPPED | WS_SYSMENU,
|
WS_OVERLAPPED | WS_SYSMENU,
|
||||||
r.left + 100, r.top + 100, width, height, NULL, NULL, Instance, NULL);
|
r.left + 100, r.top + 100, width, height, NULL, NULL, Instance, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user