Fix Unicode Win32 API calls in cord de_win
authorIvan Maidanski <ivmai@mail.ru>
Sat, 2 Aug 2014 08:56:27 +0000 (12:56 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 2 Aug 2014 08:56:27 +0000 (12:56 +0400)
* 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

index 84a5bc7..a19ff49 100644 (file)
 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);