Advertisement
Guest User

Untitled

a guest
Aug 29th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #include "heads.h"
  2.  
  3. #pragma comment( linker, "/entry:my_main" )
  4. #pragma comment(linker,"/SUBSYSTEM:WINDOWS")
  5.  
  6. base_gui *main_window=0;
  7. menu_builder *m_creator=0;
  8. richedit_using *text_area=0;
  9. text_operator *ft_ops = 0;
  10.  
  11. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  12.  
  13. int my_main()
  14. {
  15. main_window = new base_gui("MY_NOTEPAD", WndProc, GetModuleHandleA(0));
  16. main_window->ShowLikeParentWindow("");
  17. ExitProcess(0);
  18. return 0;
  19. }
  20.  
  21. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  22. {
  23. HDC hdc;
  24. PAINTSTRUCT ps;
  25. switch (message)
  26. {
  27. case WM_CREATE:
  28. {
  29. m_creator = new menu_builder(hWnd);
  30. m_creator->BeginCreateMenu();
  31. m_creator->AddMenuLabel("&Відкрити", IDM_OPEN);
  32. m_creator->AddSeparator();
  33. m_creator->AddMenuLabel("&Зберегти", IDM_SAVE);
  34. m_creator->AddSeparator();
  35. m_creator->AddMenuLabel("&Вихід", IDM_CLOSE);
  36. m_creator->FinishMenu("&Файл");
  37. m_creator->SetMenu();
  38. text_area = new richedit_using(hWnd, "RICHEDIT", ID_RICH, GetModuleHandleA(0));
  39. text_area->ShowLikeChild("");
  40. text_area->AlignSize();
  41. ft_ops = new text_operator(hWnd);
  42. }break;
  43. case WM_SIZE:
  44. {
  45. if (text_area != 0)
  46. {
  47. text_area->AlignSize();
  48. }
  49. }break;
  50. case WM_PAINT:
  51. {
  52. hdc = BeginPaint(hWnd, &ps);
  53. EndPaint(hWnd, &ps);
  54. }
  55. break;
  56. case WM_COMMAND:
  57. switch (LOWORD(wParam))
  58. {
  59. case IDM_OPEN:
  60. {
  61. char *data=0;
  62. data=ft_ops->OpenFile();
  63. text_area->SetText(data);
  64. if (data != 0)
  65. {
  66. delete[]data;
  67. }
  68. }break;
  69. case IDM_SAVE:
  70. {
  71. char *data = 0;
  72. data = text_area->GetText();
  73. ft_ops->SaveFile(data);
  74. delete []data;
  75. }break;
  76. case IDM_CLOSE:
  77. {
  78. PostQuitMessage(0);
  79. }
  80. }
  81. break;
  82. case WM_DESTROY:
  83. PostQuitMessage(0);
  84. break;
  85. default:
  86. return DefWindowProc(hWnd, message, wParam, lParam);
  87. }
  88. return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement