The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MPEyeFinderApp.cpp

Go to the documentation of this file.
00001 // MPEyeFinderApp.cpp : Defines the entry point for the application.
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "resource.h"
00006 #include <atlbase.h>
00007 #include <streams.h>
00008 #include <initguid.h>
00009 #include "DirectShow/MPDirectShow.h"
00010 #include <cstdio>
00011 
00012 #define MAX_LOADSTRING 100
00013 
00014 // Global Variables:
00015 HINSTANCE hInst;                                                                // current instance
00016 TCHAR szTitle[MAX_LOADSTRING];                                                          // The title bar text
00017 TCHAR szWindowClass[MAX_LOADSTRING];                                                            // The title bar text
00018 
00019 // Foward declarations of functions included in this code module:
00020 ATOM                            MyRegisterClass(HINSTANCE hInstance);
00021 BOOL                            InitInstance(HINSTANCE, int);
00022 LRESULT CALLBACK        WndProc(HWND, UINT, WPARAM, LPARAM);
00023 LRESULT CALLBACK        About(HWND, UINT, WPARAM, LPARAM);
00024 
00025 
00026 //
00027 //HWND WINAPI CreateTrackbar(
00028 //       HWND hwndDlg,
00029 //       UINT iMin,
00030 //       UINT iMax,
00031 //       UINT iSelMin,
00032 //       UINT iSelMAx,
00033 //       UINT iXPosition,
00034 //       UINT iYPosition,
00035 //       UINT iLength);
00036 
00037 //LRESULT CALLBACK DlgProc(HWND hGlg, UINT message, WPARAM wParam, LPARAM lParam);
00038 #define WM_GRAPHNOTIFY   WM_APP + 1
00039 
00040 MPDirectShow m_directShow;
00041 
00042 //return from callback 'cause graph is stopping
00043 BYTE bReturnImmediatelyFromCallback = 0;
00044 
00046 
00047 // ================================================================
00048 
00049 int APIENTRY WinMain(HINSTANCE hInstance,
00050                      HINSTANCE hPrevInstance,
00051                      LPSTR     lpCmdLine,
00052                      int       nCmdShow)
00053 {
00054         // TODO: Place code here.
00055         MSG msg;
00056         HACCEL hAccelTable;
00057 
00058         // Initialize global strings
00059         LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
00060         LoadString(hInstance, IDC_MPEYEFINDERAPP, szWindowClass, MAX_LOADSTRING);
00061         MyRegisterClass(hInstance);
00062 
00063         // Perform application initialization:
00064         if (!InitInstance (hInstance, nCmdShow))
00065         {
00066                 return FALSE;
00067         }
00068 
00069         hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_MPEYEFINDERAPP);
00070 
00071         // Main message loop:
00072         while (GetMessage(&msg, NULL, 0, 0))
00073         {
00074                 if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
00075                 {
00076                         TranslateMessage(&msg);
00077                         DispatchMessage(&msg);
00078                 }
00079         }
00080 
00081         return msg.wParam;
00082 }
00083 
00084 // ================================================================
00085 
00086 //
00087 //  FUNCTION: MyRegisterClass()
00088 //
00089 //  PURPOSE: Registers the window class.
00090 //
00091 //  COMMENTS:
00092 //
00093 //    This function and its usage is only necessary if you want this code
00094 //    to be compatible with Win32 systems prior to the 'RegisterClassEx'
00095 //    function that was added to Windows 95. It is important to call this function
00096 //    so that the application will get 'well formed' small icons associated
00097 //    with it.
00098 //
00099 ATOM MyRegisterClass(HINSTANCE hInstance)
00100 {
00101         WNDCLASSEX wcex;
00102 
00103         wcex.cbSize = sizeof(WNDCLASSEX);
00104 
00105         wcex.style                      = CS_HREDRAW | CS_VREDRAW;
00106         wcex.lpfnWndProc        = (WNDPROC)WndProc;
00107         wcex.cbClsExtra         = 0;
00108         wcex.cbWndExtra         = 0;
00109         wcex.hInstance          = hInstance;
00110         wcex.hIcon                      = LoadIcon(hInstance, (LPCTSTR)IDI_MPEYEFINDERAPP);
00111         wcex.hCursor            = LoadCursor(NULL, IDC_ARROW);
00112         wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW+1);
00113         wcex.lpszMenuName       = (LPCSTR)IDC_MPEYEFINDERAPP;
00114         wcex.lpszClassName      = szWindowClass;
00115         wcex.hIconSm            = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
00116 
00117         return RegisterClassEx(&wcex);
00118 }
00119 
00120 // ================================================================
00121 
00122 //
00123 //   FUNCTION: InitInstance(HANDLE, int)
00124 //
00125 //   PURPOSE: Saves instance handle and creates main window
00126 //
00127 //   COMMENTS:
00128 //
00129 //        In this function, we save the instance handle in a global variable and
00130 //        create and display the main program window.
00131 //
00132 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
00133 {
00134    HWND hWnd;
00135 
00136    hInst = hInstance; // Store instance handle in our global variable
00137 
00138    hWnd = CreateWindow(szWindowClass, szTitle, WS_DLGFRAME|WS_SYSMENU|WS_MINIMIZEBOX,
00139       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
00140 
00141    if (!hWnd)
00142    {
00143       return FALSE;
00144    }
00145          m_directShow.SetProject(ds_eyefinder);  
00146          m_directShow.SetInput(320, 240);
00147          m_directShow.RunDirectShow(hWnd);
00148    SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL-1);
00149 
00150    ShowWindow(hWnd, nCmdShow);
00151    UpdateWindow(hWnd);
00152 
00153    return TRUE;
00154 }
00155 
00156 // ================================================================
00157 
00158 //
00159 //  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
00160 //
00161 //  PURPOSE:  Processes messages for the main window.
00162 //
00163 //  WM_COMMAND  - process the application menu
00164 //  WM_PAINT    - Paint the main window
00165 //  WM_DESTROY  - post a quit message and return
00166 //
00167 //
00168 void HandleEvent()
00169 {
00170     long evCode, param1, param2;
00171     HRESULT hr;
00172 
00173 }
00174 
00175 // ================================================================
00176 
00177 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00178 {
00179         int wmId, wmEvent;
00180 //      PAINTSTRUCT ps;
00181 //      HDC hdc;
00182         TCHAR szHello[MAX_LOADSTRING];
00183         LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
00184 
00185         switch (message)
00186         {
00187                 case WM_GRAPHNOTIFY:
00188                     HandleEvent();
00189                         break;
00190                 case WM_COMMAND:
00191                         wmId    = LOWORD(wParam);
00192                         wmEvent = HIWORD(wParam);
00193                         // Parse the menu selections:
00194                         switch (wmId)
00195                         {
00196                                 case IDM_ABOUT:
00197                                    DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
00198                                    break;
00199                                 case IDM_EXIT:
00200 
00201                                    DestroyWindow(hWnd);
00202                                    break;
00203                                 default:
00204                                    return DefWindowProc(hWnd, message, wParam, lParam);
00205                         }
00206                         break;
00207 
00208 
00209                 case WM_PAINT:
00210 //                      hdc = BeginPaint(hWnd, &ps);
00211 //                      // TODO: Add any drawing code here...
00212 //                      RECT rt;
00213 //                      GetClientRect(hWnd, &rt);
00214 //                      DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
00215 //                      EndPaint(hWnd, &ps);
00216                         break;
00217 //              case WM_SIZE:
00218 //              {
00219 //                      int nWidth = LOWORD(lParam);  // width of client area
00220 //                      int nHeight = HIWORD(lParam); // height of client area
00221 //                      switch(wParam)
00222 //                      {
00223 //                      case SIZE_MINIMIZED:
00224 //                              pWindow->put_Visible(OAFALSE);
00225 //                              break;
00226 //                      default:
00227 //                              pWindow->put_Visible(OATRUE);
00228 //                              break;
00229 //                      }
00230 //                      break;
00231 //              }
00232                 case WM_DESTROY:
00233                         PostQuitMessage(0);
00234                         break;
00235                 default:
00236                         return DefWindowProc(hWnd, message, wParam, lParam);
00237    }
00238    return 0;
00239 }
00240 
00241 // ================================================================
00242 
00243 // Mesage handler for about box.
00244 LRESULT CALLBACK About(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00245 {
00246         switch (message)
00247         {
00248                 case WM_INITDIALOG:
00249                                 return TRUE;
00250 
00251                 case WM_COMMAND:
00252                         if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
00253                         {
00254                                 EndDialog(hWnd, LOWORD(wParam));
00255                                 return TRUE;
00256                         }
00257                         break;
00258         }
00259     return FALSE;
00260 }
00261 
00262 // ================================================================
00263 
00264 void Msg(TCHAR *szFormat, ...)
00265 {
00266     TCHAR szBuffer[1024];  // Large buffer for very long filenames (like HTTP)
00267 
00268     // Format the input string
00269 
00270         va_list pArgs;
00271     va_start(pArgs, szFormat);
00272     _vstprintf(szBuffer, szFormat, pArgs);
00273     va_end(pArgs);
00274 
00275     // Display a message box with the formatted string
00276     MessageBox(NULL, szBuffer, TEXT("First Grab Sample"), MB_OK);
00277 }
00278 
00279 // ================================================================
00280 

Generated on Mon Nov 8 17:07:43 2004 for MPT by  doxygen 1.3.9.1