SoundGraphAccess.cpp
author lenclud@WUE-9BW295J.ad.garmin.com
Fri, 08 Feb 2013 17:43:02 +0100
changeset 3 e4cac218e73f
parent 2 ebd2fb40b033
child 4 0b9403db32ef
permissions -rw-r--r--
Sorting out both server side and client side. Now supporting more display APIs.
sl@0
     1
// SoundGraphAccess.cpp : Defines the entry point for the application.
sl@0
     2
//
sl@0
     3
sl@0
     4
#include "stdafx.h"
sl@0
     5
#include "SoundGraphAccess.h"
sl@0
     6
#include "iMONDisplayAPI.h"
lenclud@3
     7
#include <stdio.h>
sl@0
     8
lenclud@3
     9
#define WM_DSP_PLUGIN_NOTIFY			WM_APP + 1100
lenclud@3
    10
#define WM_IMON_INIT					WM_APP + 1101
lenclud@3
    11
#define WM_IMON_UNINIT					WM_APP + 1102
lenclud@3
    12
#define WM_IMON_IS_INIT					WM_APP + 1103
lenclud@3
    13
#define WM_IMON_IS_PLUGIN_MODE_ENABLED	WM_APP + 1104
lenclud@3
    14
lenclud@3
    15
//
sl@0
    16
#define MAX_LOADSTRING 100
sl@0
    17
sl@0
    18
sl@0
    19
// Global Variables:
sl@0
    20
HINSTANCE hInst = 0;								// current instance
sl@0
    21
TCHAR szTitle[MAX_LOADSTRING];					// The title bar text
sl@0
    22
TCHAR szWindowClass[MAX_LOADSTRING];			// the main window class name
lenclud@3
    23
HANDLE gThreadReceiver = INVALID_HANDLE_VALUE;
lenclud@3
    24
//HANDLE gThreadSender = INVALID_HANDLE_VALUE;
sl@0
    25
BOOL gQuit=FALSE;
sl@0
    26
sl@0
    27
LPTSTR gPipeNameSender = TEXT("\\\\.\\pipe\\sga-sender"); 
sl@0
    28
LPTSTR gPipeNameReceiver = TEXT("\\\\.\\pipe\\sga-receiver"); 
lenclud@3
    29
HANDLE gPipeSender=INVALID_HANDLE_VALUE;
lenclud@3
    30
HANDLE gPipeReceiver=INVALID_HANDLE_VALUE;
sl@0
    31
sl@0
    32
char gBufferReceiver[256];
sl@0
    33
char gBufferSender[256];
sl@0
    34
lenclud@2
    35
//
lenclud@2
    36
HWND gWnd;
sl@0
    37
sl@0
    38
//
sl@0
    39
BOOL m_bVfdConnected;
sl@0
    40
BOOL m_bLcdConnected;
sl@0
    41
sl@0
    42
// Forward declarations of functions included in this code module:
sl@0
    43
ATOM				MyRegisterClass(HINSTANCE hInstance);
sl@0
    44
BOOL				InitInstance(HINSTANCE, int);
sl@0
    45
LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
sl@0
    46
INT_PTR CALLBACK	About(HWND, UINT, WPARAM, LPARAM);
sl@0
    47
lenclud@3
    48
//Supported responses
lenclud@3
    49
const char KRspDone[]="done:";
lenclud@3
    50
const char KRspPending[]="pending:";
lenclud@3
    51
const char KRspError[]="error:";
lenclud@3
    52
const char KRspClose[]="close:";
lenclud@3
    53
const char KRspOpen[]="open:";
lenclud@3
    54
const char KRspUnknown[]="unknown:";
lenclud@3
    55
const char KRspTrue[]="true:";
lenclud@3
    56
const char KRspFalse[]="false:";
lenclud@3
    57
//Supported incoming messages
lenclud@3
    58
const char KMsgInit[]="init:";
lenclud@3
    59
const char KMsgUninit[]="uninit:";
lenclud@3
    60
const char KMsgIsInit[]="is-init:";
lenclud@3
    61
const char KMsgIsPluginModeEnabled[]="is-plugin-mode-enabled:";
lenclud@2
    62
lenclud@2
    63
/**
lenclud@2
    64
Send a message to our server.
lenclud@2
    65
*/
lenclud@2
    66
void SendMessageToServer(const char* aResponse)
lenclud@2
    67
	{
lenclud@2
    68
	DWORD cbWritten=0;
lenclud@3
    69
	char msg[512];
lenclud@3
    70
	sprintf(msg,"%s\n",aResponse);
lenclud@3
    71
	OutputDebugStringA(msg);
lenclud@2
    72
	WriteFile(gPipeSender, aResponse, strlen(aResponse), &cbWritten, NULL);		
lenclud@2
    73
	}
lenclud@2
    74
lenclud@2
    75
lenclud@2
    76
/**
lenclud@2
    77
Handle messages from our server.
lenclud@2
    78
*/
lenclud@2
    79
void MessageReceived(const char* aMsg)
lenclud@2
    80
	{
lenclud@2
    81
	//
lenclud@3
    82
	if (strcmp(aMsg,KMsgInit)==0)
lenclud@2
    83
		{
lenclud@2
    84
		//IMON API call need to be done from window thread for some reason
lenclud@3
    85
		SendMessageToServer(KRspPending);
lenclud@3
    86
		PostMessage(gWnd,WM_IMON_INIT,0,0);
lenclud@3
    87
		}
lenclud@3
    88
	else if (strcmp(aMsg,KMsgUninit)==0)
lenclud@3
    89
		{
lenclud@3
    90
		//IMON API call need to be done from window thread for some reason
lenclud@3
    91
		SendMessageToServer(KRspPending);
lenclud@3
    92
		PostMessage(gWnd,WM_IMON_UNINIT,0,0);		
lenclud@3
    93
		}
lenclud@3
    94
	else if (strcmp(aMsg,KMsgIsPluginModeEnabled)==0)
lenclud@3
    95
		{
lenclud@3
    96
		//IMON API call need to be done from window thread for some reason
lenclud@3
    97
		SendMessageToServer(KRspPending);
lenclud@3
    98
		PostMessage(gWnd,WM_IMON_IS_PLUGIN_MODE_ENABLED,0,0);		
lenclud@3
    99
		}
lenclud@3
   100
	else if (strcmp(aMsg,KMsgIsInit)==0)
lenclud@3
   101
		{
lenclud@3
   102
		//IMON API call need to be done from window thread for some reason
lenclud@3
   103
		SendMessageToServer(KRspPending);
lenclud@3
   104
		PostMessage(gWnd,WM_IMON_IS_INIT,0,0);		
lenclud@3
   105
		}
lenclud@3
   106
	else
lenclud@3
   107
		{		
lenclud@3
   108
		SendMessageToServer(KRspUnknown);
lenclud@3
   109
		}
lenclud@3
   110
	}
lenclud@3
   111
lenclud@3
   112
lenclud@3
   113
lenclud@3
   114
/**
lenclud@3
   115
Connect our named pipes from here.
lenclud@3
   116
First connect our read pipe then our write pipe.
lenclud@3
   117
Then notify our server we are connected.
lenclud@3
   118
Then keep on waiting for incoming messages.
lenclud@3
   119
*/
lenclud@3
   120
DWORD WINAPI ThreadReceiver( LPVOID lpParam )
lenclud@3
   121
	{
lenclud@3
   122
	//Keep on trying to connect on our read pipe
lenclud@3
   123
	while (gPipeReceiver==INVALID_HANDLE_VALUE && !gQuit)
lenclud@3
   124
		{
lenclud@3
   125
		OutputDebugStringA("Trying to connect...\n");
lenclud@3
   126
		gPipeReceiver=CreateFile(gPipeNameReceiver,	GENERIC_READ ,0,NULL,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL);
lenclud@3
   127
		Sleep(1000);
lenclud@3
   128
		}
lenclud@3
   129
	
lenclud@3
   130
	OutputDebugStringA("Read pipe open!\n");
lenclud@3
   131
	//Now try connecting on our write pipe
lenclud@3
   132
	gPipeSender=CreateFile(gPipeNameSender,	GENERIC_WRITE ,0,NULL,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL);
lenclud@3
   133
	if (gPipeSender==INVALID_HANDLE_VALUE)
lenclud@3
   134
		{
lenclud@3
   135
		OutputDebugStringA("ERROR: Write pipe failure!\n");
lenclud@3
   136
		gQuit=TRUE;
lenclud@2
   137
		}
lenclud@2
   138
	else
lenclud@2
   139
		{
lenclud@3
   140
		OutputDebugStringA("Write pipe opened.\n");
lenclud@3
   141
		OutputDebugStringA("Connected.\n");
lenclud@3
   142
		SendMessageToServer(KRspOpen);
lenclud@2
   143
		}
lenclud@3
   144
	//
sl@0
   145
sl@0
   146
	while(!gQuit)
sl@0
   147
		{
sl@0
   148
		DWORD cbRead;
sl@0
   149
		BOOL success=ReadFile(gPipeReceiver,gBufferReceiver,sizeof(gBufferReceiver),&cbRead, NULL); 
sl@0
   150
		if(success)
lenclud@3
   151
			{
sl@0
   152
			gBufferReceiver[cbRead]='\0';
sl@0
   153
			OutputDebugStringA(gBufferReceiver);
lenclud@2
   154
			MessageReceived(gBufferReceiver);
sl@0
   155
			}
lenclud@3
   156
		//if (!success && GetLastError() != ERROR_MORE_DATA) 
lenclud@3
   157
		//	{
lenclud@3
   158
		//	OutputDebugStringA("Can't Read\n");
lenclud@3
   159
		//	}
lenclud@3
   160
		//
lenclud@3
   161
		//Sleep(500);
lenclud@3
   162
lenclud@3
   163
		if (!success)
sl@0
   164
			{
lenclud@3
   165
			gQuit=TRUE;
sl@0
   166
			}
sl@0
   167
		}
sl@0
   168
lenclud@3
   169
	//Try tell our server
lenclud@3
   170
	SendMessageToServer(KRspClose);
lenclud@3
   171
	//Close our pipes
lenclud@3
   172
	CloseHandle(gPipeReceiver);	
lenclud@3
   173
	gPipeReceiver=INVALID_HANDLE_VALUE;
lenclud@3
   174
	CloseHandle(gPipeSender);	
lenclud@3
   175
	gPipeSender=INVALID_HANDLE_VALUE;
lenclud@3
   176
	//Quit our application
lenclud@3
   177
	PostMessage(gWnd,WM_CLOSE,0,0);
lenclud@3
   178
		
sl@0
   179
	return 0;
sl@0
   180
	}
sl@0
   181
sl@0
   182
sl@0
   183
sl@0
   184
/**
sl@0
   185
*/
sl@0
   186
int APIENTRY _tWinMain(HINSTANCE hInstance,
sl@0
   187
                     HINSTANCE hPrevInstance,
sl@0
   188
                     LPTSTR    lpCmdLine,
sl@0
   189
                     int       nCmdShow)
sl@0
   190
{
sl@0
   191
	UNREFERENCED_PARAMETER(hPrevInstance);
sl@0
   192
	UNREFERENCED_PARAMETER(lpCmdLine);
sl@0
   193
sl@0
   194
	// TODO: Place code here.
sl@0
   195
	MSG msg;
sl@0
   196
	HACCEL hAccelTable;
sl@0
   197
sl@0
   198
	// Initialize global strings
sl@0
   199
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
sl@0
   200
	LoadString(hInstance, IDC_SOUNDGRAPHACCESS, szWindowClass, MAX_LOADSTRING);
sl@0
   201
	MyRegisterClass(hInstance);
sl@0
   202
sl@0
   203
	// Perform application initialization:
sl@0
   204
	if (!InitInstance (hInstance, /*SW_HIDE*/ nCmdShow))
sl@0
   205
		{
sl@0
   206
		return FALSE;
sl@0
   207
		}
sl@0
   208
sl@0
   209
sl@0
   210
sl@0
   211
	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SOUNDGRAPHACCESS));
sl@0
   212
sl@0
   213
	// Main message loop:
sl@0
   214
	while (GetMessage(&msg, NULL, 0, 0))
sl@0
   215
		{
sl@0
   216
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
sl@0
   217
			{
sl@0
   218
			TranslateMessage(&msg);
sl@0
   219
			DispatchMessage(&msg);
sl@0
   220
			}
sl@0
   221
		}
sl@0
   222
sl@0
   223
	return (int) msg.wParam;
sl@0
   224
	}
sl@0
   225
lenclud@2
   226
/**
lenclud@2
   227
*/
sl@0
   228
void DisplayPluginMessage(UINT uErrCode, BOOL bError)
sl@0
   229
	{
lenclud@2
   230
	char* strErrMsg = "";
sl@0
   231
sl@0
   232
	if(bError)
sl@0
   233
		{
sl@0
   234
		switch(uErrCode)
sl@0
   235
			{
lenclud@2
   236
			case DSPN_ERR_IN_USED:			strErrMsg = ("Display Plug-in is Already Used by Other Application.");		break;
lenclud@2
   237
			case DSPN_ERR_HW_DISCONNECTED:	strErrMsg = ("iMON HW is Not Connected.");									break;
lenclud@2
   238
			case DSPN_ERR_NOT_SUPPORTED_HW:	strErrMsg = ("The Connected iMON HW doesn't Support Display Plug-in.");		break;
lenclud@3
   239
			case DSPN_ERR_PLUGIN_DISABLED:	strErrMsg = ("Display Plug-in Mode Option is Disabled.");					break;
lenclud@2
   240
			case DSPN_ERR_IMON_NO_REPLY:	strErrMsg = ("The Latest iMON is Not Installed or iMON Not Running.");		break;
lenclud@3
   241
			case DSPN_ERR_UNKNOWN:			strErrMsg = ("Unknown Failure.");											break;
sl@0
   242
			}
sl@0
   243
		}
sl@0
   244
	else
sl@0
   245
		{
sl@0
   246
		switch(uErrCode)
sl@0
   247
			{
lenclud@3
   248
			case DSPNM_PLUGIN_SUCCEED:		strErrMsg = ("Plug-in Mode Inited Successfully.");			break;
lenclud@2
   249
			case DSPNM_IMON_RESTARTED:		strErrMsg = ("iMON Started and Plug-in Mode Inited.");		break;
lenclud@2
   250
			case DSPNM_HW_CONNECTED:		strErrMsg = ("iMON HW Connected and Plug-in Mode Inited.");	break;
sl@0
   251
			}
sl@0
   252
		}
sl@0
   253
	//
lenclud@2
   254
	OutputDebugStringA(strErrMsg);
lenclud@3
   255
lenclud@3
   256
	char msg[256];
lenclud@3
   257
	if (bError)
lenclud@3
   258
		{
lenclud@3
   259
		sprintf(msg,"error:%s",strErrMsg);
lenclud@3
   260
		}
lenclud@3
   261
	else
lenclud@3
   262
		{
lenclud@3
   263
		sprintf(msg,"done:%s",strErrMsg);	
lenclud@3
   264
		}	
lenclud@3
   265
	SendMessageToServer(msg);
sl@0
   266
	}
sl@0
   267
sl@0
   268
sl@0
   269
sl@0
   270
//
sl@0
   271
//  FUNCTION: MyRegisterClass()
sl@0
   272
//
sl@0
   273
//  PURPOSE: Registers the window class.
sl@0
   274
//
sl@0
   275
//  COMMENTS:
sl@0
   276
//
sl@0
   277
//    This function and its usage are only necessary if you want this code
sl@0
   278
//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
sl@0
   279
//    function that was added to Windows 95. It is important to call this function
sl@0
   280
//    so that the application will get 'well formed' small icons associated
sl@0
   281
//    with it.
sl@0
   282
//
sl@0
   283
ATOM MyRegisterClass(HINSTANCE hInstance)
sl@0
   284
{
sl@0
   285
	WNDCLASSEX wcex;
sl@0
   286
sl@0
   287
	wcex.cbSize = sizeof(WNDCLASSEX);
sl@0
   288
sl@0
   289
	wcex.style			= CS_HREDRAW | CS_VREDRAW;
sl@0
   290
	wcex.lpfnWndProc	= WndProc;
sl@0
   291
	wcex.cbClsExtra		= 0;
sl@0
   292
	wcex.cbWndExtra		= 0;
sl@0
   293
	wcex.hInstance		= hInstance;
sl@0
   294
	wcex.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SOUNDGRAPHACCESS));
sl@0
   295
	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
sl@0
   296
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
sl@0
   297
	wcex.lpszMenuName	= MAKEINTRESOURCE(IDC_SOUNDGRAPHACCESS);
sl@0
   298
	wcex.lpszClassName	= szWindowClass;
sl@0
   299
	wcex.hIconSm		= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
sl@0
   300
sl@0
   301
	return RegisterClassEx(&wcex);
sl@0
   302
}
sl@0
   303
sl@0
   304
//
sl@0
   305
//   FUNCTION: InitInstance(HINSTANCE, int)
sl@0
   306
//
sl@0
   307
//   PURPOSE: Saves instance handle and creates main window
sl@0
   308
//
sl@0
   309
//   COMMENTS:
sl@0
   310
//
sl@0
   311
//        In this function, we save the instance handle in a global variable and
sl@0
   312
//        create and display the main program window.
sl@0
   313
//
sl@0
   314
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
sl@0
   315
{
lenclud@2
   316
   
sl@0
   317
sl@0
   318
   hInst = hInstance; // Store instance handle in our global variable
sl@0
   319
lenclud@2
   320
   gWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
sl@0
   321
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
sl@0
   322
lenclud@2
   323
   if (!gWnd)
sl@0
   324
   {
sl@0
   325
      return FALSE;
sl@0
   326
   }
sl@0
   327
lenclud@2
   328
   ShowWindow(gWnd, nCmdShow);
lenclud@2
   329
   UpdateWindow(gWnd);
sl@0
   330
sl@0
   331
   return TRUE;
sl@0
   332
}
sl@0
   333
sl@0
   334
//
sl@0
   335
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
sl@0
   336
//
sl@0
   337
//  PURPOSE:  Processes messages for the main window.
sl@0
   338
//
sl@0
   339
//  WM_COMMAND	- process the application menu
sl@0
   340
//  WM_PAINT	- Paint the main window
sl@0
   341
//  WM_DESTROY	- post a quit message and return
sl@0
   342
//
sl@0
   343
//
sl@0
   344
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
sl@0
   345
{
sl@0
   346
	int wmId, wmEvent;
sl@0
   347
	PAINTSTRUCT ps;
sl@0
   348
	HDC hdc;
sl@0
   349
sl@0
   350
	switch (message)
sl@0
   351
	{
sl@0
   352
	case WM_CREATE:
sl@0
   353
		//IMON_Display_Uninit();
sl@0
   354
		//IMON_Display_Init(hWnd, WM_DSP_PLUGIN_NOTIFY);
sl@0
   355
		gThreadReceiver = CreateThread( NULL, 0, ThreadReceiver, NULL/*data pointer*/, 0, NULL);
sl@0
   356
		break;
sl@0
   357
	case WM_COMMAND:
sl@0
   358
		wmId    = LOWORD(wParam);
sl@0
   359
		wmEvent = HIWORD(wParam);
sl@0
   360
		// Parse the menu selections:
sl@0
   361
		switch (wmId)
sl@0
   362
		{
sl@0
   363
		case IDM_ABOUT:
sl@0
   364
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
sl@0
   365
			break;
sl@0
   366
		case IDM_EXIT:
sl@0
   367
			DestroyWindow(hWnd);
sl@0
   368
			break;
sl@0
   369
		default:
sl@0
   370
			return DefWindowProc(hWnd, message, wParam, lParam);
sl@0
   371
		}
sl@0
   372
		break;
sl@0
   373
	case WM_PAINT:
sl@0
   374
		hdc = BeginPaint(hWnd, &ps);
sl@0
   375
		// TODO: Add any drawing code here...
sl@0
   376
		EndPaint(hWnd, &ps);
sl@0
   377
		break;
sl@0
   378
	case WM_DESTROY:
sl@0
   379
		gQuit=TRUE;
sl@0
   380
		//To complete write op
lenclud@3
   381
		if (gPipeSender!=INVALID_HANDLE_VALUE)
sl@0
   382
			{
sl@0
   383
			CloseHandle(gPipeSender);
lenclud@3
   384
			gPipeSender=INVALID_HANDLE_VALUE;
sl@0
   385
			}
sl@0
   386
		//To complete read op
lenclud@3
   387
		if (gPipeReceiver!=INVALID_HANDLE_VALUE)
sl@0
   388
			{
sl@0
   389
			CloseHandle(gPipeReceiver);
lenclud@3
   390
			gPipeReceiver=INVALID_HANDLE_VALUE;
sl@0
   391
			}
lenclud@3
   392
sl@0
   393
		WaitForSingleObject(gThreadReceiver,INFINITE);
sl@0
   394
		CloseHandle(gThreadReceiver);
sl@0
   395
		//IMON_Display_Uninit();
sl@0
   396
		PostQuitMessage(0);
sl@0
   397
		break;
lenclud@2
   398
lenclud@2
   399
	case WM_IMON_UNINIT:
lenclud@2
   400
		IMON_Display_Uninit();
lenclud@3
   401
		SendMessageToServer(KRspDone);
lenclud@2
   402
		break;
lenclud@2
   403
lenclud@2
   404
	case WM_IMON_INIT:
lenclud@2
   405
		IMON_Display_Uninit();
lenclud@2
   406
		IMON_Display_Init(hWnd, WM_DSP_PLUGIN_NOTIFY);
lenclud@2
   407
		break;
lenclud@3
   408
	//
lenclud@3
   409
	case WM_IMON_IS_PLUGIN_MODE_ENABLED:
lenclud@3
   410
		if (IMON_Display_IsPluginModeEnabled()==DSP_S_IN_PLUGIN_MODE)
lenclud@3
   411
			{
lenclud@3
   412
			SendMessageToServer(KRspTrue);
lenclud@3
   413
			}
lenclud@3
   414
		else
lenclud@3
   415
			{
lenclud@3
   416
			SendMessageToServer(KRspFalse);
lenclud@3
   417
			}
lenclud@3
   418
		break;
lenclud@3
   419
	//
lenclud@3
   420
	case WM_IMON_IS_INIT:
lenclud@3
   421
		if (IMON_Display_IsInited()==DSP_S_INITED)
lenclud@3
   422
			{
lenclud@3
   423
			SendMessageToServer(KRspTrue);
lenclud@3
   424
			}
lenclud@3
   425
		else
lenclud@3
   426
			{
lenclud@3
   427
			SendMessageToServer(KRspFalse);
lenclud@3
   428
			}
lenclud@3
   429
		break;
lenclud@3
   430
lenclud@2
   431
sl@0
   432
	case WM_DSP_PLUGIN_NOTIFY:
sl@0
   433
		switch(wParam)
sl@0
   434
			{
sl@0
   435
			case DSPNM_PLUGIN_SUCCEED:
sl@0
   436
			case DSPNM_IMON_RESTARTED:
sl@0
   437
			case DSPNM_HW_CONNECTED:
sl@0
   438
				{
sl@0
   439
				//GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
sl@0
   440
				m_bVfdConnected = FALSE;
sl@0
   441
				m_bLcdConnected = FALSE;
sl@0
   442
				if((lParam & DSPN_DSP_VFD) == DSPN_DSP_VFD)		m_bVfdConnected = TRUE;
sl@0
   443
				if((lParam & DSPN_DSP_LCD) == DSPN_DSP_LCD)		m_bLcdConnected = TRUE;
sl@0
   444
				//UpdateControlUI();
sl@0
   445
sl@0
   446
				DisplayPluginMessage(wParam, FALSE);
sl@0
   447
				}
sl@0
   448
				break;
sl@0
   449
sl@0
   450
			case DSPNM_PLUGIN_FAILED:
sl@0
   451
			case DSPNM_HW_DISCONNECTED:
sl@0
   452
			case DSPNM_IMON_CLOSED:
sl@0
   453
				{
sl@0
   454
				//GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
sl@0
   455
				m_bVfdConnected = FALSE;
sl@0
   456
				m_bLcdConnected = FALSE;
sl@0
   457
				//UpdateControlUI();
sl@0
   458
sl@0
   459
				DisplayPluginMessage(lParam, TRUE);
sl@0
   460
				}
sl@0
   461
				break;
sl@0
   462
sl@0
   463
			case DSPNM_LCD_TEXT_SCROLL_DONE:
sl@0
   464
				{
sl@0
   465
				//TRACE(_T("LCD Text Scroll Finished.\n"));
sl@0
   466
				}
sl@0
   467
				break;
sl@0
   468
			}
sl@0
   469
		return 0;
sl@0
   470
		break;
sl@0
   471
	default:
sl@0
   472
		return DefWindowProc(hWnd, message, wParam, lParam);
sl@0
   473
	}
sl@0
   474
	return 0;
sl@0
   475
}
sl@0
   476
sl@0
   477
// Message handler for about box.
sl@0
   478
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
sl@0
   479
{
sl@0
   480
	UNREFERENCED_PARAMETER(lParam);
sl@0
   481
	switch (message)
sl@0
   482
	{
sl@0
   483
	case WM_INITDIALOG:
sl@0
   484
		return (INT_PTR)TRUE;
sl@0
   485
sl@0
   486
	case WM_COMMAND:
sl@0
   487
		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
sl@0
   488
		{
sl@0
   489
			EndDialog(hDlg, LOWORD(wParam));
sl@0
   490
			return (INT_PTR)TRUE;
sl@0
   491
		}
sl@0
   492
		break;
sl@0
   493
	}
sl@0
   494
	return (INT_PTR)FALSE;
sl@0
   495
}
sl@0
   496