示例#1
0
//----------------------------------------------------------------------
BOOL CALLBACK x_DialogProc(HWND hDlgWnd, UINT message, WPARAM wParam, LPARAM lParam) { 
 
  switch (message) {
  
    case WM_COMMAND: 
      if (HIWORD(wParam) == BN_CLICKED) { 
        switch (LOWORD(wParam)) { 
          case IDC_CMD_EXIT:  // Exit button
            PostMessage( hDlgWnd, WM_CLOSE, 0,0);
            return TRUE;
          case IDC_CMD_START:  // Start button
            g_CmdStart();
            DrawBackground( hDlgWnd );
            return TRUE;
          case IDC_CMD_STOP:  // Stop button
            g_CmdStop();
            DrawBackground( hDlgWnd );
            return TRUE;

/*
          case IDC_BOX1: 
            // Retrieve the state of the check box. 
            lState = SendDlgItemMessage( hDlg, IDC_BOX1, BM_GETSTATE, 0, 0); 
            DoSomething(lState); 
            break; 
*/
        } // switch
      }  // if BN_CLICKED
      break;

    case WM_TIMER:
      OnTimer( hDlgWnd );
      return TRUE;

    case WM_PAINT:
      DrawBackground( hDlgWnd );
      return FALSE;

    case WM_DESTROY:
      PostQuitMessage(0);
      return TRUE;

    case WM_CLOSE:
      // TODO: check status and ask for confirmation
      g_Release_EyeTrack();
      CP_printfDestroy(); // close console window    
      DestroyWindow (hDlgWnd);
      return TRUE;

    } 
    return FALSE;       // did not process a message 
} 
示例#2
0
//----------------------------------------------------------------------
// This is  a DialogProc, not a WindowProc
// It should not call "return DefWindowProc()" at the end
// It returns TRUE for handled messages and FALSE otherwise
BOOL CALLBACK x_DialogProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { 
  LRESULT  lngRes;
  char * szResult;
  int  iResult; 

  switch (uMsg) {

    case WM_PI_RAWDATA_READY:
      g_OnNewData( wParam, lParam);
      return TRUE;

    case WM_PI_DATA_STARTED:
      CP_printf("\nLiberty data started.\n");
      return TRUE;
      
    case WM_PI_DATA_STOPPED:
      CP_printf("\nLiberty data stopped.\n");
      InvalidateRgn( hDlgWnd, NULL, TRUE); // refresh the window
      return TRUE;
      
    case WM_PI_RAWDATA_ERROR :
      g_GetLibertyResult( &szResult, &iResult  );
      CP_printf("\nLiberty data error: %s   Code: %X\n", szResult, iResult);
      return TRUE;
      
    case WM_PI_RAWDATA_WARNING :
      CP_printf("\nLiberty data warning.\n");
      return TRUE;
      
 
    case WM_COMMAND: 
      if (HIWORD(wParam) == BN_CLICKED) { 
        switch (LOWORD(wParam)) { 
          case IDC_CMD_EXIT:  // Exit button
            PostMessage( hDlgWnd, WM_CLOSE, 0,0);
            return TRUE;
          case IDC_CMD_START:  // Start button
            g_CmdStart();
            return TRUE;
          case IDC_CMD_STOP:  // Stop button
            g_CmdStop();
            return TRUE;
          case IDC_CHK_SHOWLOG: 
            // Retrieve the state of the check box. 
            lngRes = SendDlgItemMessage( hDlgWnd, IDC_CHK_SHOWLOG, BM_GETCHECK, 0, 0); 
            if( lngRes == BST_CHECKED ) CP_printfShow();
            if( lngRes == BST_UNCHECKED ) CP_printfHide();
            return TRUE; 

        } // switch
      }  // if BN_CLICKED
      break;

    case WM_TIMER:
      OnTimer( hDlgWnd );
      return TRUE;

    case WM_DESTROY:
      PostQuitMessage(0);
      return TRUE;

    case WM_CLOSE:
      g_Release_LibertyTrack();
      CP_printfDestroy(); // close console window    
      DestroyWindow (hDlgWnd);
      return TRUE;
    } 
  return FALSE;
} 
示例#3
0
//----------------------------------------------------------------------
BOOL CALLBACK x_DialogProc(HWND hDlgWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) { 
  UINT uiTimerID; 
  int iRes;
 
  switch (uiMsg) {

    case WM_COMMAND: 
      if (HIWORD(wParam) == BN_CLICKED) { 
        switch (LOWORD(wParam)) { 
          case IDC_CMD_EXIT:  // Exit button
            PostMessage( hDlgWnd, WM_CLOSE, 0, 0);
            return TRUE;
          case IDC_CMD_START:  // Start button
            g_CmdStart();
            return TRUE;
          case IDC_CMD_STOP:  // Stop button
            g_CmdStop();
            return TRUE;

          // Hide/show log window
          case IDC_CHK_SHOWLOG: 
            // Retrieve the state of the check box. 
            iRes = SendDlgItemMessage( hDlgWnd, IDC_CHK_SHOWLOG, BM_GETCHECK, 0, 0); 
            if( iRes == BST_CHECKED ) CP_printfShow();
            if( iRes == BST_UNCHECKED ) CP_printfHide();
            return TRUE; 

        } // switch
      }  // if BN_CLICKED
      break;

    case WM_TIMER:
      OnTimer( hDlgWnd );
      return TRUE;

    case WM_DESTROY:
      PostQuitMessage(0);
      return TRUE;

    case WM_CLOSE:
      KillTimer( hDlgWnd, TIMER_ID);
      g_Release_OptoTrack();
      DestroyWindow (hDlgWnd);
      return TRUE;

    case WM_INITDIALOG:
      g_hWnd = hDlgWnd;

      SetWindowText(hDlgWnd, x_szTitle);
      SendMessage(hDlgWnd, WM_SETICON, ICON_BIG, 
                  (LPARAM)LoadIcon(x_hInstance, MAKEINTRESOURCE(IDI_ICON_APPL)));
      SendMessage(hDlgWnd, WM_SETICON, ICON_SMALL, 
                 (LPARAM)LoadImage(x_hInstance, MAKEINTRESOURCE(IDI_ICON_APPL), IMAGE_ICON, 16, 16, 0));
      ShowWindow(hDlgWnd, SW_SHOW); 
  
      uiTimerID = SetTimer( hDlgWnd,  TIMER_ID,  TIMER_PERIOD_MS,  NULL ); 
 
      if ( uiTimerID == 0){ 
        CP_printf("Error: could not create timer!"); // don't exit we are still functional
      } 

      iRes = g_Init_OptoTrack( );
      if( iRes != 0 ) { 
        MessageBox( NULL, "Error: g_Init_OptoTrack() failed.", x_szTitle, MB_OK);
        PostMessage( hDlgWnd, WM_CLOSE, 0, 0);
        return TRUE;
      }

      return TRUE;
  } // switch (uiMsg)

  return FALSE;       // did not process a message 
}