Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //{{NO_DEPENDENCIES}}
- // Microsoft Visual C++ generated include file.
- // Used by WindowsProject5.rc
- //
- #define IDC_MYICON 2
- #define ID_INSERT 3
- #define ID_RESULT 4
- #define ID_START 5
- #define IDD_WINDOWSPROJECT5_DIALOG 102
- #define IDS_APP_TITLE 103
- #define IDD_ABOUTBOX 103
- #define IDM_ABOUT 104
- #define IDM_EXIT 105
- #define IDI_WINDOWSPROJECT5 107
- #define IDI_SMALL 108
- #define IDC_WINDOWSPROJECT5 109
- #define IDR_MAINFRAME 128
- #define IDD_DIALOG1 129
- #define IDC_EDIT1 1000
- #define IDC_LIST1 1001
- #define IDC_EDIT2 1002
- #define IDC_EDIT3 1003
- #define IDC_RADIO1 1004
- #define IDC_RADIO2 1005
- #define IDC_COMBO1 1006
- #define IDC_EDIT4 1007
- #define IDC_EDIT5 1008
- #define IDC_PROGRESS1 1009
- #define ID_FILE_INSERT 32771
- #define IDC_STATIC -1
- // Next default values for new objects
- //
- #ifdef APSTUDIO_INVOKED
- #ifndef APSTUDIO_READONLY_SYMBOLS
- #define _APS_NO_MFC 1
- #define _APS_NEXT_RESOURCE_VALUE 130
- #define _APS_NEXT_COMMAND_VALUE 32772
- #define _APS_NEXT_CONTROL_VALUE 1010
- #define _APS_NEXT_SYMED_VALUE 110
- #endif
- #endif
- ------------------------------------------------------------------------------------------------------------
- // WindowsProject5.cpp : Defines the entry point for the application.
- //
- #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
- #include "stdafx.h"
- #include "WindowsProject5.h"
- #define MAX_LOADSTRING 100
- // Global Variables:
- HINSTANCE hInst; // current instance
- WCHAR szTitle[MAX_LOADSTRING]; // The title bar text
- WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
- // Forward declarations of functions included in this code module:
- ATOM MyRegisterClass(HINSTANCE hInstance);
- BOOL InitInstance(HINSTANCE, int);
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
- INT_PTR CALLBACK Dialog(HWND, UINT, WPARAM, LPARAM);
- void CALLBACK TimerCallback(HWND, UINT, UINT, DWORD);
- auto counter(0);
- int pbStep, pbPos;
- auto hasReachedMaxRange = false;
- int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
- _In_opt_ HINSTANCE hPrevInstance,
- _In_ LPWSTR lpCmdLine,
- _In_ int nCmdShow)
- {
- UNREFERENCED_PARAMETER(hPrevInstance);
- UNREFERENCED_PARAMETER(lpCmdLine);
- // TODO: Place code here.
- // Initialize global strings
- LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
- LoadStringW(hInstance, IDC_WINDOWSPROJECT5, szWindowClass, MAX_LOADSTRING);
- MyRegisterClass(hInstance);
- // Perform application initialization:
- if (!InitInstance (hInstance, nCmdShow))
- {
- return FALSE;
- }
- HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WINDOWSPROJECT5));
- MSG msg;
- // Main message loop:
- while (GetMessage(&msg, nullptr, 0, 0))
- {
- if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- return (int) msg.wParam;
- }
- //
- // FUNCTION: MyRegisterClass()
- //
- // PURPOSE: Registers the window class.
- //
- ATOM MyRegisterClass(HINSTANCE hInstance)
- {
- WNDCLASSEXW wcex;
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.style = CS_HREDRAW | CS_VREDRAW;
- wcex.lpfnWndProc = WndProc;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
- wcex.hInstance = hInstance;
- wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WINDOWSPROJECT5));
- wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
- wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_WINDOWSPROJECT5);
- wcex.lpszClassName = szWindowClass;
- wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
- return RegisterClassExW(&wcex);
- }
- //
- // FUNCTION: InitInstance(HINSTANCE, int)
- //
- // PURPOSE: Saves instance handle and creates main window
- //
- // COMMENTS:
- //
- // In this function, we save the instance handle in a global variable and
- // create and display the main program window.
- //
- BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
- {
- INITCOMMONCONTROLSEX InitCtrlEx;
- InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
- InitCtrlEx.dwICC = ICC_PROGRESS_CLASS;
- InitCommonControlsEx(&InitCtrlEx);
- hInst = hInstance; // Store instance handle in our global variable
- HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
- if (!hWnd)
- {
- return FALSE;
- }
- ShowWindow(hWnd, nCmdShow);
- UpdateWindow(hWnd);
- return TRUE;
- }
- //
- // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
- //
- // PURPOSE: Processes messages for the main window.
- //
- // WM_COMMAND - process the application menu
- // WM_PAINT - Paint the main window
- // WM_DESTROY - post a quit message and return
- //
- //
- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message)
- {
- case WM_COMMAND:
- {
- int wmId = LOWORD(wParam);
- // Parse the menu selections:
- switch (wmId)
- {
- case IDM_ABOUT:
- DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
- break;
- case ID_FILE_INSERT:
- DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, Dialog);
- break;
- case IDM_EXIT:
- DestroyWindow(hWnd);
- break;
- default:
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- }
- break;
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(hWnd, &ps);
- POINT pts[13] = {
- { 10, 35 },
- { 35, 35 },
- { 35, 10 },
- { 135, 10 },
- { 135, 35 },
- { 160, 35 },
- { 160, 135 },
- { 135, 135 },
- { 135, 160 },
- { 35, 160 },
- { 35, 135 },
- { 10, 135 },
- { 10, 35 },
- };
- Polyline(hdc, pts, 13);
- EndPaint(hWnd, &ps);
- }
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- return 0;
- }
- // Message handler for about box.
- INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
- {
- UNREFERENCED_PARAMETER(lParam);
- auto wmId = LOWORD(wParam);
- switch (message)
- {
- case WM_COMMAND:
- switch (wmId) {
- case IDOK:
- case IDCANCEL:
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- break;
- }
- return (INT_PTR)FALSE;
- }
- INT_PTR CALLBACK Dialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
- {
- UNREFERENCED_PARAMETER(lParam);
- INITCOMMONCONTROLSEX InitCtrlEx;
- InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
- InitCtrlEx.dwICC = ICC_PROGRESS_CLASS;
- InitCommonControlsEx(&InitCtrlEx);
- auto wmId = LOWORD(wParam);
- switch (message)
- {
- case WM_INITDIALOG: {
- auto hComboBox = GetDlgItem(hDlg, IDC_COMBO1);
- auto hRadio1 = GetDlgItem(hDlg, IDC_RADIO1);
- /*! Add dropdown list items on init */
- SendMessage(hComboBox, CB_ADDSTRING, NULL, (LPARAM)L"8.3");
- SendMessage(hComboBox, CB_ADDSTRING, NULL, (LPARAM)L"17.7");
- SendMessage(hComboBox, CB_ADDSTRING, NULL, (LPARAM)L"9.6");
- /*! Set the first radio button to be checked on init */
- SendMessage(hRadio1, BM_SETCHECK, BST_CHECKED, NULL);
- return (INT_PTR)TRUE;
- }
- case WM_COMMAND:
- switch (wmId) {
- case IDOK:
- case IDCANCEL:
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- case ID_INSERT: {
- auto hListBox = GetDlgItem(hDlg, IDC_LIST1);
- auto hEdit = GetDlgItem(hDlg, IDC_EDIT1);
- std::string temp;
- temp.resize(GetWindowTextLength(hEdit) + 1, '\0');
- GetWindowTextW(hEdit, (LPWSTR)temp.c_str(), GetWindowTextLength(hEdit) + 1);
- SendMessage(hListBox, LB_ADDSTRING, NULL, (LPARAM)temp.c_str());
- break;
- }
- case ID_RESULT: {
- std::string value1, value2, value3;
- auto hEdit1 = GetDlgItem(hDlg, IDC_EDIT2);
- auto hEdit2 = GetDlgItem(hDlg, IDC_EDIT3);
- auto hCombo = GetDlgItem(hDlg, IDC_COMBO1);
- value1.resize(GetWindowTextLength(hEdit1) + 1, '\0');
- value2.resize(GetWindowTextLength(hEdit2) + 1, '\0');
- value3.resize(GetWindowTextLength(hCombo) + 1, '\0');
- GetWindowTextA(hEdit1, (LPSTR)value1.c_str(), GetWindowTextLength(hEdit1) + 1);
- GetWindowTextA(hEdit2, (LPSTR)value2.c_str(), GetWindowTextLength(hEdit2) + 1);
- GetWindowTextA(hCombo, (LPSTR)value3.c_str(), GetWindowTextLength(hCombo) + 1);
- auto fVal1 = atof(value1.c_str());
- auto fVal2 = atof(value2.c_str());
- auto fVal3 = atof(value3.c_str());
- if (IsDlgButtonChecked(hDlg, IDC_RADIO1) == BST_CHECKED) {
- if (fVal2 != 0) {
- auto temp = (fVal3 - fVal1) / fVal2;
- SetDlgItemText(hDlg, IDC_EDIT4, std::to_wstring(temp).c_str());
- }
- else {
- MessageBoxW(hDlg, L"ERROR", L"The divisor is 0", MB_OK | MB_ICONERROR);
- }
- }
- else {
- auto temp = (fVal1 + fVal2) / fVal3;
- SetDlgItemText(hDlg, IDC_EDIT4, std::to_wstring(temp).c_str());
- }
- break;
- }
- case ID_START: {
- std::string value;
- auto hStep = GetDlgItem(hDlg, IDC_EDIT5);
- auto hProgress = GetDlgItem(hDlg, IDC_PROGRESS1);
- value.resize(GetWindowTextLength(hStep) + 1, '\0');
- GetWindowTextA(hStep, (LPSTR)value.c_str(), GetWindowTextLength(hStep) + 1);
- auto fVal = atof(value.c_str());
- pbStep = fVal;
- SendMessage(hProgress, PBM_SETSTEP, fVal, NULL);
- //int pos = SendMessage(hProgress, PBM_GETPOS, NULL, NULL);
- SetTimer(hDlg, 32775, 1000, &TimerCallback);
- break;
- }
- }
- break;
- }
- return (INT_PTR)FALSE;
- }
- void CALLBACK TimerCallback(HWND hWnd, UINT msg, UINT eventId, DWORD dwTime) {
- if (eventId == 32775) {
- /*! Get the control as hWnd */
- auto hProgress = GetDlgItem(hWnd, IDC_PROGRESS1);
- /*! Set hasReachedMaxRange to true if max is reached */
- if (pbPos >= 100) {
- pbPos -= pbStep;
- hasReachedMaxRange = true;
- }
- else {
- counter++;
- /*! If the progress bar reached its' maximum range */
- if (hasReachedMaxRange) {
- if (pbPos >= 0) {
- /*! If position is over zero or equal to, change the position */
- SendMessage(hProgress, PBM_SETPOS, pbPos, NULL);
- pbPos -= pbStep;
- }
- else {
- /*! Kill the timer */
- KillTimer(hWnd, 32775);
- /*! Temporary Fix, prevents the counter to go over the estimated amount */
- counter--;
- }
- }
- else {
- /*! Else, the progress bar didn't reach its' maximum, we are aiming towards it */
- pbPos += pbStep;
- SendMessage(hProgress, PBM_SETPOS, pbPos, NULL);
- }
- /*! Update the edit control to set the time there in seconds */
- SetDlgItemText(hWnd, IDC_EDIT5, std::to_wstring(counter).c_str());
- }
- }
- }
- -----------------------------------------------------------------------------------------------------------------------------------
- // Microsoft Visual C++ generated resource script.
- //
- #include "resource.h"
- #define APSTUDIO_READONLY_SYMBOLS
- /////////////////////////////////////////////////////////////////////////////
- //
- // Generated from the TEXTINCLUDE 2 resource.
- //
- #ifndef APSTUDIO_INVOKED
- #include "targetver.h"
- #endif
- #define APSTUDIO_HIDDEN_SYMBOLS
- #include "windows.h"
- #undef APSTUDIO_HIDDEN_SYMBOLS
- /////////////////////////////////////////////////////////////////////////////
- #undef APSTUDIO_READONLY_SYMBOLS
- /////////////////////////////////////////////////////////////////////////////
- // Bulgarian (Bulgaria) resources
- #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_BGR)
- LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT
- /////////////////////////////////////////////////////////////////////////////
- //
- // Dialog
- //
- IDD_DIALOG1 DIALOGEX 0, 0, 493, 234
- STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
- CAPTION "Dialog"
- FONT 8, "MS Shell Dlg", 400, 0, 0x1
- BEGIN
- DEFPUSHBUTTON "OK",IDOK,420,18,50,14
- PUSHBUTTON "Cancel",IDCANCEL,420,36,50,14
- EDITTEXT IDC_EDIT1,12,24,72,14,ES_AUTOHSCROLL
- DEFPUSHBUTTON "Insert",ID_INSERT,96,24,50,14
- LISTBOX IDC_LIST1,174,24,48,40,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
- EDITTEXT IDC_EDIT2,12,114,72,14,ES_AUTOHSCROLL
- EDITTEXT IDC_EDIT3,108,114,72,14,ES_AUTOHSCROLL
- DEFPUSHBUTTON "=",ID_RESULT,348,114,50,14
- CONTROL "(C - A) / B",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,204,108,48,10
- CONTROL "(A + B) / C",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,204,120,51,10
- COMBOBOX IDC_COMBO1,276,114,48,60,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
- EDITTEXT IDC_EDIT4,420,114,48,14,ES_AUTOHSCROLL
- EDITTEXT IDC_EDIT5,12,204,72,14,ES_AUTOHSCROLL
- DEFPUSHBUTTON "Start",ID_START,96,204,50,14
- CONTROL "",IDC_PROGRESS1,"msctls_progress32",WS_BORDER,216,204,252,14
- END
- /////////////////////////////////////////////////////////////////////////////
- //
- // DESIGNINFO
- //
- #ifdef APSTUDIO_INVOKED
- GUIDELINES DESIGNINFO
- BEGIN
- IDD_DIALOG1, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 486
- TOPMARGIN, 7
- BOTTOMMARGIN, 227
- END
- END
- #endif // APSTUDIO_INVOKED
- #endif // Bulgarian (Bulgaria) resources
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // English (United States) resources
- #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
- LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
- /////////////////////////////////////////////////////////////////////////////
- //
- // Icon
- //
- // Icon with lowest ID value placed first to ensure application icon
- // remains consistent on all systems.
- IDI_WINDOWSPROJECT5 ICON "WindowsProject5.ico"
- IDI_SMALL ICON "small.ico"
- /////////////////////////////////////////////////////////////////////////////
- //
- // Menu
- //
- IDC_WINDOWSPROJECT5 MENU
- BEGIN
- POPUP "&File"
- BEGIN
- MENUITEM "Insert", ID_FILE_INSERT
- MENUITEM "E&xit", IDM_EXIT
- END
- POPUP "&Help"
- BEGIN
- MENUITEM "&About ...", IDM_ABOUT
- END
- END
- /////////////////////////////////////////////////////////////////////////////
- //
- // Accelerator
- //
- IDC_WINDOWSPROJECT5 ACCELERATORS
- BEGIN
- "?", IDM_ABOUT, ASCII, ALT
- "/", IDM_ABOUT, ASCII, ALT
- END
- /////////////////////////////////////////////////////////////////////////////
- //
- // Dialog
- //
- IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62
- STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
- CAPTION "About WindowsProject5"
- FONT 8, "MS Shell Dlg", 0, 0, 0x1
- BEGIN
- ICON IDR_MAINFRAME,IDC_STATIC,14,14,21,20
- LTEXT "WindowsProject5, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX
- LTEXT "Copyright (c) 2019",IDC_STATIC,42,26,114,8
- DEFPUSHBUTTON "OK",IDOK,113,41,50,14,WS_GROUP
- END
- /////////////////////////////////////////////////////////////////////////////
- //
- // DESIGNINFO
- //
- #ifdef APSTUDIO_INVOKED
- GUIDELINES DESIGNINFO
- BEGIN
- IDD_ABOUTBOX, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 163
- TOPMARGIN, 7
- BOTTOMMARGIN, 55
- END
- END
- #endif // APSTUDIO_INVOKED
- #ifdef APSTUDIO_INVOKED
- /////////////////////////////////////////////////////////////////////////////
- //
- // TEXTINCLUDE
- //
- 1 TEXTINCLUDE
- BEGIN
- "resource.h\0"
- END
- 2 TEXTINCLUDE
- BEGIN
- "#ifndef APSTUDIO_INVOKED\r\n"
- "#include ""targetver.h""\r\n"
- "#endif\r\n"
- "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
- "#include ""windows.h""\r\n"
- "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
- "\0"
- END
- 3 TEXTINCLUDE
- BEGIN
- "\r\n"
- "\0"
- END
- #endif // APSTUDIO_INVOKED
- /////////////////////////////////////////////////////////////////////////////
- //
- // String Table
- //
- STRINGTABLE
- BEGIN
- IDS_APP_TITLE "WindowsProject5"
- IDC_WINDOWSPROJECT5 "WINDOWSPROJECT5"
- END
- #endif // English (United States) resources
- /////////////////////////////////////////////////////////////////////////////
- #ifndef APSTUDIO_INVOKED
- /////////////////////////////////////////////////////////////////////////////
- //
- // Generated from the TEXTINCLUDE 3 resource.
- //
- /////////////////////////////////////////////////////////////////////////////
- #endif // not APSTUDIO_INVOKED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement