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

MPBlinkDetectorApp.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 // Global Variables:
00014 HINSTANCE hInst;                                                                // current instance
00015 TCHAR szTitle[MAX_LOADSTRING];                                                          // The title bar text
00016 TCHAR szWindowClass[MAX_LOADSTRING];                                                            // The title bar text
00017 
00018 // Foward declarations of functions included in this code module:
00019 ATOM                            MyRegisterClass(HINSTANCE hInstance);
00020 BOOL                            InitInstance(HINSTANCE, int);
00021 LRESULT CALLBACK        WndProc(HWND, UINT, WPARAM, LPARAM);
00022 LRESULT CALLBACK        About(HWND, UINT, WPARAM, LPARAM);
00023 
00024 //
00025 //HWND WINAPI CreateTrackbar(
00026 //       HWND hwndDlg,
00027 //       UINT iMin,
00028 //       UINT iMax,
00029 //       UINT iSelMin,
00030 //       UINT iSelMAx,
00031 //       UINT iXPosition,
00032 //       UINT iYPosition,
00033 //       UINT iLength);
00034 
00035 //LRESULT CALLBACK DlgProc(HWND hGlg, UINT message, WPARAM wParam, LPARAM lParam);
00036 #define WM_GRAPHNOTIFY   WM_APP + 1
00037 
00038 
00039 MPDirectShow m_directShow;
00040 
00041 //return from callback 'cause graph is stopping
00042 BYTE bReturnImmediatelyFromCallback = 0;
00043 
00045 
00046 // ================================================================
00047 
00048 int APIENTRY WinMain(HINSTANCE hInstance,
00049                      HINSTANCE hPrevInstance,
00050                      LPSTR     lpCmdLine,
00051                      int       nCmdShow)
00052 {
00053         // TODO: Place code here.
00054         MSG msg;
00055         HACCEL hAccelTable;
00056 
00057         // Initialize global strings
00058         LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
00059         LoadString(hInstance, IDC_MPBLINKDETECTORAPP, szWindowClass, MAX_LOADSTRING);
00060         MyRegisterClass(hInstance);
00061 
00062         // Perform application initialization:
00063         if (!InitInstance (hInstance, nCmdShow))
00064         {
00065                 return FALSE;
00066         }
00067 
00068         hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_MPBLINKDETECTORAPP);
00069 
00070         // Main message loop:
00071         while (GetMessage(&msg, NULL, 0, 0))
00072         {
00073                 if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
00074                 {
00075                         TranslateMessage(&msg);
00076                         DispatchMessage(&msg);
00077                 }
00078         }
00079 
00080         return msg.wParam;
00081 }
00082 
00083 // ================================================================
00084 
00085 //
00086 //  FUNCTION: MyRegisterClass()
00087 //
00088 //  PURPOSE: Registers the window class.
00089 //
00090 //  COMMENTS:
00091 //
00092 //    This function and its usage is only necessary if you want this code
00093 //    to be compatible with Win32 systems prior to the 'RegisterClassEx'
00094 //    function that was added to Windows 95. It is important to call this function
00095 //    so that the application will get 'well formed' small icons associated
00096 //    with it.
00097 //
00098 ATOM MyRegisterClass(HINSTANCE hInstance)
00099 {
00100         WNDCLASSEX wcex;
00101 
00102         wcex.cbSize = sizeof(WNDCLASSEX);
00103 
00104         wcex.style                      = CS_HREDRAW | CS_VREDRAW;
00105         wcex.lpfnWndProc        = (WNDPROC)WndProc;
00106         wcex.cbClsExtra         = 0;
00107         wcex.cbWndExtra         = 0;
00108         wcex.hInstance          = hInstance;
00109         wcex.hIcon                      = LoadIcon(hInstance, (LPCTSTR)IDI_MPBLINKDETECTORAPP);
00110         wcex.hCursor            = LoadCursor(NULL, IDC_ARROW);
00111         wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW+1);
00112         wcex.lpszMenuName       = (LPCSTR)IDC_MPBLINKDETECTORAPP;
00113         wcex.lpszClassName      = szWindowClass;
00114         wcex.hIconSm            = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
00115 
00116         return RegisterClassEx(&wcex);
00117 }
00118 
00119 // ================================================================
00120 
00121 //
00122 //   FUNCTION: InitInstance(HANDLE, int)
00123 //
00124 //   PURPOSE: Saves instance handle and creates main window
00125 //
00126 //   COMMENTS:
00127 //
00128 //        In this function, we save the instance handle in a global variable and
00129 //        create and display the main program window.
00130 //
00131 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
00132 {
00133    HWND hWnd;
00134 
00135    hInst = hInstance; // Store instance handle in our global variable
00136 
00137    hWnd = CreateWindow(szWindowClass, szTitle, WS_DLGFRAME|WS_SYSMENU|WS_MINIMIZEBOX,
00138       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
00139 
00140    if (!hWnd)
00141    {
00142       return FALSE;
00143    }
00144    //RunDirectShow(hWnd);
00145          m_directShow.SetProject(ds_blinkDetector);      
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 
00171 }
00172 
00173 // ================================================================
00174 
00175 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00176 {
00177         int wmId, wmEvent;
00178 //      PAINTSTRUCT ps;
00179 //      HDC hdc;
00180         TCHAR szHello[MAX_LOADSTRING];
00181         LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
00182 
00183         switch (message)
00184         {
00185                 case WM_GRAPHNOTIFY:
00186                         break;
00187                 case WM_COMMAND:
00188                         wmId    = LOWORD(wParam);
00189                         wmEvent = HIWORD(wParam);
00190                         // Parse the menu selections:
00191                         switch (wmId)
00192                         {
00193                                 case IDM_ABOUT:
00194                                    DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
00195                                    break;
00196                                 case IDM_EXIT:
00197 
00198                                    DestroyWindow(hWnd);
00199                                    break;
00200                                 default:
00201                                    return DefWindowProc(hWnd, message, wParam, lParam);
00202                         }
00203                         break;
00204 
00205 
00206                 case WM_PAINT:
00207                         break;
00208                 case WM_DESTROY:
00209                         PostQuitMessage(0);
00210                         break;
00211                 default:
00212                         return DefWindowProc(hWnd, message, wParam, lParam);
00213    }
00214    return 0;
00215 }
00216 
00217 // ================================================================
00218 
00219 // Mesage handler for about box.
00220 LRESULT CALLBACK About(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
00221 {
00222         switch (message)
00223         {
00224                 case WM_INITDIALOG:
00225                                 return TRUE;
00226 
00227                 case WM_COMMAND:
00228                         if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
00229                         {
00230                                 EndDialog(hWnd, LOWORD(wParam));
00231                                 return TRUE;
00232                         }
00233                         break;
00234         }
00235     return FALSE;
00236 }
00237 
00238 // ================================================================
00239 
00240 void Msg(TCHAR *szFormat, ...)
00241 {
00242     TCHAR szBuffer[1024];  // Large buffer for very long filenames (like HTTP)
00243 
00244     // Format the input string
00245 
00246         va_list pArgs;
00247     va_start(pArgs, szFormat);
00248     _vstprintf(szBuffer, szFormat, pArgs);
00249     va_end(pArgs);
00250 
00251     // Display a message box with the formatted string
00252     MessageBox(NULL, szBuffer, TEXT("First Grab Sample"), MB_OK);
00253 }
00254 
00255 // ================================================================
00256 

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