Project

General

Profile

Bug #581 » PaCtrlDlg.cpp

yufeng wu, 06/08/2020 11:14 AM

 
1
// PisCtrlDlg.cpp : implementation file
2
//
3

    
4
#include "stdafx.h"
5
#include "PaCtrlDlg.h"
6
#include "se_rbac.h"
7
#ifdef _DEBUG
8
#define new DEBUG_NEW
9
#undef THIS_FILE
10
static char THIS_FILE[] = __FILE__;
11
#endif
12

    
13
#pragma comment(lib, "Msimg32")
14

    
15
static BOOL GradientRect(HDC hDC, RECT rc, COLORREF c0, COLORREF c1, COLORREF c2, COLORREF c3)
16
{
17
	TRIVERTEX vert[] = 
18
	{
19
		{ rc.left,  rc.top,    GetRValue(c0)<<8, GetGValue(c0)<<8, GetBValue(c0)<<8, 0 },
20
		{ rc.right, rc.top,    GetRValue(c1)<<8, GetGValue(c1)<<8, GetBValue(c1)<<8, 0 },
21
		{ rc.right, rc.bottom, GetRValue(c2)<<8, GetGValue(c2)<<8, GetBValue(c2)<<8, 0 },
22
		{ rc.left,  rc.bottom, GetRValue(c3)<<8, GetGValue(c3)<<8, GetBValue(c3)<<8, 0 }
23
	};
24
	ULONG Index[] = { 0, 1, 2, 0, 2, 3 };
25
	return GradientFill(hDC, vert, 4, Index, 2, GRADIENT_FILL_TRIANGLE);
26
}
27

    
28
static char *szVoice[] = 
29
{
30
	"?????г???վ",
31
	"?????г???վ",
32
	"????ĩ?೵",
33
	"?????г???վ",
34
	"??Ʊ",
35
	"??????",
36
	"??ȫ",
37
	"???",
38
	"??ѩ",
39
	"????",
40
	"վ̨?????????㲥",
41
	"ǣ????????Ϲ㲥"
42
}; 
43

    
44
static char *szMusic[] = 
45
{
46
	"??·????1?㲥",
47
	"??·????2?㲥",
48
	"??·????3?㲥",
49
	"??·????4?㲥",
50
	"??·????5?㲥",
51
	"??·????6?㲥",
52
	"??·????7?㲥",
53
	"??·????8?㲥",
54
	"??·????9?㲥",
55
	"??·????10?㲥"
56
};
57

    
58
/*static char *szClose[] =
59
{
60
	"?رջ?Ͳ",
61
	"?ر?????",
62
	"?رձ???",
63
	"?ر?????"
64
};*/
65
/////////////////////////////////////////////////////////////////////////////
66
// CPaCtrlDlg dialog
67
CPaCtrlDlg::CPaCtrlDlg(CWnd* pParent /*=NULL*/, LPVOID lpData)
68
	: CDialog(CPaCtrlDlg::IDD, pParent)
69
{
70
	//{{AFX_DATA_INIT(CPaCtrlDlg)
71
	//}}AFX_DATA_INIT
72
	m_nZone = 0;
73
	m_lpPropData = (LPPAPROPDATA)lpData;
74
	m_bGradient = TRUE;
75
	m_nStationNo = 0;
76
}
77

    
78
CPaCtrlDlg::~CPaCtrlDlg()
79
{
80

    
81
}
82

    
83
void CPaCtrlDlg::DoDataExchange(CDataExchange* pDX)
84
{
85
	CDialog::DoDataExchange(pDX);
86
	//{{AFX_DATA_MAP(CPaCtrlDlg)
87
	DDX_Control(pDX, IDC_SLIDER1, m_Slider1);
88
	DDX_Control(pDX, IDC_BTN_LISTEN, m_btnListenOpen);
89
	DDX_Control(pDX, IDC_STATIC_INFO, m_wndRetInfo);
90
	DDX_Control(pDX, IDC_BTN_VOICE_CLOSE, m_btnVoiceClose);
91
	DDX_Control(pDX, IDC_BTN_MUSIC_CLOSE, m_btnMusicClose);
92
	DDX_Control(pDX, IDC_BTN_MIKE_CLOSE, m_btnMikeClose);
93
	DDX_Control(pDX, IDC_BTN_ALL_CLOSE, m_btnAllClose);
94
	DDX_Control(pDX, IDC_BTN_SHORTCUT, m_btnShortCut);
95
	DDX_Control(pDX, IDC_BTN_EDITWORD, m_btnEditWord);
96
	DDX_Control(pDX, IDC_BTN_PAINFO, m_btnPAInfo);
97
	DDX_Control(pDX, IDC_BTN_SELECT, m_btnSelect);
98
	DDX_Control(pDX, IDC_AERA11, m_btnGroupArea3);
99
	DDX_Control(pDX, IDC_AERA10, m_btnGroupArea2);
100
	DDX_Control(pDX, IDC_AERA9, m_btnGroupArea1);
101
	DDX_Control(pDX, IDC_CMB_VOICE, m_cmbVoice);
102
	DDX_Control(pDX, IDC_CMB_MUSIC, m_cmbMusic);
103
	DDX_Control(pDX, IDC_BTN_BROADCAST_VOICE, m_btnBroadcastVoice);
104
	DDX_Control(pDX, IDC_BTN_BROADCAST_MUSIC, m_btnBroadcastMusic);
105
	DDX_Control(pDX, IDC_BTN_BROADCAST_MIKE, m_btnBroadcastMike);
106
	DDX_Control(pDX, IDC_AERA8, m_btnArea8);
107
	DDX_Control(pDX, IDC_AERA7, m_btnArea7);
108
	DDX_Control(pDX, IDC_AERA6, m_btnArea6);
109
	DDX_Control(pDX, IDC_AERA5, m_btnArea5);
110
	DDX_Control(pDX, IDC_AERA4, m_btnArea4);
111
	DDX_Control(pDX, IDC_AERA3, m_btnArea3);
112
	DDX_Control(pDX, IDC_AERA2, m_btnArea2);
113
	DDX_Control(pDX, IDC_AERA1, m_btnArea1);
114
	//}}AFX_DATA_MAP
115
}
116

    
117

    
118
BEGIN_MESSAGE_MAP(CPaCtrlDlg, CDialog)
119
	//{{AFX_MSG_MAP(CPaCtrlDlg)
120
	ON_WM_ERASEBKGND()
121
	ON_WM_CTLCOLOR()
122
	ON_BN_CLICKED(IDC_BTN_BROADCAST_VOICE, OnBtnBroadcastVoice)
123
	ON_BN_CLICKED(IDC_BTN_BROADCAST_MUSIC, OnBtnBroadcastMusic)
124
	ON_BN_CLICKED(IDC_BTN_BROADCAST_MIKE, OnBtnBroadcastMike)
125
	ON_BN_CLICKED(IDC_BTN_SELECT, OnBtnSelect)
126
	ON_BN_CLICKED(IDC_BTN_SHORTCUT, OnBtnShortcut)
127
	ON_BN_CLICKED(IDC_BTN_EDITWORD, OnBtnEditword)
128
	ON_BN_CLICKED(IDC_BTN_PAINFO, OnBtnPainfo)
129
	ON_BN_CLICKED(IDC_BTN_VOICE_CLOSE, OnBtnVoiceClose)
130
	ON_BN_CLICKED(IDC_BTN_MUSIC_CLOSE, OnBtnMusicClose)
131
	ON_BN_CLICKED(IDC_BTN_MIKE_CLOSE, OnBtnMikeClose)
132
	ON_BN_CLICKED(IDC_BTN_ALL_CLOSE, OnBtnAllClose)
133
	ON_WM_DESTROY()
134
	ON_WM_TIMER()
135
	ON_BN_CLICKED(IDC_BTN_LISTEN, OnBtnListen)
136
	ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER1, OnReleasedcaptureSlider1)
137
	//}}AFX_MSG_MAP
138
	ON_COMMAND_RANGE(IDC_BTN_F1, IDC_BTN_F10, OnBtnFN)
139
	ON_COMMAND_RANGE(IDC_AERA1, IDC_AERA11, OnBtnArea)
140
END_MESSAGE_MAP()
141

    
142
/////////////////////////////////////////////////////////////////////////////
143
// CPaCtrlDlg message handlers
144
BOOL CPaCtrlDlg::OnInitDialog() 
145
{
146
	CDialog::OnInitDialog();
147
	m_wndRetInfo.SetBkColor(RGB(0, 0, 255), RGB(0, 0, 255), CLabel::Gradient);
148
	//m_wndTitle.SetFont3D(TRUE, CLabel::Sunken);
149
	m_wndRetInfo.SetTextColor(RGB(255, 0, 0));
150
	m_wndRetInfo.SetFontName("????");
151
	m_wndRetInfo.SetFontSize(10);
152
	m_wndRetInfo.SetFontBold(TRUE);
153
	// ??ʼ??Ȩ??????
154
	uint32 nPLevel[AOJ_K_MAX_CTRLPRIO];	// 0-Switch;1-PTZ;2-PA
155
	char szRoleName[256];
156
	RBAC_Initialize();
157
	AOJ_Initialize();
158
	RBAC_GetUserRoleDescription(NULL, NULL, NULL, szRoleName);
159
	RBAC_GetRolePLevel(szRoleName, nPLevel);
160
	m_nKeyID = nPLevel[2];
161

    
162
	CSE_DBOption dbo;
163
	CString strText;
164
	int nCount, i;
165
	char szSQL[1024];
166
	CString	strGroupDesc;
167
	CStatic *pEdt = (CStatic *)GetDlgItem(IDC_STATION);
168
	
169
	if (m_lpPropData->bArea)
170
	{
171
		m_btnBroadcastVoice.EnableWindow(FALSE);
172
		m_btnBroadcastMusic.EnableWindow(FALSE);
173
		m_btnBroadcastMike.EnableWindow(FALSE);	
174
		m_btnVoiceClose.EnableWindow(FALSE);	
175
		m_btnMusicClose.EnableWindow(FALSE);	
176
		m_btnMikeClose.EnableWindow(FALSE);	
177
		m_btnAllClose.EnableWindow(FALSE);	
178
		m_btnListenOpen.EnableWindow(FALSE);
179
	}
180
	else 
181
	{
182
		if (m_lpPropData->Code != _T(""))
183
		{
184
			char cmdbuf[256];
185
			sprintf(cmdbuf, "select F1001_GROUPNO, F1001_GROUPDESC from SEMODEL.TB1001_GROUP " \
186
				"Where F1001_GROUPCODE = '%s'", m_lpPropData->Code);
187
			
188
			CSE_DBOption dbOption;
189
			if (dbOption.BeginSelectRcdSet(cmdbuf) == SEDB_SUCCESS)
190
			{			
191
				int retcount = dbOption.GetRcdCount();
192
				if (retcount == 1)
193
				{
194
					strGroupDesc = (char *)dbOption.GetColVal(0, _T("F1001_GROUPDESC"));
195
					UINT nStationNo = dbOption.GetUShortVal(0, _T("F1001_GROUPNO"));
196
					m_aryStationNo.Add(nStationNo);
197
					GROUPTYPE grptype;
198
					strcpy(grptype.Code, m_lpPropData->Code);
199
					grptype.GroupNo = nStationNo;
200
					strcpy(grptype.szDesc, strGroupDesc); 
201
					m_arySelectGroup.Add(grptype);
202
				}
203
				else
204
				{
205
					strGroupDesc = "";
206
				}
207
			}		
208
			dbOption.EndSelectRcdSet();		
209
			pEdt->SetWindowText(strGroupDesc);	
210
		}
211
		m_cmbVoice.EnableWindow(TRUE);
212
		m_cmbMusic.EnableWindow(TRUE);
213
		m_btnSelect.EnableWindow(FALSE);
214
		//pEdt->EnableWindow(FALSE);
215
		m_btnBroadcastVoice.EnableWindow(TRUE);
216
		m_btnBroadcastMusic.EnableWindow(TRUE);
217
		m_btnListenOpen.EnableWindow(TRUE);
218
	}	
219

    
220
	//LoadStationList();
221
	DWORD dwData=0;
222
	sprintf(szSQL, "select * from TB4063_PAVOICE WHERE F4063_TYPE = 0");
223
	if (dbo.BeginSelectRcdSet(szSQL) == SEDB_SUCCESS)
224
	{
225
		nCount = dbo.GetRcdCount();
226
		for (i = 0; i < nCount; i++)
227
		{
228
			strText = dbo.GetStringVal(i, _T("F4063_NAME"));
229
			dwData = (DWORD)dbo.GetIntVal(i, _T("F4063_NO"));			
230
			m_cmbVoice.InsertString(i, strText);
231
			m_cmbVoice.SetItemData(i, dwData);
232
		}
233
	}
234
	dbo.EndSelectRcdSet();
235
	m_cmbVoice.SetCurSel(0);
236
	
237
	sprintf(szSQL, "select * from TB4063_PAVOICE WHERE F4063_TYPE = 1");
238
	if (dbo.BeginSelectRcdSet(szSQL) == SEDB_SUCCESS)
239
	{
240
		nCount = dbo.GetRcdCount();
241
		for (i = 0; i < nCount; i++)
242
		{
243
			strText = dbo.GetStringVal(i, _T("F4063_NAME"));
244
			dwData = (DWORD)dbo.GetIntVal(i, _T("F4063_NO"))-10;//????????-10	
245
			m_cmbMusic.InsertString(i, strText);
246
			m_cmbMusic.SetItemData(i, dwData);
247
		}
248
	}
249
	dbo.EndSelectRcdSet();
250
	m_cmbMusic.SetCurSel(0);
251

    
252
	for (i = 0; i < 12; i++)
253
	{
254
		UINT nID = IDC_BTN_F1 + i;
255
		m_btnF[i].SubclassDlgItem(nID, this);
256
		m_btnF[i].DrawBorder(TRUE);
257
		m_btnF[i].DrawTransparent();
258
		m_btnF[i].SetFlat(FALSE);
259
	}
260

    
261
	sprintf(szSQL, "select * from TB4062_PAHOTKEY WHERE F4062_TYPE = 0");
262
	if (dbo.BeginSelectRcdSet(szSQL) == SEDB_SUCCESS)
263
	{
264
		nCount = dbo.GetRcdCount();
265
		nCount = nCount > 10 ? 10 : nCount;
266
		for (i = 0; i < nCount; i++)
267
		{
268
			strText = dbo.GetStringVal(i, _T("F4062_HKDESC"));
269
			GetDlgItem(IDC_BTN_F1 + i)->SetWindowText(strText);
270
			HOTKEYTYPE hotkey;
271
			strcpy(hotkey.szDesc, strText);
272
			strcpy(hotkey.Group, dbo.GetStringVal(i, _T("F4062_GROUP")));
273
			hotkey.AreaNo = (unsigned char)dbo.GetShortVal(i, _T("F1002_BAYAREANO"));
274
			hotkey.FileNo = (unsigned char)dbo.GetShortVal(i, _T("F4062_FILECODE"));
275
			m_aryHotKeyType.Add(hotkey);
276
		}
277
	}
278
	dbo.EndSelectRcdSet();
279

    
280
	m_Slider1.SetRange(0, 100);
281

    
282
	// TODO: Add extra initialization here
283
	m_btnPAInfo.SetIcon(IDI_PAINFO, (int)BTNST_AUTO_DARKER);
284
//	m_btnPAInfo.SetTooltipText(_T("ִ??"));
285
	m_btnPAInfo.DrawBorder(FALSE);
286
	m_btnPAInfo.DrawTransparent();
287

    
288
	m_btnEditWord.SetIcon(IDI_EDITWORD, (int)BTNST_AUTO_DARKER);
289
//	m_btnPAInfo.SetTooltipText(_T("ִ??"));
290
	m_btnEditWord.DrawBorder(FALSE);
291
	m_btnEditWord.DrawTransparent();
292

    
293
	m_btnShortCut.SetBitmaps(IDB_SHORTCUT, RGB(0, 255, 0), (int)BTNST_AUTO_DARKER);	
294
	m_btnShortCut.DrawBorder(FALSE);
295
//	m_btnBroadcastVoice.SetTooltipText(_T("ִ??"));
296
	m_btnShortCut.DrawTransparent();
297
	
298
	//++++m_btnSelect.SetIcon(IDI_OPEN);	
299
	m_btnSelect.DrawBorder(TRUE);
300
	m_btnSelect.SetTooltipText(_T("ѡ??վ"));
301
	m_btnSelect.DrawTransparent();
302
	m_btnSelect.SetFlat(FALSE);
303

    
304
	//++++m_btnBroadcastMike.SetIcon(IDI_OPEN);	
305
	m_btnBroadcastMike.DrawBorder(TRUE);
306
	m_btnBroadcastMike.SetTooltipText(_T("?򿪻?Ͳ"));
307
	m_btnBroadcastMike.DrawTransparent();
308
	m_btnBroadcastMike.SetFlat(FALSE);
309
	
310
	//++++m_btnMikeClose.SetIcon(IDI_OPEN);	
311
	m_btnMikeClose.DrawBorder(TRUE);
312
	m_btnMikeClose.SetTooltipText(_T("?رջ?Ͳ"));
313
	m_btnMikeClose.DrawTransparent();
314
	m_btnMikeClose.SetFlat(FALSE);
315
	
316
	//++++m_btnBroadcastVoice.SetIcon(IDI_OPEN);	
317
	m_btnBroadcastVoice.DrawBorder(TRUE);
318
	m_btnBroadcastVoice.SetTooltipText(_T("??????"));
319
	m_btnBroadcastVoice.DrawTransparent();
320
	m_btnBroadcastVoice.SetFlat(FALSE);
321
	
322
	//++++m_btnVoiceClose.SetIcon(IDI_OPEN);	
323
	m_btnVoiceClose.DrawBorder(TRUE);
324
	m_btnVoiceClose.SetTooltipText(_T("?ر?????"));
325
	m_btnVoiceClose.DrawTransparent();
326
	m_btnVoiceClose.SetFlat(FALSE);
327

    
328
	//++++m_btnBroadcastMusic.SetIcon(IDI_OPEN);	
329
	m_btnBroadcastMusic.DrawBorder(TRUE);
330
	m_btnBroadcastMusic.SetTooltipText(_T("????·?㲥"));
331
	m_btnBroadcastMusic.DrawTransparent();
332
	m_btnBroadcastMusic.SetFlat(FALSE);
333
	
334
	//++++m_btnMusicClose.SetIcon(IDI_OPEN);	
335
	m_btnMusicClose.DrawBorder(TRUE);
336
	m_btnMusicClose.SetTooltipText(_T("?ر???·?㲥"));
337
	m_btnMusicClose.DrawTransparent();
338
	m_btnMusicClose.SetFlat(FALSE);
339

    
340
	//++++m_btnAllClose.SetIcon(IDI_OPEN);	
341
	m_btnAllClose.DrawBorder(TRUE);
342
	m_btnAllClose.SetTooltipText(_T("?رռ???"));
343
	m_btnAllClose.DrawTransparent();
344
	m_btnAllClose.SetFlat(FALSE);
345

    
346
	m_btnListenOpen.DrawBorder(TRUE);
347
	m_btnListenOpen.SetTooltipText(_T("?򿪼???"));
348
	m_btnListenOpen.DrawTransparent();
349
	m_btnListenOpen.SetFlat(FALSE);
350

    
351
	for (i = 0; i < 11; i++)
352
	{
353
		CButtonST *pBtnArea = (CButtonST *)GetDlgItem(IDC_AERA1 + i);
354
		pBtnArea->ShowWindow(SW_HIDE);
355
	}
356
	// ??????
357
	sprintf(szSQL, "select F1002_BAYAREANO, F1002_BAYAREADESC,F1002_ASSIGNMENT from TB1002_BAYAREA "
358
		"where F1002_BAYAREA=1 ORDER BY F1002_BAYAREANO ASC"); // =1 PA
359
	if (dbo.BeginSelectRcdSet(szSQL) == SEDB_SUCCESS)
360
	{
361
		BYTE BayAreaNo;
362
		int nMask, nAssignment;
363
		nCount = dbo.GetRcdCount();
364
		nCount = nCount > 8 ? 8 : nCount;
365
		for (i = 0; i < nCount; i++)
366
		{
367
			AREAPADATA AreaData;
368
			BayAreaNo = dbo.GetByteVal(i, _T("F1002_BAYAREANO"));
369
			strText = dbo.GetStringVal(i, _T("F1002_BAYAREADESC"));
370
			nAssignment = dbo.GetIntVal(i, _T("F1002_ASSIGNMENT"));
371
			AreaData.BayAreaNo = BayAreaNo;
372
			AreaData.Assignment = (UINT)nAssignment;
373
			strncpy(AreaData.szDesc, strText.GetBuffer(40), 40);
374
			//nMask = 1 << i;
375
			nMask = i + 1;
376
			CButtonST *pBtnArea = (CButtonST *)GetDlgItem(IDC_AERA1 + i);
377
			if (nMask == nAssignment)
378
			{
379
				pBtnArea->SetWindowText(strText);
380
				pBtnArea->ShowWindow(SW_SHOW);			
381
				pBtnArea->SetItemData(1 << i);
382
			}
383
			else
384
			{
385
				pBtnArea->EnableWindow(FALSE);
386
			}
387
			m_aryAreaPAData.Add(AreaData);
388
		}
389
	}
390
	dbo.EndSelectRcdSet();
391

    
392
	// ??????
393
	sprintf(szSQL, "select * from TB4062_PAHOTKEY WHERE F4062_TYPE = 1");
394
	if (dbo.BeginSelectRcdSet(szSQL) == SEDB_SUCCESS)
395
	{
396
		nCount = dbo.GetRcdCount();
397
		nCount = nCount > 3 ? 3 : nCount;
398
		CStatic *pStaGroup = (CStatic *)GetDlgItem(IDC_STATIC_GROUP);		
399
		if (nCount == 0)
400
		{
401
			pStaGroup->ShowWindow(SW_HIDE);
402
		}
403
		
404
		for (i = 0; i < nCount; i++)
405
		{
406
			strText = dbo.GetStringVal(i, _T("F4062_HKDESC"));
407
			CButtonST *pBtnGroup = (CButtonST *)GetDlgItem(IDC_AERA9 + i);
408
			pBtnGroup->SetWindowText(strText);
409
			BYTE zone = (unsigned char)dbo.GetShortVal(i, _T("F1002_BAYAREANO"));
410
			pBtnGroup->ShowWindow(SW_SHOW);	
411
			pBtnGroup->SetItemData(zone);
412
		}
413
	}
414
	dbo.EndSelectRcdSet();
415

    
416
	m_btnArea1.SetIcon(IDI_LEDON, IDI_LEDOFF);
417
	m_btnArea1.DrawBorder(FALSE);
418
	m_btnArea1.DrawTransparent();
419

    
420
	m_btnArea2.SetIcon(IDI_LEDON, IDI_LEDOFF);
421
	m_btnArea2.DrawBorder(FALSE);
422
	m_btnArea2.DrawTransparent();
423

    
424
	m_btnArea3.SetIcon(IDI_LEDON, IDI_LEDOFF);
425
	m_btnArea3.DrawBorder(FALSE);
426
	m_btnArea3.DrawTransparent();
427

    
428
	m_btnArea4.SetIcon(IDI_LEDON, IDI_LEDOFF);
429
	m_btnArea4.DrawBorder(FALSE);
430
	m_btnArea4.DrawTransparent();
431

    
432
	m_btnArea5.SetIcon(IDI_LEDON, IDI_LEDOFF);
433
	m_btnArea5.DrawBorder(FALSE);
434
	m_btnArea5.DrawTransparent();
435

    
436
	m_btnArea6.SetIcon(IDI_LEDON, IDI_LEDOFF);
437
	m_btnArea6.DrawBorder(FALSE);
438
	m_btnArea6.DrawTransparent();
439

    
440
	m_btnArea7.SetIcon(IDI_LEDON, IDI_LEDOFF);
441
	m_btnArea7.DrawBorder(FALSE);
442
	m_btnArea7.DrawTransparent();
443

    
444
	m_btnArea8.SetIcon(IDI_LEDON, IDI_LEDOFF);
445
	m_btnArea8.DrawBorder(FALSE);
446
	m_btnArea8.DrawTransparent();
447

    
448
	m_btnGroupArea1.SetIcon(IDI_LEDON, IDI_LEDOFF);
449
	m_btnGroupArea1.DrawBorder(FALSE);
450
	m_btnGroupArea1.DrawTransparent();
451

    
452
	m_btnGroupArea2.SetIcon(IDI_LEDON, IDI_LEDOFF);
453
	m_btnGroupArea2.DrawBorder(FALSE);
454
	m_btnGroupArea2.DrawTransparent();
455

    
456
	m_btnGroupArea3.SetIcon(IDI_LEDON, IDI_LEDOFF);
457
	m_btnGroupArea3.DrawBorder(FALSE);
458
	m_btnGroupArea3.DrawTransparent();
459

    
460
	sprintf(szSQL, "select F1001_GROUPDESC,F1001_GROUPNO,F1001_GROUPCODE from "
461
		"TB1001_GROUP where F1005_DEVTYPEID=201 order by F1001_GROUPNO asc");
462
	if (dbo.BeginSelectRcdSet(szSQL) == SEDB_SUCCESS)
463
	{
464
		int nCount = dbo.GetRcdCount();
465
		nCount = nCount > 36 ? 36 : nCount;
466
		for (i = 0; i < nCount; i++)
467
		{
468
			CString strName = dbo.GetStringVal(i, _T("F1001_GROUPDESC"));
469
			CString strCode = dbo.GetStringVal(i, _T("F1001_GROUPCODE"));
470
			UINT nID = dbo.GetIntVal(i, _T("F1001_GROUPNO"));		
471
			GROUPTYPE GrpType;
472
			GrpType.GroupNo = nID;
473
			strncpy(GrpType.Code, strCode.GetBuffer(10), 8);
474
			strncpy(GrpType.szDesc, strName.GetBuffer(10), 24);
475
			m_aryGroup.Add(GrpType);
476
		}
477
		dbo.EndSelectRcdSet();	
478
	}
479
	SetTimer(1, 1000, 0);
480
	return TRUE;  // return TRUE unless you set the focus to a control
481
	              // EXCEPTION: OCX Property Pages should return FALSE
482
}
483

    
484

    
485
HBRUSH CPaCtrlDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
486
{
487
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
488
	
489
	// TODO: Change any attributes of the DC here
490
	UINT nID = pWnd->GetDlgCtrlID();
491
	if (nCtlColor == CTLCOLOR_STATIC || IDC_STATION == nID)
492
	{
493
		pDC->SetBkMode(TRANSPARENT);
494
		hbr = (HBRUSH)::GetStockObject(NULL_BRUSH);
495
	}
496
	// TODO: Return a different brush if the default is not desired
497
	return hbr;
498
}
499

    
500
BOOL CPaCtrlDlg::GetGroupInfo(char *Group)
501
{
502
	BOOL bRet = FALSE;
503
	if (Group && strlen(Group) > 0)
504
	{
505
		int nPos;
506
		UINT nValue;
507
		m_aryStationNo.RemoveAll();	
508
		CString strValue, strTemp = Group;
509
		while (!strTemp.IsEmpty())
510
		{
511
			nPos = strTemp.Find(",", 0);
512
			if (nPos == -1)
513
			{
514
				nValue = atoi(strTemp);
515
				m_aryStationNo.Add(nValue);			
516
				break;
517
			}
518
			strValue = strTemp.Mid(0, nPos);
519
			nValue = atoi(strValue);
520
			m_aryStationNo.Add(nValue);			
521
			strTemp = strTemp.Mid(nPos + 1);
522
		}
523
		bRet = TRUE;
524
		int nID = 0;
525
		m_arySelectGroup.RemoveAll();
526
		for (int i = 0; i < m_aryStationNo.GetSize(); i++)
527
		{
528
			nID = m_aryStationNo.GetAt(i);
529
			for (int j = 0; j < m_aryGroup.GetSize(); j++)
530
			{
531
				GROUPTYPE grptype = (GROUPTYPE)m_aryGroup.GetAt(j);
532
				if (nID == grptype.GroupNo)
533
				{
534
					m_arySelectGroup.Add(grptype);
535
				}
536
			}
537
		}
538
	}
539
	else
540
	{
541
		m_arySelectGroup.RemoveAll();
542
	}	
543
	return bRet;
544
}
545

    
546
void CPaCtrlDlg::OnBtnFN(UINT nID)
547
{
548
	int nSize = m_aryStationNo.GetSize();
549
	if (nSize == 0)
550
	{
551
		MessageBox("??ѡ??վ!", "??ʾ", MB_ICONINFORMATION);
552
		return;
553
	}
554

    
555
	m_nFNo = nID - IDC_BTN_F1;
556
	nSize = m_aryHotKeyType.GetSize();
557
	if (nSize > m_nFNo)
558
	{
559
		CString strText;
560
		GetDlgItem(nID)->GetWindowText(strText);
561
		if (m_aryHotKeyType.GetAt(m_nFNo).szDesc == strText)
562
		{
563
			uint16 stnno, zone, no;
564
			/*if (m_lpPropData->bArea)
565
			{
566
				char *Group = m_aryHotKeyType.GetAt(m_nFNo).Group;
567
				BOOL bRet = GetGroupInfo(Group);
568
			}*/
569
			int nStaSize = m_aryStationNo.GetSize();
570
			if (nStaSize > 0)
571
			{
572
				m_csiServer.PA_BeginSelect();
573
				m_csiServer.PA_Login(m_nKeyID);
574
				for (int i = 0; i < nStaSize; i++)
575
				{
576
//					stnno = (UINT)m_aryStationNo.GetAt(i);
577
					zone = m_aryHotKeyType.GetAt(m_nFNo).AreaNo;
578
					no = m_aryHotKeyType.GetAt(m_nFNo).FileNo;				
579
					m_csiServer.PA_SelectZone(m_nStationNo,0, zone);	
580
					m_nZone = zone;
581
				}
582
				int nRet = m_csiServer.PA_PlayVoice(no);
583
			}
584
		}		
585
	}
586
}
587

    
588
void CPaCtrlDlg::OnBtnBroadcastVoice() 
589
{
590
	// TODO: Add your control notification handler code here
591
	if (m_nZone == 0)
592
	{
593
		MessageBox("??ѡ??һ??????!", "??ʾ", MB_ICONINFORMATION);
594
		return;
595
	}
596
	uint16 stnno, zone, no;
597
	int nSize = m_aryStationNo.GetSize();
598
	if (nSize > 0)
599
	{
600
		no = m_cmbVoice.GetCurSel();
601
		DWORD dwData = m_cmbVoice.GetItemData(no);
602
		m_csiServer.PA_BeginSelect();
603
		m_csiServer.PA_Login(m_nKeyID);
604
		for (int i = 0; i < nSize; i++)
605
		{		
606
//			stnno = (UINT)m_aryStationNo.GetAt(i);
607
			zone = m_nZone;
608
			m_csiServer.PA_SelectZone(m_nStationNo,0, zone);		
609
		}
610
		int nRet = m_csiServer.PA_PlayVoice((BYTE)dwData);
611
	}
612
}
613

    
614
void CPaCtrlDlg::OnBtnBroadcastClose(unsigned char no) 
615
{
616
	// TODO: Add your control notification handler code here
617
	if (m_nZone == 0)
618
	{
619
		MessageBox("??ѡ??һ??????!", "??ʾ", MB_ICONINFORMATION);
620
		return;
621
	}
622
	uint16 stnno, zone;
623
	int nSize = m_aryStationNo.GetSize();
624
	if (nSize > 0)
625
	{
626
		m_csiServer.PA_BeginSelect();
627
		m_csiServer.PA_Login(m_nKeyID);
628
		for (int i = 0; i < nSize; i++)
629
		{		
630
			stnno = (UINT)m_aryStationNo.GetAt(i);
631
			zone = m_nZone;
632
			m_csiServer.PA_SelectZone(m_nStationNo,0, zone);		
633
		}
634
		int nRet = m_csiServer.PA_Stop(no);
635
	}
636
}
637

    
638
void CPaCtrlDlg::OnBtnBroadcastMusic() 
639
{
640
	// TODO: Add your control notification handler code here
641
	if (m_nZone == 0)
642
	{
643
		MessageBox("??ѡ??һ??????!", "??ʾ", MB_ICONINFORMATION);
644
		return;
645
	}
646
	uint16 stnno, zone, no;
647
	int nSize = m_aryStationNo.GetSize();
648
	if (nSize > 0)
649
	{
650
//		no = m_cmbMusic.GetCurSel() + 1;
651
		no = m_cmbMusic.GetCurSel();
652
		DWORD dwData = m_cmbMusic.GetItemData(no);
653
		m_csiServer.PA_BeginSelect();
654
		m_csiServer.PA_Login(m_nKeyID);
655
		for (int i = 0; i < nSize; i++)
656
		{		
657
//			stnno = (UINT)m_aryStationNo.GetAt(i);
658
			zone = m_nZone;
659
			m_csiServer.PA_SelectZone(m_nStationNo,0, zone);//WYF 20180731		
660
		}
661
		int nRet = m_csiServer.PA_PlayBack((BYTE)dwData);
662
	}
663
}
664

    
665
void CPaCtrlDlg::OnBtnBroadcastMike() 
666
{
667
	// TODO: Add your control notification handler code here
668
	if (m_nZone == 0)
669
	{
670
		MessageBox("??ѡ??һ??????!", "??ʾ", MB_ICONINFORMATION);
671
		return;
672
	}
673
	uint16 stnno, zone;
674
	int nSize = m_aryStationNo.GetSize();
675
	if (nSize > 0)
676
	{
677
		m_csiServer.PA_BeginSelect();
678
		m_csiServer.PA_Login(m_nKeyID);
679
		for (int i = 0; i < nSize; i++)
680
		{		
681
//			stnno = (UINT)m_aryStationNo.GetAt(i);
682
			zone = m_nZone;
683
			m_csiServer.PA_SelectZone(m_nStationNo,0, zone);//WYF 20180731	
684
		}
685
		int nRet = m_csiServer.PA_Mike();
686
	}
687
}
688

    
689
void CPaCtrlDlg::OnBtnArea(UINT nID)
690
{
691
	UINT nNo = nID - IDC_AERA1;
692
	for (UINT i = 0; i < 11; i++)
693
	{
694
		CButtonST *pBtn = (CButtonST *)GetDlgItem(IDC_AERA1 + i);
695
		if (nNo != i)
696
		{
697
			if (pBtn->GetCheck())
698
			{
699
				pBtn->SetCheck(0);
700
			}
701
		}
702
		else
703
		{
704
			CButtonST *pBtnArea = (CButtonST *)GetDlgItem(nID);						
705
			m_nZone = (unsigned char)pBtnArea->GetItemData();
706
		}
707
	}
708
}
709

    
710
#include "SelectDlg.h"
711
void CPaCtrlDlg::OnBtnSelect() 
712
{
713
	// TODO: Add your control notification handler code here
714
	CSelectDlg dlg(m_aryGroup);
715
	if (dlg.DoModal() == IDOK)
716
	{
717
		m_nStationNo=dlg.retGroupNo();
718
		BOOL bRet = GetGroupInfo(dlg.GetGroupNo().GetBuffer(10));
719
		CStatic *pEdt = (CStatic *)GetDlgItem(IDC_STATION);
720
		pEdt->SetWindowText(dlg.GetGroupDesc());
721
		if (bRet)
722
		{
723
			m_btnBroadcastVoice.EnableWindow(TRUE);
724
			m_btnBroadcastMusic.EnableWindow(TRUE);
725
			m_btnBroadcastMike.EnableWindow(TRUE);
726
			m_btnVoiceClose.EnableWindow(TRUE);	
727
			m_btnMusicClose.EnableWindow(TRUE);	
728
			m_btnMikeClose.EnableWindow(TRUE);	
729
			m_btnAllClose.EnableWindow(TRUE);
730
			m_btnListenOpen.EnableWindow(TRUE);
731
		}
732
		else
733
		{
734
			m_btnBroadcastVoice.EnableWindow(FALSE);
735
			m_btnBroadcastMusic.EnableWindow(FALSE);
736
			m_btnBroadcastMike.EnableWindow(FALSE);
737
			m_btnVoiceClose.EnableWindow(FALSE);	
738
			m_btnMusicClose.EnableWindow(FALSE);	
739
			m_btnMikeClose.EnableWindow(FALSE);	
740
			m_btnAllClose.EnableWindow(FALSE);
741
			m_btnListenOpen.EnableWindow(FALSE);
742
		}
743
		CRect rect;
744
		pEdt->GetWindowRect(&rect);
745
		ScreenToClient(rect);
746
		InvalidateRect(rect);
747
	}
748
}
749

    
750
#include "ShortCutDlg.h"
751
void CPaCtrlDlg::OnBtnShortcut() 
752
{
753
	// TODO: Add your control notification handler code here
754
	CShortCutDlg dlg;
755
	dlg.DoModal();
756
}
757

    
758
#include "PAVoiceEditDlg.h"
759
void CPaCtrlDlg::OnBtnEditword() 
760
{
761
	// TODO: Add your control notification handler code here
762
	CPAVoiceEditDlg dlg;
763
	dlg.DoModal();
764
}
765

    
766
#include "PAInfoDialog.h"
767
void CPaCtrlDlg::OnBtnPainfo() 
768
{
769
	// TODO: Add your control notification handler code here
770
/*	if (m_arySelectGroup.GetSize() == 0 )
771
	{
772
		MessageBox("??ѡ??վ??Ϣ!", "??ʾ", MB_ICONINFORMATION);
773
	}
774
	else
775
	{
776
		CPAInfoDialog dlg(m_arySelectGroup, m_aryAreaPAData, m_lpPropData->AppSysID, m_nKeyID);
777
		dlg.DoModal();
778
	}*/
779
	if (m_nZone == 0 || m_arySelectGroup.GetSize() == 0 )
780
	{
781
		MessageBox("??ѡ??һ????վ??????!", "??ʾ", MB_ICONINFORMATION);
782
		return;
783
	}
784
	else{
785
	int nSpeed = m_Slider1.GetPos()*2/5;//0-40
786
	uint16 stnno, zone;
787
	int nSize = m_aryStationNo.GetSize();
788
	m_csiServer.PA_BeginSelect();
789
	m_csiServer.PA_Login(m_nKeyID);		
790
	for (int i = 0; i < nSize; i++)
791
	{		
792
//		stnno = (UINT)m_aryStationNo.GetAt(i);
793
		zone = m_nZone;
794
		m_csiServer.PA_SelectZone(m_nStationNo,0, zone);		
795
	}		
796
	int nRet = m_csiServer.PA_SetVol(nSpeed & 0xff);
797
	}
798
}
799

    
800
// PA ?رղ???
801
#define  DEF_CLOSE_MIKE		1	//?رջ?Ͳ
802
#define  DEF_CLOSE_VOICE	2	//?ر?????
803
#define  DEF_CLOSE_BACK		3	//?رձ???
804
#define  DEF_CLOSE_ALL		4	//?ر?????
805
void CPaCtrlDlg::OnBtnVoiceClose() 
806
{
807
	// TODO: Add your control notification handler code here
808
	OnBtnBroadcastClose(DEF_CLOSE_VOICE);
809
}
810

    
811
void CPaCtrlDlg::OnBtnMusicClose() 
812
{
813
	// TODO: Add your control notification handler code here
814
	OnBtnBroadcastClose(DEF_CLOSE_BACK);
815
}
816

    
817
void CPaCtrlDlg::OnBtnMikeClose() 
818
{
819
	// TODO: Add your control notification handler code here
820
	OnBtnBroadcastClose(DEF_CLOSE_MIKE);
821
}
822

    
823
void CPaCtrlDlg::OnBtnAllClose() 
824
{
825
	// TODO: Add your control notification handler code here
826
	OnBtnBroadcastClose(DEF_CLOSE_ALL);
827
}
828

    
829
void CPaCtrlDlg::OnDestroy() 
830
{
831
	CDialog::OnDestroy();
832
	
833
	// TODO: Add your message handler code here
834
	m_nZone = 0xffff;
835
	OnBtnBroadcastClose(DEF_CLOSE_VOICE);
836
	OnBtnBroadcastClose(DEF_CLOSE_BACK);
837
	OnBtnBroadcastClose(DEF_CLOSE_MIKE);
838
	OnBtnBroadcastClose(DEF_CLOSE_ALL);
839
//	OnBtnAllClose();
840
	for (int i = 0; i < 12; i++)
841
	{
842
		m_btnF[i].UnsubclassWindow();		
843
	}
844
	KillTimer(1);
845
}
846

    
847
BOOL CPaCtrlDlg::OnEraseBkgnd(CDC* pDC)
848
{
849
	// TODO: Add your message handler code here and/or call default
850
	/*CRect	Rect;
851
	GetClientRect(&Rect);
852
	COLORREF crBackgroundColor;
853
	crBackgroundColor = m_lpPropData->clrBack; 
854
	dc.FillSolidRect(&Rect, crBackgroundColor);*/
855
	if (m_bGradient)
856
	{
857
		COLORREF clr[4];
858
		clr[0] = RGB(243, 245, 247);
859
		clr[1] = RGB(201, 200, 208);
860
		clr[2] = RGB(115, 123, 140);
861
		clr[3] = RGB(181, 189, 206);
862
		CRect rect;
863
		GetClientRect(&rect);
864

    
865
		CDC memdc;
866
		memdc.CreateCompatibleDC(pDC);
867
		CBitmap bmp;
868
		bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
869
		CBitmap *pOldBmp = memdc.SelectObject(&bmp);
870

    
871
		GradientRect(memdc, rect, clr[0], clr[1], clr[2], clr[3]);
872

    
873
		pDC->BitBlt(0, 0, rect.right, rect.bottom, &memdc, 0, 0, SRCCOPY);
874

    
875
		memdc.SelectObject(pOldBmp);
876
		bmp.DeleteObject();
877
		memdc.DeleteDC();
878
		return TRUE;
879
	}
880
	
881
	return CDialog::OnEraseBkgnd(pDC);
882
}
883

    
884
SE_MSG_ID CPaCtrlDlg::RecieveRequestShortMsg(int &nRequest)
885
{	
886
	CPipeOpt	    RtuPipeManager;
887
	void		    *PipeBuff;
888
	int			    PipeLen;
889
	DAC_D_PIPE_HEADER	    PipeHeader; 
890
	PIPE_LABLE	SourceId,DestId;        	
891
	int nLevel;
892
	
893
	RtuPipeManager.SetSrvType(RTU_SERVER);
894
	nLevel = DC_K_LEVEL_PA;
895
	if (RtuPipeManager.CResult(&SourceId, &DestId, &PipeBuff, &PipeLen, nLevel) == TRUE)
896
	{
897
		if (PipeLen > sizeof(DAC_D_PIPE_HEADER)) 
898
		{	
899
			memcpy((char *)&PipeHeader, (char *)PipeBuff, sizeof(DAC_D_PIPE_HEADER));
900
			sdbhostbyte(REALDB_SHORT, &PipeHeader.ServiceType);
901
			int nReqLen = PipeLen - sizeof(DAC_D_PIPE_HEADER);
902
			ST_DCTCMD dctCmd;
903
			memcpy(&dctCmd,((char *)PipeBuff) + sizeof(DAC_D_PIPE_HEADER), nReqLen);
904
			S_CMD_RET cmdret;
905
			memcpy(&cmdret, dctCmd.data, dctCmd.len > 512 ? 512 : dctCmd.len);
906
			nRequest = cmdret.RetCode;
907
			return(PipeHeader.ServiceType);
908
		}
909
	}
910
	return (CSI_K_PIPE_NULL);
911
}
912

    
913
// ??????SCADAӦ?÷??????Ľ???
914
void CPaCtrlDlg::ScadaReplay()
915
{
916
	int	nRequest = 0;
917
	int nServiceType;
918
	nServiceType = RecieveRequestShortMsg(nRequest);
919
	if (nServiceType == DC_K_CMDRET_PAOPRATE)
920
	{		
921
		CString strTxt = _T("");
922
		if (nRequest == 0)
923
		{
924
			strTxt = _T("????ʧ??");
925
		}
926
		else if (nRequest == 1)
927
		{
928
			strTxt = _T("???Ƴɹ?");
929
		}
930
		m_wndRetInfo.SetWindowText(strTxt);
931
		CRect rect;
932
		m_wndRetInfo.GetWindowRect(&rect);
933
		ScreenToClient(rect);
934
		InvalidateRect(rect);
935
	}		
936
}
937

    
938
void CPaCtrlDlg::OnTimer(UINT nIDEvent) 
939
{
940
	// TODO: Add your message handler code here and/or call default
941
	switch (nIDEvent)
942
	{
943
	case 1:
944
		ScadaReplay();
945
		break;
946
	default:
947
		break;
948
	}
949
	CDialog::OnTimer(nIDEvent);
950
}
951

    
952
void CPaCtrlDlg::OnBtnListen() 
953
{
954
	// TODO: Add your control notification handler code here
955
	OnBtnBroadcastClose(6);
956
}
957

    
958
void CPaCtrlDlg::OnReleasedcaptureSlider1(NMHDR* pNMHDR, LRESULT* pResult) 
959
{
960
	// TODO: Add your control notification handler code here
961
	CString strTxt;
962
	int nSpeed = m_Slider1.GetPos();
963
//	strTxt.Format("??  ??:%d %%", 100-nSpeed);//????0?????--100??С??
964
	strTxt.Format("??  ??:%d %%", nSpeed);
965
	CWnd *pWnd = (CWnd *)GetDlgItem(IDC_SLIDER_VOL);
966
	pWnd->SetWindowText(strTxt);
967
	
968
	CRect rect;
969
	pWnd->GetWindowRect(&rect);
970
	ScreenToClient(rect);
971
	InvalidateRect(rect);
972

    
973
	*pResult = 0;
974
}
    (1-1/1)