Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.01 KB | None | 0 0
  1. // Athius.cpp : Defines the entry point for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Athius.h"
  6. #include <iostream>
  7. #include <string>
  8. #include <windows.h>
  9. #include <stdlib.h>
  10. #include <time.h>
  11. #include <stdio.h>
  12.  
  13. #define MAX_LOADSTRING 100
  14.  
  15. // Global Variables:
  16. HINSTANCE hInst;                                // current instance
  17. WCHAR szTitle[MAX_LOADSTRING];                  // The title bar text
  18. WCHAR szWindowClass[MAX_LOADSTRING];            // the main window class name
  19.  
  20. // Forward declarations of functions included in this code module:
  21. ATOM                MyRegisterClass(HINSTANCE hInstance);
  22. BOOL                InitInstance(HINSTANCE, int);
  23. LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
  24. INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);
  25.  
  26. int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
  27.                      _In_opt_ HINSTANCE hPrevInstance,
  28.                      _In_ LPWSTR    lpCmdLine,
  29.                      _In_ int       nCmdShow)
  30. {
  31.     UNREFERENCED_PARAMETER(hPrevInstance);
  32.     UNREFERENCED_PARAMETER(lpCmdLine);
  33.  
  34.     // TODO: Place code here.
  35.  
  36.     // Initialize global strings
  37.     LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
  38.     LoadStringW(hInstance, IDC_ATHIUS, szWindowClass, MAX_LOADSTRING);
  39.     MyRegisterClass(hInstance);
  40.  
  41.     // Perform application initialization:
  42.     if (!InitInstance (hInstance, nCmdShow))
  43.     {
  44.         return FALSE;
  45.     }
  46.  
  47.     HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_ATHIUS));
  48.  
  49.     MSG msg;
  50.  
  51.     // Main message loop:
  52.     while (GetMessage(&msg, nullptr, 0, 0))
  53.     {
  54.         if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
  55.         {
  56.             TranslateMessage(&msg);
  57.             DispatchMessage(&msg);
  58.         }
  59.     }
  60.  
  61.     return (int) msg.wParam;
  62. }
  63.  
  64.  
  65.  
  66. //
  67. //  FUNCTION: MyRegisterClass()
  68. //
  69. //  PURPOSE: Registers the window class.
  70. //
  71. ATOM MyRegisterClass(HINSTANCE hInstance)
  72. {
  73.     WNDCLASSEXW wcex;
  74.  
  75.     wcex.cbSize = sizeof(WNDCLASSEX);
  76.  
  77.     wcex.style          = CS_HREDRAW | CS_VREDRAW;
  78.     wcex.lpfnWndProc    = WndProc;
  79.     wcex.cbClsExtra     = 0;
  80.     wcex.cbWndExtra     = 0;
  81.     wcex.hInstance      = hInstance;
  82.     wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ATHIUS));
  83.     wcex.hCursor        = LoadCursor(nullptr, IDC_ARROW);
  84.     wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
  85.     wcex.lpszMenuName   = MAKEINTRESOURCEW(IDC_ATHIUS);
  86.     wcex.lpszClassName  = szWindowClass;
  87.     wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
  88.  
  89.     return RegisterClassExW(&wcex);
  90. }
  91.  
  92. //
  93. //   FUNCTION: InitInstance(HINSTANCE, int)
  94. //
  95. //   PURPOSE: Saves instance handle and creates main window
  96. //
  97. //   COMMENTS:
  98. //
  99. //        In this function, we save the instance handle in a global variable and
  100. //        create and display the main program window.
  101. //
  102. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  103. {
  104.    hInst = hInstance; // Store instance handle in our global variable
  105.  
  106.    HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  107.       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
  108.  
  109.    if (!hWnd)
  110.    {
  111.       return FALSE;
  112.    }
  113.  
  114.    ShowWindow(hWnd, nCmdShow);
  115.    UpdateWindow(hWnd);
  116.  
  117.    return TRUE;
  118. }
  119.  
  120. //
  121. //  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
  122. //
  123. //  PURPOSE:  Processes messages for the main window.
  124. //
  125. //  WM_COMMAND  - process the application menu
  126. //  WM_PAINT    - Paint the main window
  127. //  WM_DESTROY  - post a quit message and return
  128. //
  129. //
  130. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  131. {
  132.     switch (message)
  133.     {
  134.     case WM_COMMAND:
  135.         {
  136.             int wmId = LOWORD(wParam);
  137.             // Parse the menu selections:
  138.             switch (wmId)
  139.             {
  140.             case IDM_ABOUT:
  141.                 DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
  142.                 break;
  143.             case IDM_EXIT:
  144.                 DestroyWindow(hWnd);
  145.                 break;
  146.             default:
  147.                 return DefWindowProc(hWnd, message, wParam, lParam);
  148.             }
  149.         }
  150.         break;
  151.     case WM_PAINT:
  152.         {
  153.             PAINTSTRUCT ps;
  154.             HDC hdc = BeginPaint(hWnd, &ps);
  155.             // TODO: Add any drawing code that uses hdc here...
  156.             EndPaint(hWnd, &ps);
  157.         }
  158.         break;
  159.     case WM_DESTROY:
  160.         PostQuitMessage(0);
  161.         break;
  162.     default:
  163.         return DefWindowProc(hWnd, message, wParam, lParam);
  164.     }
  165.     return 0;
  166. }
  167.  
  168. // Message handler for about box.
  169. INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  170. {
  171.     UNREFERENCED_PARAMETER(lParam);
  172.     switch (message)
  173.     {
  174.     case WM_INITDIALOG:
  175.         return (INT_PTR)TRUE;
  176.  
  177.     case WM_COMMAND:
  178.         if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
  179.         {
  180.             EndDialog(hDlg, LOWORD(wParam));
  181.             return (INT_PTR)TRUE;
  182.         }
  183.         break;
  184.     }
  185.     return (INT_PTR)FALSE;
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement