home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / LOCALIZE.PAK / LOCALIZE.CPP next >
C/C++ Source or Header  |  1995-08-29  |  2KB  |  70 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectComponents - (C) Copyright 1994 by Borland International
  3. // Localization test
  4. //----------------------------------------------------------------------------
  5.  
  6. #define STRICT
  7. #include <windows.h>
  8. #include <stdio.h>
  9. #include <osl/locale.h>
  10. #include "localize.rh"
  11.  
  12. #if !defined(__WIN32__) // WINNLS defines these for WIN32
  13. #include "olenls.h"
  14. #endif
  15.  
  16. TLangId TLocaleString::NativeLangId = 0x0009; // = LANG_ENGLISH;
  17.  
  18. #define WM_USERSTAT (WM_USER + 100)
  19.  
  20. bool CALLBACK __export
  21. DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  22. {
  23.   if (msg == WM_INITDIALOG) {
  24.     return 1;
  25.   } else if (msg == WM_COMMAND) {
  26.     ::PostMessage(hDlg, WM_USERSTAT, wParam, lParam);
  27.     return 1;
  28.   } else if (msg == WM_CLOSE) {
  29.     ::PostMessage(hDlg, WM_USERSTAT, IDABORT, 0);
  30.     return 1;
  31.   }
  32.   return 0;
  33. }
  34.  
  35. int PASCAL
  36. WinMain(HINSTANCE hInst, HINSTANCE/*prev*/, char far* /*cmdLine*/, int/*show*/)
  37. {
  38.   HWND hWnd = ::CreateDialog(hInst, MAKEINTRESOURCE(IDD_OUT), 0, (DLGPROC)DlgProc);
  39.   if (!hWnd) {
  40.     ::MessageBox(0, "Could Not Create Dialog Box", "Error", MB_OK);
  41.     return 1;
  42.   }
  43.   for(;;) {
  44.     MSG msg;
  45.     int id = 0;
  46.     while (!id && ::GetMessage(&msg, 0, 0, 0)) {
  47.       if (msg.message == WM_USERSTAT)
  48.         id = msg.wParam;
  49.       else
  50.         ::IsDialogMessage(hWnd, &msg);
  51.     }
  52.     if (id == IDABORT || id == IDOK)
  53.       break;
  54.     if (id & 0x8000) {
  55.       id &= ~0x8000;
  56.       for (int w = IDC_FIRSTWORD; w <= IDC_LASTWORD; w++) {
  57.         char buf[50];
  58. //      TLocaleString word = (const char*)buf;
  59.         TLocaleString word;
  60.         word = (const char*)buf;
  61.         ::GetDlgItemText(hWnd, w, buf, sizeof(buf)-1);
  62.         const char* xlat = word.Translate((TLangId)id);
  63.         ::SetDlgItemText(hWnd, w + IDC_FIRSTXLAT - IDC_FIRSTWORD, xlat);
  64.       }
  65.     }
  66.   }
  67.   ::DestroyWindow(hWnd);
  68.   return 0;
  69. }
  70.