Sorting Network Verify and Draw
Check Whether Comparator Networks Sort and Draw Them
DialogBox.cpp
Go to the documentation of this file.
1
3
4// MIT License
5//
6// Copyright (c) 2022 Ian Parberry
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to deal
10// in the Software without restriction, including without limitation the rights
11// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12// copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in all
16// copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24// SOFTWARE.
25
26#include "DialogBox.h"
27#include "resource.h"
28
30
37
38HRESULT CDialogBox::GetNumInputs(HWND hwnd, UINT& n){
39 DialogBox(nullptr, MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)DlgProc);
40
41 if(m_nNumInputs < 2)
42 return E_FAIL;
43
44 n = (UINT)m_nNumInputs;
45 return S_OK;
46} //GetNumInputs
47
56
57BOOL CALLBACK CDialogBox::DlgProc(HWND hDlg, UINT iMsg, WPARAM wp, LPARAM lp){
58 BOOL bOK = TRUE;
59
60 switch(iMsg){
61 case WM_INITDIALOG:
62 SetDlgItemInt(hDlg, IDC_EDIT1, 16, FALSE); //default number of inputs
63 return TRUE;
64
65 case WM_COMMAND:
66 switch(LOWORD(wp)){
67 case IDOK: //user specifies the number of inputs
68 m_nNumInputs = GetDlgItemInt(hDlg, IDC_EDIT1, &bOK, FALSE);
69 if(!bOK)m_nNumInputs = 0; //something went wrong
70 EndDialog(hDlg, wp);
71 return TRUE;
72
73 case IDCANCEL: //user declines
74 m_nNumInputs = 0;
75 EndDialog(hDlg, wp);
76 return TRUE;
77 } //switch
78 } //switch
79
80 return FALSE;
81} //DlgProc
Interface for CDialogBox.
static UINT m_nNumInputs
Number of inputs.
Definition: DialogBox.h:38
HRESULT GetNumInputs(HWND, UINT &)
Get number of inputs.
Definition: DialogBox.cpp:38
static BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM)
Dialog box procedure.
Definition: DialogBox.cpp:57