Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include <windows.h>
  2. #include <Strsafe.h>
  3.  
  4. //deklaracja zapowiadająca
  5. LRESULT CALLBACK NaszaProcedura(HWND hwnd, UINT message, WPARAM wpar, LPARAM lpar);
  6. HWND hOkno;
  7.  
  8. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpsCmdLine, int nMode)
  9. {
  10.  
  11. MSG message;
  12. WNDCLASS okno;
  13.  
  14. okno.hInstance = hInstance;
  15. okno.lpszClassName = "klasa główna";
  16. okno.lpfnWndProc = NaszaProcedura; //tutaj pojawia się nowość!!
  17. okno.lpszMenuName = NULL;
  18. okno.style = 0;
  19. okno.hIcon = LoadIcon(NULL, IDI_WINLOGO);
  20. okno.hCursor = LoadCursor(NULL, IDC_ARROW);
  21. okno.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
  22. okno.cbClsExtra = 0;
  23. okno.cbWndExtra = 0;
  24. if (!RegisterClass(&okno)) return 0;
  25. hOkno = CreateWindow("klasa główna", "",
  26. WS_OVERLAPPEDWINDOW, 100, 100, 900, 100,
  27. NULL, NULL, hInstance, NULL);
  28. ShowWindow(hOkno, SW_SHOW);
  29. while (GetMessage(&message, NULL, 0, 0))
  30. {
  31. TranslateMessage(&message);
  32. DispatchMessage(&message);
  33. }
  34. }
  35.  
  36. LRESULT CALLBACK NaszaProcedura(HWND hwnd, UINT message, WPARAM wpar, LPARAM lpar)
  37. {
  38. switch (message)
  39. {
  40. case WM_KEYDOWN:
  41. switch (wpar)
  42. {
  43. default:
  44. char kod = (char)wpar;
  45. char znak[2] = " ";
  46. znak[0] = kod;
  47. LPSTR bufor = (LPSTR)GlobalAlloc(GPTR, 0);
  48. LPSTR tekst = (LPSTR)GlobalAlloc(GPTR, 100);
  49. GetWindowText(hOkno, tekst, 100);
  50. strcpy_s(bufor, 2, znak);
  51. lstrcat(tekst, bufor);
  52. SetWindowText(hOkno, tekst);
  53.  
  54. OpenClipboard(hOkno);
  55. EmptyClipboard();
  56. SetClipboardData(CF_TEXT, tekst);
  57. CloseClipboard();
  58.  
  59. break;
  60.  
  61. }
  62. break;
  63. case WM_PAINT:
  64. break;
  65. default:
  66. return DefWindowProc(hwnd, message, wpar, lpar);
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement