begin process at 2012 05 29 18:36:59
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C/C++

 > 

Archives

 > 

Au secours

 > 

pb list box en VC++


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

pb list box en VC++

mardi 5 novembre 2002 à 18:32:55 | pb list box en VC++

owel

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
mardi 5 novembre 2002 à 18:51:48 | Re : pb list box en VC++

owel

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);

}




-------------------------------
Réponse au message :
-------------------------------

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
jeudi 7 novembre 2002 à 21:54:06 | Re : pb list box en VC++

Xaviou

Y'a plus simple :

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

J'ai jamais essayé, mais ça devrait pas être sorcier.
vendredi 8 novembre 2002 à 01:14:28 | Re : pb list box en VC++

owel

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....


-------------------------------
Réponse au message :
-------------------------------

Y'a plus simple :

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

J'ai jamais essayé, mais ça devrait pas être sorcier.
samedi 9 novembre 2002 à 11:53:30 | Re : pb list box en VC++

Xaviou

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
samedi 9 novembre 2002 à 14:41:34 | Re : pb list box en VC++

owel

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 !!!

je c pas tjrs quoi mettre en parametre !! par exemple avec cette fonction je c pas koi mettre en param 1 et 4....


-------------------------------
Réponse au message :
-------------------------------

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

mardi 12 novembre 2002 à 22:56:21 | Re : pb list box en VC++

Xaviou

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

mardi 12 novembre 2002 à 23:03:42 | Re : pb list box en VC++

owel

ok !
mais le param 4 c :nIDStaticPath
c celui la qui me pose pb ... je vois pas ce kil veux dire !



-------------------------------
Réponse au message :
-------------------------------

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


samedi 16 novembre 2002 à 16:56:32 | Re : pb list box en VC++

Xaviou

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.



-------------------------------
Réponse au message :
-------------------------------

ok !
mais le param 4 c :nIDStaticPath
c celui la qui me pose pb ... je vois pas ce kil veux dire !

lundi 30 décembre 2002 à 14:54:04 | Re : pb list box en VC++

shu

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
-------------------------------
Réponse au message :
-------------------------------

> 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.
>
>
>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> ok !
> mais le param 4 c :nIDStaticPath
> c celui la qui me pose pb ... je vois pas ce kil veux dire !
>
>


Cette discussion est classée dans : pb, box, vc, list


Répondre à ce message

Sujets en rapport avec ce message

VC++ 6 && list box [ par safira ] safiraSalut!!je voudrais savoir comment faire apparaître sélectionné, le premier champs d'une list box?Merci List Box Multi colonne ;) [ par AlexMAN ] Bonjour, Ben mon pb se resume en une kestion (come tt pb :) ; comment créer un controle ListBox multi colonne dans une boite de dialogue ? Je sais kil pb avec combo box [ par melkiorlenecrarque ] bonjour,ma combo box ne défile pa vers le bas, je suis obligé d'utiliser maroulette de souris ou les fleches du clavier pour changer la selectionje p ListBox [ par mop666 ] Salut!Est il possible de mettre une list box surune view pour une appli MFC?sinon comment se fait il que lorsqu on met des scroll bars sur une list bo [VC++] Modifier le texte d'une edit box sur plusieurs lignes... [ par ndj55 ] Salut à tous!Voila,je souhaiterais ecrire dans une edit box une chaine de caracteres,pour cela j'ai le code suivant:strcpy(info,"Prenom:\nNicolas\nAge pb débutant utilisation combo box [ par chouchou123 ] salut,j'ai un e interface avec une combo box et une text box, je voudrai remplir cette combo box avec les nom de personne contenu dans une base de do List Box + BMP [ par oliverman ] Salut,Est ce qu'il y aurait quelqu'un qui aurait une idée pour mettre des bmp dans une list box:un bmp pour le fond, et pour chaque bouton d'ascenseur Pb de compilation C++ pour Windows [ par valoue ] Bonjour,Je developpe actuellement un appli qui doit tourner sous Windows et etre protable sous Linux.J'utilise donc dans mon prog C++ (sous VC++ .net) List box recuperation des string [ par youpiyoyo ] j'aurai besoin de recup les donné dans une list boxdans case LBN_SELCHANGE:j'ai essayé GetDlgItemText mais ca marche pomerci d'avanceyoupiopen source pb de linkage pendant la compilation sous VC.NET2003 [ par xjacques ] voila le pb que j ai a la compilation:nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in play.objC est lorsque j essaie de defi


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

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 : 1,654 sec (4)

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