Want more features on Pastebin? Sign Up, it's FREE!
Guest

giulio8

By: a guest on Jun 15th, 2009  |  syntax: C++  |  size: 17.42 KB  |  views: 260  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Avi PostEdit - Camstudio Annotation Re-capture
  2. // Initial drafted code developed by giulio8
  3. // http://camstudio.org/forum/comments.php?DiscussionID=145&page=1#Item_0
  4. // https://sourceforge.net/forum/forum.php?thread_id=3287208&forum_id=447910
  5.  
  6. // Play an AVI using the MSvfw32.lib
  7. // in the case of Dev-C++ link with libmsvfw32.a via
  8. // Project>>Project Options>>Parameters>>Add Lib>>libmsvfw32.a
  9. // created via BCX generated C code then modified for Dev-C++
  10. // (actually-Dev C++ is the IDE for the GNU GCC/G++ compiler)
  11. // a Dev-C++ tested Windows Application by  vegaseat  21nov2004
  12.  
  13. #include <cstdio>
  14. #include <fstream>
  15. using namespace std;
  16.  
  17. #include <windows.h>
  18. #include <vfw.h>
  19.  
  20. #define ID_MCIFrame 0
  21. #define ID_MENU1 9001
  22. #define ID_MENU2 9002
  23. #define ID_MENU3 9003
  24. #define ID_MENU4 9004
  25. #define ID_MENU5 9005
  26.  
  27.  
  28. static HINSTANCE BCX_hInstance;
  29. static int     BCX_ScaleX;
  30. static int     BCX_ScaleY;
  31. static char    BCX_ClassName[2048];
  32. static HANDLE  ghInst;
  33. static HWND    Form1;
  34. static HWND    MCIFrame;
  35. static HMENU   MainMenu;
  36. static HMENU   FileMenu;
  37. static OPENFILENAME OpenFileName;
  38. static char    szFile[2048];
  39. static char    szFileTitle[2048];
  40. static char    szFileBmp[2048];
  41. static char    szFileTitleBmp[2048];
  42. static char    szFileBmpC[2048];
  43. static char    szFileTitleBmpC[2048];
  44.  
  45. #define Show(Window)  RedrawWindow(Window,0,0,0);ShowWindow(Window,SW_SHOW);
  46.  
  47. HWND    BCX_Form(char*,int=0,int=0,int=250,int=150,int=0,int=0);
  48. void    BCX_Set_Form_Color (HWND,COLORREF);
  49. void    Center (HWND,HWND=0,HWND=0);
  50. char*   BCX_TmpStr(size_t);
  51. char*   str (double);
  52. char*   curdir (void);
  53.  
  54. void    FormLoad (void);
  55. LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
  56. int     InitOpenFileName (void);
  57. int     PopFileOpenDlg (HWND, char *, char *);
  58. BOOL    AddMenu (HWND);
  59.  
  60.  
  61. // standard Windows Graphical User Interface main
  62. int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrev,LPSTR CmdLine,int CmdShow)
  63. {
  64.  WNDCLASS Wc;
  65.  MSG      Msg;
  66.  // *****************************
  67.  strcpy(BCX_ClassName,"MCI_demo1");
  68.  // ************************************
  69.  // Scale Dialog Units To Screen Units
  70.  // ************************************
  71.  RECT rc          =  {0,0,4,8};
  72.  MapDialogRect       (NULL,&rc);
  73.  BCX_ScaleX       =  rc.right/2;
  74.  BCX_ScaleY       =  rc.bottom/4;
  75.  BCX_hInstance    =  hInst;
  76.  // ******************************************************
  77.  Wc.style         =  CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
  78.  Wc.lpfnWndProc   =  WndProc;
  79.  Wc.cbClsExtra    =  0;
  80.  Wc.cbWndExtra    =  0;
  81.  Wc.hInstance     =  hInst;
  82.  Wc.hIcon         =  LoadIcon(NULL,IDI_WINLOGO);
  83.  Wc.hCursor       =  LoadCursor(NULL,IDC_ARROW);
  84.  Wc.hbrBackground =  (HBRUSH)(COLOR_BTNFACE+1);
  85.  Wc.lpszMenuName  =  NULL;
  86.  Wc.lpszClassName =  BCX_ClassName;
  87.  RegisterClass(&Wc);
  88.  
  89.  FormLoad();
  90.  // event message loop
  91.  while(GetMessage(&Msg,NULL,0,0))
  92.  {
  93.     HWND hActiveWindow = GetActiveWindow();
  94.     if (!IsWindow(hActiveWindow) || !IsDialogMessage(hActiveWindow,&Msg))
  95.       {
  96.         TranslateMessage(&Msg);
  97.         DispatchMessage(&Msg);
  98.       }
  99.  }
  100.  return Msg.wParam;
  101. }
  102.  
  103.  
  104. // circular storage, hold the memory leaks to a minimum
  105. char *BCX_TmpStr (size_t Bites)
  106. {
  107.   static int   StrCnt;
  108.   static char *StrFunc[2048];
  109.   StrCnt=(StrCnt + 1) & 2047;
  110.   if(StrFunc[StrCnt]) free (StrFunc[StrCnt]);
  111.   return StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(char));
  112. }
  113.  
  114.  
  115. char *str (double d)
  116. {
  117.   register char *strtmp = BCX_TmpStr(16);
  118.   sprintf(strtmp,"% .15G",d);
  119.   return strtmp;
  120. }
  121.  
  122.  
  123. char *curdir (void)
  124. {
  125.   register char *strtmp = BCX_TmpStr(2048);
  126.   GetCurrentDirectory (1024,strtmp);
  127.   return strtmp;
  128. }
  129.  
  130.  
  131. // center the window form on the screen, optional, for looks
  132. void Center (HWND hwnd, HWND Xhwnd, HWND Yhwnd)
  133. {
  134.   RECT rect, rectP;
  135.   int  x, y, width, height;
  136.   int  screenwidth, screenheight;
  137.   if(Xhwnd==0)
  138.     {
  139.       RECT  DesktopArea;
  140.       RECT  rc;
  141.       SystemParametersInfo(SPI_GETWORKAREA,0,&DesktopArea,0);
  142.       GetWindowRect(hwnd,&rc);
  143.       SetWindowPos(hwnd,HWND_TOP,
  144.         ((DesktopArea.right-DesktopArea.left)-(rc.right-rc.left))/2+
  145.           DesktopArea.left,((DesktopArea.bottom-DesktopArea.top)-
  146.          (rc.bottom-rc.top))/2 + DesktopArea.top,0,0,SWP_NOSIZE);
  147.       return;
  148.     }
  149.   GetWindowRect (hwnd,&rect);
  150.   GetWindowRect (Xhwnd,&rectP);
  151.   width = rect.right-rect.left;
  152.   x = ((rectP.right-rectP.left)-width)/2 + rectP.left;
  153.   if (Yhwnd==NULL)
  154.   {
  155.       height = rect.bottom-rect.top;
  156.       y = ((rectP.bottom-rectP.top)-height)/2 + rectP.top;
  157.   }
  158.   else
  159.   {
  160.       GetWindowRect(Yhwnd,&rectP);
  161.       height = rect.bottom-rect.top;
  162.       y = ((rectP.bottom-rectP.top)-height)/2+rectP.top;
  163.   }
  164.   screenwidth = GetSystemMetrics(SM_CXSCREEN);
  165.   screenheight = GetSystemMetrics(SM_CYSCREEN);
  166.   if ((x<0))
  167.     x=0;
  168.   if ((y<0))
  169.     y=0;
  170.   if ((x+width>screenwidth))  
  171.     x = screenwidth-width;
  172.   if ((y+height>screenheight))
  173.     y = screenheight-height;
  174.   MoveWindow (hwnd, x, y, width, height, FALSE);
  175. }
  176.  
  177.  
  178. // create the windows form
  179. HWND BCX_Form(char *Caption, int X, int Y, int W, int H, int Style, int Exstyle)
  180. {
  181.    HWND  A;
  182.    // assigne default style if none given
  183.    if (!Style)
  184.    {
  185.         Style= WS_MINIMIZEBOX  |
  186.         WS_SIZEBOX      |
  187.         WS_CAPTION      |
  188.         WS_MAXIMIZEBOX  |
  189.         WS_POPUP        |
  190.         WS_SYSMENU;
  191.    }
  192.    A = CreateWindowEx(Exstyle,BCX_ClassName,Caption,
  193.    Style,
  194.    X*BCX_ScaleX,
  195.    Y*BCX_ScaleY,
  196.    (4+W)*BCX_ScaleX,
  197.    (12+H)*BCX_ScaleY,
  198.    NULL,(HMENU)NULL,BCX_hInstance,NULL);
  199.    SendMessage(A,(UINT)WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),
  200.      (LPARAM)MAKELPARAM(FALSE,0));
  201.    return A;
  202. }
  203.  
  204.  
  205. // color, why not
  206. void BCX_Set_Form_Color (HWND hWnd, COLORREF Kolor)
  207. {
  208.   HBRUSH hbr=CreateSolidBrush(Kolor);
  209.   DeleteObject((HBRUSH)SetClassLong(hWnd,GCL_HBRBACKGROUND,(DWORD)hbr));
  210.   InvalidateRect (hWnd,NULL,TRUE);
  211. }
  212.  
  213.  
  214. // the details - corner coordinates,width,height,title
  215. void FormLoad (void)
  216. {
  217.     Form1=BCX_Form("PostEdit Capture",0,0,197,170);
  218.     SetClassLong(Form1,GCL_STYLE,GetClassLong(Form1,GCL_STYLE)|CS_DBLCLKS);
  219.     BCX_Set_Form_Color(Form1,RGB(0,0,0));
  220.     //  Now create the MCIWnd
  221.     MCIFrame=MCIWndCreate(Form1,(HINSTANCE)ghInst,WS_CHILD|WS_VISIBLE|MCIWNDF_NOPLAYBAR|MCIWNDF_NOTIFYALL,"");
  222.     AddMenu(Form1);
  223.     Center(Form1);
  224.     Show(Form1);
  225.     //MessageBox (NULL , "Edit", "Avviso", MB_ICONEXCLAMATION | MB_OK);
  226. }
  227.  
  228. int InitSaveFileName (void)
  229. {
  230.   *szFile=0;
  231.   *szFileTitle=0;
  232.   OpenFileName.lStructSize=sizeof(OPENFILENAME);
  233.   OpenFileName.hwndOwner=MCIFrame;
  234.   OpenFileName.hInstance=(HINSTANCE)ghInst;
  235.   OpenFileName.lpstrFilter =
  236.     "Avi Files (*.BMP)\0*.bmp\0All Files(*.*)\0*.*\0\0";
  237.   OpenFileName.lpstrCustomFilter=NULL;
  238.   OpenFileName.nMaxCustFilter=0;
  239.   OpenFileName.nFilterIndex=0;
  240.   OpenFileName.lpstrFile=szFile;
  241.   OpenFileName.nMaxFile=MAX_PATH;
  242.   OpenFileName.lpstrFileTitle=szFileTitle;
  243.   OpenFileName.nMaxFileTitle=MAX_PATH;
  244.   OpenFileName.lpstrInitialDir=curdir();
  245.   OpenFileName.lpstrTitle=NULL;
  246.   OpenFileName.nFileOffset=0;
  247.   OpenFileName.nFileExtension=0;
  248.   OpenFileName.lpstrDefExt="*.bmp";
  249.   OpenFileName.lCustData=0L;
  250.   OpenFileName.Flags=OFN_SHOWHELP|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
  251.   OpenFileName.lpfnHook=NULL;
  252.   OpenFileName.lpTemplateName=NULL;
  253.   return 0;
  254. }
  255.  
  256. int PopFileSaveDlg (HWND Form1, char *szFileBmp, char *szFileTitleBmp)
  257. {
  258.   OpenFileName.lpstrTitle="Save bitmap";
  259.   OpenFileName.hwndOwner=MCIFrame;
  260.   OpenFileName.lpstrFile=szFileBmp;
  261.   OpenFileName.lpstrFileTitle=szFileTitleBmp;
  262.   OpenFileName.Flags=OFN_EXPLORER|OFN_CREATEPROMPT;
  263.   return GetOpenFileNamePreview(&OpenFileName);
  264. }
  265.  
  266. /*
  267. Funzione per scrivere l'handle di una bitmap su file
  268. Thanks to http://www.geocities.com/krishnapg/bitmap.html#SaveBitmap
  269. */
  270. void SaveBitmap(char *szFilename,HBITMAP hBitmap){
  271.       HDC        hdc=NULL;
  272.       FILE*      fp=NULL;
  273.       LPVOID     pBuf=NULL;
  274.       BITMAPINFO bmpInfo;
  275.       BITMAPFILEHEADER  bmpFileHeader;
  276.       do{
  277.             hdc=GetDC(NULL);
  278.             ZeroMemory(&bmpInfo,sizeof(BITMAPINFO));
  279.             bmpInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
  280.             GetDIBits(hdc,hBitmap,0,0,NULL,&bmpInfo,DIB_RGB_COLORS);
  281.             if(bmpInfo.bmiHeader.biSizeImage<=0)
  282.             bmpInfo.bmiHeader.biSizeImage=bmpInfo.bmiHeader.biWidth*abs(bmpInfo.bmiHeader.biHeight)*(bmpInfo.bmiHeader.biBitCount+7)/8;
  283.             if((pBuf = malloc(bmpInfo.bmiHeader.biSizeImage))==NULL)
  284.             {
  285.                   //MessageBox( NULL, "Unable to Allocate Bitmap Memory", "Error", MB_OK|MB_ICONERROR);
  286.                   break;
  287.             }          
  288.             bmpInfo.bmiHeader.biCompression=BI_RGB;
  289.             GetDIBits(hdc,hBitmap,0,bmpInfo.bmiHeader.biHeight,pBuf, &bmpInfo, DIB_RGB_COLORS);      
  290.             if((fp = fopen(szFilename,"wb"))==NULL)
  291.             {
  292.                   //MessageBox( NULL, "Unable to Create Bitmap File", "Error", MB_OK|MB_ICONERROR);
  293.                   break;
  294.             }
  295.             bmpFileHeader.bfReserved1=0;
  296.             bmpFileHeader.bfReserved2=0;
  297.             bmpFileHeader.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+bmpInfo.bmiHeader.biSizeImage;
  298.             bmpFileHeader.bfType='MB';
  299.             bmpFileHeader.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
  300.             fwrite(&bmpFileHeader,sizeof(BITMAPFILEHEADER),1,fp);
  301.             fwrite(&bmpInfo.bmiHeader,sizeof(BITMAPINFOHEADER),1,fp);
  302.             fwrite(pBuf,bmpInfo.bmiHeader.biSizeImage,1,fp);
  303.       }while(false);
  304.             if(hdc)     ReleaseDC(NULL,hdc);
  305.             if(pBuf)    free(pBuf);
  306.             if(fp)      fclose(fp);
  307. }
  308.  
  309.  
  310. // event message handler
  311. LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
  312. {
  313.   static char s[2048];
  314.   memset(&s,0,sizeof(s));
  315.   static char mstr[2048];
  316.   memset(&mstr,0,sizeof(mstr));
  317.   static char mstr1[2048];
  318.   memset(&mstr1,0,sizeof(mstr1));
  319.   while(1)
  320.   {
  321.     if (Msg==WM_CREATE)
  322.     {
  323.       return 0;
  324.       break;
  325.     }
  326.     if (Msg==WM_COMMAND)
  327.     {
  328.       if (LOWORD(wParam)==ID_MENU2)
  329.       {
  330.           MCIWndClose(MCIFrame);
  331.           InitOpenFileName();
  332.           PopFileOpenDlg(Form1,szFile,szFileTitle);
  333.           if(strlen(szFile)>0)
  334.           {
  335.               MCIWndOpen(MCIFrame,szFile,0);
  336.           }
  337.           return 0;
  338.       }
  339.       if(LOWORD(wParam)==ID_MENU3)
  340.       {
  341.           MCIWndClose(MCIFrame);
  342.           ExitProcess(0);
  343.       }
  344.       //break;
  345.        if(LOWORD(wParam)==ID_MENU4)
  346.       {
  347.                                    
  348. // Some steps:
  349.  
  350.  PAVIFILE   aviFile;
  351.  PAVISTREAM  aviStream;
  352.  AVISTREAMINFO  aviStreamInfo;
  353.  
  354.  AVIFileInit();
  355.  AVIFileOpen(&aviFile,szFile,OF_READ,NULL);
  356.  AVIFileGetStream(aviFile,&aviStream,streamtypeVIDEO,0);
  357.  AVIFileRelease(aviFile);
  358.  AVIStreamInfo(aviStream,&aviStreamInfo,sizeof(aviStreamInfo));
  359.  
  360. // OK! Now we can extract any frame from AVI stream!
  361.  
  362.  BITMAPFILEHEADER BMPFileHeader;
  363.  LPBITMAPINFOHEADER lpbi;
  364.  PGETFRAME  pgf;
  365.  
  366.  pgf=AVIStreamGetFrameOpen(aviStream,NULL);
  367.  LONG lFrame;
  368. lFrame = MCIWndGetPosition(MCIFrame);
  369.  
  370.  lpbi=(LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf,lFrame);
  371.  
  372.  
  373.  
  374.  BMPFileHeader.bfType=0x4d42;
  375.  BMPFileHeader.bfSize=(DWORD)(sizeof(BITMAPFILEHEADER)+lpbi->biSize+
  376.   lpbi->biClrUsed*sizeof(RGBQUAD)+lpbi->biSizeImage);
  377.  BMPFileHeader.bfReserved1=0;
  378.  BMPFileHeader.bfReserved2=0;
  379.  BMPFileHeader.bfOffBits=(DWORD)sizeof(BITMAPFILEHEADER)+lpbi->biSize+
  380.   lpbi->biClrUsed*sizeof(RGBQUAD);
  381.  
  382. // Than create file to save frame and write BMP sections into it!
  383.  
  384. // WriteFile(hFile,(LPVOID)&BMPFileHeader,sizeof(BITMAPFILEHEADER),
  385. //  (LPDWORD)&lpNumberOfBytesWritten,NULL);
  386. // WriteFile(hFile,(LPVOID)lpbi,sizeof(BITMAPFILEHEADER)+lpbi->biSize+
  387. //  lpbi->biClrUsed*sizeof(RGBQUAD)+lpbi->biSizeImage,
  388. //  (LPDWORD)&lpNumberOfBytesWritten,NULL);
  389.  
  390.           InitSaveFileName();
  391.           PopFileSaveDlg(Form1,szFileBmp,szFileTitleBmp);    
  392.  
  393.  
  394. ofstream fout(szFileBmp, ios::binary);
  395.  
  396. BITMAPFILEHEADER bfh;
  397.  
  398.  
  399.         fout.write((const char *)&BMPFileHeader,sizeof(BITMAPFILEHEADER));
  400.         fout.write((const char *)lpbi,sizeof(BITMAPFILEHEADER)+lpbi->biSize+
  401.   lpbi->biClrUsed*sizeof(RGBQUAD)+lpbi->biSizeImage);
  402.   //fout.write((char *)lpbuff,len);
  403.   fout.close();
  404.  
  405. // And in the end make some clean!
  406.  
  407.  AVIStreamGetFrameClose(pgf);
  408.  
  409. // We can save one more frame or finish or work.
  410.  
  411.  AVIFileExit();                        
  412.                                    
  413.  
  414.       }
  415.      
  416.      
  417.        if(LOWORD(wParam)==ID_MENU5)
  418.       {
  419. HDC hDc = CreateCompatibleDC(0);
  420. RECT rcWind;
  421. GetClientRect(MCIFrame, &rcWind);
  422. int width = rcWind.right - rcWind.left;
  423. int height = rcWind.bottom - rcWind.top;
  424. HBITMAP hBmp = CreateCompatibleBitmap(GetDC(MCIFrame), width, height);  
  425.    
  426.    // join em up
  427.    SelectObject(hDc, hBmp);  
  428.    
  429.    // copy from the screen to my bitmap
  430.    BitBlt(hDc, 0, 0, width, height, GetDC(MCIFrame), 0, 0, SRCCOPY);  
  431.    
  432.    // save my bitmap
  433.           InitSaveFileName();
  434.           PopFileSaveDlg(Form1,szFileBmpC,szFileTitleBmpC);    
  435.  
  436.    SaveBitmap(szFileBmpC,hBmp);
  437.  
  438.  DeleteObject(hBmp);                                      
  439.                                    
  440.       }
  441.       break;
  442.     }
  443.  
  444.     if (Msg==MCIWNDM_NOTIFYMODE)
  445.     {
  446.       while(1)
  447.       {
  448.         if ((long)lParam==MCI_MODE_NOT_READY)
  449.         {
  450.           SetWindowText(Form1,"Not Ready");
  451.           break;
  452.         }
  453.         if ((long)lParam==MCI_MODE_PAUSE)
  454.         {
  455.           SetWindowText(Form1,"Paused");
  456.           break;
  457.         }
  458.         if ((long)lParam==MCI_MODE_PLAY)
  459.         {
  460.           SetWindowText(Form1,"Playing");
  461.           break;
  462.         }
  463.         if ((long)lParam==MCI_MODE_STOP)
  464.         {
  465.           SetWindowText(Form1,"Stopped");
  466.           break;
  467.         }
  468.         if ((long)lParam==MCI_MODE_OPEN)
  469.         {
  470.           SetWindowText(Form1,"Opening");
  471.           break;
  472.         }
  473.         if ((long)lParam==MCI_MODE_RECORD)
  474.         {
  475.           SetWindowText(Form1,"Recording");
  476.           break;
  477.         }
  478.         if ((long)lParam==MCI_MODE_SEEK)
  479.         {
  480.           SetWindowText(Form1,"Seeking");
  481.         }
  482.         break;
  483.       }
  484.       break;
  485.     }
  486.     if (Msg==MCIWNDM_NOTIFYMEDIA)
  487.     {
  488.       SetWindowText(Form1,(LPSTR)lParam);
  489.       break;
  490.     }
  491.     if (Msg==MCIWNDM_NOTIFYPOS)
  492.     {
  493.       SetWindowText(Form1,str(MCIWndGetPosition(MCIFrame)));
  494.       break;
  495.     }
  496.     if (Msg==MCIWNDM_NOTIFYERROR)
  497.     {
  498.       SetWindowText(Form1,"MCI ERROR");
  499.       break;
  500.     }
  501.     if (Msg==WM_PAINT)
  502.     {
  503.       //  The VideoWindow is restricted to a ratio of 4:3 here
  504.       break;
  505.     }
  506.     if (Msg==WM_SIZE)
  507.     {
  508.       static  WORD  Basedsp;
  509.       memset(&Basedsp,0,sizeof(Basedsp));
  510.       static  WORD  Cntr;
  511.       memset(&Cntr,0,sizeof(Cntr));
  512.       Basedsp=(HIWORD(lParam)-20)/3;
  513.       Cntr=(LOWORD(lParam)-(Basedsp*4))/2;
  514.       // MoveWindow(MCIFrame,Cntr,0,(Basedsp*4),HIWORD(lParam),TRUE);
  515.       //  Don't forget to close opened Files
  516.       break;
  517.     }
  518.     if (Msg==WM_CLOSE)
  519.     {
  520.       MCIWndClose(MCIFrame);
  521.       DestroyWindow(Form1);
  522.       return 0;
  523.       break;
  524.     }
  525.     if (Msg==WM_DESTROY)
  526.     {
  527.       MCIWndClose(MCIFrame);
  528.       PostQuitMessage(0);
  529.       return 0;
  530.     }
  531.     break;
  532.   }
  533.   // tidy up and exit program
  534.   if (Msg==WM_DESTROY)
  535.   {
  536.        UnregisterClass(BCX_ClassName,BCX_hInstance);
  537.        PostQuitMessage(0);
  538.   }
  539.   return DefWindowProc(hWnd,Msg,wParam,lParam);
  540. }
  541.  
  542.  
  543. // tons of options for the neat file dialog box
  544. int InitOpenFileName (void)
  545. {
  546.   *szFile=0;
  547.   *szFileTitle=0;
  548.   OpenFileName.lStructSize=sizeof(OPENFILENAME);
  549.   OpenFileName.hwndOwner=MCIFrame;
  550.   OpenFileName.hInstance=(HINSTANCE)ghInst;
  551.   OpenFileName.lpstrFilter =
  552.     "Avi Files (*.AVI)\0*.avi\0All Files(*.*)\0*.*\0\0";
  553.   OpenFileName.lpstrCustomFilter=NULL;
  554.   OpenFileName.nMaxCustFilter=0;
  555.   OpenFileName.nFilterIndex=0;
  556.   OpenFileName.lpstrFile=szFile;
  557.   OpenFileName.nMaxFile=MAX_PATH;
  558.   OpenFileName.lpstrFileTitle=szFileTitle;
  559.   OpenFileName.nMaxFileTitle=MAX_PATH;
  560.   OpenFileName.lpstrInitialDir=curdir();
  561.   OpenFileName.lpstrTitle=NULL;
  562.   OpenFileName.nFileOffset=0;
  563.   OpenFileName.nFileExtension=0;
  564.   OpenFileName.lpstrDefExt="*.avi";
  565.   OpenFileName.lCustData=0L;
  566.   OpenFileName.Flags=OFN_SHOWHELP|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
  567.   OpenFileName.lpfnHook=NULL;
  568.   OpenFileName.lpTemplateName=NULL;
  569.   return 0;
  570. }
  571.  
  572. int PopFileOpenDlg (HWND Form1, char *szFile, char *szFileTitle)
  573. {
  574.   OpenFileName.lpstrTitle="Open File";
  575.   OpenFileName.hwndOwner=MCIFrame;
  576.   OpenFileName.lpstrFile=szFile;
  577.   OpenFileName.lpstrFileTitle=szFileTitle;
  578.   OpenFileName.Flags=OFN_EXPLORER|OFN_CREATEPROMPT;
  579.   return GetOpenFileNamePreview(&OpenFileName);
  580. }
  581.  
  582.  
  583. BOOL AddMenu (HWND hwndOwner)
  584. {
  585.   MainMenu=CreateMenu();
  586.   FileMenu=CreateMenu();
  587.   InsertMenu(MainMenu,0,MF_POPUP,(UINT)FileMenu,"&File");
  588.   AppendMenu(FileMenu,MF_STRING,ID_MENU2,"&Open");
  589.   AppendMenu(FileMenu,MF_STRING,ID_MENU3,"&Exit");
  590.   AppendMenu(FileMenu,MF_STRING,ID_MENU4,"&Save bmp");
  591.   AppendMenu(FileMenu,MF_STRING,ID_MENU5,"&Save capture");
  592.   // activate the menu
  593.   if (!SetMenu(hwndOwner,MainMenu))
  594.   {
  595.       return FALSE;
  596.   }
  597.   return TRUE;
  598. }
  599.  
  600. // ************* credit to a true genius Kevin *****************
  601. //   Created with BCX -- The BASIC To C Translator (ver 5.02)
  602. //  BCX (c) 1999, 2000, 2001, 2002, 2003, 2004 by Kevin Diggins
  603. // *************************************************************
clone this paste RAW Paste Data