begin process at 2012 05 29 06:28:57
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C/C++

 > 

Archives

 > 

Au secours

 > 

Où est ce #!?\ de bug ? (projet MFC)


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Où est ce #!?\ de bug ? (projet MFC)

jeudi 18 août 2005 à 14:51:25 | Où est ce #!?\ de bug ? (projet MFC)

MasterShadows

Salut à tous,

j'vais exposer brièvement le problème, dans le projet que j'effectue (il est écrit en MFC (pas trop le choix d'ailleurs)) il faut que je fasse une partie de prog qui ouvre un fichier avi, qu'il prenne et affiche les paramètres de l'avi en question et qu'enfin il "bitmap" chaque image du film.

Tout est fait, excepté le fait que la bitmap en question est rempli de vert.

Je vous envoie le code pour voir où est le bug

FICHIER RC :

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// French (France) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE
BEGIN
    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
    "#define _AFX_NO_OLE_RESOURCES\r\n"
    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
    "\r\n"
    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)\r\n"
    "LANGUAGE 12, 1\r\n"
    "#pragma code_page(1252)\r\n"
    "#include ""res\\CinemaMovieMaker.rc2""  // ressources non modifiées par Microsoft Visual C++\r\n"
    "#include ""afxres.rc""     // Composants standard\r\n"
    "#endif\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME           ICON                    "..\\res\\Cinema_Movie_Maker.ico"

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "À propos de Cinema Movie Maker"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
    ICON            IDR_MAINFRAME,IDC_STATIC,11,17,20,20
    LTEXT           "Cinema Movie Maker Version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX
    LTEXT           "Copyright (C) 2005",IDC_STATIC,40,25,119,8
    DEFPUSHBUTTON   "OK",IDOK,178,7,50,16,WS_GROUP
END

IDD_CINEMAMOVIEMAKER_DIALOG DIALOGEX 0, 0, 540, 460
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Cinema Movie Maker"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
    PUSHBUTTON      "Quitter le Programme",IDCANCEL,453,431,80,20
    CONTROL         "",IDC_TAB_CINEMA_MOVIE_MAKER,"SysTabControl32",0x0,7,7,526,420
END

IDD_FRAMES_TO_FILM DIALOGEX 0, 0, 310, 361
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    GROUPBOX        "Images à Ajouter",IDC_STATIC1,7,7,296,158,BS_CENTER
    EDITTEXT        IDC_EDIT_IMAGES_A_AJOUTER,92,34,207,14,ES_AUTOHSCROLL | ES_READONLY
    LISTBOX         IDC_LIST_IMAGES_A_AJOUTER,15,49,284,101,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
    GROUPBOX        "Son à Ajouter",IDC_STATIC2,7,168,296,30,BS_CENTER
    PUSHBUTTON      "Parcourir",IDC_PARCOURIR_IMAGES,15,34,70,14
    PUSHBUTTON      "Parcourir",IDC_PARCOURIR_SON,15,178,70,14
    EDITTEXT        IDC_EDIT_SON_A_AJOUTER,92,178,207,14,ES_AUTOHSCROLL | ES_READONLY
    GROUPBOX        "Vidéo",IDC_STATIC3,7,200,296,56,BS_CENTER
    PUSHBUTTON      "Parcourir",IDC_PARCOURIR_VIDEO,15,209,70,14
    EDITTEXT        IDC_EDIT_VIDEO_A_CREER,92,209,207,14,ES_AUTOHSCROLL
    CONTROL         "Compresser la Vidéo",IDC_CHECKCOMPRESS_VIDEO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,230,81,10
    LTEXT           "Délai d'attente entre 2 images :",IDC_STATIC4,15,242,102,8
    EDITTEXT        IDC_EDIT_WAIT_BETWEEN_IMAGES,119,239,40,14,ES_CENTER | ES_AUTOHSCROLL | ES_NUMBER
    LTEXT           "secondes.",IDC_STATIC5,164,242,34,8
    PUSHBUTTON      "Créer le Film",IDC_CREER_LE_FILM,79,261,150,14
    LTEXT           "",IDC_NB_IMAGES_LISTE,120,152,122,8
    LTEXT           "Nombre d'Images dans la liste :",IDC_STATIC6,15,152,100,8
    LTEXT           "Extension des images à inclure :",IDC_STATIC7,18,20,103,8
    CONTROL         "Bmp",IDC_RADIO_BMP,"Button",BS_AUTORADIOBUTTON,125,20,29,10
    CONTROL         "Jpg",IDC_RADIO_JPG,"Button",BS_AUTORADIOBUTTON,160,20,27,10
    CONTROL         "Png",IDC_RADIO_PNG,"Button",BS_AUTORADIOBUTTON,230,20,28,10
    CONTROL         "Jpeg",IDC_RADIO_JPEG,"Button",BS_AUTORADIOBUTTON,195,20,28,10
    GROUPBOX        "Progression Totale de la création du Film.",IDC_STATIC8,7,279,296,74,BS_CENTER
    CONTROL         "",IDC_PROGRESS_CREATION,"msctls_progress32",WS_BORDER,10,333,290,14
    LTEXT           "",IDC_INFO,10,321,290,8
    LTEXT           "",IDC_AVANCEMENT_IMG_EN_COURS,10,292,290,8
    CONTROL         "",IDC_PROGRESS_AJOUT_IMAGE,"msctls_progress32",WS_BORDER,10,302,290,14
END

IDD_CONVERT_FILM_TO_AVI DIALOGEX 0, 0, 354, 347
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    GROUPBOX        "Vidéo d' Entrée.",IDC_STATIC9,7,7,340,26,BS_CENTER
    PUSHBUTTON      "Parcourir",IDC_PARCOURIR_VIDEO_ENTREE,15,15,50,14
    EDITTEXT        IDC_EDIT_VIDEO_ENTREE,68,15,270,14,ES_AUTOHSCROLL
    GROUPBOX        "Vidéo de Sortie.",IDC_STATIC10,7,37,340,26,BS_CENTER
    EDITTEXT        IDC_EDIT_VIDEO_SORTIE,15,45,320,14,ES_AUTOHSCROLL
    GROUPBOX        "Méthode de convertion de la Vidéo.",IDC_STATIC11,7,67,340,49,BS_CENTER
    COMBOBOX        IDC_COMPRESSEUR,16,86,321,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
    LTEXT           "Choix d'un compresseur.",IDC_STATIC12,19,75,80,8
    CONTROL         "Enregistrer la bande sonore à l'interieure de la Vidéo.",IDC_CHECK_SAVE_AUDIO,
                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,104,185,10
    CONTROL         "",IDC_PROGRESS_CONVERTION,"msctls_progress32",WS_BORDER,7,149,340,14
    PUSHBUTTON      "Démarrer la Convertion.",IDC_START_COMPRESSION,132,118,90,14
    LTEXT           "",IDC_INFO_CONVERTION,7,138,340,8
    GROUPBOX        "Vérification des Vidéos.",IDC_STATIC13,7,168,340,172,BS_CENTER
    CONTROL         "",IDC_ECRAN,"Static",SS_BLACKRECT,15,180,325,131
    PUSHBUTTON      "Lire Fichier d'entrée.",IDC_PLAY_INPUT_FILE,15,316,90,20
    PUSHBUTTON      "Stopper la lecture",IDC_STOP,133,316,90,20
    PUSHBUTTON      "Lire Fichier de Sortie.",IDC_PLAY_OUTPUT_FILE,250,316,90,20
END

IDD_FILM_TO_FRAMES DIALOGEX 0, 0, 350, 181
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    GROUPBOX        "Sélection du film à déompiler en images.",IDC_STATIC14,7,7,336,30,BS_CENTER
    PUSHBUTTON      "Parcourir",IDC_PARCOURIR_FILM_A_DECOMPILER,15,17,50,14
    EDITTEXT        IDC_EDIT_FILM_A_DECOMPILER,70,17,265,14,ES_AUTOHSCROLL
    GROUPBOX        "Informations sur la Vidéo.",IDC_STATIC15,7,40,336,73,BS_CENTER
    GROUPBOX        "Répertoire de destination des Images.",IDC_STATIC16,7,119,336,30,BS_CENTER
    PUSHBUTTON      "Parcourir",IDC_PARCOURIR_DEST_IMAGES,15,129,50,14
    EDITTEXT        IDC_EDIT_DEST_IMAGES,70,129,265,14,ES_AUTOHSCROLL
    PUSHBUTTON      "Extraction des Images",IDC_EXTRAIRE_IMAGES,135,154,80,20
    LTEXT           "Dimensions de la Vidéo :",IDC_STATIC17,15,50,78,8
    LTEXT           "0000",IDC_LARGEUR_VIDEO,96,50,16,8
    LTEXT           "x",IDC_STATIC18,116,50,8,8
    LTEXT           "0000",IDC_HAUTEUR_VIDEO,128,50,17,8
    LTEXT           "Nombre d' Images :",IDC_STATIC19,15,65,63,8
    LTEXT           "000000",IDC_NOMBRE_IMAGES,82,65,25,8
    LTEXT           "Taux de transfert maximal :",IDC_STATIC20,15,80,90,8
    LTEXT           "000000",IDC_TAUX_TRANSFERT,109,80,25,8
    LTEXT           "Bits par seconde.",IDC_STATIC21,139,80,56,8
    LTEXT           "Images par Seconde :",IDC_STATIC22,17,95,71,8
    LTEXT           "00",IDC_IMAGES_PAR_SECONDE,92,95,9,8
    LTEXT           "Flux Vidéo :",IDC_STATIC23,200,65,38,8
    LTEXT           "Aucun",IDC_FLUX_VIDEO,242,65,90,8
    LTEXT           "Type de Fichier :",IDC_STATIC24,200,80,54,8
    LTEXT           "Aucun",IDC_TYPE_FICHIER,258,80,75,8
END


/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040c04e4"
        BEGIN
            VALUE "CompanyName", "SHADOWS Productions"
            VALUE "FileDescription", "Générateur de Film"
            VALUE "FileVersion", "1.0.0.1"
            VALUE "InternalName", "Cinema Movie Maker.exe"
            VALUE "LegalCopyright", "(c) Shadows Productions. Tous droits réservés."
            VALUE "OriginalFilename", "Cinema Movie Maker.exe"
            VALUE "ProductName", "Cinema Movie Maker"
            VALUE "ProductVersion", "1.0.0.1"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x40c, 1252
    END
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
    IDD_ABOUTBOX, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 228
        TOPMARGIN, 7
        BOTTOMMARGIN, 48
    END

    IDD_CINEMAMOVIEMAKER_DIALOG, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 533
        TOPMARGIN, 7
        BOTTOMMARGIN, 451
    END

    IDD_FRAMES_TO_FILM, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 303
        TOPMARGIN, 7
        BOTTOMMARGIN, 353
    END

    IDD_CONVERT_FILM_TO_AVI, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 347
        TOPMARGIN, 7
        BOTTOMMARGIN, 340
    END

    IDD_FILM_TO_FRAMES, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 343
        TOPMARGIN, 7
        BOTTOMMARGIN, 174
    END
END
#endif    // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// RT_MANIFEST
//

1                       RT_MANIFEST             "C:\\Documents and Settings\\JANISZEWSKI\\Mes documents\\Visual Studio 2005\\Projects\\Cinema Movie Maker\\res\\Cinema Movie Maker.exe.manifest"

/////////////////////////////////////////////////////////////////////////////
//
// String Table
//

STRINGTABLE
BEGIN
    IDS_ABOUTBOX            "&À propos de Cinema Movie Maker..."
END

#endif    // French (France) resources
/////////////////////////////////////////////////////////////////////////////

#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
LANGUAGE 12, 1
#pragma code_page(1252)
#include "res\CinemaMovieMaker.rc2"  // ressources non modifiées par Microsoft Visual C++
#include "afxres.rc"     // Composants standard
#endif

/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

FICHIER resource.h

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Cinema Movie Maker.rc
//
#define IDM_ABOUTBOX                    0x0010
#define IDD_ABOUTBOX                    100
#define IDS_ABOUTBOX                    101
#define IDD_CINEMAMOVIEMAKER_DIALOG     102
#define IDR_MAINFRAME                   128
#define IDD_FRAMES_TO_FILM              129
#define IDD_CONVERT_FILM_TO_AVI         130
#define IDD_FILM_TO_FRAMES              137
#define IDC_TAB_CINEMA_MOVIE_MAKER      1000
#define IDC_EDIT_IMAGES_A_AJOUTER       1001
#define IDC_LIST_IMAGES_A_AJOUTER       1002
#define IDC_PARCOURIR_IMAGES            1003
#define IDC_PARCOURIR_SON               1004
#define IDC_EDIT_SON_A_AJOUTER          1005
#define IDC_PARCOURIR_VIDEO             1006
#define IDC_EDIT_VIDEO_A_CREER          1007
#define IDC_CHECKCOMPRESS_VIDEO         1008
#define IDC_EDIT_WAIT_BETWEEN_IMAGES    1009
#define IDC_CREER_LE_FILM               1010
#define IDC_STATIC1                     1011
#define IDC_STATIC2                     1012
#define IDC_STATIC3                     1013
#define IDC_STATIC4                     1014
#define IDC_STATIC5                     1015
#define IDC_NB_IMAGES_LISTE             1016
#define IDC_STATIC6                     1017
#define IDC_STATIC7                     1018
#define IDC_RADIO_BMP                   1019
#define IDC_RADIO_JPG                   1020
#define IDC_RADIO_PNG                   1021
#define IDC_RADIO_JPEG                  1022
#define IDC_PROGRESS_CREATION           1023
#define IDC_INFO                        1024
#define IDC_STATIC8                     1026
#define IDC_STATIC9                     1027
#define IDC_STATIC10                    1028
#define IDC_PARCOURIR_VIDEO_ENTREE      1029
#define IDC_EDIT_VIDEO_ENTREE           1030
#define IDC_STATIC11                    1031
#define IDC_EDIT_VIDEO_SORTIE           1032
#define IDC_STATIC12                    1033
#define IDC_COMPRESSEUR                 1034
#define IDC_STATIC13                    1035
#define IDC_CHECK_SAVE_AUDIO            1036
#define IDC_PROGRESS_CONVERTION         1037
#define IDC_START_COMPRESSION           1038
#define IDC_INFO_CONVERTION             1039
#define IDC_ECRAN                       1040
#define IDC_PLAY_INPUT_FILE             1041
#define IDC_STOP                        1042
#define IDC_PLAY_OUTPUT_FILE            1043
#define IDC_PARCOURIR_FILM_A_DECOMPILER 1044
#define IDC_EDIT_FILM_A_DECOMPILER      1045
#define IDC_STATIC14                    1046
#define IDC_STATIC15                    1047
#define IDC_STATIC16                    1048
#define IDC_PARCOURIR_DEST_IMAGES       1049
#define IDC_EDIT_DEST_IMAGES            1050
#define IDC_EXTRAIRE_IMAGES             1051
#define IDC_STATIC17                    1052
#define IDC_LARGEUR_VIDEO               1053
#define IDC_STATIC18                    1054
#define IDC_HAUTEUR_VIDEO               1055
#define IDC_STATIC19                    1056
#define IDC_NOMBRE_IMAGES               1057
#define IDC_STATIC20                    1058
#define IDC_TAUX_TRANSFERT              1059
#define IDC_STATIC21                    1060
#define IDC_STATIC22                    1061
#define IDC_IMAGES_PAR_SECONDE          1062
#define IDC_STATIC23                    1063
#define IDC_FLUX_VIDEO                  1064
#define IDC_STATIC24                    1065
#define IDC_TYPE_FICHIER                1066
#define IDC_AVANCEMENT_IMG_EN_COURS     1074
#define IDC_PROGRESS_AJOUT_IMAGE     1075

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        138
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1076
#define _APS_NEXT_SYMED_VALUE           105
#endif
#endif

Fichier PathDialog.h

#if !defined(AFX_PATHDIALOG_H__0F70BC86_11DB_11D4_B012_0000E8DD8DAA__INCLUDED_)
#define AFX_PATHDIALOG_H__0F70BC86_11DB_11D4_B012_0000E8DD8DAA__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PathDialog.h : header file
//
#include "shlobj.h"

#pragma warning(disable : 4996)
#pragma warning(disable : 4267)


class CPathDialog;

// CPathDialogSub - intercepts messages from child controls
class CPathDialogSub : public CWnd
{
 friend CPathDialog;
public:
 CPathDialog* m_pPathDialog;
protected:
    afx_msg void OnOK();              // OK button clicked
 afx_msg void OnChangeEditPath();
    DECLARE_MESSAGE_MAP()
private:
};

/////////////////////////////////////////////////////////////////////////////
// CPathDialog dialog

class CPathDialog
{
 friend CPathDialogSub;
// Construction
public:
 CPathDialog(LPCTSTR lpszCaption=NULL,
  LPCTSTR lpszTitle=NULL,
  LPCTSTR lpszInitialPath=NULL,
  CWnd* pParent = NULL);

 CString GetPathName();
 virtual int DoModal();

 static int Touch(LPCTSTR lpPath, BOOL bValidate=TRUE);
 static int MakeSurePathExists(LPCTSTR lpPath);
 static BOOL IsFileNameValid(LPCTSTR lpFileName);
 static int ConcatPath(LPTSTR lpRoot, LPCTSTR lpMorePath);

private:
 static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lParam, LPARAM pData);

 LPCTSTR m_lpszCaption;
 LPCTSTR m_lpszInitialPath;

 TCHAR m_szPathName[MAX_PATH];

 BROWSEINFO m_bi;
 HWND m_hWnd;
 CWnd* m_pParentWnd;
 BOOL m_bParentDisabled;
 BOOL m_bGetSuccess;

 CPathDialogSub m_PathDialogSub;

};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_PATHDIALOG_H__0F70BC86_11DB_11D4_B012_0000E8DD8DAA__INCLUDED_)

Fichier PathDialog.cpp

#include "stdafx.h"
#include "PathDialog.h"
#include <io.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define IDC_FOLDERTREE  0x3741
#define IDC_TITLE   0x3742
#define IDC_STATUSTEXT  0x3743

#define IDC_NEW_EDIT_PATH 0x3744

// Class CDlgWnd
BEGIN_MESSAGE_MAP(CPathDialogSub, CWnd)
        ON_BN_CLICKED(IDOK, OnOK)
  ON_EN_CHANGE(IDC_NEW_EDIT_PATH, OnChangeEditPath)
END_MESSAGE_MAP()

void CPathDialogSub::OnOK()
{
 ::GetWindowText(::GetDlgItem(m_hWnd, IDC_NEW_EDIT_PATH),
  m_pPathDialog->m_szPathName, MAX_PATH);

 if(CPathDialog::MakeSurePathExists(m_pPathDialog->m_szPathName)==0)
 {
  m_pPathDialog->m_bGetSuccess=TRUE;
  ::EndDialog(m_pPathDialog->m_hWnd, IDOK);
 }
 else
 {
  ::SetFocus(::GetDlgItem(m_hWnd, IDC_NEW_EDIT_PATH));
 }
}

void CPathDialogSub::OnChangeEditPath()
{
 ::GetWindowText(::GetDlgItem(m_hWnd, IDC_NEW_EDIT_PATH),
  m_pPathDialog->m_szPathName, MAX_PATH);
 BOOL bEnableOKButton = (_tcslen(m_pPathDialog->m_szPathName)>0);
 SendMessage(BFFM_ENABLEOK, 0, bEnableOKButton);
}
/////////////////////////////////////////////////////////////////////////////
// CPathDialog dialog


CPathDialog::CPathDialog(LPCTSTR lpszCaption,
       LPCTSTR lpszTitle,
       LPCTSTR lpszInitialPath,
       CWnd* pParent)
{
 m_hWnd=NULL;
 m_PathDialogSub.m_pPathDialog= this;
    m_bParentDisabled = FALSE;

    // Get the true parent of the dialog
    m_pParentWnd = CWnd::GetSafeOwner(pParent);

 m_lpszCaption = lpszCaption;
 m_lpszInitialPath = lpszInitialPath;

 memset(&m_bi, 0, sizeof(BROWSEINFO) );
 m_bi.hwndOwner = (m_pParentWnd==NULL)?NULL:m_pParentWnd->GetSafeHwnd();
 m_bi.pszDisplayName = 0;
 m_bi.pidlRoot = 0;
 m_bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
 m_bi.lpfn = BrowseCallbackProc;
 m_bi.lpszTitle = lpszTitle;
}


/////////////////////////////////////////////////////////////////////////////
// CPathDialog message handlers

CString CPathDialog::GetPathName()
{
 return CString(m_szPathName);
}

int CALLBACK CPathDialog::BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lParam, LPARAM pData)
{
 CPathDialog* pDlg = (CPathDialog*)pData;

 switch(uMsg)
 {
 case BFFM_INITIALIZED:
  {
   RECT rc;
   HWND hEdit;
   HFONT hFont;

   pDlg->m_hWnd = hwnd;

   if(pDlg->m_lpszCaption!=NULL)
   {
    ::SetWindowText(hwnd, pDlg->m_lpszCaption);
   }

   VERIFY(pDlg->m_PathDialogSub.SubclassWindow(hwnd));
   ::ShowWindow(::GetDlgItem(hwnd, IDC_STATUSTEXT), SW_HIDE);
   ::GetWindowRect(::GetDlgItem(hwnd, IDC_FOLDERTREE), &rc);
   rc.bottom = rc.top - 4;
   rc.top = rc.bottom - 23;
   ::ScreenToClient(hwnd, (LPPOINT)&rc);
   ::ScreenToClient(hwnd, ((LPPOINT)&rc)+1);
   hEdit = ::CreateWindowEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""),
    WS_CHILD|WS_TABSTOP|WS_VISIBLE|ES_AUTOHSCROLL,
    rc.left, rc.top,
    rc.right-rc.left, rc.bottom-rc.top,
    hwnd, NULL, NULL, NULL);
   ::SetWindowLong(hEdit, GWL_ID, IDC_NEW_EDIT_PATH);
   ::ShowWindow(hEdit, SW_SHOW);

   hFont = (HFONT)::SendMessage(hwnd, WM_GETFONT, 0, 0);
   ::SendMessage(hEdit, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));

   LPCTSTR lpszPath = pDlg->m_lpszInitialPath;
   TCHAR szTemp[MAX_PATH];
   if(lpszPath==NULL)
   {
    ::GetCurrentDirectory(MAX_PATH, szTemp );
    lpszPath = szTemp;
   }
   // WParam is TRUE since you are passing a path.
   // It would be FALSE if you were passing a pidl.
   ::SendMessage(hwnd,BFFM_SETSELECTION,TRUE,
    (LPARAM)lpszPath);
   break;
  }
 case BFFM_SELCHANGED:
  {
   char szSelection[MAX_PATH];
   if(!::SHGetPathFromIDList((LPITEMIDLIST)lParam, szSelection) ||
    szSelection[1]!=':')
   {
    szSelection[0] = '\0';
    ::SendMessage(hwnd, BFFM_ENABLEOK, 0, FALSE);
   }
   else
   {
    ::SendMessage(hwnd, BFFM_ENABLEOK, 0, TRUE);
   }
   ::SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)szSelection);
   ::SetWindowText(::GetDlgItem(hwnd, IDC_NEW_EDIT_PATH), szSelection);
   break;
  }
 default:
  break;
 }
 return 0;
}

 

int CPathDialog::DoModal()
{

 /////////////////////////////////////////////////////////
 TCHAR szPathTemp[MAX_PATH];
    m_bi.lpfn = BrowseCallbackProc;  // address of callback function
    m_bi.lParam = (LPARAM)this;      // pass address of object to callback function
 m_bi.pszDisplayName = szPathTemp;

 LPITEMIDLIST pidl;
 LPMALLOC pMalloc;

 int iResult=-1;
 if(SUCCEEDED(SHGetMalloc(&pMalloc)))
 {
//  if((m_pParentWnd!=NULL) && m_pParentWnd->IsWindowEnabled())
//  {
//    m_pParentWnd->EnableWindow(FALSE);
//    m_bParentDisabled = TRUE;
//  }
  m_bGetSuccess = FALSE;
  pidl = SHBrowseForFolder(&m_bi);
  if (pidl!=NULL)
  {
   //not need do this because OnOK function did
   //bSucceeded = SHGetPathFromIDList(pidl, m_szPathName);
   // In C++:
   pMalloc->Free(pidl);
   //In C:
   //pMalloc->lpVtbl->Free(pMalloc,pidl);
   //pMalloc->lpVtbl->Release(pMalloc);
  }
  if(m_bGetSuccess)
  {
   iResult = IDOK;
  }
  pMalloc->Release();
 }

    if(m_bParentDisabled && (m_pParentWnd!=NULL))
 {
  m_pParentWnd->EnableWindow(TRUE);
 }
    m_bParentDisabled=FALSE;

 return iResult;
}

BOOL CPathDialog::IsFileNameValid(LPCTSTR lpFileName)
{
 if(lpFileName==NULL)
 {
  return FALSE;
 }

 int nLen = _tcslen(lpFileName);
 if(nLen<=0)
 {
  return FALSE;
 }

 //check first char
 switch(lpFileName[0])
 {
 case _T('.'):
 case _T(' '):
 case _T('\t'):
  return FALSE;
 }

 //check last char
 switch(lpFileName[nLen-1])
 {
 case _T('.'):
 case _T(' '):
 case _T('\t'):
  return FALSE;
 }

 //check all
 int i=0;
 while(lpFileName[i]!=0)
 {
  switch(lpFileName[i])
  {
  case _T('\\'):
  case _T('/'):
  case _T(':'):
  case _T('*'):
  case _T('?'):
  case _T('\"'):
  case _T('<'):
  case _T('>'):
  case _T('|'):
   return FALSE;
  }
  i++;
 }


 return TRUE;
}

const TCHAR c_FolderDoesNotExist[] = _T(
  "Le répertoire:\n\n"
  "%s\n\n"
  "n'existe pas. Voulez vous le créer ?");
const TCHAR c_szErrInvalidPath[] = _T(
  "Le répertoire:"
  "\n\n"
  "%s\n\n"
  "est invalide. Recommencez.");
const TCHAR c_szErrCreatePath[] = _T(
  "Le répertoire:"
  "\n\n"
  "%s"
  "\n\nne peut être créer.");

//return -1: user break;
//return 0: no error
//return 1: lpPath is invalid
//return 2: can not create lpPath
int CPathDialog::MakeSurePathExists(LPCTSTR lpPath)
{
 CString strMsg;
 int iRet;
 try
 {
  //validate path
  iRet=Touch(lpPath, TRUE);
  if(iRet!=0)
  {
   throw iRet;
  }

  if(_taccess(lpPath, 0)==0)
  {
   return (int)0;
  }

  strMsg.Format(c_FolderDoesNotExist, lpPath);
  if(AfxMessageBox(strMsg, MB_YESNO|MB_ICONQUESTION) != IDYES)
  {
   return (int)-1;
  }

  //create path
  iRet=Touch(lpPath, FALSE);
  if(iRet!=0)
  {
   throw iRet;
  }

  return 0;
 }
 catch(int nErrCode)
 {
  switch(nErrCode)
  {
  case 1:
   strMsg.Format(c_szErrInvalidPath, lpPath);
   break;
  case 2:
  default:
   strMsg.Format(c_szErrCreatePath, lpPath);
   break;
  }

  AfxMessageBox(strMsg, MB_OK|MB_ICONEXCLAMATION);

 }

 return iRet;
}

//return 0: no error
//return 1: lpPath is invalid
//return 2: lpPath can not be created(bValidate==FALSE)
int CPathDialog::Touch(LPCTSTR lpPath, BOOL bValidate)
{
 if(lpPath==NULL)
 {
  return 1;
 }

 TCHAR szPath[MAX_PATH];
 _tcscpy(szPath, lpPath);
 int nLen = _tcslen(szPath);

 //path must be "x:\..."
 if( ( nLen<3 ) ||
  ( ( szPath[0]<_T('A') || _T('Z')<szPath[0] ) &&
    ( szPath[0]<_T('a') || _T('z')<szPath[0] ) ||
  ( szPath[1]!=_T(':') )||
  ( szPath[2]!=_T('\\') )
  )
   )
 {
  return 1;
 }

 int i;
 if(nLen==3)
 {
  if(!bValidate)
  {
   if(_access(szPath, 0)!=0)
   {
    return 2;
   }
  }
  return 0;
 }

 i = 3;
 BOOL bLastOne=TRUE;
 LPTSTR lpCurrentName;
 while(szPath[i]!=0)
 {
  lpCurrentName = &szPath[i];
  while( (szPath[i]!=0) && (szPath[i]!=_T('\\')) )
  {
   i++;
  }

  bLastOne =(szPath[i]==0);
  szPath[i] = 0;

  if( !IsFileNameValid(lpCurrentName) )
  {
   return 1;
  }

  if(!bValidate)
  {
   CreateDirectory(szPath, NULL);
   if(_taccess(szPath, 0)!=0)
   {
    return 2;
   }
  }

  if(bLastOne)
  {
   break; //it's done
  }
  else
  {
   szPath[i] = _T('\\');
  }

  i++;
 }

 return (bLastOne?0:1);
}

//return 0: ok
//return 1: error
int CPathDialog::ConcatPath(LPTSTR lpRoot, LPCTSTR lpMorePath)
{
 if(lpRoot==NULL)
 {
  return 1;
 }

 int nLen = _tcslen(lpRoot);

 if(nLen<3)
 {
  return 1;
 }

 if(lpMorePath==NULL)
 {
  return 0;
 }

 if(nLen==3)
 {
  _tcscat(lpRoot, lpMorePath);
  return 0;
 }

 _tcscat(lpRoot, _T("\\"));
 _tcscat(lpRoot, lpMorePath);

 return 0;
}

Ficher Film2Frames.h

#pragma once

#include <vfw.h>

#pragma comment(lib, "vfw32.lib")

#pragma warning(disable : 4996)

// CFilm2Frames dialog

class CFilm2Frames : public CDialog
{
 DECLARE_DYNAMIC(CFilm2Frames)

public:
 CFilm2Frames(CWnd* pParent = NULL);   // standard constructor
 virtual ~CFilm2Frames();

// Dialog Data
 enum { IDD = IDD_FILM_TO_FRAMES };
 
 bool ExtractAVIFrames(CString m_sFileName);
 bool CreateBMPFromDIBPointer(LPBYTE pDIB, int iImg);

 CBrush m_whitebrush;

 CString m_sFilm_a_Decompiler;
 CString m_sFolderFrames;
 CString m_info;

 CStatic m_sLargeur;
 CStatic m_sHauteur;
 CStatic m_sNbImages;
 CStatic m_sTauxTransfert;
 CStatic m_sImageParSec;
 CStatic m_sFluxVideo;
 CStatic m_sTypeFichier;
 CEdit m_sEditFrames;

protected:
 virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

 //{{AFX_MSG(CFilm2Frames)
 afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
 virtual BOOL OnInitDialog();
 afx_msg void OnParcourirFilmADecompiler();
 afx_msg bool OnRecuperationInfoVideo(CString m_sFileName);
 afx_msg void OnParcourirFolderFrames();
 afx_msg void OnExtractAVIFrames();
 //}}AFX_MSG

 DECLARE_MESSAGE_MAP()
};

Fichier Film2Frames.cpp

// Film2Frames.cpp : implementation file
//

#include "stdafx.h"
#include "Cinema Movie Maker.h"
#include "Film2Frames.h"


// CFilm2Frames dialog

IMPLEMENT_DYNAMIC(CFilm2Frames, CDialog)

CFilm2Frames::CFilm2Frames(CWnd* pParent /*=NULL*/)
 : CDialog(CFilm2Frames::IDD, pParent)
{
 m_sFolderFrames = _T("Répertoire de destination des Images.");
 m_sFilm_a_Decompiler = _T("Film dont les images seront extraites.");
}

CFilm2Frames::~CFilm2Frames()
{
}

void CFilm2Frames::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);

 DDX_Text(pDX, IDC_EDIT_FILM_A_DECOMPILER, m_sFilm_a_Decompiler);
 DDX_Control(pDX, IDC_LARGEUR_VIDEO, m_sLargeur);
 DDX_Control(pDX, IDC_HAUTEUR_VIDEO, m_sHauteur);
 DDX_Control(pDX, IDC_NOMBRE_IMAGES, m_sNbImages);
 DDX_Control(pDX, IDC_TAUX_TRANSFERT, m_sTauxTransfert);
 DDX_Control(pDX, IDC_IMAGES_PAR_SECONDE, m_sImageParSec);
 DDX_Control(pDX, IDC_FLUX_VIDEO, m_sFluxVideo);
 DDX_Control(pDX, IDC_TYPE_FICHIER, m_sTypeFichier);
 DDX_Text(pDX, IDC_EDIT_DEST_IMAGES, m_sFolderFrames);
 DDX_Control(pDX, IDC_EDIT_DEST_IMAGES, m_sEditFrames);
}


BEGIN_MESSAGE_MAP(CFilm2Frames, CDialog)
 ON_WM_CTLCOLOR()
 ON_BN_CLICKED(IDC_PARCOURIR_FILM_A_DECOMPILER, OnParcourirFilmADecompiler)
 ON_BN_CLICKED(IDC_PARCOURIR_DEST_IMAGES, OnParcourirFolderFrames)
 ON_BN_CLICKED(IDC_EXTRAIRE_IMAGES, OnExtractAVIFrames)
END_MESSAGE_MAP()


// CFilm2Frames message handlers

BOOL CFilm2Frames::OnInitDialog()
{
 CDialog::OnInitDialog();

 m_whitebrush.CreateSolidBrush(RGB(255,255,255));

 return TRUE;
}

HBRUSH CFilm2Frames::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
{
 HBRUSH hbr;

 switch(nCtlColor)
 {
  case CTLCOLOR_DLG:
   return m_whitebrush;

  case CTLCOLOR_STATIC:
  {
   switch(pWnd->GetDlgCtrlID())
   {
    case IDC_STATIC14:
    case IDC_STATIC15:
    case IDC_STATIC16:
    case IDC_STATIC17:
    case IDC_STATIC18:
    case IDC_STATIC19:
    case IDC_STATIC20:
    case IDC_STATIC21:
    case IDC_STATIC22:
    case IDC_STATIC23:
    case IDC_STATIC24:
    {
     pDC->SetTextColor(RGB(0,255,255));
     hbr = (HBRUSH)m_whitebrush;
    }
    break;

    case IDC_LARGEUR_VIDEO:
    case IDC_HAUTEUR_VIDEO:
    case IDC_TAUX_TRANSFERT:
    case IDC_FLUX_VIDEO:
    case IDC_TYPE_FICHIER:
    case IDC_NOMBRE_IMAGES:
    case IDC_IMAGES_PAR_SECONDE:
    {
     pDC->SetTextColor(RGB(255,0,0));
     hbr = (HBRUSH)m_whitebrush;
    }
    break;

    default:
     hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
   }
  }
  break;

  default:
   hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
 }

 return hbr;
}

void CFilm2Frames::OnParcourirFilmADecompiler()
{
 CFileDialog dlg(TRUE, 0, 0, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST,
  "Fichier Audio Vidéo Interleaved (.avi)|*.avi\0\0");

 dlg.m_ofn.lpstrTitle = _T("Nom du Film qui aura l'insigne honneur d'être décompiler...");

 if(dlg.DoModal() == IDOK)
 {
  UpdateData(TRUE);

  m_sFilm_a_Decompiler = dlg.GetPathName();

  UpdateData(FALSE);

  OnRecuperationInfoVideo(m_sFilm_a_Decompiler);
 }
}

bool CFilm2Frames::OnRecuperationInfoVideo(CString m_sFileName)
{
 AVIFileInit();

 PAVIFILE avi;

 int res = AVIFileOpen(&avi, m_sFileName, OF_READ, NULL);

 if(res != AVIERR_OK)
 {
  // Erreur
  if(avi != NULL)
   AVIFileRelease(avi);

  return false;
 }

 // Variable de récupération des données
 AVIFILEINFO m_avi_info;

 AVIFileInfo(avi, &m_avi_info, sizeof(AVIFILEINFO));

 m_info.Format("%d", m_avi_info.dwWidth);
 m_sLargeur.SetWindowText(m_info);

 m_info.Format("%d", m_avi_info.dwHeight);
 m_sHauteur.SetWindowText(m_info);

 m_info.Format("%d", m_avi_info.dwLength);
 m_sNbImages.SetWindowText(m_info);

 m_info.Format("%d", m_avi_info.dwMaxBytesPerSec);
 m_sTauxTransfert.SetWindowText(m_info);

 m_info.Format("%d", ((DWORD)m_avi_info.dwRate / m_avi_info.dwScale));
 m_sImageParSec.SetWindowText(m_info);

 m_info.Format("%d", m_avi_info.dwStreams);
 m_sFluxVideo.SetWindowText(m_info);

 m_info.Format("%s", m_avi_info.szFileType);
 m_sTypeFichier.SetWindowText(m_info);

 return true;
}

#include "PathDialog.h"

void CFilm2Frames::OnParcourirFolderFrames()
{
 CString szPath;
 CString szTitle = _T("Choisissez le dossier de destination qui recevra les images du film.");
 CString szCaption = _T("Répertoire de décompilation du Film");

 CPathDialog dlg(szCaption, szTitle, szPath);

 if(dlg.DoModal() == IDOK)
 {
  UpdateData(TRUE);

  m_sFolderFrames = dlg.GetPathName();

  UpdateData(FALSE);
 }
}

void CFilm2Frames::OnExtractAVIFrames()
{
 ExtractAVIFrames(m_sFilm_a_Decompiler);
}

bool CFilm2Frames::ExtractAVIFrames(CString m_sFileName)
{
 AVIFileInit();

 PAVIFILE avi;

 int res = AVIFileOpen(&avi, m_sFileName, OF_READ, NULL);

 if(res != AVIERR_OK)
 {
  if(avi != NULL)
   AVIFileRelease(avi);

  return false;
 }

 PAVISTREAM pStream;

 res = AVIFileGetStream(avi, &pStream, streamtypeVIDEO, 0);

 if(res != AVIERR_OK)
 {
  if(pStream != NULL)
   AVIStreamRelease(pStream);

  AVIFileExit();

  return false;
 }

 // Variable de récupération d'images;
 // jouons avec le stream
 int iNbImages;
 int iFirstImg;

 iFirstImg = AVIStreamStart(pStream);

 if(iFirstImg == -1)
 {
  // Erreur durant l' "attrapage" de l'image par le stream
  if(pStream != NULL)
   AVIStreamRelease(pStream);

  AVIFileExit();

  return false;
 }

 iNbImages = AVIStreamLength(pStream);

 if(iNbImages == -1)
 {
  // Erreur durant l' "attrapage" du nombre d'images par le stream
  if(pStream != NULL)
   AVIStreamRelease(pStream);

  AVIFileExit();

  return false;
 }

 // Bitmaps à partir de l'image
 BITMAPINFOHEADER bih;
 ZeroMemory(&bih, sizeof(BITMAPINFOHEADER));

 // Paramètres de l'image bitmap
 bih.biBitCount = 24; // 24 bits par pixels
 bih.biClrImportant=0;
    bih.biClrUsed = 0;
    bih.biCompression = BI_RGB;
    bih.biPlanes = 1;
    bih.biSize = 40;
    bih.biXPelsPerMeter = 0;
    bih.biYPelsPerMeter = 0;

 // Calcul de la taille total du RGBQUAD
 bih.biSizeImage = (((bih.biWidth * 3) + 3) & 0xFFFC) * bih.biHeight;

 // Méthode d' "attrapage" d'image
 PGETFRAME pFrame;

 pFrame = AVIStreamGetFrameOpen(pStream, NULL);

 // 1ère Image
 int iIndex = 0;

 for(int i = iFirstImg; i < iNbImages; i++)
 {
  iIndex = i - iFirstImg;

  BYTE* pDIB = static_cast<BYTE*>(AVIStreamGetFrame(pFrame, iIndex));

  CreateBMPFromDIBPointer(pDIB, iIndex);
 }

 AVIStreamGetFrameClose(pFrame);

 // Fermons le stream après la fin de la tâche

 if(pStream != NULL)
  AVIStreamRelease(pStream);

 AVIFileExit();

 return true;
}

bool CFilm2Frames::CreateBMPFromDIBPointer(LPBYTE pDIB, int iImg)
{
 ASSERT(pDIB != NULL); // Il faut impérativement que le pointeur ne soit pas nul.

 BITMAPINFOHEADER bih; // déplaçons le bloc mémoire d'un secteur à un autre
 RtlMoveMemory(&bih.biSize, pDIB, sizeof(BITMAPINFOHEADER));

 // Maintenant, cherchons le nombre de bits de la bitmap
 if(bih.biSizeImage < 1)
 {
  return false;
 }

 BYTE* bits = new BYTE[bih.biSizeImage];

    BYTE memBitmapInfo[40];
    RtlMoveMemory(memBitmapInfo, &bih, sizeof(bih));

    BITMAPFILEHEADER bfh;
    bfh.bfType=19778;    //BM header
    bfh.bfSize=55 + bih.biSizeImage;
    bfh.bfReserved1=0;
    bfh.bfReserved2=0;
    bfh.bfOffBits=sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER); //54

 char szFile[512];
 CString m_sFileName;

 m_sFileName.Format("Image%05d.bmp", iImg);
 m_sEditFrames.GetWindowText(szFile, 512);

 lstrcat(szFile, "\\");
 lstrcat(szFile, m_sFileName);

 FILE* fp;

 fp = fopen(szFile, "wb");

 if(fp != NULL)
 {
  fwrite(&bfh, sizeof(bfh), 1, fp);
  fwrite(&memBitmapInfo, sizeof(memBitmapInfo), 1, fp);
  fwrite(bits, bih.biSizeImage, 1, fp);
  fclose(fp);
 }
 else
 {
  TRACE0("Erreur durant l'écriture du bitmap");
  return false;
 }
 
 delete [] bits;

 return true;
}

Fichier CinemaMovieMakerDlg.h

// Cinema Movie MakerDlg.h : fichier d'en-tête
//

/*#include "Frames2Film.h"
#include "Convertisseur.h"*/
#include "Film2Frames.h"

#pragma once


// boîte de dialogue CCinemaMovieMakerDlg
class CCinemaMovieMakerDlg : public CDialog
{
// Construction
public:
 CCinemaMovieMakerDlg(CWnd* pParent = NULL); // constructeur standard

// Données de boîte de dialogue
 enum { IDD = IDD_CINEMAMOVIEMAKER_DIALOG };

 CTabCtrl m_tabctrl;

 protected:
 virtual void DoDataExchange(CDataExchange* pDX); // Prise en charge de DDX/DDV
 virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);

// Implémentation
protected:
 HICON m_hIcon;

 // Fonctions générées de la table des messages
 virtual BOOL OnInitDialog();
 afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
 afx_msg void OnPaint();
 afx_msg HCURSOR OnQueryDragIcon();
 DECLARE_MESSAGE_MAP()

private:
 void MAJChoix();
 /*CFrames2Film* m_pCF2F;
 CConvertisseur* m_pConvert;*/
 CFilm2Frames* m_pF2F;
};

Fichier CinemaMovieMakerDlg.cpp

// Cinema Movie MakerDlg.cpp : fichier d'implémentation
//

#include "stdafx.h"
#include "Cinema Movie Maker.h"
#include "Cinema Movie MakerDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// boîte de dialogue CAboutDlg utilisée pour la boîte de dialogue 'À propos de' pour votre application

class CAboutDlg : public CDialog
{
public:
 CAboutDlg();

// Données de boîte de dialogue
 enum { IDD = IDD_ABOUTBOX };

 protected:
 virtual void DoDataExchange(CDataExchange* pDX);    // Prise en charge de DDX/DDV

// Implémentation
protected:
 DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// boîte de dialogue CCinemaMovieMakerDlg

CCinemaMovieMakerDlg::CCinemaMovieMakerDlg(CWnd* pParent /*=NULL*/)
 : CDialog(CCinemaMovieMakerDlg::IDD, pParent)
{
 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CCinemaMovieMakerDlg::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);

 DDX_Control(pDX, IDC_TAB_CINEMA_MOVIE_MAKER, m_tabctrl);
}

BEGIN_MESSAGE_MAP(CCinemaMovieMakerDlg, CDialog)
 //{{AFX_MSG_MAP(CCinemaMovieMakerDlg)
 ON_WM_SYSCOMMAND()
 ON_WM_PAINT()
 ON_WM_QUERYDRAGICON()
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()


// gestionnaires de messages pour CCinemaMovieMakerDlg

BOOL CCinemaMovieMakerDlg::OnInitDialog()
{
 CDialog::OnInitDialog();

 // Ajouter l'élément de menu "À propos de..." au menu Système.

 // IDM_ABOUTBOX doit se trouver dans la plage des commandes système.
 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
 ASSERT(IDM_ABOUTBOX < 0xF000);

 CMenu* pSysMenu = GetSystemMenu(FALSE);
 if (pSysMenu != NULL)
 {
  CString strAboutMenu;
  strAboutMenu.LoadString(IDS_ABOUTBOX);
  if (!strAboutMenu.IsEmpty())
  {
   pSysMenu->AppendMenu(MF_SEPARATOR);
   pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  }
 }

 // Définir l'icône de cette boîte de dialogue. L'infrastructure effectue cela automatiquement
 //  lorsque la fenêtre principale de l'application n'est pas une boîte de dialogue
 SetIcon(m_hIcon, TRUE);   // Définir une grande icône
 SetIcon(m_hIcon, FALSE);  // Définir une petite icône

 // TODO : ajoutez ici une initialisation supplémentaire
 m_tabctrl.DeleteAllItems();
 m_tabctrl.InsertItem(0, "Créer un Film.");
 m_tabctrl.InsertItem(1, "Convertir un Film.");
 m_tabctrl.InsertItem(2, "Décompiler une Vidéo.");

/* m_pCF2F = new CFrames2Film(this);
 m_pCF2F->Create(IDD_FRAMES_TO_FILM, this);
 m_pCF2F->ShowWindow(SW_SHOW);

 m_pConvert = new CConvertisseur(this);
 m_pConvert->Create(IDD_CONVERT_FILM_TO_AVI, this);
 m_pConvert->ShowWindow(SW_HIDE);*/

 m_pF2F = new CFilm2Frames(this);
 m_pF2F->Create(IDD_FILM_TO_FRAMES, this);
 m_pF2F->ShowWindow(SW_HIDE);
 {
  CRect rcTabCtrl;
  m_tabctrl.GetWindowRect(&rcTabCtrl);
  m_tabctrl.SendMessage(TCM_ADJUSTRECT, FALSE, (LPARAM)&rcTabCtrl);
  m_tabctrl.MapWindowPoints(this, (LPPOINT)&rcTabCtrl, 2);

  CRect rcChildTab[3];
/*  m_pCF2F->GetWindowRect(&rcChildTab[0]);
  m_pConvert->GetWindowRect(&rcChildTab[1]);*/
  m_pF2F->GetWindowRect(&rcChildTab[2]);

  ScreenToClient(&rcTabCtrl);

/*  int x0 = (rcTabCtrl.left + rcTabCtrl.right) / 2 - (rcChildTab[0].right - rcChildTab[0].left) / 2;
  int y0 = (rcTabCtrl.top + rcTabCtrl.bottom) / 2 - (rcChildTab[0].bottom - rcChildTab[0].top) / 2;

  int x1 = (rcTabCtrl.left + rcTabCtrl.right) / 2 - (rcChildTab[1].right - rcChildTab[1].left) / 2;
  int y1 = (rcTabCtrl.top + rcTabCtrl.bottom) / 2 - (rcChildTab[1].bottom - rcChildTab[1].top) / 2;*/

  int x2 = (rcTabCtrl.left + rcTabCtrl.right) / 2 - (rcChildTab[2].right - rcChildTab[2].left) / 2;
  int y2 = (rcTabCtrl.top + rcTabCtrl.bottom) / 2 - (rcChildTab[2].bottom - rcChildTab[2].top) / 2;

 /* m_pCF2F->SetWindowPos(NULL, x0, y0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOREDRAW);
  m_pConvert->SetWindowPos(NULL, x1, y1, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOREDRAW);*/
  m_pF2F->SetWindowPos(NULL, x2, y2, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOREDRAW);
 }

 m_tabctrl.SetCurSel(0);
/* m_pCF2F->ShowWindow(SW_SHOW);*/

 return TRUE;  // retourne TRUE, sauf si vous avez défini le focus sur un contrôle
}

void CCinemaMovieMakerDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
 if ((nID & 0xFFF0) == IDM_ABOUTBOX)
 {
  CAboutDlg dlgAbout;
  dlgAbout.DoModal();
 }
 else
 {
  CDialog::OnSysCommand(nID, lParam);
 }
}

// Si vous ajoutez un bouton Réduire à votre boîte de dialogue, vous devez utiliser le code ci-dessous
//  pour dessiner l'icône. Pour les applications MFC utilisant le modèle Document/Vue,
//  cela est fait automatiquement par l'infrastructure.

void CCinemaMovieMakerDlg::OnPaint()
{
 if (IsIconic())
 {
  CPaintDC dc(this); // contexte de périphérique pour la peinture

  SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

  // Centrer l'icône dans le rectangle client
  int cxIcon = GetSystemMetrics(SM_CXICON);
  int cyIcon = GetSystemMetrics(SM_CYICON);
  CRect rect;
  GetClientRect(&rect);
  int x = (rect.Width() - cxIcon + 1) / 2;
  int y = (rect.Height() - cyIcon + 1) / 2;

  // Dessiner l'icône
  dc.DrawIcon(x, y, m_hIcon);
 }
 else
 {
  CDialog::OnPaint();
 }
}

// Le système appelle cette fonction pour obtenir le curseur à afficher lorsque l'utilisateur fait glisser
//  la fenêtre réduite.
HCURSOR CCinemaMovieMakerDlg::OnQueryDragIcon()
{
 return static_cast<HCURSOR>(m_hIcon);
}

BOOL CCinemaMovieMakerDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT *pResult)
{
 if(wParam == IDC_TAB_CINEMA_MOVIE_MAKER)
 {
  NMHDR* plomp = (NMHDR*)lParam;

  if(plomp->code = TCN_SELCHANGE)
   MAJChoix();
 }

 return CDialog::OnNotify(wParam, lParam, pResult);
}

void CCinemaMovieMakerDlg::MAJChoix()
{
 UpdateData(true);

 int iTraitement = m_tabctrl.GetCurSel();

/* m_pCF2F->ShowWindow(iTraitement == 0 ? SW_SHOW : SW_HIDE);
 m_pConvert->ShowWindow(iTraitement == 1 ? SW_SHOW : SW_HIDE);*/
 m_pF2F->ShowWindow(iTraitement == 2 ? SW_SHOW : SW_HIDE);

 UpdateData(false);
}

Voilà, y'a plus qu'créer le projet CinemaMovieMaker en utilisant le MFC, si je vous ai donné tout ce code c'est pour bien évidemment voir de quel bug il s'agit, ce sera peut être plus simple de le trouver en construisant l'exe que de vous donner la partie du code où il y'a le problème...

jeudi 18 août 2005 à 15:04:59 | Re : Où est ce #!?\ de bug ? (projet MFC)

neodelphi

Membre Club

1358 lignes de code à débugger pour toi... il faut juste quelques heures pour digérer les pages. Tu crois pas que c'est un peu exagéré (juste un peu) ?

On est sur un forum et ce genre de messages personne ne prendra le temps de le lire, parcequ'on à autre chose à faire et on préfère aider les gens qui ont déjà cherché un minimum avant de poser leur problème, d'autant plus qu'à juger la taille du source et du problème mis en avant tu ne doit pas être débutant ! Tu veux peut-être que l'on coupe aussi ta viande avant de la manger ?


neodelphi

jeudi 18 août 2005 à 15:09:56 | Re : Où est ce #!?\ de bug ? (projet MFC)

MasterShadows

Non, non t'as pas saisi ce que j'ai fait : je sais qu'il y'a un bug dans l'une de ces lignes (au niveau de la bitmap) mais j'arrive pas à le trouver (3 semaines que je cherche et y'a pas moyen) :

bool CFilm2Frames::ExtractAVIFrames(CString m_sFileName)
{
 AVIFileInit();

 PAVIFILE avi;

 int res = AVIFileOpen(&avi, m_sFileName, OF_READ, NULL);

 if(res != AVIERR_OK)
 {
  if(avi != NULL)
   AVIFileRelease(avi);

  return false;
 }

 PAVISTREAM pStream;

 res = AVIFileGetStream(avi, &pStream, streamtypeVIDEO, 0);

 if(res != AVIERR_OK)
 {
  if(pStream != NULL)
   AVIStreamRelease(pStream);

  AVIFileExit();

  return false;
 }

 // Variable de récupération d'images;
 // jouons avec le stream
 int iNbImages;
 int iFirstImg;

 iFirstImg = AVIStreamStart(pStream);

 if(iFirstImg == -1)
 {
  // Erreur durant l' "attrapage" de l'image par le stream
  if(pStream != NULL)
   AVIStreamRelease(pStream);

  AVIFileExit();

  return false;
 }

 iNbImages = AVIStreamLength(pStream);

 if(iNbImages == -1)
 {
  // Erreur durant l' "attrapage" du nombre d'images par le stream
  if(pStream != NULL)
   AVIStreamRelease(pStream);

  AVIFileExit();

  return false;
 }

 // Bitmaps à partir de l'image
 BITMAPINFOHEADER bih;
 ZeroMemory(&bih, sizeof(BITMAPINFOHEADER));

 // Paramètres de l'image bitmap
 bih.biBitCount = 24; // 24 bits par pixels
 bih.biClrImportant=0;
    bih.biClrUsed = 0;
    bih.biCompression = BI_RGB;
    bih.biPlanes = 1;
    bih.biSize = 40;
    bih.biXPelsPerMeter = 0;
    bih.biYPelsPerMeter = 0;

 // Calcul de la taille total du RGBQUAD
 bih.biSizeImage = (((bih.biWidth * 3) + 3) & 0xFFFC) * bih.biHeight;

 // Méthode d' "attrapage" d'image
 PGETFRAME pFrame;

 pFrame = AVIStreamGetFrameOpen(pStream, NULL);

 // 1ère Image
 int iIndex = 0;

 for(int i = iFirstImg; i < iNbImages; i++)
 {
  iIndex = i - iFirstImg;

  BYTE* pDIB = static_cast<BYTE*>(AVIStreamGetFrame(pFrame, iIndex));

  CreateBMPFromDIBPointer(pDIB, iIndex);
 }

 AVIStreamGetFrameClose(pFrame);

 // Fermons le stream après la fin de la tâche

 if(pStream != NULL)
  AVIStreamRelease(pStream);

 AVIFileExit();

 return true;
}

bool CFilm2Frames::CreateBMPFromDIBPointer(LPBYTE pDIB, int iImg)
{
 ASSERT(pDIB != NULL); // Il faut impérativement que le pointeur ne soit pas nul.

 BITMAPINFOHEADER bih; // déplaçons le bloc mémoire d'un secteur à un autre
 RtlMoveMemory(&bih.biSize, pDIB, sizeof(BITMAPINFOHEADER));

 // Maintenant, cherchons le nombre de bits de la bitmap
 if(bih.biSizeImage < 1)
 {
  return false;
 }

 BYTE* bits = new BYTE[bih.biSizeImage];

    BYTE memBitmapInfo[40];
    RtlMoveMemory(memBitmapInfo, &bih, sizeof(bih));

    BITMAPFILEHEADER bfh;
    bfh.bfType=19778;    //BM header
    bfh.bfSize=55 + bih.biSizeImage;
    bfh.bfReserved1=0;
    bfh.bfReserved2=0;
    bfh.bfOffBits=sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER); //54

 char szFile[512];
 CString m_sFileName;

 m_sFileName.Format("Image%05d.bmp", iImg);
 m_sEditFrames.GetWindowText(szFile, 512);

 lstrcat(szFile, "\\");
 lstrcat(szFile, m_sFileName);

 FILE* fp;

 fp = fopen(szFile, "wb");

 if(fp != NULL)
 {
  fwrite(&bfh, sizeof(bfh), 1, fp);
  fwrite(&memBitmapInfo, sizeof(memBitmapInfo), 1, fp);
  fwrite(bits, bih.biSizeImage, 1, fp);
  fclose(fp);
 }
 else
 {
  TRACE0("Erreur durant l'écriture du bitmap");
  return false;
 }
 
 delete [] bits;

 return true;
}

mais si j'ai mis toutes ces lignes de codes, c'est pour que ceux qui veulent compiler le code pour bien voir le problème ne se cassent pas la tête à réécrire tout un programme avec ce le bug qu'il y' au dessus

jeudi 18 août 2005 à 15:12:56 | Re : Où est ce #!?\ de bug ? (projet MFC)

xterminhate

Membre Club
Tu as une variable qui n'est pas correctement initialisée. Je te laisse la trouver.
jeudi 18 août 2005 à 17:11:19 | Re : Où est ce #!?\ de bug ? (projet MFC)

MasterShadows

Ah, donc l'erreur serait une variable qui ne s'initialise pas correctement ???

Honnêtement, je pensais que l'erreur venait de la variable

jeudi 18 août 2005 à 17:16:21 | Re : Où est ce #!?\ de bug ? (projet MFC)

MasterShadows

Désolé, mon pc à claquer une quiche.

J'recommence le truc :

Ah, donc l'erreur serait une variable qui ne s'initialise pas correctement ???

Honnêtement, je pensais que l'erreur venait de la variable memBitmapInfo, car en fonction de la valeur que je lui fixe, j'obtient des bitmaps différentes (vertes, bleues, striés de moults couleurs...)

Bon, j'ai plus qu'à faire une batterie de test parce que VS2005 béta 2, ben il aime pas débuggué avec une platforme 64 bits...

Bon, j'y retourne

Merci à toi xterminhate de m'avoir dit que c'était une variable mal initialisée, parce que franchement, je m'étais demandé si le code entier gérant la bitmap était faux (car c'est la première fois que je traite la bitmap comme ça, alors forcément, même en ayant fait moultes recherches, je ne pensais pas à une bête variable mal initialisé, mais à une erreur de structuration de code complète..)

jeudi 18 août 2005 à 17:30:00 | Re : Où est ce #!?\ de bug ? (projet MFC)

MasterShadows

J'ai trouvé une partie de l'erreur :

effectivement, j'ai écris :

BYTE* bits = new BYTE[bih.biSizeImage];

    BYTE memBitmapInfo[40];
    RtlMoveMemory(memBitmapInfo, &bih, sizeof(bih));

alors que j'aurais du écrire :

BYTE* bits = new BYTE[bih.biSizeImage];
RtlMoveMemory(bits, pDIB + sizeof(BITMAPINFOHEADER), bih.biSizeImage);

BYTE memBitmapInfo[40];
RtlMoveMemory(memBitmapInfo, &bih, sizeof(bih));

J'ai dit une partie car maintenant, j'ai bien la bitmap voulu à part que la bitmap est scindé en son milieu et la partie droite de la bitmap se trouve à gauche et la partie de gauche se trouve à sa droite

jeudi 18 août 2005 à 18:09:36 | Re : Où est ce #!?\ de bug ? (projet MFC)

xterminhate

Membre Club
J'ai dit ça au hazard, ma réponse était ironique.

Cordialement,
Xterminhate.
jeudi 18 août 2005 à 18:34:02 | Re : Où est ce #!?\ de bug ? (projet MFC)

MasterShadows

Meme si ta réponse était ironique, (sans dec, j'pensais que t'étais sérieux), néanmoins j'ai trouvé l'erreur, il ne me reste donc qu'à trouvé pour j'ai cette p*** d'erreur d'offset sur les images.

Donc en fait l'erreur est sur ce petit bout de programme :

bool CFilm2Frames::CreateBMPFromDIBPointer(LPBYTE pDIB, int iImg)
{
 ASSERT(pDIB != NULL); // Il faut impérativement que le pointeur ne soit pas nul.

 BITMAPINFOHEADER bih; // déplaçons le bloc mémoire d'un secteur à un autre
 RtlMoveMemory(&bih.biSize, pDIB, sizeof(BITMAPINFOHEADER));

 // Maintenant, cherchons le nombre de bits de la bitmap
 if(bih.biSizeImage < 1)
 {
  return false;
 }

 BYTE* bits = new BYTE[bih.biSizeImage];
RtlMoveMemory(bits, pDIB + sizeof(BITMAPINFOHEADER), bih.biSizeImage); 

   BYTE memBitmapInfo[40];
    RtlMoveMemory(memBitmapInfo, &bih, sizeof(bih));

    BITMAPFILEHEADER bfh;
    bfh.bfType=19778;    //BM header
    bfh.bfSize=55 + bih.biSizeImage;
    bfh.bfReserved1=0;
    bfh.bfReserved2=0;
    bfh.bfOffBits=sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER); //54

 char szFile[512];
 CString m_sFileName;

 m_sFileName.Format("Image%05d.bmp", iImg);
 m_sEditFrames.GetWindowText(szFile, 512);

 lstrcat(szFile, "\\");
 lstrcat(szFile, m_sFileName);

 FILE* fp;

 fp = fopen(szFile, "wb");

 if(fp != NULL)
 {
  fwrite(&bfh, sizeof(bfh), 1, fp);
  fwrite(&memBitmapInfo, sizeof(memBitmapInfo), 1, fp);
  fwrite(bits, bih.biSizeImage, 1, fp);
  fclose(fp);
 }
 else
 {
  TRACE0("Erreur durant l'écriture du bitmap");
  return false;
 }
 
 delete [] bits;

 return true;
}



Cette discussion est classée dans : images, case, return, idc, define


Répondre à ce message

Sujets en rapport avec ce message

Pb de changement de curseur (SetClassLong) [ par AlexMAN ] Voila, J'essaye de changer le curseur lorsk l'utilisateur survole un controle static, j'utilise (a linstar de BruNews) la fonction SetClassLong mais c Ecrir du texte dans un Edit [ par XKaliBur ] Voila avec ce code ça ecrit le texte dans EDIT1 mais le problème c'est que ça efface se qu'il y avait avant or je voudrais faire en sorte qu'il écirve Ré-initialiser un programme avec socket [ par malik7934 ] socket ... tu auras ma peau!Hello! C'est moi la maxi- pine des sockets!Voici mon x'ème problème: dans mon prog, lorsque je clique sur un bouton (IDC_L objet non initialisé (API Win32) [ par Xs ] salut !voici mon code, d'abord :#include #include #include "resource.h"LRESULT CALLBACK DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam){cha ChooseColor bloqué ? [ par NeKoF ] Salut tous le monde !J'ai un gros soucis ma boite de dialogJe vous explique :Dans ma boite de configuration, je souhaite sélectionner une couleur en c petite question sur les message [ par LordBob ] bonjour a tous,voila mon code est structuré comme ca:BOOL CALLBACK Dialog(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){switch(msg){case WM_INI Hep Hep Hep [ par Joky ] Salut les gens :pPtit Pb, me lancer pas de cailloux s'il vous plait ;)Bon me lance dans vc++ 6.0 win32jdéfinie tout mes controle de fenetreIDC_EDIT et probleme de menu [ par Stubbornman ] Bonsoir a tous,J'ai un soucis avec des menus. Je souhaite creer des fenetres filles qui ont chacune un menu. Or je n'arrive pas a afficher les menus d [vc++]Plusieurs boite de dialogues [ par shadow1779 ] Bonjour,mon probleme est avec visual c++ en C, si je fais plusieurs dialogbox avec l'editeur de ressource, le probleme est que quand j'en appel plusie PROBLEME DE CHARGEMENT JPEG DANS UN ECRAN DE VEILLE [ par Batman60 ] bonjourclic droit sur l'exe et puis "tester" le prog fonctionne à merveille mais une fois installé à l'execution de l'ecran de veille les textures jpe


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

Photothèque

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,655 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales