fork download
  1. #include <windows.h>
  2. #include <malloc.h>
  3. #define SHIFTED 0x8000
  4.  
  5. MSG message;
  6.  
  7. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  8. {
  9. int code;
  10. HANDLE data;
  11. const char* text;
  12. char* newtext;
  13. int len;
  14. HGLOBAL hMem;
  15.  
  16. switch(msg)
  17. {
  18. case WM_CLOSE:
  19. DestroyWindow(hwnd);
  20. break;
  21.  
  22. case WM_DESTROY:
  23. PostQuitMessage(0);
  24. break;
  25.  
  26. case WM_KEYDOWN:
  27. code = (int)wParam;
  28. if(code >= 65 && code <= 90)
  29. {
  30. if(!(GetKeyState(VK_SHIFT) & SHIFTED))
  31. {
  32. code += 32;
  33. }
  34.  
  35. if(IsClipboardFormatAvailable(CF_TEXT))
  36. {
  37. OpenClipboard(hwnd);
  38. data = GetClipboardData(CF_TEXT);
  39. if(data != NULL)
  40. {
  41. text = (const char*)data;
  42. len = GlobalSize(data);
  43. newtext = (char*)malloc((len+1)*sizeof(char));
  44. for(int i = 0;i<len-1;i++)
  45. {
  46. newtext[i] = text[i];
  47. }
  48.  
  49. newtext[len-1] = code;
  50. newtext[len] = 0;
  51.  
  52. hMem = GlobalAlloc(GHND, len + 1);
  53. memcpy(GlobalLock(hMem), newtext, len + 1);
  54. GlobalUnlock(hMem);
  55. SetClipboardData(CF_TEXT, hMem);
  56. }
  57. CloseClipboard();
  58. }
  59. }
  60. break;
  61.  
  62. default:
  63. return DefWindowProc(hwnd, msg, wParam, lParam);
  64. }
  65.  
  66. return 0;
  67. }
  68.  
  69. int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
  70. {
  71. WNDCLASSEX window;
  72. LPSTR WClass = "ASDF";
  73.  
  74. window.cbSize = sizeof( WNDCLASSEX );
  75. window.style = 0;
  76. window.lpfnWndProc = WndProc;
  77. window.cbClsExtra = 0;
  78. window.cbWndExtra = 0;
  79. window.hInstance = hInstance;
  80. window.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  81. window.hCursor = LoadCursor(NULL, IDC_ARROW);
  82. window.hbrBackground =(HBRUSH)(COLOR_WINDOW + 1);
  83. window.lpszMenuName = NULL;
  84. window.lpszClassName = (LPCWSTR)WClass;
  85. window.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  86.  
  87. if(!RegisterClassEx(&window))
  88. {
  89. return 1;
  90. }
  91.  
  92. HWND hwnd;
  93. hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, (LPCWSTR)WClass, L"Aplikacja", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, hInstance, NULL);
  94. if(hwnd == NULL)
  95. {
  96. return 2;
  97. }
  98.  
  99. ShowWindow(hwnd,nCmdShow);
  100. UpdateWindow(hwnd);
  101.  
  102. while(GetMessage(&message, NULL, 0, 0))
  103. {
  104. TranslateMessage(&message);
  105. DispatchMessage(&message);
  106. }
  107.  
  108. return 0;
  109. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty