sl@0: // SoundGraphAccess.cpp : Defines the entry point for the application. sl@0: // sl@0: sl@0: #include "stdafx.h" sl@0: #include "SoundGraphAccess.h" sl@0: #include "iMONDisplayAPI.h" lenclud@3: #include sl@0: lenclud@3: #define WM_DSP_PLUGIN_NOTIFY WM_APP + 1100 lenclud@3: #define WM_IMON_INIT WM_APP + 1101 lenclud@3: #define WM_IMON_UNINIT WM_APP + 1102 lenclud@3: #define WM_IMON_IS_INIT WM_APP + 1103 lenclud@3: #define WM_IMON_IS_PLUGIN_MODE_ENABLED WM_APP + 1104 lenclud@4: #define WM_IMON_DISPLAY_SET_VFD_TEXT WM_APP + 1105 lenclud@3: lenclud@3: // sl@0: #define MAX_LOADSTRING 100 sl@0: StephaneLenclud@6: const int BUFFER_SIZE = 256; sl@0: sl@0: // Global Variables: sl@0: HINSTANCE hInst = 0; // current instance sl@0: TCHAR szTitle[MAX_LOADSTRING]; // The title bar text sl@0: TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name lenclud@3: HANDLE gThreadReceiver = INVALID_HANDLE_VALUE; lenclud@3: //HANDLE gThreadSender = INVALID_HANDLE_VALUE; sl@0: BOOL gQuit=FALSE; sl@0: StephaneLenclud@6: LPTSTR gPipeNameInbound = TEXT("\\\\.\\pipe\\sga-inbound"); StephaneLenclud@6: LPTSTR gPipeNameOutbound = TEXT("\\\\.\\pipe\\sga-outbound"); StephaneLenclud@6: HANDLE gPipeInbound=INVALID_HANDLE_VALUE; StephaneLenclud@6: HANDLE gPipeOutbound=INVALID_HANDLE_VALUE; sl@0: sl@0: char gBufferReceiver[256]; sl@0: char gBufferSender[256]; lenclud@4: // lenclud@4: char gTextFirstLine[256]; lenclud@4: char gTextSecondLine[256]; lenclud@4: wchar_t gTextFirstLine16[256]; lenclud@4: wchar_t gTextSecondLine16[256]; sl@0: lenclud@2: // lenclud@2: HWND gWnd; sl@0: sl@0: // sl@0: BOOL m_bVfdConnected; sl@0: BOOL m_bLcdConnected; StephaneLenclud@5: BOOL m_IsInit=FALSE; sl@0: sl@0: // Forward declarations of functions included in this code module: sl@0: ATOM MyRegisterClass(HINSTANCE hInstance); sl@0: BOOL InitInstance(HINSTANCE, int); sl@0: LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); sl@0: INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); sl@0: lenclud@3: //Supported responses lenclud@3: const char KRspDone[]="done:"; lenclud@3: const char KRspPending[]="pending:"; lenclud@3: const char KRspError[]="error:"; lenclud@3: const char KRspClose[]="close:"; lenclud@3: const char KRspOpen[]="open:"; lenclud@3: const char KRspUnknown[]="unknown:"; lenclud@3: const char KRspTrue[]="true:"; lenclud@3: const char KRspFalse[]="false:"; lenclud@3: //Supported incoming messages lenclud@3: const char KMsgInit[]="init:"; lenclud@3: const char KMsgUninit[]="uninit:"; lenclud@3: const char KMsgIsInit[]="is-init:"; lenclud@3: const char KMsgIsPluginModeEnabled[]="is-plugin-mode-enabled:"; lenclud@4: const char KMsgSetVfdText[]="set-vfd-text:"; StephaneLenclud@6: const char KMsgQuit[]="quit:"; lenclud@4: StephaneLenclud@6: /** StephaneLenclud@6: Create inbound pipe to receive messages. StephaneLenclud@6: */ StephaneLenclud@6: bool CreateInboundPipe() StephaneLenclud@6: { StephaneLenclud@6: gPipeInbound = CreateNamedPipe(gPipeNameInbound, PIPE_ACCESS_INBOUND, PIPE_TYPE_BYTE, PIPE_UNLIMITED_INSTANCES, BUFFER_SIZE, BUFFER_SIZE, 0, NULL); StephaneLenclud@6: StephaneLenclud@6: //could not create named pipe StephaneLenclud@6: if (gPipeInbound==INVALID_HANDLE_VALUE) StephaneLenclud@6: return false; StephaneLenclud@6: StephaneLenclud@6: //Will complete once a client connects StephaneLenclud@6: int success = ConnectNamedPipe(gPipeInbound, NULL); StephaneLenclud@6: StephaneLenclud@6: //could not connect client StephaneLenclud@6: if (success == 0) StephaneLenclud@6: return false; StephaneLenclud@6: StephaneLenclud@6: return true; StephaneLenclud@6: } StephaneLenclud@6: StephaneLenclud@6: StephaneLenclud@6: /** StephaneLenclud@6: Create outbound pipe to send message StephaneLenclud@6: */ StephaneLenclud@6: bool CreateOutboundPipe() StephaneLenclud@6: { StephaneLenclud@6: gPipeOutbound = CreateNamedPipe(gPipeNameOutbound, PIPE_ACCESS_OUTBOUND /*| FILE_FLAG_OVERLAPPED*/, PIPE_TYPE_BYTE, PIPE_UNLIMITED_INSTANCES, BUFFER_SIZE, BUFFER_SIZE, 0, NULL); StephaneLenclud@6: StephaneLenclud@6: //could not create named pipe StephaneLenclud@6: if (gPipeOutbound==INVALID_HANDLE_VALUE) StephaneLenclud@6: return false; StephaneLenclud@6: StephaneLenclud@6: //Will complete once a client connects StephaneLenclud@6: int success = ConnectNamedPipe(gPipeOutbound, NULL); StephaneLenclud@6: StephaneLenclud@6: //could not connect client StephaneLenclud@6: if (success == 0) StephaneLenclud@6: return false; StephaneLenclud@6: StephaneLenclud@6: return true; StephaneLenclud@6: } lenclud@2: lenclud@2: /** lenclud@2: Send a message to our server. lenclud@2: */ lenclud@2: void SendMessageToServer(const char* aResponse) lenclud@2: { lenclud@2: DWORD cbWritten=0; lenclud@3: char msg[512]; lenclud@3: sprintf(msg,"%s\n",aResponse); lenclud@3: OutputDebugStringA(msg); StephaneLenclud@6: WriteFile(gPipeOutbound, aResponse, strlen(aResponse), &cbWritten, NULL); StephaneLenclud@6: if (strlen(aResponse)!=cbWritten) StephaneLenclud@6: { StephaneLenclud@6: int err = GetLastError(); StephaneLenclud@6: OutputDebugStringA("ERROR: WriteFile failure!\n"); StephaneLenclud@6: } lenclud@2: } lenclud@2: lenclud@2: StephaneLenclud@6: lenclud@2: /** lenclud@2: Handle messages from our server. lenclud@2: */ lenclud@2: void MessageReceived(const char* aMsg) lenclud@2: { lenclud@2: // lenclud@3: if (strcmp(aMsg,KMsgInit)==0) lenclud@2: { lenclud@2: //IMON API call need to be done from window thread for some reason lenclud@3: SendMessageToServer(KRspPending); lenclud@3: PostMessage(gWnd,WM_IMON_INIT,0,0); lenclud@3: } lenclud@3: else if (strcmp(aMsg,KMsgUninit)==0) lenclud@3: { lenclud@3: //IMON API call need to be done from window thread for some reason lenclud@3: SendMessageToServer(KRspPending); lenclud@3: PostMessage(gWnd,WM_IMON_UNINIT,0,0); lenclud@3: } lenclud@3: else if (strcmp(aMsg,KMsgIsPluginModeEnabled)==0) lenclud@3: { lenclud@3: //IMON API call need to be done from window thread for some reason lenclud@3: SendMessageToServer(KRspPending); lenclud@3: PostMessage(gWnd,WM_IMON_IS_PLUGIN_MODE_ENABLED,0,0); lenclud@3: } lenclud@3: else if (strcmp(aMsg,KMsgIsInit)==0) lenclud@3: { lenclud@3: //IMON API call need to be done from window thread for some reason lenclud@3: SendMessageToServer(KRspPending); StephaneLenclud@6: PostMessage(gWnd,WM_IMON_IS_INIT,0,0); StephaneLenclud@6: } StephaneLenclud@6: else if (strcmp(aMsg,KMsgQuit)==0) StephaneLenclud@6: { StephaneLenclud@6: //gQuit=TRUE; StephaneLenclud@6: SendMessageToServer(KRspDone); StephaneLenclud@6: DestroyWindow(gWnd); lenclud@3: } lenclud@4: else if (strstr(aMsg,KMsgSetVfdText)==aMsg) lenclud@4: { lenclud@4: int textLen=strlen(aMsg)-strlen(KMsgSetVfdText); lenclud@4: strncpy(gTextFirstLine,aMsg+strlen(KMsgSetVfdText),textLen); lenclud@4: gTextFirstLine[textLen]='\0'; StephaneLenclud@7: //Check if we have a second line StephaneLenclud@7: char* ptr=strchr(gTextFirstLine,'\n'); StephaneLenclud@7: if (ptr!=NULL) StephaneLenclud@7: { StephaneLenclud@7: *ptr='\0'; //Terminate our first line here StephaneLenclud@7: ptr++; StephaneLenclud@7: //Get our second line StephaneLenclud@7: textLen=strlen(ptr); StephaneLenclud@7: strncpy(gTextSecondLine,ptr,textLen); StephaneLenclud@7: gTextSecondLine[textLen]='\0'; StephaneLenclud@7: } StephaneLenclud@7: else StephaneLenclud@7: { StephaneLenclud@7: //No second line specified StephaneLenclud@7: gTextSecondLine[0]='\0'; StephaneLenclud@7: gTextSecondLine16[0]='\0'; StephaneLenclud@7: } StephaneLenclud@7: StephaneLenclud@7: //Convert first line lenclud@4: OutputDebugStringA(gTextFirstLine); lenclud@4: int convertedChars = MultiByteToWideChar(CP_UTF8, 0, gTextFirstLine, -1, gTextFirstLine16, sizeof(gTextFirstLine16)); lenclud@4: OutputDebugString(gTextFirstLine16); StephaneLenclud@7: //Convert second line StephaneLenclud@7: OutputDebugStringA(gTextSecondLine); StephaneLenclud@7: convertedChars = MultiByteToWideChar(CP_UTF8, 0, gTextSecondLine, -1, gTextSecondLine16, sizeof(gTextSecondLine16)); StephaneLenclud@7: OutputDebugString(gTextSecondLine16); StephaneLenclud@7: lenclud@4: //IMON API call need to be done from window thread for some reason lenclud@4: SendMessageToServer(KRspPending); StephaneLenclud@5: if (!m_IsInit) StephaneLenclud@5: { StephaneLenclud@5: PostMessage(gWnd,WM_IMON_INIT,0,0); StephaneLenclud@5: } lenclud@4: PostMessage(gWnd,WM_IMON_DISPLAY_SET_VFD_TEXT,0,0); lenclud@4: } lenclud@3: else lenclud@3: { lenclud@3: SendMessageToServer(KRspUnknown); lenclud@3: } lenclud@3: } lenclud@3: lenclud@3: lenclud@3: lenclud@3: /** lenclud@3: Connect our named pipes from here. lenclud@3: First connect our read pipe then our write pipe. lenclud@3: Then notify our server we are connected. lenclud@3: Then keep on waiting for incoming messages. lenclud@3: */ lenclud@3: DWORD WINAPI ThreadReceiver( LPVOID lpParam ) lenclud@3: { StephaneLenclud@6: StephaneLenclud@6: /* lenclud@3: //Keep on trying to connect on our read pipe StephaneLenclud@6: while (gPipeInbound==INVALID_HANDLE_VALUE && !gQuit) lenclud@3: { lenclud@3: OutputDebugStringA("Trying to connect...\n"); StephaneLenclud@6: gPipeInbound=CreateFile(gPipeNameInbound, GENERIC_READ ,0,NULL,OPEN_EXISTING,0,NULL); lenclud@3: Sleep(1000); lenclud@3: } lenclud@3: lenclud@3: OutputDebugStringA("Read pipe open!\n"); lenclud@3: //Now try connecting on our write pipe StephaneLenclud@6: gPipeOutbound=CreateFile(gPipeNameOutbound, GENERIC_WRITE ,0,NULL,OPEN_EXISTING,0,NULL); StephaneLenclud@6: if (gPipeOutbound==INVALID_HANDLE_VALUE) lenclud@3: { StephaneLenclud@5: int err=GetLastError(); lenclud@3: OutputDebugStringA("ERROR: Write pipe failure!\n"); StephaneLenclud@5: //gQuit=TRUE; lenclud@2: } lenclud@2: else lenclud@2: { lenclud@3: OutputDebugStringA("Write pipe opened.\n"); lenclud@3: OutputDebugStringA("Connected.\n"); lenclud@3: SendMessageToServer(KRspOpen); lenclud@2: } lenclud@3: // StephaneLenclud@6: */ StephaneLenclud@6: StephaneLenclud@6: StephaneLenclud@6: CreateOutboundPipe(); StephaneLenclud@6: CreateInboundPipe(); sl@0: sl@0: while(!gQuit) sl@0: { sl@0: DWORD cbRead; StephaneLenclud@6: BOOL success=ReadFile(gPipeInbound,gBufferReceiver,sizeof(gBufferReceiver),&cbRead, NULL); sl@0: if(success) lenclud@3: { sl@0: gBufferReceiver[cbRead]='\0'; sl@0: OutputDebugStringA(gBufferReceiver); lenclud@2: MessageReceived(gBufferReceiver); sl@0: } lenclud@3: //if (!success && GetLastError() != ERROR_MORE_DATA) lenclud@3: // { lenclud@3: // OutputDebugStringA("Can't Read\n"); lenclud@3: // } lenclud@3: // lenclud@3: //Sleep(500); lenclud@3: lenclud@3: if (!success) sl@0: { lenclud@3: gQuit=TRUE; sl@0: } sl@0: } sl@0: lenclud@3: //Try tell our server lenclud@3: SendMessageToServer(KRspClose); lenclud@3: //Close our pipes StephaneLenclud@6: DisconnectNamedPipe(gPipeInbound); StephaneLenclud@6: CloseHandle(gPipeInbound); StephaneLenclud@6: gPipeInbound=INVALID_HANDLE_VALUE; StephaneLenclud@6: DisconnectNamedPipe(gPipeOutbound); StephaneLenclud@6: CloseHandle(gPipeOutbound); StephaneLenclud@6: gPipeOutbound=INVALID_HANDLE_VALUE; lenclud@3: //Quit our application lenclud@3: PostMessage(gWnd,WM_CLOSE,0,0); lenclud@3: sl@0: return 0; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: */ sl@0: int APIENTRY _tWinMain(HINSTANCE hInstance, sl@0: HINSTANCE hPrevInstance, sl@0: LPTSTR lpCmdLine, sl@0: int nCmdShow) sl@0: { sl@0: UNREFERENCED_PARAMETER(hPrevInstance); sl@0: UNREFERENCED_PARAMETER(lpCmdLine); sl@0: lenclud@4: gTextFirstLine[0]='\0'; lenclud@4: gTextSecondLine[0]='\0'; lenclud@4: gTextFirstLine16[0]='\0'; lenclud@4: gTextSecondLine16[0]='\0'; lenclud@4: lenclud@4: sl@0: // TODO: Place code here. sl@0: MSG msg; sl@0: HACCEL hAccelTable; sl@0: sl@0: // Initialize global strings sl@0: LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); sl@0: LoadString(hInstance, IDC_SOUNDGRAPHACCESS, szWindowClass, MAX_LOADSTRING); sl@0: MyRegisterClass(hInstance); sl@0: sl@0: // Perform application initialization: sl@0: if (!InitInstance (hInstance, /*SW_HIDE*/ nCmdShow)) sl@0: { sl@0: return FALSE; sl@0: } sl@0: sl@0: sl@0: sl@0: hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SOUNDGRAPHACCESS)); sl@0: sl@0: // Main message loop: sl@0: while (GetMessage(&msg, NULL, 0, 0)) sl@0: { sl@0: if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) sl@0: { sl@0: TranslateMessage(&msg); sl@0: DispatchMessage(&msg); sl@0: } sl@0: } sl@0: sl@0: return (int) msg.wParam; sl@0: } sl@0: lenclud@2: /** lenclud@2: */ sl@0: void DisplayPluginMessage(UINT uErrCode, BOOL bError) sl@0: { lenclud@2: char* strErrMsg = ""; sl@0: sl@0: if(bError) sl@0: { sl@0: switch(uErrCode) sl@0: { lenclud@2: case DSPN_ERR_IN_USED: strErrMsg = ("Display Plug-in is Already Used by Other Application."); break; lenclud@2: case DSPN_ERR_HW_DISCONNECTED: strErrMsg = ("iMON HW is Not Connected."); break; lenclud@2: case DSPN_ERR_NOT_SUPPORTED_HW: strErrMsg = ("The Connected iMON HW doesn't Support Display Plug-in."); break; lenclud@3: case DSPN_ERR_PLUGIN_DISABLED: strErrMsg = ("Display Plug-in Mode Option is Disabled."); break; lenclud@2: case DSPN_ERR_IMON_NO_REPLY: strErrMsg = ("The Latest iMON is Not Installed or iMON Not Running."); break; lenclud@3: case DSPN_ERR_UNKNOWN: strErrMsg = ("Unknown Failure."); break; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: switch(uErrCode) sl@0: { lenclud@3: case DSPNM_PLUGIN_SUCCEED: strErrMsg = ("Plug-in Mode Inited Successfully."); break; lenclud@2: case DSPNM_IMON_RESTARTED: strErrMsg = ("iMON Started and Plug-in Mode Inited."); break; lenclud@2: case DSPNM_HW_CONNECTED: strErrMsg = ("iMON HW Connected and Plug-in Mode Inited."); break; sl@0: } StephaneLenclud@5: StephaneLenclud@5: m_IsInit=TRUE; sl@0: } sl@0: // lenclud@2: OutputDebugStringA(strErrMsg); lenclud@3: lenclud@3: char msg[256]; lenclud@3: if (bError) lenclud@3: { lenclud@3: sprintf(msg,"error:%s",strErrMsg); lenclud@3: } lenclud@3: else lenclud@3: { lenclud@3: sprintf(msg,"done:%s",strErrMsg); lenclud@3: } lenclud@3: SendMessageToServer(msg); sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: // FUNCTION: MyRegisterClass() sl@0: // sl@0: // PURPOSE: Registers the window class. sl@0: // sl@0: // COMMENTS: sl@0: // sl@0: // This function and its usage are only necessary if you want this code sl@0: // to be compatible with Win32 systems prior to the 'RegisterClassEx' sl@0: // function that was added to Windows 95. It is important to call this function sl@0: // so that the application will get 'well formed' small icons associated sl@0: // with it. sl@0: // sl@0: ATOM MyRegisterClass(HINSTANCE hInstance) sl@0: { sl@0: WNDCLASSEX wcex; sl@0: sl@0: wcex.cbSize = sizeof(WNDCLASSEX); sl@0: sl@0: wcex.style = CS_HREDRAW | CS_VREDRAW; sl@0: wcex.lpfnWndProc = WndProc; sl@0: wcex.cbClsExtra = 0; sl@0: wcex.cbWndExtra = 0; sl@0: wcex.hInstance = hInstance; sl@0: wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SOUNDGRAPHACCESS)); sl@0: wcex.hCursor = LoadCursor(NULL, IDC_ARROW); sl@0: wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); sl@0: wcex.lpszMenuName = MAKEINTRESOURCE(IDC_SOUNDGRAPHACCESS); sl@0: wcex.lpszClassName = szWindowClass; sl@0: wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); sl@0: sl@0: return RegisterClassEx(&wcex); sl@0: } sl@0: sl@0: // sl@0: // FUNCTION: InitInstance(HINSTANCE, int) sl@0: // sl@0: // PURPOSE: Saves instance handle and creates main window sl@0: // sl@0: // COMMENTS: sl@0: // sl@0: // In this function, we save the instance handle in a global variable and sl@0: // create and display the main program window. sl@0: // sl@0: BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) sl@0: { lenclud@2: sl@0: sl@0: hInst = hInstance; // Store instance handle in our global variable sl@0: lenclud@2: gWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, sl@0: CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); sl@0: lenclud@2: if (!gWnd) sl@0: { sl@0: return FALSE; sl@0: } sl@0: lenclud@2: ShowWindow(gWnd, nCmdShow); lenclud@2: UpdateWindow(gWnd); sl@0: sl@0: return TRUE; sl@0: } sl@0: sl@0: // sl@0: // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) sl@0: // sl@0: // PURPOSE: Processes messages for the main window. sl@0: // sl@0: // WM_COMMAND - process the application menu sl@0: // WM_PAINT - Paint the main window sl@0: // WM_DESTROY - post a quit message and return sl@0: // sl@0: // sl@0: LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) sl@0: { sl@0: int wmId, wmEvent; sl@0: PAINTSTRUCT ps; sl@0: HDC hdc; sl@0: sl@0: switch (message) sl@0: { sl@0: case WM_CREATE: sl@0: //IMON_Display_Uninit(); sl@0: //IMON_Display_Init(hWnd, WM_DSP_PLUGIN_NOTIFY); sl@0: gThreadReceiver = CreateThread( NULL, 0, ThreadReceiver, NULL/*data pointer*/, 0, NULL); sl@0: break; sl@0: case WM_COMMAND: sl@0: wmId = LOWORD(wParam); sl@0: wmEvent = HIWORD(wParam); sl@0: // Parse the menu selections: sl@0: switch (wmId) sl@0: { sl@0: case IDM_ABOUT: sl@0: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); sl@0: break; sl@0: case IDM_EXIT: sl@0: DestroyWindow(hWnd); sl@0: break; sl@0: default: sl@0: return DefWindowProc(hWnd, message, wParam, lParam); sl@0: } sl@0: break; sl@0: case WM_PAINT: sl@0: hdc = BeginPaint(hWnd, &ps); sl@0: // TODO: Add any drawing code here... sl@0: EndPaint(hWnd, &ps); sl@0: break; sl@0: case WM_DESTROY: sl@0: gQuit=TRUE; sl@0: //To complete write op StephaneLenclud@6: if (gPipeOutbound!=INVALID_HANDLE_VALUE) sl@0: { StephaneLenclud@6: DisconnectNamedPipe(gPipeOutbound); StephaneLenclud@6: CloseHandle(gPipeOutbound); StephaneLenclud@6: gPipeOutbound=INVALID_HANDLE_VALUE; sl@0: } sl@0: //To complete read op StephaneLenclud@6: if (gPipeInbound!=INVALID_HANDLE_VALUE) sl@0: { StephaneLenclud@6: DisconnectNamedPipe(gPipeInbound); StephaneLenclud@6: CloseHandle(gPipeInbound); StephaneLenclud@6: gPipeInbound=INVALID_HANDLE_VALUE; sl@0: } lenclud@3: sl@0: WaitForSingleObject(gThreadReceiver,INFINITE); sl@0: CloseHandle(gThreadReceiver); sl@0: //IMON_Display_Uninit(); sl@0: PostQuitMessage(0); sl@0: break; lenclud@2: lenclud@2: case WM_IMON_UNINIT: StephaneLenclud@5: m_IsInit=FALSE; lenclud@2: IMON_Display_Uninit(); lenclud@3: SendMessageToServer(KRspDone); lenclud@2: break; lenclud@2: lenclud@2: case WM_IMON_INIT: lenclud@2: IMON_Display_Uninit(); lenclud@2: IMON_Display_Init(hWnd, WM_DSP_PLUGIN_NOTIFY); lenclud@2: break; lenclud@3: // lenclud@3: case WM_IMON_IS_PLUGIN_MODE_ENABLED: lenclud@3: if (IMON_Display_IsPluginModeEnabled()==DSP_S_IN_PLUGIN_MODE) lenclud@3: { lenclud@3: SendMessageToServer(KRspTrue); lenclud@3: } lenclud@3: else lenclud@3: { lenclud@3: SendMessageToServer(KRspFalse); lenclud@3: } lenclud@3: break; lenclud@3: // lenclud@3: case WM_IMON_IS_INIT: lenclud@3: if (IMON_Display_IsInited()==DSP_S_INITED) lenclud@3: { lenclud@3: SendMessageToServer(KRspTrue); lenclud@3: } lenclud@3: else lenclud@3: { lenclud@3: SendMessageToServer(KRspFalse); lenclud@3: } lenclud@3: break; lenclud@4: // lenclud@4: case WM_IMON_DISPLAY_SET_VFD_TEXT: lenclud@4: if (DSP_SUCCEEDED==IMON_Display_SetVfdText(gTextFirstLine16,gTextSecondLine16)) lenclud@4: { lenclud@4: SendMessageToServer(KRspDone); lenclud@4: } lenclud@4: else lenclud@4: { lenclud@4: SendMessageToServer(KRspError); lenclud@4: } lenclud@4: break; lenclud@2: sl@0: case WM_DSP_PLUGIN_NOTIFY: sl@0: switch(wParam) sl@0: { sl@0: case DSPNM_PLUGIN_SUCCEED: sl@0: case DSPNM_IMON_RESTARTED: sl@0: case DSPNM_HW_CONNECTED: sl@0: { sl@0: //GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE); sl@0: m_bVfdConnected = FALSE; sl@0: m_bLcdConnected = FALSE; sl@0: if((lParam & DSPN_DSP_VFD) == DSPN_DSP_VFD) m_bVfdConnected = TRUE; sl@0: if((lParam & DSPN_DSP_LCD) == DSPN_DSP_LCD) m_bLcdConnected = TRUE; sl@0: //UpdateControlUI(); sl@0: sl@0: DisplayPluginMessage(wParam, FALSE); sl@0: } sl@0: break; sl@0: sl@0: case DSPNM_PLUGIN_FAILED: sl@0: case DSPNM_HW_DISCONNECTED: sl@0: case DSPNM_IMON_CLOSED: sl@0: { sl@0: //GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE); sl@0: m_bVfdConnected = FALSE; sl@0: m_bLcdConnected = FALSE; sl@0: //UpdateControlUI(); sl@0: sl@0: DisplayPluginMessage(lParam, TRUE); sl@0: } sl@0: break; sl@0: sl@0: case DSPNM_LCD_TEXT_SCROLL_DONE: sl@0: { sl@0: //TRACE(_T("LCD Text Scroll Finished.\n")); sl@0: } sl@0: break; sl@0: } sl@0: return 0; sl@0: break; sl@0: default: sl@0: return DefWindowProc(hWnd, message, wParam, lParam); sl@0: } sl@0: return 0; sl@0: } sl@0: sl@0: // Message handler for about box. sl@0: INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) sl@0: { sl@0: UNREFERENCED_PARAMETER(lParam); sl@0: switch (message) sl@0: { sl@0: case WM_INITDIALOG: sl@0: return (INT_PTR)TRUE; sl@0: sl@0: case WM_COMMAND: sl@0: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) sl@0: { sl@0: EndDialog(hDlg, LOWORD(wParam)); sl@0: return (INT_PTR)TRUE; sl@0: } sl@0: break; sl@0: } sl@0: return (INT_PTR)FALSE; sl@0: } sl@0: