Repository navigation
Expand file tree
/
Copy pathRPCDlg.cpp
More file actions
134 lines (104 loc) · 6.42 KB
/
Copy pathRPCDlg.cpp
File metadata and controls
134 lines (104 loc) · 6.42 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// RPCDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "UIDemo.h"
#include "RPCDlg.h"
#include "afxdialogex.h"
#include "CommonStruct.h"
#include "LoadLanguage.h"
// CRPCDlg 对话框
IMPLEMENT_DYNAMIC(CRPCDlg, CDialogEx)
CRPCDlg::CRPCDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CRPCDlg::IDD, pParent)
{
}
CRPCDlg::~CRPCDlg()
{
}
void CRPCDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CRPCDlg, CDialogEx)
//ON_MESSAGE(WM_SEND_RPCCOMMAND,&OnInputRPCCommand)
ON_MESSAGE(WM_SHOW_RECV_DATA,OnShowRecvData)
ON_MESSAGE(WM_SHOW_SEND_DATA,OnShowSendData)
ON_BN_CLICKED(IDC_BTN_CLEAR, &CRPCDlg::OnBnClickedBtnClear)
END_MESSAGE_MAP()
BOOL CRPCDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
CLoadLanguage::getInstance()->Load(_T("rpc"),this);
CRect rcClient;
GetClientRect(&rcClient);
CEdit* pShowInfoEdit = (CEdit*)GetDlgItem(IDC_EDIT_SHOWINFO);
ASSERT(pShowInfoEdit);
pShowInfoEdit->MoveWindow(5,10,rcClient.Width()-60,rcClient.Height()-130);
CStatic* pStaticInput = (CStatic*)GetDlgItem(IDC_STATIC_INPUT);
ASSERT(pStaticInput);
pStaticInput->MoveWindow(5,rcClient.Height()-100,40,20);
CEdit* pInputEdit = (CEdit*)GetDlgItem(IDC_EDIT_INPUT);
ASSERT(pInputEdit);
pInputEdit->MoveWindow(50,rcClient.Height()-103,rcClient.Width()-160,25);
CButton* pBtnClear = (CButton*)GetDlgItem(IDC_BTN_CLEAR);
ASSERT(pBtnClear);
pBtnClear->MoveWindow(rcClient.Width()-95,rcClient.Height()-103,30,25);
return TRUE;
}
BOOL CRPCDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
{
if (pMsg->hwnd == GetDlgItem(IDC_EDIT_INPUT)->GetSafeHwnd())
{
CString strShow;
GetDlgItem(IDC_EDIT_SHOWINFO)->GetWindowTextW(strShow);
CString strCommand;
GetDlgItem(IDC_EDIT_INPUT)->GetWindowTextW(strCommand);
GetDlgItem(IDC_EDIT_INPUT)->SetWindowTextW(_T(""));
if (!strShow.IsEmpty() )
{
strShow += _T("\r\n");
}
strShow += strCommand;
strShow += _T(":");
GetDlgItem(IDC_EDIT_SHOWINFO)->SetWindowTextW(strShow);
CStringA strSendData;
RPCCommandToJson(strCommand,strSendData);
AfxGetMainWnd()->SendMessage(WM_SEND_RPC_DATA,(WPARAM)&strSendData,emRPCCommand);
return TRUE;
}
}
return CDialogEx::PreTranslateMessage(pMsg);
}
LRESULT CRPCDlg::OnShowRecvData(WPARAM wparam,LPARAM lparam)
{
CStringA str = *(CStringA*)wparam;
UpdateEditContent(str,_T("RecvData:"));
return TRUE;
}
void CRPCDlg::OnBnClickedBtnClear()
{
GetDlgItem(IDC_EDIT_SHOWINFO)->SetWindowTextW(_T(""));
}
LRESULT CRPCDlg::OnShowSendData(WPARAM wparam,LPARAM lparam)
{
CStringA str = *(CStringA*)wparam;
UpdateEditContent(str,_T("SendData:"));
return TRUE;
}
void CRPCDlg::UpdateEditContent(const CStringA& strNewData,const CString& strKeyWord)
{
CString strShow;
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_SHOWINFO);
pEdit->GetWindowTextW(strShow);
if(strShow.GetLength()> 1024*10)
strShow.Empty();
strShow += _T("\r\n");
strShow += strKeyWord;
strShow += _T("\r\n");
strShow += CString(strNewData.GetString());
pEdit->SetWindowTextW(strShow);
int nLines = pEdit->GetLineCount();
pEdit->LineScroll(nLines);
}