Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

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