Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <sstream>
- #include <Windows.h>
- #include <cstdio>
- #include <string>
- #include <cstring>
- #include <tchar.h>
- #include <stdlib.h>
- #include <stdio.h>
- // Copyright: rhouland@epastas.lt & evgeniistorozhev@mail.ru
- LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
- static HWND HWNDStatic; // Label OutPut
- static HWND HWNDButton;
- static HWND HWNDButton2;
- static HWND HWNDButton3;
- static HWND HWNDEdit1;
- static HWND HWNDEdit2;
- switch(Message) {
- case WM_DESTROY: {
- PostQuitMessage(0);
- break;
- }
- case WM_CREATE: {
- CreateWindow(TEXT("STATIC"),TEXT(" Enter Digit A : "),
- WS_VISIBLE | WS_CHILD | SS_CENTER | SS_CENTERIMAGE,
- 110,30,170,32,hwnd,(HMENU)1,NULL,NULL );
- HWNDEdit1 = CreateWindow(TEXT("edit"),TEXT(""),
- WS_VISIBLE | WS_CHILD | WS_BORDER | SS_CENTER,
- 310,35,170,20,hwnd,(HMENU)2,NULL,NULL);
- CreateWindow(TEXT("STATIC"),TEXT(" Enter Digit B : "),
- WS_VISIBLE | WS_CHILD | SS_CENTER | SS_CENTERIMAGE,
- 110,70,170,32,hwnd,(HMENU)3,NULL,NULL );
- HWNDEdit2 = CreateWindow(TEXT("edit"),TEXT(""),
- WS_VISIBLE | WS_CHILD | WS_BORDER | SS_CENTER,
- 310,75,170,20,hwnd,(HMENU)4,NULL,NULL);
- HWNDButton = CreateWindow(TEXT("button"),TEXT(" Call A + B "),
- WS_VISIBLE | WS_CHILD,
- 80,120,130,35,hwnd,(HMENU) 5,NULL,NULL );
- HWNDButton2 = CreateWindow(TEXT("button"),TEXT(" Call A * B "),
- WS_VISIBLE | WS_CHILD,
- 240,120,130,35,hwnd,(HMENU) 8,NULL,NULL );
- HWNDButton3 = CreateWindow(TEXT("button"),TEXT(" Call A / B "),
- WS_VISIBLE | WS_CHILD,
- 390,120,130,35,hwnd,(HMENU) 9,NULL,NULL );
- HWNDStatic = CreateWindow(TEXT("STATIC"),TEXT(" .... "),
- WS_VISIBLE | WS_CHILD | SS_CENTER | SS_CENTERIMAGE,
- 250,200,90,22,hwnd,(HMENU)6,NULL,NULL);
- CreateWindow(TEXT("button"), TEXT("Exit!"),
- WS_VISIBLE | WS_CHILD | SS_CENTER,
- 250,300,90,35,hwnd, (HMENU) 7, NULL, NULL);
- CreateWindow(TEXT("button"), TEXT("Clear All!"),
- WS_VISIBLE | WS_CHILD | SS_CENTER,
- 220,240,160,35,hwnd, (HMENU) 10, NULL, NULL);
- case WM_COMMAND: // Dead programm!
- if (LOWORD(wParam) == 7)
- {
- PostQuitMessage(0);
- }
- if (LOWORD(wParam) == 5) // Call A + B
- {
- char hhh[400];
- int vt=16;
- GetWindowText( HWNDEdit1, hhh, vt );
- double aaa = atof(hhh);
- char yyy[400];
- int vtf=16;
- GetWindowText( HWNDEdit2, yyy, vtf );
- double bbb = atof(yyy);
- double fn1=aaa, fn2=bbb, fn3=fn1+fn2;
- std::ostringstream ss;
- ss << fn3;
- SetWindowText(HWNDStatic, ss.str().c_str());
- SetWindowText(HWNDButton, "Result A + B ");
- SetWindowText(HWNDButton2, "Call A * B ");
- SetWindowText(HWNDButton3, "Call A / B ");
- }
- if (LOWORD(wParam) == 8) // Call A * B
- {
- char hhh[400];
- int vt=16;
- GetWindowText( HWNDEdit1, hhh, vt );
- double aaa = atof(hhh);
- char yyy[400];
- int vtf=16;
- GetWindowText( HWNDEdit2, yyy, vtf );
- double bbb = atof(yyy);
- double fn1=aaa, fn2=bbb, fn3=fn1*fn2;
- std::ostringstream ss;
- ss << fn3;
- SetWindowText(HWNDStatic, ss.str().c_str());
- SetWindowText(HWNDButton2, "Result A * B ");
- SetWindowText(HWNDButton, "Call A + B ");
- SetWindowText(HWNDButton3, "Call A / B ");
- }
- if (LOWORD(wParam) == 9) // Call A / B
- {
- char hhh[400];
- int vt=16;
- GetWindowText( HWNDEdit1, hhh, vt );
- double aaa = atof(hhh);
- char yyy[400];
- int vtf=16;
- GetWindowText( HWNDEdit2, yyy, vtf );
- double bbb = atof(yyy);
- double fn1=aaa, fn2=bbb, fn3=fn1/fn2;
- std::ostringstream ss;
- ss << fn3;
- SetWindowText(HWNDStatic, ss.str().c_str());
- SetWindowText(HWNDButton3, "Result A / B ");
- SetWindowText(HWNDButton, "Call A + B ");
- SetWindowText(HWNDButton2, "Call A * B ");
- }
- if (LOWORD(wParam) == 10) // Clear all
- {
- SetWindowText(HWNDStatic, " .... ");
- SetWindowText(HWNDButton3, "Call A / B ");
- SetWindowText(HWNDButton, "Call A + B ");
- SetWindowText(HWNDButton2, "Call A * B ");
- SetWindowText(HWNDEdit1, "");
- SetWindowText(HWNDEdit2, "");
- }
- }
- default:
- return DefWindowProc(hwnd, Message, wParam, lParam);
- }
- return 0;
- }
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
- setlocale(LC_ALL, "Lithuanian");
- WNDCLASSEX wc;
- HWND hwnd;
- MSG msg;
- memset(&wc,0,sizeof(wc));
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.lpfnWndProc = WndProc;
- wc.hInstance = hInstance;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wc.lpszClassName = "WindowClass";
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- if(!RegisterClassEx(&wc)) {
- MessageBox(NULL, "Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
- return 0;
- }
- hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass","Butt-Lbl-Out",WS_VISIBLE|WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- 640,480,NULL,NULL,hInstance,NULL);
- if(hwnd == NULL) {
- MessageBox(NULL, "Window Creation Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
- return 0;
- }
- while(GetMessage(&msg, NULL, 0, 0) > 0) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return msg.wParam;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement