Pb list box en VC++

cs_owel Messages postés 19 Date d'inscription jeudi 25 avril 2002 Statut Membre Dernière intervention 6 février 2004 - 5 nov. 2002 à 18:32
cs_shu Messages postés 1 Date d'inscription lundi 23 décembre 2002 Statut Membre Dernière intervention 30 décembre 2002 - 30 déc. 2002 à 14:54
salut !!

je voudrai faire un truc simple affiché le contenu d'un repertoire dans une list box mais je n'y arrive pas !
la lecture du fichié pas de pb !
mais inséré le nom de chaque fichier sur chaque ligne de ma list box me pose pb !!

merci de me filé un coup de mains !! ;o))
owel

9 réponses

cs_owel Messages postés 19 Date d'inscription jeudi 25 avril 2002 Statut Membre Dernière intervention 6 février 2004
5 nov. 2002 à 18:51
c bon g trouvé . pour ceux que ca interresse:
LPCSTR fichier = "E:\\mp3\\*.mp3" ;

WIN32_FIND_DATA wData;
//char nom[MAX_PATH];
HANDLE listing;
CString affichageListing ;

listing = FindFirstFile(fichier,&wData);

while((FindNextFile(listing,&wData)))
{
m_listingRep.AddString(wData.cFileName);

}
0
cs_Xaviou Messages postés 154 Date d'inscription dimanche 1 avril 2001 Statut Membre Dernière intervention 2 octobre 2009 1
7 nov. 2002 à 21:54
Y'a plus simple :

Utilise la fonction DlgDirList , elle est faite pour ça.

J'ai jamais essayé, mais ça devrait pas être sorcier.
0
cs_owel Messages postés 19 Date d'inscription jeudi 25 avril 2002 Statut Membre Dernière intervention 6 février 2004
8 nov. 2002 à 01:14
effectivement c plus simple ...mais je n'est pas reussi a m'en servir !!! par contre je me suis servi de la fonction CListBox.Dir() ...

vu que celle ci fais ce que j'attend je l'utilise !! mais alors je vois pas a quoi sert dlgdirlist....
0
cs_Xaviou Messages postés 154 Date d'inscription dimanche 1 avril 2001 Statut Membre Dernière intervention 2 octobre 2009 1
9 nov. 2002 à 11:53
Voici ce qu'ils disent sur MSDN :

DlgDirList
The DlgDirList function fills the specified list box with the names of all files matching the specified path or filename.

int DlgDirList(
HWND hDlg, // handle to dialog box with list box
LPTSTR lpPathSpec, // pointer to path or filename string
int nIDListBox, // identifier of list box
int nIDStaticPath, // identifier of static control
UINT uFileType // file attributes to display
);

Parameters
hDlg
Handle to the dialog box that contains the list box.
lpPathSpec
Pointer to a null-terminated string that contains the path or filename. DlgDirList modifies this string, which should be long enough to contain the modifications. For more information about this parameter, see the Remarks section.
nIDListBox
Specifies the identifier of a list box. If this parameter is zero, DlgDirList assumes that no list box exists and does not attempt to fill one.
nIDStaticPath
Specifies the identifier of the static control used for displaying the current drive and directory. If this parameter is zero, DlgDirList assumes that no such control is present.
uFileType
Specifies attributes of the filenames to be displayed. This parameter must be one or more of the following values: Value Description
DDL_ARCHIVE Includes archived files.
DDL_DIRECTORY Includes subdirectories. Subdirectory names are enclosed in square brackets ([ ]).
DDL_DRIVES Includes drives. Drives are listed in the form [-x-], where x is the drive letter.
DDL_EXCLUSIVE Includes only files with the specified attributes. By default, read-write files are listed even if DDL_READWRITE is not specified.
DDL_HIDDEN Includes hidden files.
DDL_READONLY Includes read-only files.
DDL_READWRITE Includes read-write files with no additional attributes.
DDL_SYSTEM Includes system files.
DDL_POSTMSGS Posts messages to the application's message queue. By default, DlgDirList sends messages directly to the dialog box procedure.

Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. For example, if the string specified by lpPathSpec is not a valid path, the function fails. To get extended error information, callGetLastError.

Remarks
If you specify a zero-length string for the lpPathSpec parameter or if you specify only a directory name with no filename, the string will be changed to *.*

The lpPathSpec parameter has the following form:

[drive:] [[\u]directory[\idirectory]\u] [filename]

In this example, drive is a drive letter, directory is a valid directory name, and filename is a valid filename that must contain at least one wildcard (? or *).

If lpPathSpec includes a drive or directory name, or both, the current drive and directory are changed to the specified drive and directory before the list box is filled. The static control identified by the nIDStaticPath parameter is also updated with the new drive or directory name, or both.

After the list box is filled, DlgDirList updates lpPathSpec by removing the drive or directory portion, or both, of the path and filename.

DlgDirList sends the LB_RESETCONTENT and LB_DIR messages to the list box.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winuser.h.
Import Library: Use user32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_owel Messages postés 19 Date d'inscription jeudi 25 avril 2002 Statut Membre Dernière intervention 6 février 2004
9 nov. 2002 à 14:41
:big) loooool oui ok ca c le msdn ......je l'avais biensur regardé mais entre ce qu'il dis et ce que je comprend... il n'y a qu'un pas !!!
en effet g des fois du mal a interprété le msdn ... je comprend pas forcement tjrs ce kil raconte !!! :big)

je c pas tjrs quoi mettre en parametre !! par exemple avec cette fonction je c pas koi mettre en param 1 et 4....
0
cs_Xaviou Messages postés 154 Date d'inscription dimanche 1 avril 2001 Statut Membre Dernière intervention 2 octobre 2009 1
12 nov. 2002 à 22:56
En fait, cette fonction a l'air d'être faite pour les boites de dialogues, mais ça devrais marcher quand même avec une fenêtre normale:

hDlg=Handle de la fenêtre contenant la ListBox
uFiletype=Attributs des fichiers à afficher : Tu peux mettre une combinaison des valeurs données par MSDN
0
cs_owel Messages postés 19 Date d'inscription jeudi 25 avril 2002 Statut Membre Dernière intervention 6 février 2004
12 nov. 2002 à 23:03
ok !
mais le param 4 c :nIDStaticPath
c celui la qui me pose pb ... je vois pas ce kil veux dire !
0
cs_Xaviou Messages postés 154 Date d'inscription dimanche 1 avril 2001 Statut Membre Dernière intervention 2 octobre 2009 1
16 nov. 2002 à 16:56
C'est le Numéro ID d'un control static (un label) dans lequel s'affichera le répertoire et le lecteur courant. si tu n'en a pas besoin, tu peux mettre zéro.
0
cs_shu Messages postés 1 Date d'inscription lundi 23 décembre 2002 Statut Membre Dernière intervention 30 décembre 2002
30 déc. 2002 à 14:54
Salut,

J'ai le meme probleme.
J'utilise Dev c++, et je voulais egalement me servir de DlgDirList avec :

DlgDirList
(
frmhWnd,
"c:\\*.*",
id_listBox ,
0,
DDL_DIRECTORY|DDL_READWRITE
);

- frmhWnd................handle de la fenetre mere
- "c:\\*.*".................le repertoire d'origine
- id_listBox ..............id de la listBox
- 0...........................id du control ( pour affichier le chemin par ex. ) 0 = rien
- DDL_DIRECTORY|DDL_READWRITE........les attributs

et a chaque fois la fonction retourne 0, indiquant un echec... :-(

Bref, la chose valable que j'ai trouve peniblement c'est
d'envoyer un message a la listBox:

SendMessage
(
id_listBox,
LB_DIR, DDL_DRIVES |DDL_DIRECTORY,
(LPARAM)(LPSTR)"c:\\*.*"
);

Voila, mais :
1- je ne sais pas si c'est totalement correct.
2- si quelqu'un a la solution, j'achete ! ( juste par curiosite )

Bon courage,
Stef
0
Rejoignez-nous