Advertisement
alexx876

Untitled

Jan 14th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <time.h>
  4. #include <Windowsx.h>
  5. #include "resource.h"
  6. #include <fstream>
  7.  
  8. using namespace std;
  9.  
  10. HWND Edit;
  11. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  12.  
  13. int max = 500, current = 10;
  14. int randx, randy, randz;
  15.  
  16. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  17. srand(time(0));
  18.  
  19. HWND Main;
  20. MSG msg;
  21. Main = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1),0, (DLGPROC)WndProc);
  22. if (!Main) {
  23. MessageBox(0, 0, 0, 0);
  24. }
  25. ShowWindow(Main, nCmdShow);
  26.  
  27. while (GetMessage(&msg, NULL, 0, 0)) {
  28. TranslateMessage(&msg);
  29. DispatchMessage(&msg);
  30. }
  31.  
  32. return 1;
  33. }
  34.  
  35.  
  36. LRESULT CALLBACK WndProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) {
  37. HDC hdc;
  38.  
  39. switch (Msg) {
  40. case WM_INITDIALOG: {
  41. Button_Enable(GetDlgItem(hDlg, 4001), 0);
  42. break;
  43. }
  44. case WM_COMMAND: {
  45. if (LOWORD(wParam) == 4001) {
  46. ofstream file("text.txt", ios_base::app);
  47. char text[200];
  48.  
  49. Edit_GetText(GetDlgItem(hDlg, IDC_EDIT1), text, 200);
  50. file << text << endl;
  51.  
  52. Edit_GetText(GetDlgItem(hDlg, IDC_EDIT2), text, 200);
  53. file << text << endl;
  54. file.close();
  55. Edit_SetText(GetDlgItem(hDlg, IDC_EDIT1), "");
  56. Edit_SetText(GetDlgItem(hDlg, IDC_EDIT2), "");
  57. } else {
  58. Button_Enable(GetDlgItem(hDlg, 4001), 0);
  59. char text[200];
  60.  
  61. Edit_GetText(GetDlgItem(hDlg, IDC_EDIT1), text, 200);
  62.  
  63. if (strlen(text) < 1) break;
  64.  
  65. Edit_GetText(GetDlgItem(hDlg, IDC_EDIT2), text, 200);
  66.  
  67. if (strlen(text) < 1) break;
  68.  
  69. Button_Enable(GetDlgItem(hDlg, 4001), 1);
  70.  
  71. }
  72.  
  73. break;
  74. }
  75. case WM_CLOSE: {
  76. DestroyWindow(hDlg);
  77. break;
  78. }
  79. case WM_DESTROY: {
  80. PostQuitMessage(0);
  81. break;
  82. }
  83. }
  84. return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement