From 5145ea19859f13f5a08df2ff84857d080b70743d Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 2 Aug 2014 12:56:27 +0400 Subject: Fix Unicode Win32 API calls in cord de_win * cord/tests/de_win.c (FullAppName): Remove global variable. * cord/tests/de_win.c (szAppName): Turn into macro; use TEXT(). * cord/tests/de_win.c (de_error): Force calling ANSI version of MessageBox; remove casts to LPSTR. * cord/tests/de_win.c (WinMain): Use TEXT() for lpszMenuName field and for CreateWindow agrument. * cord/tests/de_win.c (WndProc): Use TEXT() for DialogBox argument; force calling ANSI version of TextOut. --- cord/tests/de_win.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/cord/tests/de_win.c b/cord/tests/de_win.c index 84a5bc70..a19ff495 100644 --- a/cord/tests/de_win.c +++ b/cord/tests/de_win.c @@ -28,16 +28,14 @@ int LINES = 0; int COLS = 0; -char szAppName[] = "DE"; -char FullAppName[] = "Demonstration Editor"; +#define szAppName TEXT("DE") HWND hwnd; void de_error(char *s) { - MessageBox( hwnd, (LPSTR) s, - (LPSTR) FullAppName, - MB_ICONINFORMATION | MB_OK ); + (void)MessageBoxA(hwnd, s, "Demonstration Editor", + MB_ICONINFORMATION | MB_OK); InvalidateRect(hwnd, NULL, TRUE); } @@ -63,7 +61,7 @@ int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wndclass.hIcon = LoadIcon (hInstance, szAppName); wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = GetStockObject(WHITE_BRUSH); - wndclass.lpszMenuName = "DE"; + wndclass.lpszMenuName = TEXT("DE"); wndclass.lpszClassName = szAppName; if (RegisterClass (&wndclass) == 0) { @@ -96,7 +94,7 @@ int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, } hwnd = CreateWindow (szAppName, - FullAppName, + TEXT("Demonstration Editor"), WS_OVERLAPPEDWINDOW | WS_CAPTION, /* Window style */ CW_USEDEFAULT, 0, /* default pos. */ CW_USEDEFAULT, 0, /* default width, height */ @@ -279,7 +277,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, return( 0 ); case IDM_HELPABOUT: - if( DialogBox( hInstance, "ABOUTBOX", + if( DialogBox( hInstance, TEXT("ABOUTBOX"), hwnd, AboutBoxCallback ) ) InvalidateRect( hwnd, NULL, TRUE ); return( 0 ); @@ -324,15 +322,15 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, SetBkMode(dc, OPAQUE); SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT)); - TextOut(dc, this_line.left, this_line.top, - plain, (int)len); - TextOut(dc, this_line.left + (int)len * char_width, - this_line.top, - blanks, (int)(COLS - len)); + TextOutA(dc, this_line.left, this_line.top, + plain, (int)len); + TextOutA(dc, this_line.left + (int)len * char_width, + this_line.top, + blanks, (int)(COLS - len)); SetBkMode(dc, TRANSPARENT); SetTextColor(dc, RED); - TextOut(dc, this_line.left, this_line.top, - control, (int)strlen(control)); + TextOutA(dc, this_line.left, this_line.top, + control, (int)strlen(control)); } } EndPaint(hwnd, &ps); -- cgit v1.2.1