IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MFC Discussion :

Comment cree une boite de dialogue parcourir [FAQ]


Sujet :

MFC

  1. #1
    Membre à l'essai
    Inscrit en
    Décembre 2002
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Décembre 2002
    Messages : 18
    Points : 14
    Points
    14
    Par défaut Comment cree une boite de dialogue parcourir
    Je cherche un moyen de creer une boite de dialogue parcourir ou juste le treewiev avec la liste des dossier de mon disque :

    Je sais qu'il exixte une classe la CDialogFile pour les fichiers je cherche la meme chose pour les repertoires merci

  2. #2
    Futur Membre du Club
    Inscrit en
    Juin 2002
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Juin 2002
    Messages : 4
    Points : 5
    Points
    5
    Par défaut
    LPITEMIDLIST SHBrowseForFolder(
    LPBROWSEINFO lpbi
    );

    voir sur MSDN pour la documentation complète.

  3. #3
    Membre habitué
    Inscrit en
    Avril 2002
    Messages
    180
    Détails du profil
    Informations forums :
    Inscription : Avril 2002
    Messages : 180
    Points : 157
    Points
    157
    Par défaut
    Salut Voici un bout ce code qui fait le bouleau er retien le chemin du repertoire selectioner
    la variable CString strTmpPath; est global

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
     
    void CInitControl::OnBrowse() 
    {
    	// TODO: Add your control notification handler code here
    	CString strFolderPath;
    	GetFolder(&strFolderPath, "Sample of  getting folder.", this->m_hWnd, NULL, NULL);
    	CEdit *experiment=(CEdit*)GetDlgItem(IDC_EXPERIMENT);
    	experiment->SetWindowText(strFolderPath);
    }
     
    void CInitControl::GetFolder(CString *strSelectedFolder, const char *lpszTitle, const HWND hwndOwner, const char *strRootFolder, const char *strStartFolder)
    {
    	char pszDisplayName[MAX_PATH];
    	LPITEMIDLIST lpID;
    	BROWSEINFOA bi;
     
    	bi.hwndOwner = hwndOwner;
    	if (strRootFolder == NULL)
    	{
    		bi.pidlRoot = NULL;
    	}
    	else
    	{
    	   LPITEMIDLIST  pIdl = NULL;
    	   IShellFolder* pDesktopFolder;
    	   char          szPath[MAX_PATH];
    	   OLECHAR       olePath[MAX_PATH];
    	   ULONG         chEaten;
    	   ULONG         dwAttributes;
     
    	   strcpy(szPath, (LPCTSTR)strRootFolder);
    	   if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))
    	   {
    		   MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szPath, -1, olePath, MAX_PATH);
    		   pDesktopFolder->ParseDisplayName(NULL, NULL, olePath, &chEaten, &pIdl, &dwAttributes);
    		   pDesktopFolder->Release();
    	   }
    	   bi.pidlRoot = pIdl;
    	}
    	bi.pszDisplayName = pszDisplayName;
    	bi.lpszTitle = lpszTitle;
    	bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
    	bi.lpfn = 0;
    	if (strStartFolder == NULL)
    	{
    		bi.lParam = FALSE;
    	}
    	else
    	{
    		strTmpPath.Format("%s", strStartFolder);
    		bi.lParam = TRUE;
    	}
    	bi.iImage = NULL;
    	lpID = SHBrowseForFolderA(&bi);
    	if (lpID != NULL){
    		BOOL b = SHGetPathFromIDList(lpID, pszDisplayName);
    		if (b == TRUE)
    		{
    			strSelectedFolder->Format("%s",pszDisplayName);
    		}
    	}
    	else
    	{
    		strSelectedFolder->Empty();
    	}
    }
    Ce bout de code fonctionne bien
    ne en moin il contien un probleme d'initialisation de parametre ces pas bien grave et ca ne beure pas de memoire, le message retourner par Rational purified est:
    A PAR message indicates that the program called a Win32API or C run-time routine, such as write(), with a bad parameter.
    [W] PAR: Both Debug and non-Debug versions of CRT are active; This may cause CRT heap operations to fail. {1 occurrence}
    Call location
    FindResourceExW [KERNEL32.dll]
    OpenComponentLibraryOnMemEx [CLBCATQ.DLL]
    OpenComponentLibraryOnMemEx [CLBCATQ.DLL]
    RtlCharToInteger [ntdll.dll]
    RtlCharToInteger [ntdll.dll]
    LdrLoadDll [ntdll.dll]
    LoadLibraryExA [KERNEL32.dll]
    LoadLibraryA [KERNEL32.dll]
    CLSIDFromOle1Class [ole32.DLL]
    CoTaskMemRealloc [ole32.DLL]
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
     
    J'espere que ca va t'aider
        ALP

  4. #4
    Membre habitué
    Inscrit en
    Avril 2002
    Messages
    180
    Détails du profil
    Informations forums :
    Inscription : Avril 2002
    Messages : 180
    Points : 157
    Points
    157
    Par défaut
    Salut Voici un bout ce code qui fait le bouleau er retien le chemin du repertoire selectioner
    la variable CString strTmpPath; est global

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
     
    void CInitControl::OnBrowse() 
    {
    	// TODO: Add your control notification handler code here
    	CString strFolderPath;
    	GetFolder(&strFolderPath, "Sample of  getting folder.", this->m_hWnd, NULL, NULL);
    	CEdit *experiment=(CEdit*)GetDlgItem(IDC_EXPERIMENT);
    	experiment->SetWindowText(strFolderPath);
    }
     
    void CInitControl::GetFolder(CString *strSelectedFolder, const char *lpszTitle, const HWND hwndOwner, const char *strRootFolder, const char *strStartFolder)
    {
    	char pszDisplayName[MAX_PATH];
    	LPITEMIDLIST lpID;
    	BROWSEINFOA bi;
     
    	bi.hwndOwner = hwndOwner;
    	if (strRootFolder == NULL)
    	{
    		bi.pidlRoot = NULL;
    	}
    	else
    	{
    	   LPITEMIDLIST  pIdl = NULL;
    	   IShellFolder* pDesktopFolder;
    	   char          szPath[MAX_PATH];
    	   OLECHAR       olePath[MAX_PATH];
    	   ULONG         chEaten;
    	   ULONG         dwAttributes;
     
    	   strcpy(szPath, (LPCTSTR)strRootFolder);
    	   if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))
    	   {
    		   MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szPath, -1, olePath, MAX_PATH);
    		   pDesktopFolder->ParseDisplayName(NULL, NULL, olePath, &chEaten, &pIdl, &dwAttributes);
    		   pDesktopFolder->Release();
    	   }
    	   bi.pidlRoot = pIdl;
    	}
    	bi.pszDisplayName = pszDisplayName;
    	bi.lpszTitle = lpszTitle;
    	bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
    	bi.lpfn = 0;
    	if (strStartFolder == NULL)
    	{
    		bi.lParam = FALSE;
    	}
    	else
    	{
    		strTmpPath.Format("%s", strStartFolder);
    		bi.lParam = TRUE;
    	}
    	bi.iImage = NULL;
    	lpID = SHBrowseForFolderA(&bi);
    	if (lpID != NULL){
    		BOOL b = SHGetPathFromIDList(lpID, pszDisplayName);
    		if (b == TRUE)
    		{
    			strSelectedFolder->Format("%s",pszDisplayName);
    		}
    	}
    	else
    	{
    		strSelectedFolder->Empty();
    	}
    }
    Ce bout de code fonctionne bien
    ne en moin il contien un probleme d'initialisation de parametre ces pas bien grave et ca ne beure pas de memoire, le message retourner par Rational purified est:
    A PAR message indicates that the program called a Win32API or C run-time routine, such as write(), with a bad parameter.
    [W] PAR: Both Debug and non-Debug versions of CRT are active; This may cause CRT heap operations to fail. {1 occurrence}
    Call location
    FindResourceExW [KERNEL32.dll]
    OpenComponentLibraryOnMemEx [CLBCATQ.DLL]
    OpenComponentLibraryOnMemEx [CLBCATQ.DLL]
    RtlCharToInteger [ntdll.dll]
    RtlCharToInteger [ntdll.dll]
    LdrLoadDll [ntdll.dll]
    LoadLibraryExA [KERNEL32.dll]
    LoadLibraryA [KERNEL32.dll]
    CLSIDFromOle1Class [ole32.DLL]
    CoTaskMemRealloc [ole32.DLL]
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
     
    J'espere que ca va t'aider
        ALP

  5. #5
    Membre habitué
    Inscrit en
    Avril 2002
    Messages
    180
    Détails du profil
    Informations forums :
    Inscription : Avril 2002
    Messages : 180
    Points : 157
    Points
    157
    Par défaut
    Salut Voici un bout ce code qui fait le bouleau er retien le chemin du repertoire selectioner
    la variable CString strTmpPath; est global

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
     
    void CInitControl::OnBrowse() 
    {
    	// TODO: Add your control notification handler code here
    	CString strFolderPath;
    	GetFolder(&strFolderPath, "Sample of  getting folder.", this->m_hWnd, NULL, NULL);
    	CEdit *experiment=(CEdit*)GetDlgItem(IDC_EXPERIMENT);
    	experiment->SetWindowText(strFolderPath);
    }
     
    void CInitControl::GetFolder(CString *strSelectedFolder, const char *lpszTitle, const HWND hwndOwner, const char *strRootFolder, const char *strStartFolder)
    {
    	char pszDisplayName[MAX_PATH];
    	LPITEMIDLIST lpID;
    	BROWSEINFOA bi;
     
    	bi.hwndOwner = hwndOwner;
    	if (strRootFolder == NULL)
    	{
    		bi.pidlRoot = NULL;
    	}
    	else
    	{
    	   LPITEMIDLIST  pIdl = NULL;
    	   IShellFolder* pDesktopFolder;
    	   char          szPath[MAX_PATH];
    	   OLECHAR       olePath[MAX_PATH];
    	   ULONG         chEaten;
    	   ULONG         dwAttributes;
     
    	   strcpy(szPath, (LPCTSTR)strRootFolder);
    	   if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))
    	   {
    		   MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szPath, -1, olePath, MAX_PATH);
    		   pDesktopFolder->ParseDisplayName(NULL, NULL, olePath, &chEaten, &pIdl, &dwAttributes);
    		   pDesktopFolder->Release();
    	   }
    	   bi.pidlRoot = pIdl;
    	}
    	bi.pszDisplayName = pszDisplayName;
    	bi.lpszTitle = lpszTitle;
    	bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
    	bi.lpfn = 0;
    	if (strStartFolder == NULL)
    	{
    		bi.lParam = FALSE;
    	}
    	else
    	{
    		strTmpPath.Format("%s", strStartFolder);
    		bi.lParam = TRUE;
    	}
    	bi.iImage = NULL;
    	lpID = SHBrowseForFolderA(&bi);
    	if (lpID != NULL){
    		BOOL b = SHGetPathFromIDList(lpID, pszDisplayName);
    		if (b == TRUE)
    		{
    			strSelectedFolder->Format("%s",pszDisplayName);
    		}
    	}
    	else
    	{
    		strSelectedFolder->Empty();
    	}
    }
    Ce bout de code fonctionne bien
    ne en moin il contien un probleme d'initialisation de parametre ces pas bien grave et ca ne beure pas de memoire, le message retourner par Rational purified est:
    A PAR message indicates that the program called a Win32API or C run-time routine, such as write(), with a bad parameter.
    [W] PAR: Both Debug and non-Debug versions of CRT are active; This may cause CRT heap operations to fail. {1 occurrence}
    Call location
    FindResourceExW [KERNEL32.dll]
    OpenComponentLibraryOnMemEx [CLBCATQ.DLL]
    OpenComponentLibraryOnMemEx [CLBCATQ.DLL]
    RtlCharToInteger [ntdll.dll]
    RtlCharToInteger [ntdll.dll]
    LdrLoadDll [ntdll.dll]
    LoadLibraryExA [KERNEL32.dll]
    LoadLibraryA [KERNEL32.dll]
    CLSIDFromOle1Class [ole32.DLL]
    CoTaskMemRealloc [ole32.DLL]
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
     
    J'espere que ca va t'aider
        ALP

  6. #6
    Membre à l'essai
    Inscrit en
    Décembre 2002
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Décembre 2002
    Messages : 18
    Points : 14
    Points
    14
    Par défaut
    Merci je vais tester toutes ces solutions

    Bonne Année A tous

    Boggalow

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. comment faire une Boite de dialogue perso
    Par electrosat03 dans le forum Access
    Réponses: 6
    Dernier message: 11/01/2007, 11h24
  2. Comment afficher une boite de dialogue ?
    Par THkiller dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 28/08/2006, 21h24
  3. Réponses: 2
    Dernier message: 20/04/2006, 13h20
  4. Réponses: 4
    Dernier message: 26/01/2006, 16h13
  5. comment afficher une boite de dialogue simple ?
    Par Ekimasu dans le forum Agents de placement/Fenêtres
    Réponses: 4
    Dernier message: 08/06/2004, 16h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo