Viết tiếng Việt trong Code Block

  1. #if defined(UNICODE) && !defined(_UNICODE)

  2. #define _UNICODE

  3. #elif defined(_UNICODE) && !defined(UNICODE)

  4. #define UNICODE

  5. #endif

  6. #include

  7. #include

  8. #define ID_LABEL 1

  9. HWND hwndLabel;

  10. /*  Declare Windows procedure  */

  11. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

  12. /*  Make the class name into a global variable  */

  13. TCHAR szClassName[ ] = _T("CodeBlocksWindowsApp");

  14. int WINAPI WinMain (HINSTANCE hThisInstance,

  15. HINSTANCE hPrevInstance,

  16. LPSTR lpszArgument,

  17. int nCmdShow)

  18. {

  19. HWND hwnd;               /* This is the handle for our window */

  20. MSG messages;            /* Here messages to the application are saved */

  21. WNDCLASSEX wincl;        /* Data structure for the windowclass */

  22. /* The Window structure */

  23. wincl.hInstance = hThisInstance;

  24. wincl.lpszClassName = szClassName;

  25. wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */

  26. wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */

  27. wincl.cbSize = sizeof (WNDCLASSEX);

  28. /* Use default icon and mouse-pointer */

  29. wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);

  30. wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);

  31. wincl.hCursor = LoadCursor (NULL, IDC_ARROW);

  32. wincl.lpszMenuName = NULL;                 /* No menu */

  33. wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */

  34. wincl.cbWndExtra = 0;                      /* structure or the window instance */

  35. /* Use Windows's default colour as the background of the window */

  36. wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

  37. /* Register the window class, and if it fails quit the program */

  38. if (!RegisterClassEx (&wincl))

  39. return 0;

  40. /* The class is registered, let's create the program*/

  41. hwnd = CreateWindowEx (

  42. 0,                   /* Extended possibilites for variation */

  43. szClassName,         /* Classname */

  44. _T("Code::Blocks Template Windows App"),       /* Title Text */

  45. WS_OVERLAPPEDWINDOW, /* default window */

  46. CW_USEDEFAULT,       /* Windows decides the position */

  47. CW_USEDEFAULT,       /* where the window ends up on the screen */

  48. 544,                 /* The programs width */

  49. 375,                 /* and height in pixels */

  50. HWND_DESKTOP,        /* The window is a child-window to desktop */

  51. NULL,                /* No menu */

  52. hThisInstance,       /* Program Instance handler */

  53. NULL                 /* No Window Creation data */

  54. );

  55. /* Make the window visible on the screen */

  56. ShowWindow (hwnd, nCmdShow);

  57. /* Run the message loop. It will run until GetMessage() returns 0 */

  58. while (GetMessage (&messages, NULL, 0, 0))

  59. {

  60. /* Translate virtual-key messages into character messages */

  61. TranslateMessage(&messages);

  62. /* Send message to WindowProcedure */

  63. DispatchMessage(&messages);

  64. }

  65. /* The program return-value is 0 - The value that PostQuitMessage() gave */

  66. return messages.wParam;

  67. }

  68. /*  This function is called by the Windows function DispatchMessage()  */

  69. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

  70. {

  71. switch (message)                  /* handle the messages */

  72. {

  73. case WM_CREATE:

  74. hwndLabel = CreateWindow(

  75. TEXT("EDIT"), TEXT("Trâu chậm uống nước đục"), WS_VISIBLE | WS_CHILD | WS_BORDER,

  76. 10,10,300,20, hwnd, (HMENU)ID_LABEL, NULL, NULL

  77. );

  78. break;

  79. case WM_DESTROY:

  80. PostQuitMessage (0);       /* send a WM_QUIT to the message queue */

  81. break;

  82. default:                      /* for messages that we don't deal with */

  83. return DefWindowProc (hwnd, message, wParam, lParam);

  84. }

  85. return 0;

  86. }