Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- #include <time.h>
- #include <Windowsx.h>
- #include "resource.h"
- #include <fstream>
- using namespace std;
- HWND Edit;
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- int max = 500, current = 10;
- int randx, randy, randz;
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
- srand(time(0));
- HWND Main;
- MSG msg;
- Main = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1),0, (DLGPROC)WndProc);
- if (!Main) {
- MessageBox(0, 0, 0, 0);
- }
- ShowWindow(Main, nCmdShow);
- while (GetMessage(&msg, NULL, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 1;
- }
- LRESULT CALLBACK WndProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) {
- HDC hdc;
- switch (Msg) {
- case WM_INITDIALOG: {
- Button_Enable(GetDlgItem(hDlg, 4001), 0);
- break;
- }
- case WM_COMMAND: {
- if (LOWORD(wParam) == 4001) {
- ofstream file("text.txt", ios_base::app);
- char text[200];
- Edit_GetText(GetDlgItem(hDlg, IDC_EDIT1), text, 200);
- file << text << endl;
- Edit_GetText(GetDlgItem(hDlg, IDC_EDIT2), text, 200);
- file << text << endl;
- file.close();
- Edit_SetText(GetDlgItem(hDlg, IDC_EDIT1), "");
- Edit_SetText(GetDlgItem(hDlg, IDC_EDIT2), "");
- } else {
- Button_Enable(GetDlgItem(hDlg, 4001), 0);
- char text[200];
- Edit_GetText(GetDlgItem(hDlg, IDC_EDIT1), text, 200);
- if (strlen(text) < 1) break;
- Edit_GetText(GetDlgItem(hDlg, IDC_EDIT2), text, 200);
- if (strlen(text) < 1) break;
- Button_Enable(GetDlgItem(hDlg, 4001), 1);
- }
- break;
- }
- case WM_CLOSE: {
- DestroyWindow(hDlg);
- break;
- }
- case WM_DESTROY: {
- PostQuitMessage(0);
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement