iMONDisplayApiSample/DisplayTest/DisplayTestDlg.cpp
author sl
Sat, 15 Mar 2014 13:03:01 +0100
changeset 12 2f70b4447d70
permissions -rw-r--r--
Upgrade solution from Express to VS2012
StephaneLenclud@8
     1
// DisplayTestDlg.cpp : implementation file
StephaneLenclud@8
     2
//
StephaneLenclud@8
     3
StephaneLenclud@8
     4
#include "stdafx.h"
StephaneLenclud@8
     5
#include "DisplayTest.h"
StephaneLenclud@8
     6
#include "DisplayTestDlg.h"
StephaneLenclud@8
     7
StephaneLenclud@8
     8
#ifdef _DEBUG
StephaneLenclud@8
     9
#define new DEBUG_NEW
StephaneLenclud@8
    10
#endif
StephaneLenclud@8
    11
StephaneLenclud@8
    12
static WCHAR staticCh=1;
StephaneLenclud@8
    13
StephaneLenclud@8
    14
// CAboutDlg dialog used for App About
StephaneLenclud@8
    15
StephaneLenclud@8
    16
class CAboutDlg : public CDialog
StephaneLenclud@8
    17
{
StephaneLenclud@8
    18
public:
StephaneLenclud@8
    19
	CAboutDlg();
StephaneLenclud@8
    20
StephaneLenclud@8
    21
// Dialog Data
StephaneLenclud@8
    22
	enum { IDD = IDD_ABOUTBOX };
StephaneLenclud@8
    23
StephaneLenclud@8
    24
	protected:
StephaneLenclud@8
    25
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
StephaneLenclud@8
    26
StephaneLenclud@8
    27
// Implementation
StephaneLenclud@8
    28
protected:
StephaneLenclud@8
    29
	DECLARE_MESSAGE_MAP()
StephaneLenclud@8
    30
};
StephaneLenclud@8
    31
StephaneLenclud@8
    32
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
StephaneLenclud@8
    33
{
StephaneLenclud@8
    34
}
StephaneLenclud@8
    35
StephaneLenclud@8
    36
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
StephaneLenclud@8
    37
{
StephaneLenclud@8
    38
	CDialog::DoDataExchange(pDX);
StephaneLenclud@8
    39
}
StephaneLenclud@8
    40
StephaneLenclud@8
    41
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
StephaneLenclud@8
    42
END_MESSAGE_MAP()
StephaneLenclud@8
    43
StephaneLenclud@8
    44
StephaneLenclud@8
    45
// CDisplayTestDlg dialog
StephaneLenclud@8
    46
StephaneLenclud@8
    47
CDisplayTestDlg::CDisplayTestDlg(CWnd* pParent /*=NULL*/)
StephaneLenclud@8
    48
	: CDialog(CDisplayTestDlg::IDD, pParent)
StephaneLenclud@8
    49
{
StephaneLenclud@8
    50
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
StephaneLenclud@8
    51
	
StephaneLenclud@8
    52
	m_strLine1 = _T("");
StephaneLenclud@8
    53
	m_strLine2 = _T("");
StephaneLenclud@8
    54
	m_strLine3 = _T("");
StephaneLenclud@8
    55
StephaneLenclud@8
    56
	m_uEqTimer = 0;
StephaneLenclud@8
    57
	m_uEqTimer2 = 0;
StephaneLenclud@8
    58
	m_bVfdConnected = FALSE;
StephaneLenclud@8
    59
	m_bLcdConnected = FALSE;
StephaneLenclud@8
    60
}
StephaneLenclud@8
    61
StephaneLenclud@8
    62
void CDisplayTestDlg::DoDataExchange(CDataExchange* pDX)
StephaneLenclud@8
    63
{
StephaneLenclud@8
    64
	CDialog::DoDataExchange(pDX);
StephaneLenclud@8
    65
StephaneLenclud@8
    66
	DDX_Text(pDX, IDC_EDIT1, m_strLine1);
StephaneLenclud@8
    67
	DDX_Text(pDX, IDC_EDIT2, m_strLine2);
StephaneLenclud@8
    68
	DDX_Text(pDX, IDC_EDIT3, m_strLine3);
StephaneLenclud@8
    69
}
StephaneLenclud@8
    70
StephaneLenclud@8
    71
BEGIN_MESSAGE_MAP(CDisplayTestDlg, CDialog)
StephaneLenclud@8
    72
	ON_WM_SYSCOMMAND()
StephaneLenclud@8
    73
	ON_WM_PAINT()
StephaneLenclud@8
    74
	ON_WM_QUERYDRAGICON()
StephaneLenclud@8
    75
	ON_WM_DESTROY()
StephaneLenclud@8
    76
	ON_WM_TIMER()
StephaneLenclud@8
    77
	//}}AFX_MSG_MAP
StephaneLenclud@8
    78
	ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButtonInit)
StephaneLenclud@8
    79
	ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButtonVfdSendText)
StephaneLenclud@8
    80
	ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButtonVfdRandomEq)
StephaneLenclud@8
    81
	ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButtonLcdSendText)
StephaneLenclud@8
    82
	ON_BN_CLICKED(IDC_BUTTON5, OnBnClickedButtonLcdRandomEq)
StephaneLenclud@8
    83
StephaneLenclud@8
    84
	ON_BN_CLICKED(IDC_ORANGE1, OnLcdOrangeIcon)
StephaneLenclud@8
    85
	ON_BN_CLICKED(IDC_ORANGE2, OnLcdOrangeIcon)
StephaneLenclud@8
    86
	ON_BN_CLICKED(IDC_ORANGE3, OnLcdOrangeIcon)
StephaneLenclud@8
    87
	ON_BN_CLICKED(IDC_ORANGE4, OnLcdOrangeIcon)
StephaneLenclud@8
    88
	ON_BN_CLICKED(IDC_ORANGE5, OnLcdOrangeIcon)
StephaneLenclud@8
    89
	ON_BN_CLICKED(IDC_ORANGE6, OnLcdOrangeIcon)
StephaneLenclud@8
    90
	ON_BN_CLICKED(IDC_ORANGE7, OnLcdOrangeIcon)
StephaneLenclud@8
    91
	ON_BN_CLICKED(IDC_ORANGE8, OnLcdOrangeIcon)
StephaneLenclud@8
    92
	ON_BN_CLICKED(IDC_ORANGE0, OnLcdOrangeIcon)
StephaneLenclud@8
    93
	ON_BN_CLICKED(IDC_MUSIC, OnLcdMediaTypeIcon)
StephaneLenclud@8
    94
	ON_BN_CLICKED(IDC_MOVIE, OnLcdMediaTypeIcon)
StephaneLenclud@8
    95
	ON_BN_CLICKED(IDC_PHOTO, OnLcdMediaTypeIcon)
StephaneLenclud@8
    96
	ON_BN_CLICKED(IDC_CD, OnLcdMediaTypeIcon)
StephaneLenclud@8
    97
	ON_BN_CLICKED(IDC_TV, OnLcdMediaTypeIcon)
StephaneLenclud@8
    98
	ON_BN_CLICKED(IDC_WEBCASTING, OnLcdMediaTypeIcon)
StephaneLenclud@8
    99
	ON_BN_CLICKED(IDC_NEWS, OnLcdMediaTypeIcon)
StephaneLenclud@8
   100
	ON_BN_CLICKED(IDC_SPK_L, OnLcdSpeakerIcon)
StephaneLenclud@8
   101
	ON_BN_CLICKED(IDC_SPK_C, OnLcdSpeakerIcon)
StephaneLenclud@8
   102
	ON_BN_CLICKED(IDC_SPK_R, OnLcdSpeakerIcon)
StephaneLenclud@8
   103
	ON_BN_CLICKED(IDC_SPK_SL, OnLcdSpeakerIcon)
StephaneLenclud@8
   104
	ON_BN_CLICKED(IDC_SPK_LFE, OnLcdSpeakerIcon)
StephaneLenclud@8
   105
	ON_BN_CLICKED(IDC_SPK_SR, OnLcdSpeakerIcon)
StephaneLenclud@8
   106
	ON_BN_CLICKED(IDC_SPK_RL, OnLcdSpeakerIcon)
StephaneLenclud@8
   107
	ON_BN_CLICKED(IDC_SPK_SPDIF, OnLcdSpeakerIcon)
StephaneLenclud@8
   108
	ON_BN_CLICKED(IDC_SPK_RR, OnLcdSpeakerIcon)
StephaneLenclud@8
   109
	ON_BN_CLICKED(IDC_AV_MPG, OnLcdVideoCodecIcon)
StephaneLenclud@8
   110
	ON_BN_CLICKED(IDC_AV_DIVX, OnLcdVideoCodecIcon)
StephaneLenclud@8
   111
	ON_BN_CLICKED(IDC_AV_XVID, OnLcdVideoCodecIcon)
StephaneLenclud@8
   112
	ON_BN_CLICKED(IDC_AV_WMV, OnLcdVideoCodecIcon)
StephaneLenclud@8
   113
	ON_BN_CLICKED(IDC_AV_MPA, OnLcdVideoCodecIcon)
StephaneLenclud@8
   114
	ON_BN_CLICKED(IDC_AV_AC3, OnLcdVideoCodecIcon)
StephaneLenclud@8
   115
	ON_BN_CLICKED(IDC_AV_DTS, OnLcdVideoCodecIcon)
StephaneLenclud@8
   116
	ON_BN_CLICKED(IDC_AV_WMA, OnLcdVideoCodecIcon)
StephaneLenclud@8
   117
	ON_BN_CLICKED(IDC_A_MP3, OnLcdAudioCodecIcon)
StephaneLenclud@8
   118
	ON_BN_CLICKED(IDC_A_OGG, OnLcdAudioCodecIcon)
StephaneLenclud@8
   119
	ON_BN_CLICKED(IDC_A_WMA, OnLcdAudioCodecIcon)
StephaneLenclud@8
   120
	ON_BN_CLICKED(IDC_A_WAV, OnLcdAudioCodecIcon)
StephaneLenclud@8
   121
	ON_BN_CLICKED(IDC_AR_SRC, OnLcdAspectRatioIcon)
StephaneLenclud@8
   122
	ON_BN_CLICKED(IDC_AR_FIT, OnLcdAspectRatioIcon)
StephaneLenclud@8
   123
	ON_BN_CLICKED(IDC_AR_TV, OnLcdAspectRatioIcon)
StephaneLenclud@8
   124
	ON_BN_CLICKED(IDC_AR_HDTV, OnLcdAspectRatioIcon)
StephaneLenclud@8
   125
	ON_BN_CLICKED(IDC_AR_SCR1, OnLcdAspectRatioIcon)
StephaneLenclud@8
   126
	ON_BN_CLICKED(IDC_AR_SCR2, OnLcdAspectRatioIcon)
StephaneLenclud@8
   127
	ON_BN_CLICKED(IDC_REPEAT, OnLcdEtcIcon)
StephaneLenclud@8
   128
	ON_BN_CLICKED(IDC_SHUFFLE, OnLcdEtcIcon)
StephaneLenclud@8
   129
	ON_BN_CLICKED(IDC_ALARM, OnLcdEtcIcon)
StephaneLenclud@8
   130
	ON_BN_CLICKED(IDC_REC, OnLcdEtcIcon)
StephaneLenclud@8
   131
	ON_BN_CLICKED(IDC_VOL, OnLcdEtcIcon)
StephaneLenclud@8
   132
	ON_BN_CLICKED(IDC_TIME, OnLcdEtcIcon)
StephaneLenclud@8
   133
	ON_WM_HSCROLL()
StephaneLenclud@8
   134
StephaneLenclud@8
   135
	ON_MESSAGE(WM_DSP_PLUGIN_NOTIFY, OnDisplayPluginNotify)
StephaneLenclud@8
   136
	ON_BN_CLICKED(IDC_BUTTON6, &CDisplayTestDlg::OnBnClickedScrollChar)
StephaneLenclud@8
   137
	ON_BN_CLICKED(IDC_BUTTON7, &CDisplayTestDlg::OnBnClickedNextChar)
StephaneLenclud@8
   138
	ON_BN_CLICKED(IDC_BUTTON8, &CDisplayTestDlg::OnBnClickedPreviousChar)
StephaneLenclud@8
   139
END_MESSAGE_MAP()
StephaneLenclud@8
   140
StephaneLenclud@8
   141
StephaneLenclud@8
   142
StephaneLenclud@8
   143
StephaneLenclud@8
   144
// CDisplayTestDlg message handlers
StephaneLenclud@8
   145
StephaneLenclud@8
   146
BOOL CDisplayTestDlg::OnInitDialog()
StephaneLenclud@8
   147
{
StephaneLenclud@8
   148
	CDialog::OnInitDialog();
StephaneLenclud@8
   149
StephaneLenclud@8
   150
	// Add "About..." menu item to system menu.
StephaneLenclud@8
   151
StephaneLenclud@8
   152
	// IDM_ABOUTBOX must be in the system command range.
StephaneLenclud@8
   153
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
StephaneLenclud@8
   154
	ASSERT(IDM_ABOUTBOX < 0xF000);
StephaneLenclud@8
   155
StephaneLenclud@8
   156
	CMenu* pSysMenu = GetSystemMenu(FALSE);
StephaneLenclud@8
   157
	if (pSysMenu != NULL)
StephaneLenclud@8
   158
	{
StephaneLenclud@8
   159
		CString strAboutMenu;
StephaneLenclud@8
   160
		strAboutMenu.LoadString(IDS_ABOUTBOX);
StephaneLenclud@8
   161
		if (!strAboutMenu.IsEmpty())
StephaneLenclud@8
   162
		{
StephaneLenclud@8
   163
			pSysMenu->AppendMenu(MF_SEPARATOR);
StephaneLenclud@8
   164
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
StephaneLenclud@8
   165
		}
StephaneLenclud@8
   166
	}
StephaneLenclud@8
   167
StephaneLenclud@8
   168
	// Set the icon for this dialog.  The framework does this automatically
StephaneLenclud@8
   169
	//  when the application's main window is not a dialog
StephaneLenclud@8
   170
	SetIcon(m_hIcon, TRUE);			// Set big icon
StephaneLenclud@8
   171
	SetIcon(m_hIcon, FALSE);		// Set small icon
StephaneLenclud@8
   172
StephaneLenclud@8
   173
	// TODO: Add extra initialization here
StephaneLenclud@8
   174
	m_strLine1 = _T("SoundGraph, Inc.");
StephaneLenclud@8
   175
	m_strLine2 = _T("iMON Display API");
StephaneLenclud@8
   176
	m_strLine3 = _T("SoundGraph, Inc. iMON Display API");
StephaneLenclud@8
   177
StephaneLenclud@8
   178
	UpdateControlUI();
StephaneLenclud@8
   179
StephaneLenclud@8
   180
	CSliderCtrl* pSliderCtrl = (CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
StephaneLenclud@8
   181
	if(pSliderCtrl)
StephaneLenclud@8
   182
	{
StephaneLenclud@8
   183
		pSliderCtrl->SetRange(0, 100);
StephaneLenclud@8
   184
		pSliderCtrl->SetPos(0);
StephaneLenclud@8
   185
	}
StephaneLenclud@8
   186
StephaneLenclud@8
   187
	UpdateData(FALSE);
StephaneLenclud@8
   188
StephaneLenclud@8
   189
	return TRUE;  // return TRUE  unless you set the focus to a control
StephaneLenclud@8
   190
}
StephaneLenclud@8
   191
StephaneLenclud@8
   192
void CDisplayTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
StephaneLenclud@8
   193
{
StephaneLenclud@8
   194
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
StephaneLenclud@8
   195
	{
StephaneLenclud@8
   196
		CAboutDlg dlgAbout;
StephaneLenclud@8
   197
		dlgAbout.DoModal();
StephaneLenclud@8
   198
	}
StephaneLenclud@8
   199
	else
StephaneLenclud@8
   200
	{
StephaneLenclud@8
   201
		CDialog::OnSysCommand(nID, lParam);
StephaneLenclud@8
   202
	}
StephaneLenclud@8
   203
}
StephaneLenclud@8
   204
StephaneLenclud@8
   205
// If you add a minimize button to your dialog, you will need the code below
StephaneLenclud@8
   206
//  to draw the icon.  For MFC applications using the document/view model,
StephaneLenclud@8
   207
//  this is automatically done for you by the framework.
StephaneLenclud@8
   208
StephaneLenclud@8
   209
void CDisplayTestDlg::OnPaint()
StephaneLenclud@8
   210
{
StephaneLenclud@8
   211
	if (IsIconic())
StephaneLenclud@8
   212
	{
StephaneLenclud@8
   213
		CPaintDC dc(this); // device context for painting
StephaneLenclud@8
   214
StephaneLenclud@8
   215
		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
StephaneLenclud@8
   216
StephaneLenclud@8
   217
		// Center icon in client rectangle
StephaneLenclud@8
   218
		int cxIcon = GetSystemMetrics(SM_CXICON);
StephaneLenclud@8
   219
		int cyIcon = GetSystemMetrics(SM_CYICON);
StephaneLenclud@8
   220
		CRect rect;
StephaneLenclud@8
   221
		GetClientRect(&rect);
StephaneLenclud@8
   222
		int x = (rect.Width() - cxIcon + 1) / 2;
StephaneLenclud@8
   223
		int y = (rect.Height() - cyIcon + 1) / 2;
StephaneLenclud@8
   224
StephaneLenclud@8
   225
		// Draw the icon
StephaneLenclud@8
   226
		dc.DrawIcon(x, y, m_hIcon);
StephaneLenclud@8
   227
	}
StephaneLenclud@8
   228
	else
StephaneLenclud@8
   229
	{
StephaneLenclud@8
   230
		CDialog::OnPaint();
StephaneLenclud@8
   231
	}
StephaneLenclud@8
   232
}
StephaneLenclud@8
   233
StephaneLenclud@8
   234
// The system calls this function to obtain the cursor to display while the user drags
StephaneLenclud@8
   235
//  the minimized window.
StephaneLenclud@8
   236
HCURSOR CDisplayTestDlg::OnQueryDragIcon()
StephaneLenclud@8
   237
{
StephaneLenclud@8
   238
	return static_cast<HCURSOR>(m_hIcon);
StephaneLenclud@8
   239
}
StephaneLenclud@8
   240
StephaneLenclud@8
   241
void CDisplayTestDlg::OnDestroy() 
StephaneLenclud@8
   242
{
StephaneLenclud@8
   243
	CDialog::OnDestroy();
StephaneLenclud@8
   244
StephaneLenclud@8
   245
	IMON_Display_Uninit();
StephaneLenclud@8
   246
}
StephaneLenclud@8
   247
StephaneLenclud@8
   248
void CDisplayTestDlg::OnTimer(UINT nIDEvent) 
StephaneLenclud@8
   249
{
StephaneLenclud@8
   250
	if(nIDEvent == 101)
StephaneLenclud@8
   251
	{
StephaneLenclud@8
   252
StephaneLenclud@8
   253
		DSPEQDATA eqData;
StephaneLenclud@8
   254
		for(int i=0; i<16;i++)
StephaneLenclud@8
   255
		{
StephaneLenclud@8
   256
			eqData.BandData[i] = rand()%100;
StephaneLenclud@8
   257
		}
StephaneLenclud@8
   258
		IMON_Display_SetVfdEqData(&eqData);		
StephaneLenclud@8
   259
	}
StephaneLenclud@8
   260
	else if(nIDEvent == 102)
StephaneLenclud@8
   261
	{
StephaneLenclud@8
   262
		DSPEQDATA eqDataL;
StephaneLenclud@8
   263
		DSPEQDATA eqDataR;
StephaneLenclud@8
   264
		for(int i=0; i<16;i++)
StephaneLenclud@8
   265
		{
StephaneLenclud@8
   266
			eqDataL.BandData[i] = rand()%100;
StephaneLenclud@8
   267
			eqDataR.BandData[i] = rand()%100;
StephaneLenclud@8
   268
		}
StephaneLenclud@8
   269
		IMON_Display_SetLcdEqData(&eqDataL, &eqDataR);
StephaneLenclud@8
   270
	}
StephaneLenclud@8
   271
	else if (nIDEvent == 103)
StephaneLenclud@8
   272
	{
StephaneLenclud@8
   273
		//Char scroll
StephaneLenclud@8
   274
		WCHAR myStr[17];
StephaneLenclud@8
   275
StephaneLenclud@8
   276
		WCHAR myCh=staticCh;
StephaneLenclud@8
   277
StephaneLenclud@8
   278
		for (int i=0;i<16;i++)
StephaneLenclud@8
   279
		{
StephaneLenclud@8
   280
			myStr[i]=myCh;
StephaneLenclud@8
   281
			myCh++;
StephaneLenclud@8
   282
		}
StephaneLenclud@8
   283
StephaneLenclud@8
   284
		staticCh++;
StephaneLenclud@8
   285
		myStr[16]=0;
StephaneLenclud@8
   286
		//
StephaneLenclud@8
   287
		//myCh--;
StephaneLenclud@8
   288
StephaneLenclud@8
   289
		CString counter;
StephaneLenclud@8
   290
		counter.Format(TEXT("%d - %d"),myStr[0],myStr[15]);
StephaneLenclud@8
   291
StephaneLenclud@8
   292
		IMON_Display_SetVfdText(myStr, (LPCTSTR)counter);
StephaneLenclud@8
   293
StephaneLenclud@8
   294
	}
StephaneLenclud@8
   295
StephaneLenclud@8
   296
	CDialog::OnTimer(nIDEvent);
StephaneLenclud@8
   297
}
StephaneLenclud@8
   298
StephaneLenclud@8
   299
StephaneLenclud@8
   300
void CDisplayTestDlg::OnBnClickedButtonInit()
StephaneLenclud@8
   301
{
StephaneLenclud@8
   302
	if(IMON_Display_IsInited() != DSP_S_INITED)		Init();
StephaneLenclud@8
   303
	else											Uninit();
StephaneLenclud@8
   304
}
StephaneLenclud@8
   305
StephaneLenclud@8
   306
void CDisplayTestDlg::OnBnClickedButtonVfdSendText()
StephaneLenclud@8
   307
{
StephaneLenclud@8
   308
	UpdateData(TRUE);
StephaneLenclud@8
   309
	IMON_Display_SetVfdText((LPCTSTR)m_strLine1, (LPCTSTR)m_strLine2);
StephaneLenclud@8
   310
}
StephaneLenclud@8
   311
StephaneLenclud@8
   312
void CDisplayTestDlg::OnBnClickedButtonVfdRandomEq()
StephaneLenclud@8
   313
{
StephaneLenclud@8
   314
	if(m_uEqTimer)
StephaneLenclud@8
   315
	{	
StephaneLenclud@8
   316
		KillTimer(101);		m_uEqTimer = 0;		
StephaneLenclud@8
   317
		GetDlgItem(IDC_BUTTON3)->SetWindowText(_T("Start Random EQ"));
StephaneLenclud@8
   318
	}
StephaneLenclud@8
   319
	else
StephaneLenclud@8
   320
	{
StephaneLenclud@8
   321
		m_uEqTimer = SetTimer(101, 100, NULL);
StephaneLenclud@8
   322
		GetDlgItem(IDC_BUTTON3)->SetWindowText(_T("Stop Random EQ"));
StephaneLenclud@8
   323
	}
StephaneLenclud@8
   324
}
StephaneLenclud@8
   325
StephaneLenclud@8
   326
void CDisplayTestDlg::OnBnClickedScrollChar()
StephaneLenclud@8
   327
{
StephaneLenclud@8
   328
	if(m_uEqTimer)
StephaneLenclud@8
   329
	{	
StephaneLenclud@8
   330
		KillTimer(103);		m_uEqTimer = 0;		
StephaneLenclud@8
   331
		GetDlgItem(IDC_BUTTON6)->SetWindowText(_T("Start Scroll Char"));
StephaneLenclud@8
   332
	}
StephaneLenclud@8
   333
	else
StephaneLenclud@8
   334
	{
StephaneLenclud@8
   335
		m_uEqTimer = SetTimer(103, 500, NULL);
StephaneLenclud@8
   336
		GetDlgItem(IDC_BUTTON6)->SetWindowText(_T("Stop Scroll Char"));
StephaneLenclud@8
   337
	}
StephaneLenclud@8
   338
}
StephaneLenclud@8
   339
StephaneLenclud@8
   340
void CDisplayTestDlg::OnBnClickedNextChar()
StephaneLenclud@8
   341
{
StephaneLenclud@8
   342
	//staticCh++;
StephaneLenclud@8
   343
	OnTimer(103);
StephaneLenclud@8
   344
}
StephaneLenclud@8
   345
StephaneLenclud@8
   346
void CDisplayTestDlg::OnBnClickedPreviousChar()
StephaneLenclud@8
   347
{
StephaneLenclud@8
   348
	staticCh-=2;
StephaneLenclud@8
   349
	OnTimer(103);
StephaneLenclud@8
   350
}
StephaneLenclud@8
   351
StephaneLenclud@8
   352
StephaneLenclud@8
   353
StephaneLenclud@8
   354
void CDisplayTestDlg::OnBnClickedButtonLcdSendText()
StephaneLenclud@8
   355
{
StephaneLenclud@8
   356
	UpdateData(TRUE);
StephaneLenclud@8
   357
	IMON_Display_SetLcdText((LPCTSTR)m_strLine3);
StephaneLenclud@8
   358
}
StephaneLenclud@8
   359
StephaneLenclud@8
   360
void CDisplayTestDlg::OnBnClickedButtonLcdRandomEq()
StephaneLenclud@8
   361
{
StephaneLenclud@8
   362
	if(m_uEqTimer2)
StephaneLenclud@8
   363
	{	
StephaneLenclud@8
   364
		KillTimer(102);		m_uEqTimer2 = 0;		
StephaneLenclud@8
   365
		GetDlgItem(IDC_BUTTON5)->SetWindowText(_T("Start Random EQ"));
StephaneLenclud@8
   366
	}
StephaneLenclud@8
   367
	else
StephaneLenclud@8
   368
	{
StephaneLenclud@8
   369
		m_uEqTimer2 = SetTimer(102, 40, NULL);
StephaneLenclud@8
   370
		GetDlgItem(IDC_BUTTON5)->SetWindowText(_T("Stop Random EQ"));
StephaneLenclud@8
   371
	}
StephaneLenclud@8
   372
}
StephaneLenclud@8
   373
StephaneLenclud@8
   374
void CDisplayTestDlg::OnLcdOrangeIcon()
StephaneLenclud@8
   375
{
StephaneLenclud@8
   376
	BYTE data[2];
StephaneLenclud@8
   377
	memset(data, 0, sizeof(BYTE)*2);
StephaneLenclud@8
   378
StephaneLenclud@8
   379
	if(((CButton*)GetDlgItem(IDC_ORANGE1))->GetCheck())		data[0] |= 0x80;
StephaneLenclud@8
   380
	if(((CButton*)GetDlgItem(IDC_ORANGE2))->GetCheck())		data[0] |= 0x40;
StephaneLenclud@8
   381
	if(((CButton*)GetDlgItem(IDC_ORANGE3))->GetCheck())		data[0] |= 0x20;
StephaneLenclud@8
   382
	if(((CButton*)GetDlgItem(IDC_ORANGE4))->GetCheck())		data[0] |= 0x10;
StephaneLenclud@8
   383
	if(((CButton*)GetDlgItem(IDC_ORANGE5))->GetCheck())		data[0] |= 0x08;
StephaneLenclud@8
   384
	if(((CButton*)GetDlgItem(IDC_ORANGE6))->GetCheck())		data[0] |= 0x04;
StephaneLenclud@8
   385
	if(((CButton*)GetDlgItem(IDC_ORANGE7))->GetCheck())		data[0] |= 0x02;
StephaneLenclud@8
   386
	if(((CButton*)GetDlgItem(IDC_ORANGE8))->GetCheck())		data[0] |= 0x01;
StephaneLenclud@8
   387
	if(((CButton*)GetDlgItem(IDC_ORANGE0))->GetCheck())		data[1] |= 0x80;
StephaneLenclud@8
   388
StephaneLenclud@8
   389
	IMON_Display_SetLcdOrangeIcon(data[0], data[1]);
StephaneLenclud@8
   390
}
StephaneLenclud@8
   391
StephaneLenclud@8
   392
void CDisplayTestDlg::OnLcdMediaTypeIcon()
StephaneLenclud@8
   393
{
StephaneLenclud@8
   394
	BYTE data = 0;
StephaneLenclud@8
   395
StephaneLenclud@8
   396
	if(((CButton*)GetDlgItem(IDC_MUSIC))->GetCheck())		data |= 0x80;
StephaneLenclud@8
   397
	if(((CButton*)GetDlgItem(IDC_MOVIE))->GetCheck())		data |= 0x40;
StephaneLenclud@8
   398
	if(((CButton*)GetDlgItem(IDC_PHOTO))->GetCheck())		data |= 0x20;
StephaneLenclud@8
   399
	if(((CButton*)GetDlgItem(IDC_CD))->GetCheck())			data |= 0x10;
StephaneLenclud@8
   400
	if(((CButton*)GetDlgItem(IDC_TV))->GetCheck())			data |= 0x08;
StephaneLenclud@8
   401
	if(((CButton*)GetDlgItem(IDC_WEBCASTING))->GetCheck())	data |= 0x04;
StephaneLenclud@8
   402
	if(((CButton*)GetDlgItem(IDC_NEWS))->GetCheck())		data |= 0x02;
StephaneLenclud@8
   403
StephaneLenclud@8
   404
	IMON_Display_SetLcdMediaTypeIcon(data);
StephaneLenclud@8
   405
}
StephaneLenclud@8
   406
StephaneLenclud@8
   407
void CDisplayTestDlg::OnLcdSpeakerIcon()
StephaneLenclud@8
   408
{
StephaneLenclud@8
   409
	BYTE data[2];
StephaneLenclud@8
   410
	memset(data, 0, sizeof(BYTE)*2);
StephaneLenclud@8
   411
StephaneLenclud@8
   412
	if(((CButton*)GetDlgItem(IDC_SPK_L))->GetCheck())		data[0] |= 0x80;
StephaneLenclud@8
   413
	if(((CButton*)GetDlgItem(IDC_SPK_C))->GetCheck())		data[0] |= 0x40;
StephaneLenclud@8
   414
	if(((CButton*)GetDlgItem(IDC_SPK_R))->GetCheck())		data[0] |= 0x20;
StephaneLenclud@8
   415
	if(((CButton*)GetDlgItem(IDC_SPK_SL))->GetCheck())		data[0] |= 0x10;
StephaneLenclud@8
   416
	if(((CButton*)GetDlgItem(IDC_SPK_LFE))->GetCheck())		data[0] |= 0x08;
StephaneLenclud@8
   417
	if(((CButton*)GetDlgItem(IDC_SPK_SR))->GetCheck())		data[0] |= 0x04;
StephaneLenclud@8
   418
	if(((CButton*)GetDlgItem(IDC_SPK_RL))->GetCheck())		data[0] |= 0x02;
StephaneLenclud@8
   419
	if(((CButton*)GetDlgItem(IDC_SPK_SPDIF))->GetCheck())	data[0] |= 0x01;
StephaneLenclud@8
   420
	if(((CButton*)GetDlgItem(IDC_SPK_RR))->GetCheck())		data[1] |= 0x80;
StephaneLenclud@8
   421
StephaneLenclud@8
   422
	IMON_Display_SetLcdSpeakerIcon(data[0], data[1]);
StephaneLenclud@8
   423
}
StephaneLenclud@8
   424
StephaneLenclud@8
   425
void CDisplayTestDlg::OnLcdVideoCodecIcon()
StephaneLenclud@8
   426
{
StephaneLenclud@8
   427
	BYTE data = 0;
StephaneLenclud@8
   428
StephaneLenclud@8
   429
	if(((CButton*)GetDlgItem(IDC_AV_MPG))->GetCheck())		data |= 0x80;
StephaneLenclud@8
   430
	if(((CButton*)GetDlgItem(IDC_AV_DIVX))->GetCheck())		data |= 0x40;
StephaneLenclud@8
   431
	if(((CButton*)GetDlgItem(IDC_AV_XVID))->GetCheck())		data |= 0x20;
StephaneLenclud@8
   432
	if(((CButton*)GetDlgItem(IDC_AV_WMV))->GetCheck())		data |= 0x10;
StephaneLenclud@8
   433
	if(((CButton*)GetDlgItem(IDC_AV_MPA))->GetCheck())		data |= 0x08;
StephaneLenclud@8
   434
	if(((CButton*)GetDlgItem(IDC_AV_AC3))->GetCheck())		data |= 0x04;
StephaneLenclud@8
   435
	if(((CButton*)GetDlgItem(IDC_AV_DTS))->GetCheck())		data |= 0x02;
StephaneLenclud@8
   436
	if(((CButton*)GetDlgItem(IDC_AV_WMA))->GetCheck())		data |= 0x01;
StephaneLenclud@8
   437
StephaneLenclud@8
   438
	IMON_Display_SetLcdVideoCodecIcon(data);
StephaneLenclud@8
   439
}
StephaneLenclud@8
   440
StephaneLenclud@8
   441
void CDisplayTestDlg::OnLcdAudioCodecIcon()
StephaneLenclud@8
   442
{
StephaneLenclud@8
   443
	BYTE data = 0;
StephaneLenclud@8
   444
StephaneLenclud@8
   445
	if(((CButton*)GetDlgItem(IDC_A_MP3))->GetCheck())		data |= 0x80;
StephaneLenclud@8
   446
	if(((CButton*)GetDlgItem(IDC_A_OGG))->GetCheck())		data |= 0x40;
StephaneLenclud@8
   447
	if(((CButton*)GetDlgItem(IDC_A_WMA))->GetCheck())		data |= 0x20;
StephaneLenclud@8
   448
	if(((CButton*)GetDlgItem(IDC_A_WAV))->GetCheck())		data |= 0x10;
StephaneLenclud@8
   449
StephaneLenclud@8
   450
	IMON_Display_SetLcdAudioCodecIcon(data);
StephaneLenclud@8
   451
}
StephaneLenclud@8
   452
StephaneLenclud@8
   453
void CDisplayTestDlg::OnLcdAspectRatioIcon()
StephaneLenclud@8
   454
{
StephaneLenclud@8
   455
	BYTE data = 0;
StephaneLenclud@8
   456
StephaneLenclud@8
   457
	if(((CButton*)GetDlgItem(IDC_AR_SRC))->GetCheck())		data |= 0x80;
StephaneLenclud@8
   458
	if(((CButton*)GetDlgItem(IDC_AR_FIT))->GetCheck())		data |= 0x40;
StephaneLenclud@8
   459
	if(((CButton*)GetDlgItem(IDC_AR_TV))->GetCheck())		data |= 0x20;
StephaneLenclud@8
   460
	if(((CButton*)GetDlgItem(IDC_AR_HDTV))->GetCheck())		data |= 0x10;
StephaneLenclud@8
   461
	if(((CButton*)GetDlgItem(IDC_AR_SCR1))->GetCheck())		data |= 0x08;
StephaneLenclud@8
   462
	if(((CButton*)GetDlgItem(IDC_AR_SCR2))->GetCheck())		data |= 0x04;
StephaneLenclud@8
   463
StephaneLenclud@8
   464
	IMON_Display_SetLcdAspectRatioIcon(data);
StephaneLenclud@8
   465
}
StephaneLenclud@8
   466
StephaneLenclud@8
   467
void CDisplayTestDlg::OnLcdEtcIcon()
StephaneLenclud@8
   468
{
StephaneLenclud@8
   469
	BYTE data = 0;
StephaneLenclud@8
   470
StephaneLenclud@8
   471
	if(((CButton*)GetDlgItem(IDC_REPEAT))->GetCheck())		data |= 0x80;
StephaneLenclud@8
   472
	if(((CButton*)GetDlgItem(IDC_SHUFFLE))->GetCheck())		data |= 0x40;
StephaneLenclud@8
   473
	if(((CButton*)GetDlgItem(IDC_ALARM))->GetCheck())		data |= 0x20;
StephaneLenclud@8
   474
	if(((CButton*)GetDlgItem(IDC_REC))->GetCheck())			data |= 0x10;
StephaneLenclud@8
   475
	if(((CButton*)GetDlgItem(IDC_VOL))->GetCheck())			data |= 0x08;
StephaneLenclud@8
   476
	if(((CButton*)GetDlgItem(IDC_TIME))->GetCheck())		data |= 0x04;
StephaneLenclud@8
   477
StephaneLenclud@8
   478
	IMON_Display_SetLcdEtcIcon(data);
StephaneLenclud@8
   479
}
StephaneLenclud@8
   480
StephaneLenclud@8
   481
void CDisplayTestDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
StephaneLenclud@8
   482
{
StephaneLenclud@8
   483
	CSliderCtrl* pSliderCtrl = (CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
StephaneLenclud@8
   484
	if( pSliderCtrl && pSliderCtrl->GetSafeHwnd() && 
StephaneLenclud@8
   485
		pScrollBar && pScrollBar->GetSafeHwnd() == pSliderCtrl->GetSafeHwnd() )
StephaneLenclud@8
   486
	{
StephaneLenclud@8
   487
		IMON_Display_SetLcdProgress(pSliderCtrl->GetPos(), 100);
StephaneLenclud@8
   488
	}
StephaneLenclud@8
   489
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
StephaneLenclud@8
   490
}
StephaneLenclud@8
   491
StephaneLenclud@8
   492
LRESULT CDisplayTestDlg::OnDisplayPluginNotify(WPARAM wParam, LPARAM lParam)
StephaneLenclud@8
   493
{
StephaneLenclud@8
   494
	if(!GetSafeHwnd() || !IsWindow(GetSafeHwnd()))		return 0;
StephaneLenclud@8
   495
StephaneLenclud@8
   496
	switch(wParam)
StephaneLenclud@8
   497
	{
StephaneLenclud@8
   498
	case DSPNM_PLUGIN_SUCCEED:
StephaneLenclud@8
   499
	case DSPNM_IMON_RESTARTED:
StephaneLenclud@8
   500
	case DSPNM_HW_CONNECTED:
StephaneLenclud@8
   501
		{
StephaneLenclud@8
   502
			GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
StephaneLenclud@8
   503
			m_bVfdConnected = FALSE;
StephaneLenclud@8
   504
			m_bLcdConnected = FALSE;
StephaneLenclud@8
   505
			if((lParam & DSPN_DSP_VFD) == DSPN_DSP_VFD)		m_bVfdConnected = TRUE;
StephaneLenclud@8
   506
			if((lParam & DSPN_DSP_LCD) == DSPN_DSP_LCD)		m_bLcdConnected = TRUE;
StephaneLenclud@8
   507
			UpdateControlUI();
StephaneLenclud@8
   508
StephaneLenclud@8
   509
			DisplayPluginMessage(wParam, FALSE);
StephaneLenclud@8
   510
		}
StephaneLenclud@8
   511
		break;
StephaneLenclud@8
   512
StephaneLenclud@8
   513
	case DSPNM_PLUGIN_FAILED:
StephaneLenclud@8
   514
	case DSPNM_HW_DISCONNECTED:
StephaneLenclud@8
   515
	case DSPNM_IMON_CLOSED:
StephaneLenclud@8
   516
		{
StephaneLenclud@8
   517
			GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
StephaneLenclud@8
   518
			m_bVfdConnected = FALSE;
StephaneLenclud@8
   519
			m_bLcdConnected = FALSE;
StephaneLenclud@8
   520
			UpdateControlUI();
StephaneLenclud@8
   521
StephaneLenclud@8
   522
			DisplayPluginMessage(lParam, TRUE);
StephaneLenclud@8
   523
		}
StephaneLenclud@8
   524
		break;
StephaneLenclud@8
   525
StephaneLenclud@8
   526
	case DSPNM_LCD_TEXT_SCROLL_DONE:
StephaneLenclud@8
   527
		{
StephaneLenclud@8
   528
			TRACE(_T("LCD Text Scroll Finished.\n"));
StephaneLenclud@8
   529
		}
StephaneLenclud@8
   530
		break;
StephaneLenclud@8
   531
	}
StephaneLenclud@8
   532
	return 0;
StephaneLenclud@8
   533
}
StephaneLenclud@8
   534
StephaneLenclud@8
   535
void CDisplayTestDlg::Init()
StephaneLenclud@8
   536
{
StephaneLenclud@8
   537
	Uninit();
StephaneLenclud@8
   538
StephaneLenclud@8
   539
	IMON_Display_Init(this->GetSafeHwnd(), WM_DSP_PLUGIN_NOTIFY);
StephaneLenclud@8
   540
	GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
StephaneLenclud@8
   541
}
StephaneLenclud@8
   542
StephaneLenclud@8
   543
void CDisplayTestDlg::Uninit()
StephaneLenclud@8
   544
{
StephaneLenclud@8
   545
	IMON_Display_Uninit();
StephaneLenclud@8
   546
StephaneLenclud@8
   547
	m_bVfdConnected = FALSE;
StephaneLenclud@8
   548
	m_bLcdConnected = FALSE;
StephaneLenclud@8
   549
StephaneLenclud@8
   550
	for(int i=IDC_ORANGE1;i<=IDC_AR_SCR2;i++)
StephaneLenclud@8
   551
	{
StephaneLenclud@8
   552
		if(GetDlgItem(i))
StephaneLenclud@8
   553
			((CButton*)GetDlgItem(i))->SetCheck(FALSE);
StephaneLenclud@8
   554
	}
StephaneLenclud@8
   555
	CSliderCtrl* pSliderCtrl = (CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
StephaneLenclud@8
   556
	if(pSliderCtrl)	pSliderCtrl->SetPos(0);
StephaneLenclud@8
   557
StephaneLenclud@8
   558
	UpdateControlUI();
StephaneLenclud@8
   559
}
StephaneLenclud@8
   560
StephaneLenclud@8
   561
void CDisplayTestDlg::DisplayPluginMessage(UINT uErrCode, BOOL bError)
StephaneLenclud@8
   562
{
StephaneLenclud@8
   563
	CString strErrMsg = _T("");
StephaneLenclud@8
   564
StephaneLenclud@8
   565
	if(bError)
StephaneLenclud@8
   566
	{
StephaneLenclud@8
   567
		switch(uErrCode)
StephaneLenclud@8
   568
		{
StephaneLenclud@8
   569
		case DSPN_ERR_IN_USED:			strErrMsg = _T("Display Plug-in is Already Used by Other Application.");		break;
StephaneLenclud@8
   570
		case DSPN_ERR_HW_DISCONNECTED:	strErrMsg = _T("iMON HW is Not Connected.");									break;
StephaneLenclud@8
   571
		case DSPN_ERR_NOT_SUPPORTED_HW:	strErrMsg = _T("The Connected iMON HW doesn't Support Display Plug-in.");		break;
StephaneLenclud@8
   572
		case DSPN_ERR_PLUGIN_DISABLED:	strErrMsg = _T("Display Plug-in Mode Option is Disabled.");						break;
StephaneLenclud@8
   573
		case DSPN_ERR_IMON_NO_REPLY:	strErrMsg = _T("The Latest iMON is Not Installed or iMON Not Running.");		break;
StephaneLenclud@8
   574
		case DSPN_ERR_UNKNOWN:			strErrMsg = _T("Unknown Failure.");												break;
StephaneLenclud@8
   575
		}
StephaneLenclud@8
   576
	}
StephaneLenclud@8
   577
	else
StephaneLenclud@8
   578
	{
StephaneLenclud@8
   579
		switch(uErrCode)
StephaneLenclud@8
   580
		{
StephaneLenclud@8
   581
		case DSPNM_PLUGIN_SUCCEED:		strErrMsg = _T("Plug-in Mode Inited Successfully.");		break;
StephaneLenclud@8
   582
		case DSPNM_IMON_RESTARTED:		strErrMsg = _T("iMON Started and Plug-in Mode Inited.");		break;
StephaneLenclud@8
   583
		case DSPNM_HW_CONNECTED:		strErrMsg = _T("iMON HW Connected and Plug-in Mode Inited.");	break;
StephaneLenclud@8
   584
		}
StephaneLenclud@8
   585
	}
StephaneLenclud@8
   586
	GetDlgItem(IDC_STATIC_INFO)->SetWindowText((LPCTSTR)strErrMsg);
StephaneLenclud@8
   587
}
StephaneLenclud@8
   588
StephaneLenclud@8
   589
void CDisplayTestDlg::UpdateControlUI()
StephaneLenclud@8
   590
{
StephaneLenclud@8
   591
	GetDlgItem(IDC_STATIC_INFO)->SetWindowText(_T(""));
StephaneLenclud@8
   592
	
StephaneLenclud@8
   593
	if(IMON_Display_IsInited() != DSP_S_INITED)		GetDlgItem(IDC_BUTTON1)->SetWindowText(_T("Init Plug-in"));
StephaneLenclud@8
   594
	else											GetDlgItem(IDC_BUTTON1)->SetWindowText(_T("Uninit Plug-in"));
StephaneLenclud@8
   595
StephaneLenclud@8
   596
	for(int i=IDC_EDIT1;i<=IDC_BUTTON3;i++)
StephaneLenclud@8
   597
	{
StephaneLenclud@8
   598
		if(GetDlgItem(i))
StephaneLenclud@8
   599
			GetDlgItem(i)->EnableWindow(m_bVfdConnected);
StephaneLenclud@8
   600
	}
StephaneLenclud@8
   601
	for(int i=IDC_BUTTON6;i<=IDC_BUTTON8;i++)
StephaneLenclud@8
   602
	{
StephaneLenclud@8
   603
		if(GetDlgItem(i))
StephaneLenclud@8
   604
			GetDlgItem(i)->EnableWindow(m_bVfdConnected);
StephaneLenclud@8
   605
	}
StephaneLenclud@8
   606
	for(int i=IDC_EDIT3;i<=IDC_SLIDER1;i++)
StephaneLenclud@8
   607
	{
StephaneLenclud@8
   608
		if(GetDlgItem(i))
StephaneLenclud@8
   609
			GetDlgItem(i)->EnableWindow(m_bLcdConnected);
StephaneLenclud@8
   610
	}
StephaneLenclud@8
   611
}
StephaneLenclud@8
   612
StephaneLenclud@8
   613
StephaneLenclud@8
   614