SoundGraphAccess.cpp
author StephaneLenclud
Sun, 14 Apr 2013 22:53:58 +0200
changeset 10 dfb9169831dc
parent 7 ad71cf47d037
child 11 1bf32325a98b
permissions -rw-r--r--
Removing SUOs.
     1 // SoundGraphAccess.cpp : Defines the entry point for the application.
     2 //
     3 
     4 #include "stdafx.h"
     5 #include "SoundGraphAccess.h"
     6 #include "iMONDisplayAPI.h"
     7 #include <stdio.h>
     8 
     9 #define WM_DSP_PLUGIN_NOTIFY			WM_APP + 1100
    10 #define WM_IMON_INIT					WM_APP + 1101
    11 #define WM_IMON_UNINIT					WM_APP + 1102
    12 #define WM_IMON_IS_INIT					WM_APP + 1103
    13 #define WM_IMON_IS_PLUGIN_MODE_ENABLED	WM_APP + 1104
    14 #define WM_IMON_DISPLAY_SET_VFD_TEXT	WM_APP + 1105
    15 
    16 //
    17 #define MAX_LOADSTRING 100
    18 
    19 const int BUFFER_SIZE = 256;
    20 
    21 // Global Variables:
    22 HINSTANCE hInst = 0;								// current instance
    23 TCHAR szTitle[MAX_LOADSTRING];					// The title bar text
    24 TCHAR szWindowClass[MAX_LOADSTRING];			// the main window class name
    25 HANDLE gThreadReceiver = INVALID_HANDLE_VALUE;
    26 //HANDLE gThreadSender = INVALID_HANDLE_VALUE;
    27 BOOL gQuit=FALSE;
    28 
    29 LPTSTR gPipeNameInbound = TEXT("\\\\.\\pipe\\sga-inbound"); 
    30 LPTSTR gPipeNameOutbound = TEXT("\\\\.\\pipe\\sga-outbound"); 
    31 HANDLE gPipeInbound=INVALID_HANDLE_VALUE;
    32 HANDLE gPipeOutbound=INVALID_HANDLE_VALUE;
    33 
    34 char gBufferReceiver[256];
    35 char gBufferSender[256];
    36 //
    37 char gTextFirstLine[256];
    38 char gTextSecondLine[256];
    39 wchar_t gTextFirstLine16[256];
    40 wchar_t gTextSecondLine16[256];
    41 
    42 //
    43 HWND gWnd;
    44 
    45 //
    46 BOOL m_bVfdConnected;
    47 BOOL m_bLcdConnected;
    48 BOOL m_IsInit=FALSE;
    49 
    50 // Forward declarations of functions included in this code module:
    51 ATOM				MyRegisterClass(HINSTANCE hInstance);
    52 BOOL				InitInstance(HINSTANCE, int);
    53 LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
    54 INT_PTR CALLBACK	About(HWND, UINT, WPARAM, LPARAM);
    55 
    56 //Supported responses
    57 const char KRspDone[]="done:";
    58 const char KRspPending[]="pending:";
    59 const char KRspError[]="error:";
    60 const char KRspClose[]="close:";
    61 const char KRspOpen[]="open:";
    62 const char KRspUnknown[]="unknown:";
    63 const char KRspTrue[]="true:";
    64 const char KRspFalse[]="false:";
    65 //Supported incoming messages
    66 const char KMsgInit[]="init:";
    67 const char KMsgUninit[]="uninit:";
    68 const char KMsgIsInit[]="is-init:";
    69 const char KMsgIsPluginModeEnabled[]="is-plugin-mode-enabled:";
    70 const char KMsgSetVfdText[]="set-vfd-text:";
    71 const char KMsgQuit[]="quit:";
    72 
    73 /**
    74 Create inbound pipe to receive messages.
    75 */
    76 bool CreateInboundPipe()
    77 	{
    78 	gPipeInbound = CreateNamedPipe(gPipeNameInbound, PIPE_ACCESS_INBOUND, PIPE_TYPE_BYTE, PIPE_UNLIMITED_INSTANCES, BUFFER_SIZE, BUFFER_SIZE, 0, NULL);
    79 
    80 	//could not create named pipe
    81     if (gPipeInbound==INVALID_HANDLE_VALUE)
    82         return false;
    83 
    84     //Will complete once a client connects
    85     int success = ConnectNamedPipe(gPipeInbound, NULL);
    86 
    87     //could not connect client
    88     if (success == 0)
    89         return false;
    90 
    91 	return true;
    92 	}
    93 
    94 
    95 /**
    96 Create outbound pipe to send message
    97 */
    98 bool CreateOutboundPipe()
    99 	{
   100 	gPipeOutbound = CreateNamedPipe(gPipeNameOutbound, PIPE_ACCESS_OUTBOUND /*| FILE_FLAG_OVERLAPPED*/, PIPE_TYPE_BYTE, PIPE_UNLIMITED_INSTANCES, BUFFER_SIZE, BUFFER_SIZE, 0, NULL);
   101 
   102 	//could not create named pipe
   103     if (gPipeOutbound==INVALID_HANDLE_VALUE)
   104         return false;
   105 
   106     //Will complete once a client connects
   107     int success = ConnectNamedPipe(gPipeOutbound, NULL);
   108 
   109     //could not connect client
   110     if (success == 0)
   111         return false;
   112 
   113 	return true;
   114 	}
   115 
   116 /**
   117 Send a message to our server.
   118 */
   119 void SendMessageToServer(const char* aResponse)
   120 	{
   121 	DWORD cbWritten=0;
   122 	char msg[512];
   123 	sprintf(msg,"%s\n",aResponse);
   124 	OutputDebugStringA(msg);
   125 	WriteFile(gPipeOutbound, aResponse, strlen(aResponse), &cbWritten, NULL);
   126 	if (strlen(aResponse)!=cbWritten)
   127 		{
   128 		int err = GetLastError();
   129 		OutputDebugStringA("ERROR: WriteFile failure!\n");
   130 		}
   131 	}
   132 
   133 
   134 
   135 /**
   136 Handle messages from our server.
   137 */
   138 void MessageReceived(const char* aMsg)
   139 	{
   140 	//
   141 	if (strcmp(aMsg,KMsgInit)==0)
   142 		{
   143 		//IMON API call need to be done from window thread for some reason
   144 		SendMessageToServer(KRspPending);
   145 		PostMessage(gWnd,WM_IMON_INIT,0,0);
   146 		}
   147 	else if (strcmp(aMsg,KMsgUninit)==0)
   148 		{
   149 		//IMON API call need to be done from window thread for some reason
   150 		SendMessageToServer(KRspPending);
   151 		PostMessage(gWnd,WM_IMON_UNINIT,0,0);		
   152 		}
   153 	else if (strcmp(aMsg,KMsgIsPluginModeEnabled)==0)
   154 		{
   155 		//IMON API call need to be done from window thread for some reason
   156 		SendMessageToServer(KRspPending);
   157 		PostMessage(gWnd,WM_IMON_IS_PLUGIN_MODE_ENABLED,0,0);		
   158 		}
   159 	else if (strcmp(aMsg,KMsgIsInit)==0)
   160 		{
   161 		//IMON API call need to be done from window thread for some reason
   162 		SendMessageToServer(KRspPending);
   163 		PostMessage(gWnd,WM_IMON_IS_INIT,0,0);
   164 		}
   165 	else if (strcmp(aMsg,KMsgQuit)==0)
   166 		{
   167 		//gQuit=TRUE;
   168 		SendMessageToServer(KRspDone);
   169 		DestroyWindow(gWnd);
   170 		}
   171 	else if (strstr(aMsg,KMsgSetVfdText)==aMsg)
   172 		{
   173 		int textLen=strlen(aMsg)-strlen(KMsgSetVfdText);
   174 		strncpy(gTextFirstLine,aMsg+strlen(KMsgSetVfdText),textLen);
   175 		gTextFirstLine[textLen]='\0';
   176 		//Check if we have a second line
   177 		char* ptr=strchr(gTextFirstLine,'\n');
   178 		if (ptr!=NULL)
   179 			{
   180 			*ptr='\0'; //Terminate our first line here
   181 			ptr++;
   182 			//Get our second line
   183 			textLen=strlen(ptr);
   184 			strncpy(gTextSecondLine,ptr,textLen);
   185 			gTextSecondLine[textLen]='\0';
   186 			}
   187 		else
   188 			{
   189 			//No second line specified
   190 			gTextSecondLine[0]='\0';
   191 			gTextSecondLine16[0]='\0';
   192 			}
   193 
   194 		//Convert first line
   195 		OutputDebugStringA(gTextFirstLine);
   196 		//int convertedChars = MultiByteToWideChar(CP_UTF8, 0, gTextFirstLine, -1, gTextFirstLine16, sizeof(gTextFirstLine16));
   197 		for (int i=0;i<=strlen(gTextFirstLine);i++)
   198 			{
   199 			unsigned char myChar=(unsigned char)gTextFirstLine[i];
   200 			gTextFirstLine16[i]=myChar;
   201 			}
   202 		OutputDebugStringW(gTextFirstLine16);
   203 		//Convert second line
   204 		OutputDebugStringA(gTextSecondLine);
   205 		//convertedChars = MultiByteToWideChar(CP_UTF8, 0, gTextSecondLine, -1, gTextSecondLine16, sizeof(gTextSecondLine16));
   206 		for (int i=0;i<=strlen(gTextSecondLine);i++)
   207 			{
   208 			unsigned char myChar=(unsigned char)gTextSecondLine[i];
   209 			gTextSecondLine16[i]=myChar;
   210 			}
   211 
   212 		OutputDebugStringW(gTextSecondLine16);
   213 
   214 		//IMON API call need to be done from window thread for some reason
   215 		SendMessageToServer(KRspPending);
   216 		if (!m_IsInit)
   217 			{
   218 			PostMessage(gWnd,WM_IMON_INIT,0,0);		
   219 			}
   220 		PostMessage(gWnd,WM_IMON_DISPLAY_SET_VFD_TEXT,0,0);		
   221 		}
   222 	else
   223 		{		
   224 		SendMessageToServer(KRspUnknown);
   225 		}
   226 	}
   227 
   228 
   229 
   230 /**
   231 Connect our named pipes from here.
   232 First connect our read pipe then our write pipe.
   233 Then notify our server we are connected.
   234 Then keep on waiting for incoming messages.
   235 */
   236 DWORD WINAPI ThreadReceiver( LPVOID lpParam )
   237 	{
   238 
   239 	/*
   240 	//Keep on trying to connect on our read pipe
   241 	while (gPipeInbound==INVALID_HANDLE_VALUE && !gQuit)
   242 		{
   243 		OutputDebugStringA("Trying to connect...\n");
   244 		gPipeInbound=CreateFile(gPipeNameInbound,	GENERIC_READ ,0,NULL,OPEN_EXISTING,0,NULL);
   245 		Sleep(1000);
   246 		}
   247 	
   248 	OutputDebugStringA("Read pipe open!\n");
   249 	//Now try connecting on our write pipe
   250 	gPipeOutbound=CreateFile(gPipeNameOutbound,	GENERIC_WRITE ,0,NULL,OPEN_EXISTING,0,NULL);
   251 	if (gPipeOutbound==INVALID_HANDLE_VALUE)
   252 		{
   253 		int err=GetLastError();
   254 		OutputDebugStringA("ERROR: Write pipe failure!\n");
   255 		//gQuit=TRUE;
   256 		}
   257 	else
   258 		{
   259 		OutputDebugStringA("Write pipe opened.\n");
   260 		OutputDebugStringA("Connected.\n");
   261 		SendMessageToServer(KRspOpen);
   262 		}
   263 	//
   264 	*/
   265 
   266 	
   267 	CreateOutboundPipe();
   268 	CreateInboundPipe();
   269 
   270 	while(!gQuit)
   271 		{
   272 		DWORD cbRead;
   273 		BOOL success=ReadFile(gPipeInbound,gBufferReceiver,sizeof(gBufferReceiver),&cbRead, NULL); 
   274 		if(success)
   275 			{
   276 			gBufferReceiver[cbRead]='\0';
   277 			OutputDebugStringA(gBufferReceiver);
   278 			MessageReceived(gBufferReceiver);
   279 			}
   280 		//if (!success && GetLastError() != ERROR_MORE_DATA) 
   281 		//	{
   282 		//	OutputDebugStringA("Can't Read\n");
   283 		//	}
   284 		//
   285 		//Sleep(500);
   286 
   287 		if (!success)
   288 			{
   289 			gQuit=TRUE;
   290 			}
   291 		}
   292 
   293 	//Try tell our server
   294 	SendMessageToServer(KRspClose);
   295 	//Close our pipes
   296 	DisconnectNamedPipe(gPipeInbound);
   297 	CloseHandle(gPipeInbound);
   298 	gPipeInbound=INVALID_HANDLE_VALUE;
   299 	DisconnectNamedPipe(gPipeOutbound);
   300 	CloseHandle(gPipeOutbound);	
   301 	gPipeOutbound=INVALID_HANDLE_VALUE;
   302 	//Quit our application
   303 	PostMessage(gWnd,WM_CLOSE,0,0);
   304 		
   305 	return 0;
   306 	}
   307 
   308 
   309 
   310 /**
   311 */
   312 int APIENTRY _tWinMain(HINSTANCE hInstance,
   313                      HINSTANCE hPrevInstance,
   314                      LPTSTR    lpCmdLine,
   315                      int       nCmdShow)
   316 {
   317 	UNREFERENCED_PARAMETER(hPrevInstance);
   318 	UNREFERENCED_PARAMETER(lpCmdLine);
   319 
   320 	gTextFirstLine[0]='\0';
   321 	gTextSecondLine[0]='\0';
   322 	gTextFirstLine16[0]='\0';
   323 	gTextSecondLine16[0]='\0';
   324 
   325 
   326 	// TODO: Place code here.
   327 	MSG msg;
   328 	HACCEL hAccelTable;
   329 
   330 	// Initialize global strings
   331 	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
   332 	LoadString(hInstance, IDC_SOUNDGRAPHACCESS, szWindowClass, MAX_LOADSTRING);
   333 	MyRegisterClass(hInstance);
   334 
   335 	// Perform application initialization:
   336 	if (!InitInstance (hInstance, /*SW_HIDE*/ nCmdShow))
   337 		{
   338 		return FALSE;
   339 		}
   340 
   341 
   342 
   343 	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SOUNDGRAPHACCESS));
   344 
   345 	// Main message loop:
   346 	while (GetMessage(&msg, NULL, 0, 0))
   347 		{
   348 		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
   349 			{
   350 			TranslateMessage(&msg);
   351 			DispatchMessage(&msg);
   352 			}
   353 		}
   354 
   355 	return (int) msg.wParam;
   356 	}
   357 
   358 /**
   359 */
   360 void DisplayPluginMessage(UINT uErrCode, BOOL bError)
   361 	{
   362 	char* strErrMsg = "";
   363 
   364 	if(bError)
   365 		{
   366 		switch(uErrCode)
   367 			{
   368 			case DSPN_ERR_IN_USED:			strErrMsg = ("Display Plug-in is Already Used by Other Application.");		break;
   369 			case DSPN_ERR_HW_DISCONNECTED:	strErrMsg = ("iMON HW is Not Connected.");									break;
   370 			case DSPN_ERR_NOT_SUPPORTED_HW:	strErrMsg = ("The Connected iMON HW doesn't Support Display Plug-in.");		break;
   371 			case DSPN_ERR_PLUGIN_DISABLED:	strErrMsg = ("Display Plug-in Mode Option is Disabled.");					break;
   372 			case DSPN_ERR_IMON_NO_REPLY:	strErrMsg = ("The Latest iMON is Not Installed or iMON Not Running.");		break;
   373 			case DSPN_ERR_UNKNOWN:			strErrMsg = ("Unknown Failure.");											break;
   374 			}
   375 		}
   376 	else
   377 		{
   378 		switch(uErrCode)
   379 			{
   380 			case DSPNM_PLUGIN_SUCCEED:		strErrMsg = ("Plug-in Mode Inited Successfully.");			break;
   381 			case DSPNM_IMON_RESTARTED:		strErrMsg = ("iMON Started and Plug-in Mode Inited.");		break;
   382 			case DSPNM_HW_CONNECTED:		strErrMsg = ("iMON HW Connected and Plug-in Mode Inited.");	break;
   383 			}
   384 
   385 		m_IsInit=TRUE;
   386 		}
   387 	//
   388 	OutputDebugStringA(strErrMsg);
   389 
   390 	char msg[256];
   391 	if (bError)
   392 		{
   393 		sprintf(msg,"error:%s",strErrMsg);
   394 		}
   395 	else
   396 		{
   397 		sprintf(msg,"done:%s",strErrMsg);	
   398 		}	
   399 	SendMessageToServer(msg);
   400 	}
   401 
   402 
   403 
   404 //
   405 //  FUNCTION: MyRegisterClass()
   406 //
   407 //  PURPOSE: Registers the window class.
   408 //
   409 //  COMMENTS:
   410 //
   411 //    This function and its usage are only necessary if you want this code
   412 //    to be compatible with Win32 systems prior to the 'RegisterClassEx'
   413 //    function that was added to Windows 95. It is important to call this function
   414 //    so that the application will get 'well formed' small icons associated
   415 //    with it.
   416 //
   417 ATOM MyRegisterClass(HINSTANCE hInstance)
   418 {
   419 	WNDCLASSEX wcex;
   420 
   421 	wcex.cbSize = sizeof(WNDCLASSEX);
   422 
   423 	wcex.style			= CS_HREDRAW | CS_VREDRAW;
   424 	wcex.lpfnWndProc	= WndProc;
   425 	wcex.cbClsExtra		= 0;
   426 	wcex.cbWndExtra		= 0;
   427 	wcex.hInstance		= hInstance;
   428 	wcex.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SOUNDGRAPHACCESS));
   429 	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
   430 	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
   431 	wcex.lpszMenuName	= MAKEINTRESOURCE(IDC_SOUNDGRAPHACCESS);
   432 	wcex.lpszClassName	= szWindowClass;
   433 	wcex.hIconSm		= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
   434 
   435 	return RegisterClassEx(&wcex);
   436 }
   437 
   438 //
   439 //   FUNCTION: InitInstance(HINSTANCE, int)
   440 //
   441 //   PURPOSE: Saves instance handle and creates main window
   442 //
   443 //   COMMENTS:
   444 //
   445 //        In this function, we save the instance handle in a global variable and
   446 //        create and display the main program window.
   447 //
   448 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
   449 {
   450    
   451 
   452    hInst = hInstance; // Store instance handle in our global variable
   453 
   454    gWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
   455       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
   456 
   457    if (!gWnd)
   458    {
   459       return FALSE;
   460    }
   461 
   462    ShowWindow(gWnd, nCmdShow);
   463    UpdateWindow(gWnd);
   464 
   465    return TRUE;
   466 }
   467 
   468 //
   469 //  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
   470 //
   471 //  PURPOSE:  Processes messages for the main window.
   472 //
   473 //  WM_COMMAND	- process the application menu
   474 //  WM_PAINT	- Paint the main window
   475 //  WM_DESTROY	- post a quit message and return
   476 //
   477 //
   478 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
   479 {
   480 	int wmId, wmEvent;
   481 	PAINTSTRUCT ps;
   482 	HDC hdc;
   483 
   484 	switch (message)
   485 	{
   486 	case WM_CREATE:
   487 		//IMON_Display_Uninit();
   488 		//IMON_Display_Init(hWnd, WM_DSP_PLUGIN_NOTIFY);
   489 		gThreadReceiver = CreateThread( NULL, 0, ThreadReceiver, NULL/*data pointer*/, 0, NULL);
   490 		break;
   491 	case WM_COMMAND:
   492 		wmId    = LOWORD(wParam);
   493 		wmEvent = HIWORD(wParam);
   494 		// Parse the menu selections:
   495 		switch (wmId)
   496 		{
   497 		case IDM_ABOUT:
   498 			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
   499 			break;
   500 		case IDM_EXIT:
   501 			DestroyWindow(hWnd);
   502 			break;
   503 		default:
   504 			return DefWindowProc(hWnd, message, wParam, lParam);
   505 		}
   506 		break;
   507 	case WM_PAINT:
   508 		hdc = BeginPaint(hWnd, &ps);
   509 		// TODO: Add any drawing code here...
   510 		EndPaint(hWnd, &ps);
   511 		break;
   512 	case WM_DESTROY:
   513 		gQuit=TRUE;
   514 		//To complete write op
   515 		if (gPipeOutbound!=INVALID_HANDLE_VALUE)
   516 			{
   517 			DisconnectNamedPipe(gPipeOutbound);
   518 			CloseHandle(gPipeOutbound);
   519 			gPipeOutbound=INVALID_HANDLE_VALUE;
   520 			}
   521 		//To complete read op
   522 		if (gPipeInbound!=INVALID_HANDLE_VALUE)
   523 			{
   524 			DisconnectNamedPipe(gPipeInbound);
   525 			CloseHandle(gPipeInbound);
   526 			gPipeInbound=INVALID_HANDLE_VALUE;
   527 			}
   528 
   529 		WaitForSingleObject(gThreadReceiver,INFINITE);
   530 		CloseHandle(gThreadReceiver);
   531 		//IMON_Display_Uninit();
   532 		PostQuitMessage(0);
   533 		break;
   534 
   535 	case WM_IMON_UNINIT:
   536 		m_IsInit=FALSE;
   537 		IMON_Display_Uninit();
   538 		SendMessageToServer(KRspDone);
   539 		break;
   540 
   541 	case WM_IMON_INIT:
   542 		IMON_Display_Uninit();
   543 		IMON_Display_Init(hWnd, WM_DSP_PLUGIN_NOTIFY);
   544 		break;
   545 	//
   546 	case WM_IMON_IS_PLUGIN_MODE_ENABLED:
   547 		if (IMON_Display_IsPluginModeEnabled()==DSP_S_IN_PLUGIN_MODE)
   548 			{
   549 			SendMessageToServer(KRspTrue);
   550 			}
   551 		else
   552 			{
   553 			SendMessageToServer(KRspFalse);
   554 			}
   555 		break;
   556 	//
   557 	case WM_IMON_IS_INIT:
   558 		if (IMON_Display_IsInited()==DSP_S_INITED)
   559 			{
   560 			SendMessageToServer(KRspTrue);
   561 			}
   562 		else
   563 			{
   564 			SendMessageToServer(KRspFalse);
   565 			}
   566 		break;
   567 	//
   568 	case WM_IMON_DISPLAY_SET_VFD_TEXT:
   569 #ifdef _UNICODE
   570 		if (DSP_SUCCEEDED==IMON_Display_SetVfdText(gTextFirstLine16,gTextSecondLine16))
   571 #else
   572 		if (DSP_SUCCEEDED==IMON_Display_SetVfdText(gTextFirstLine,gTextSecondLine))
   573 #endif
   574 			{
   575 			SendMessageToServer(KRspDone);
   576 			}
   577 		else
   578 			{
   579 			SendMessageToServer(KRspError);
   580 			}
   581 		break;
   582 
   583 	case WM_DSP_PLUGIN_NOTIFY:
   584 		switch(wParam)
   585 			{
   586 			case DSPNM_PLUGIN_SUCCEED:
   587 			case DSPNM_IMON_RESTARTED:
   588 			case DSPNM_HW_CONNECTED:
   589 				{
   590 				//GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
   591 				m_bVfdConnected = FALSE;
   592 				m_bLcdConnected = FALSE;
   593 				if((lParam & DSPN_DSP_VFD) == DSPN_DSP_VFD)		m_bVfdConnected = TRUE;
   594 				if((lParam & DSPN_DSP_LCD) == DSPN_DSP_LCD)		m_bLcdConnected = TRUE;
   595 				//UpdateControlUI();
   596 
   597 				DisplayPluginMessage(wParam, FALSE);
   598 				}
   599 				break;
   600 
   601 			case DSPNM_PLUGIN_FAILED:
   602 			case DSPNM_HW_DISCONNECTED:
   603 			case DSPNM_IMON_CLOSED:
   604 				{
   605 				//GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
   606 				m_bVfdConnected = FALSE;
   607 				m_bLcdConnected = FALSE;
   608 				//UpdateControlUI();
   609 
   610 				DisplayPluginMessage(lParam, TRUE);
   611 				}
   612 				break;
   613 
   614 			case DSPNM_LCD_TEXT_SCROLL_DONE:
   615 				{
   616 				//TRACE(_T("LCD Text Scroll Finished.\n"));
   617 				}
   618 				break;
   619 			}
   620 		return 0;
   621 		break;
   622 	default:
   623 		return DefWindowProc(hWnd, message, wParam, lParam);
   624 	}
   625 	return 0;
   626 }
   627 
   628 // Message handler for about box.
   629 INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   630 {
   631 	UNREFERENCED_PARAMETER(lParam);
   632 	switch (message)
   633 	{
   634 	case WM_INITDIALOG:
   635 		return (INT_PTR)TRUE;
   636 
   637 	case WM_COMMAND:
   638 		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
   639 		{
   640 			EndDialog(hDlg, LOWORD(wParam));
   641 			return (INT_PTR)TRUE;
   642 		}
   643 		break;
   644 	}
   645 	return (INT_PTR)FALSE;
   646 }
   647