-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTTYWindow.cpp
More file actions
91 lines (69 loc) · 1.99 KB
/
TTYWindow.cpp
File metadata and controls
91 lines (69 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* TTYWindow.cpp : implementation file
Copyright (c) 1987-2019 Advanced Systems for Power Engineering, Inc. (ASPEN).
All rights reserved.
*/
#include "stdafx.h"
#include "TestBenchOlxAPI.h"
#include "TTYWindow.h"
#include "afxdialogex.h"
CTTYWindow *pTTYWindow = NULL;
// CTTYWindow dialog
IMPLEMENT_DYNAMIC(CTTYWindow, CDialogEx)
CTTYWindow::CTTYWindow(CWnd* pParent /*=NULL*/)
: CDialogEx(CTTYWindow::IDD, pParent)
, m_sText( _T( "" ) )
{
m_sText = "";
}
CTTYWindow::~CTTYWindow()
{
}
void CTTYWindow::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange( pDX );
DDX_Text( pDX, IDC_EDIT1, m_sText );
}
BEGIN_MESSAGE_MAP(CTTYWindow, CDialogEx)
ON_WM_SIZE()
END_MESSAGE_MAP()
// CTTYWindow message handlers
BOOL CTTYWindow::OnInitDialog()
{
CDialogEx::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTTYWindow::OnSize( UINT nType, int cx, int cy ) {
CDialogEx::OnSize( nType, cx, cy );
CWnd *pEdit;
if ( !(pEdit = GetDlgItem( IDC_EDIT1 )) )
return;
CRect cRect, cRect1;
GetClientRect( &cRect );
pEdit->GetWindowRect( &cRect1 );
ScreenToClient( &cRect1 );
cRect1.right = cRect.right - cRect1.left;
cRect1.bottom = cRect.bottom - cRect1.top;
pEdit->MoveWindow( &cRect1 );
}
void CTTYWindow::OnClose() {
DestroyWindow();
}
void CTTYWindow::PostNcDestroy() {
CDialog::PostNcDestroy();
pTTYWindow = NULL;
delete this;
}
void ShowTTY( CString sText, BOOL bAppend ) {
if ( pTTYWindow == NULL ) {
pTTYWindow = new CTTYWindow;
pTTYWindow->Create( CTTYWindow::IDD, NULL );
}
if ( !bAppend || pTTYWindow->m_sText.GetLength() == 0 )
pTTYWindow->m_sText = sText;
else
pTTYWindow->m_sText += "\r\n" + sText;
pTTYWindow->UpdateData( FALSE );
pTTYWindow->SendDlgItemMessage( IDC_EDIT1, EM_SETSEL, pTTYWindow->m_sText.GetLength(), pTTYWindow->m_sText.GetLength() );
pTTYWindow->ShowWindow( SW_NORMAL );
}